qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

dump: Move HMP command handlers to dump/

Move the HMP handlers related to qapi/dump.json to
dump/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>
Message-Id: <20190619201050.19040-18-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
[Commit message typo fixed]

+90 -76
+1
Makefile.objs
··· 45 45 ifeq ($(CONFIG_SOFTMMU),y) 46 46 common-obj-y = blockdev.o blockdev-nbd.o block/ 47 47 common-obj-y += bootdevice.o iothread.o 48 + common-obj-y += dump/ 48 49 common-obj-y += job-qmp.o 49 50 common-obj-y += monitor/ 50 51 common-obj-y += net/
+1
dump/Makefile.objs
··· 1 1 obj-y += dump.o 2 + common-obj-y += dump-hmp-cmds.o 2 3 obj-$(TARGET_X86_64) += win_dump.o
+88
dump/dump-hmp-cmds.c
··· 1 + /* 2 + * Human Monitor Interface commands 3 + * 4 + * This work is licensed under the terms of the GNU GPL, version 2 or later. 5 + * See the COPYING file in the top-level directory. 6 + */ 7 + 8 + #include "qemu/osdep.h" 9 + #include "monitor/hmp.h" 10 + #include "monitor/monitor.h" 11 + #include "qapi/error.h" 12 + #include "qapi/qapi-commands-dump.h" 13 + #include "qapi/qmp/qdict.h" 14 + 15 + void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) 16 + { 17 + Error *err = NULL; 18 + bool win_dmp = qdict_get_try_bool(qdict, "windmp", false); 19 + bool paging = qdict_get_try_bool(qdict, "paging", false); 20 + bool zlib = qdict_get_try_bool(qdict, "zlib", false); 21 + bool lzo = qdict_get_try_bool(qdict, "lzo", false); 22 + bool snappy = qdict_get_try_bool(qdict, "snappy", false); 23 + const char *file = qdict_get_str(qdict, "filename"); 24 + bool has_begin = qdict_haskey(qdict, "begin"); 25 + bool has_length = qdict_haskey(qdict, "length"); 26 + bool has_detach = qdict_haskey(qdict, "detach"); 27 + int64_t begin = 0; 28 + int64_t length = 0; 29 + bool detach = false; 30 + enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; 31 + char *prot; 32 + 33 + if (zlib + lzo + snappy + win_dmp > 1) { 34 + error_setg(&err, "only one of '-z|-l|-s|-w' can be set"); 35 + hmp_handle_error(mon, &err); 36 + return; 37 + } 38 + 39 + if (win_dmp) { 40 + dump_format = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; 41 + } 42 + 43 + if (zlib) { 44 + dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; 45 + } 46 + 47 + if (lzo) { 48 + dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; 49 + } 50 + 51 + if (snappy) { 52 + dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; 53 + } 54 + 55 + if (has_begin) { 56 + begin = qdict_get_int(qdict, "begin"); 57 + } 58 + if (has_length) { 59 + length = qdict_get_int(qdict, "length"); 60 + } 61 + if (has_detach) { 62 + detach = qdict_get_bool(qdict, "detach"); 63 + } 64 + 65 + prot = g_strconcat("file:", file, NULL); 66 + 67 + qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin, 68 + has_length, length, true, dump_format, &err); 69 + hmp_handle_error(mon, &err); 70 + g_free(prot); 71 + } 72 + 73 + void hmp_info_dump(Monitor *mon, const QDict *qdict) 74 + { 75 + DumpQueryResult *result = qmp_query_dump(NULL); 76 + 77 + assert(result && result->status < DUMP_STATUS__MAX); 78 + monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status)); 79 + 80 + if (result->status == DUMP_STATUS_ACTIVE) { 81 + float percent = 0; 82 + assert(result->total != 0); 83 + percent = 100.0 * result->completed / result->total; 84 + monitor_printf(mon, "Finished: %.2f %%\n", percent); 85 + } 86 + 87 + qapi_free_DumpQueryResult(result); 88 + }
-76
monitor/hmp-cmds.c
··· 31 31 #include "qapi/qapi-builtin-visit.h" 32 32 #include "qapi/qapi-commands-block.h" 33 33 #include "qapi/qapi-commands-char.h" 34 - #include "qapi/qapi-commands-dump.h" 35 34 #include "qapi/qapi-commands-migration.h" 36 35 #include "qapi/qapi-commands-misc.h" 37 36 #include "qapi/qapi-commands-net.h" ··· 2160 2159 hmp_handle_error(mon, &err); 2161 2160 } 2162 2161 2163 - void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) 2164 - { 2165 - Error *err = NULL; 2166 - bool win_dmp = qdict_get_try_bool(qdict, "windmp", false); 2167 - bool paging = qdict_get_try_bool(qdict, "paging", false); 2168 - bool zlib = qdict_get_try_bool(qdict, "zlib", false); 2169 - bool lzo = qdict_get_try_bool(qdict, "lzo", false); 2170 - bool snappy = qdict_get_try_bool(qdict, "snappy", false); 2171 - const char *file = qdict_get_str(qdict, "filename"); 2172 - bool has_begin = qdict_haskey(qdict, "begin"); 2173 - bool has_length = qdict_haskey(qdict, "length"); 2174 - bool has_detach = qdict_haskey(qdict, "detach"); 2175 - int64_t begin = 0; 2176 - int64_t length = 0; 2177 - bool detach = false; 2178 - enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; 2179 - char *prot; 2180 - 2181 - if (zlib + lzo + snappy + win_dmp > 1) { 2182 - error_setg(&err, "only one of '-z|-l|-s|-w' can be set"); 2183 - hmp_handle_error(mon, &err); 2184 - return; 2185 - } 2186 - 2187 - if (win_dmp) { 2188 - dump_format = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; 2189 - } 2190 - 2191 - if (zlib) { 2192 - dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; 2193 - } 2194 - 2195 - if (lzo) { 2196 - dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; 2197 - } 2198 - 2199 - if (snappy) { 2200 - dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; 2201 - } 2202 - 2203 - if (has_begin) { 2204 - begin = qdict_get_int(qdict, "begin"); 2205 - } 2206 - if (has_length) { 2207 - length = qdict_get_int(qdict, "length"); 2208 - } 2209 - if (has_detach) { 2210 - detach = qdict_get_bool(qdict, "detach"); 2211 - } 2212 - 2213 - prot = g_strconcat("file:", file, NULL); 2214 - 2215 - qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin, 2216 - has_length, length, true, dump_format, &err); 2217 - hmp_handle_error(mon, &err); 2218 - g_free(prot); 2219 - } 2220 - 2221 2162 void hmp_netdev_add(Monitor *mon, const QDict *qdict) 2222 2163 { 2223 2164 Error *err = NULL; ··· 2947 2888 } 2948 2889 2949 2890 qapi_free_RockerOfDpaGroupList(list); 2950 - } 2951 - 2952 - void hmp_info_dump(Monitor *mon, const QDict *qdict) 2953 - { 2954 - DumpQueryResult *result = qmp_query_dump(NULL); 2955 - 2956 - assert(result && result->status < DUMP_STATUS__MAX); 2957 - monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status)); 2958 - 2959 - if (result->status == DUMP_STATUS_ACTIVE) { 2960 - float percent = 0; 2961 - assert(result->total != 0); 2962 - percent = 100.0 * result->completed / result->total; 2963 - monitor_printf(mon, "Finished: %.2f %%\n", percent); 2964 - } 2965 - 2966 - qapi_free_DumpQueryResult(result); 2967 2891 } 2968 2892 2969 2893 void hmp_info_ramblock(Monitor *mon, const QDict *qdict)