qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 17/17] dump: Move HMP command handlers to dump/
Date: Thu, 20 Jun 2019 10:57:47 +0100	[thread overview]
Message-ID: <20190620095747.GF2907@work-vm> (raw)
In-Reply-To: <20190619201050.19040-18-armbru@redhat.com>

* Markus Armbruster (armbru@redhat.com) wrote:
> Move the HMP handlers related to qapi/dump.json to
> dimp/dump-hmp-cmds.c, where they are covered by MAINTAINERS section
> "Dump", just like qapi/dump.json.
> 
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  Makefile.objs        |  1 +
>  dump/Makefile.objs   |  1 +
>  dump/dump-hmp-cmds.c | 88 ++++++++++++++++++++++++++++++++++++++++++++
>  monitor/hmp-cmds.c   | 76 --------------------------------------
>  4 files changed, 90 insertions(+), 76 deletions(-)
>  create mode 100644 dump/dump-hmp-cmds.c
> 
> diff --git a/Makefile.objs b/Makefile.objs
> index 7494d6143b..c93d731047 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -45,6 +45,7 @@ io-obj-y = io/
>  ifeq ($(CONFIG_SOFTMMU),y)
>  common-obj-y = blockdev.o blockdev-nbd.o block/
>  common-obj-y += bootdevice.o iothread.o
> +common-obj-y += dump/
>  common-obj-y += job-qmp.o
>  common-obj-y += monitor/
>  common-obj-y += net/
> diff --git a/dump/Makefile.objs b/dump/Makefile.objs
> index ea6b074967..d2a5db3b81 100644
> --- a/dump/Makefile.objs
> +++ b/dump/Makefile.objs
> @@ -1,2 +1,3 @@
>  obj-y += dump.o
> +common-obj-y += dump-hmp-cmds.o
>  obj-$(TARGET_X86_64) += win_dump.o
> diff --git a/dump/dump-hmp-cmds.c b/dump/dump-hmp-cmds.c
> new file mode 100644
> index 0000000000..3dbf44372c
> --- /dev/null
> +++ b/dump/dump-hmp-cmds.c
> @@ -0,0 +1,88 @@
> +/*
> + * Human Monitor Interface commands
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "monitor/hmp.h"
> +#include "monitor/monitor.h"
> +#include "qapi/error.h"
> +#include "qapi/qapi-commands-dump.h"
> +#include "qapi/qmp/qdict.h"
> +
> +void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
> +{
> +    Error *err = NULL;
> +    bool win_dmp = qdict_get_try_bool(qdict, "windmp", false);
> +    bool paging = qdict_get_try_bool(qdict, "paging", false);
> +    bool zlib = qdict_get_try_bool(qdict, "zlib", false);
> +    bool lzo = qdict_get_try_bool(qdict, "lzo", false);
> +    bool snappy = qdict_get_try_bool(qdict, "snappy", false);
> +    const char *file = qdict_get_str(qdict, "filename");
> +    bool has_begin = qdict_haskey(qdict, "begin");
> +    bool has_length = qdict_haskey(qdict, "length");
> +    bool has_detach = qdict_haskey(qdict, "detach");
> +    int64_t begin = 0;
> +    int64_t length = 0;
> +    bool detach = false;
> +    enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
> +    char *prot;
> +
> +    if (zlib + lzo + snappy + win_dmp > 1) {
> +        error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
> +        hmp_handle_error(mon, &err);
> +        return;
> +    }
> +
> +    if (win_dmp) {
> +        dump_format = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP;
> +    }
> +
> +    if (zlib) {
> +        dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
> +    }
> +
> +    if (lzo) {
> +        dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
> +    }
> +
> +    if (snappy) {
> +        dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
> +    }
> +
> +    if (has_begin) {
> +        begin = qdict_get_int(qdict, "begin");
> +    }
> +    if (has_length) {
> +        length = qdict_get_int(qdict, "length");
> +    }
> +    if (has_detach) {
> +        detach = qdict_get_bool(qdict, "detach");
> +    }
> +
> +    prot = g_strconcat("file:", file, NULL);
> +
> +    qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin,
> +                          has_length, length, true, dump_format, &err);
> +    hmp_handle_error(mon, &err);
> +    g_free(prot);
> +}
> +
> +void hmp_info_dump(Monitor *mon, const QDict *qdict)
> +{
> +    DumpQueryResult *result = qmp_query_dump(NULL);
> +
> +    assert(result && result->status < DUMP_STATUS__MAX);
> +    monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status));
> +
> +    if (result->status == DUMP_STATUS_ACTIVE) {
> +        float percent = 0;
> +        assert(result->total != 0);
> +        percent = 100.0 * result->completed / result->total;
> +        monitor_printf(mon, "Finished: %.2f %%\n", percent);
> +    }
> +
> +    qapi_free_DumpQueryResult(result);
> +}
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 18ffeb7017..dc12ae6129 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -31,7 +31,6 @@
>  #include "qapi/qapi-builtin-visit.h"
>  #include "qapi/qapi-commands-block.h"
>  #include "qapi/qapi-commands-char.h"
> -#include "qapi/qapi-commands-dump.h"
>  #include "qapi/qapi-commands-migration.h"
>  #include "qapi/qapi-commands-misc.h"
>  #include "qapi/qapi-commands-net.h"
> @@ -2160,64 +2159,6 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, &err);
>  }
>  
> -void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
> -{
> -    Error *err = NULL;
> -    bool win_dmp = qdict_get_try_bool(qdict, "windmp", false);
> -    bool paging = qdict_get_try_bool(qdict, "paging", false);
> -    bool zlib = qdict_get_try_bool(qdict, "zlib", false);
> -    bool lzo = qdict_get_try_bool(qdict, "lzo", false);
> -    bool snappy = qdict_get_try_bool(qdict, "snappy", false);
> -    const char *file = qdict_get_str(qdict, "filename");
> -    bool has_begin = qdict_haskey(qdict, "begin");
> -    bool has_length = qdict_haskey(qdict, "length");
> -    bool has_detach = qdict_haskey(qdict, "detach");
> -    int64_t begin = 0;
> -    int64_t length = 0;
> -    bool detach = false;
> -    enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
> -    char *prot;
> -
> -    if (zlib + lzo + snappy + win_dmp > 1) {
> -        error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
> -        hmp_handle_error(mon, &err);
> -        return;
> -    }
> -
> -    if (win_dmp) {
> -        dump_format = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP;
> -    }
> -
> -    if (zlib) {
> -        dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
> -    }
> -
> -    if (lzo) {
> -        dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
> -    }
> -
> -    if (snappy) {
> -        dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
> -    }
> -
> -    if (has_begin) {
> -        begin = qdict_get_int(qdict, "begin");
> -    }
> -    if (has_length) {
> -        length = qdict_get_int(qdict, "length");
> -    }
> -    if (has_detach) {
> -        detach = qdict_get_bool(qdict, "detach");
> -    }
> -
> -    prot = g_strconcat("file:", file, NULL);
> -
> -    qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin,
> -                          has_length, length, true, dump_format, &err);
> -    hmp_handle_error(mon, &err);
> -    g_free(prot);
> -}
> -
>  void hmp_netdev_add(Monitor *mon, const QDict *qdict)
>  {
>      Error *err = NULL;
> @@ -2949,23 +2890,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
>      qapi_free_RockerOfDpaGroupList(list);
>  }
>  
> -void hmp_info_dump(Monitor *mon, const QDict *qdict)
> -{
> -    DumpQueryResult *result = qmp_query_dump(NULL);
> -
> -    assert(result && result->status < DUMP_STATUS__MAX);
> -    monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status));
> -
> -    if (result->status == DUMP_STATUS_ACTIVE) {
> -        float percent = 0;
> -        assert(result->total != 0);
> -        percent = 100.0 * result->completed / result->total;
> -        monitor_printf(mon, "Finished: %.2f %%\n", percent);
> -    }
> -
> -    qapi_free_DumpQueryResult(result);
> -}
> -
>  void hmp_info_ramblock(Monitor *mon, const QDict *qdict)
>  {
>      ram_block_dump(mon);
> -- 
> 2.21.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


      parent reply	other threads:[~2019-06-20 10:00 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-19 20:10 [Qemu-devel] [PATCH 00/17] Move QOM, qdev, machine core and dump code Markus Armbruster
2019-06-19 20:10 ` [Qemu-devel] [PATCH 01/17] MAINTAINERS: new maintainers for QOM Markus Armbruster
2019-06-19 20:31   ` Andreas Färber
2019-06-20  8:37     ` Paolo Bonzini
2019-06-24 11:07     ` Markus Armbruster
2019-06-20  8:31   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 02/17] Makefile: Don't add monitor/ twice to common-obj-y Markus Armbruster
2019-06-20  8:32   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 03/17] hmp: Move hmp.h to include/monitor/ Markus Armbruster
2019-06-20  8:33   ` Daniel P. Berrangé
2019-06-20  9:48   ` Dr. David Alan Gilbert
2019-06-19 20:10 ` [Qemu-devel] [PATCH 04/17] qapi: Split qom.json and qdev.json off misc.json Markus Armbruster
2019-06-20  8:34   ` Daniel P. Berrangé
2019-06-20  8:38   ` Paolo Bonzini
2019-06-24 11:19     ` Markus Armbruster
2019-06-24 11:45       ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 05/17] qom: Move QMP command handlers to qom/ Markus Armbruster
2019-06-20  8:35   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 06/17] qom: Move HMP " Markus Armbruster
2019-06-20  8:39   ` Daniel P. Berrangé
2019-06-20  9:51   ` Dr. David Alan Gilbert
2019-07-02  5:08   ` Markus Armbruster
2019-06-19 20:10 ` [Qemu-devel] [PATCH 07/17] MAINTAINERS: Merge sections CPU, NUMA into Machine core Markus Armbruster
2019-06-20  8:41   ` Daniel P. Berrangé
2019-06-24 11:22     ` Markus Armbruster
2019-07-08 22:54       ` Eduardo Habkost
2019-07-09  6:36         ` Markus Armbruster
2019-06-19 20:10 ` [Qemu-devel] [PATCH 08/17] qapi: Split machine.json off misc.json Markus Armbruster
2019-06-20  8:45   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 09/17] hw/core: Move numa.c to hw/core/ Markus Armbruster
2019-06-20  8:46   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 10/17] hw/core: Collect QMP command handlers in hw/core/ Markus Armbruster
2019-06-20  8:50   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 11/17] hw/core: Collect HMP " Markus Armbruster
2019-06-20  8:51   ` Daniel P. Berrangé
2019-06-20  9:56   ` Dr. David Alan Gilbert
2019-06-19 20:10 ` [Qemu-devel] [PATCH 12/17] qapi: Split machine-target.json off target.json and misc.json Markus Armbruster
2019-06-19 20:18   ` Eric Blake
2019-06-24 11:33     ` Markus Armbruster
2019-06-20  8:53   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 13/17] qapi: Rename target.json to misc-target.json Markus Armbruster
2019-06-20  8:54   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 14/17] qapi: Split dump.json off misc.json Markus Armbruster
2019-06-19 23:36   ` Marc-André Lureau
2019-06-20  8:54   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 15/17] dump: Move the code to dump/ Markus Armbruster
2019-06-19 23:37   ` Marc-André Lureau
2019-06-20  8:55   ` Daniel P. Berrangé
2019-06-19 20:10 ` [Qemu-devel] [PATCH 16/17] MAINTAINERS: Add Windows dump to section "Dump" Markus Armbruster
2019-06-19 23:38   ` Marc-André Lureau
2019-06-20  8:56   ` Daniel P. Berrangé
2019-06-24 11:31     ` Markus Armbruster
2019-06-19 20:10 ` [Qemu-devel] [PATCH 17/17] dump: Move HMP command handlers to dump/ Markus Armbruster
2019-06-19 20:19   ` Eric Blake
2019-06-24 11:34     ` Markus Armbruster
2019-06-20  8:57   ` Daniel P. Berrangé
2019-06-20  9:57   ` Dr. David Alan Gilbert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190620095747.GF2907@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).