* Markus Armbruster ([email protected]) 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 <[email protected]> > Cc: "Dr. David Alan Gilbert" <[email protected]> > Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]> > --- > 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 / [email protected] / Manchester, UK
