From baf28f57e2dec63eebfcd3c00f8d4dea9fcde21e Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Thu, 18 Feb 2016 13:16:48 +0800 Subject: dump-guest-memory: using static DumpState, add DumpStatus Instead of malloc/free each time for DumpState, make it static. Added DumpStatus to show status for dump. This is to be used for detached dump. Signed-off-by: Peter Xu Reviewed-by: Fam Zheng Message-Id: <1455772616-8668-4-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- include/sysemu/dump.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/sysemu') diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 2f04b24..21fc02d 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -38,6 +38,7 @@ #include "sysemu/dump-arch.h" #include "sysemu/memory_mapping.h" +#include "qapi-types.h" typedef struct QEMU_PACKED MakedumpfileHeader { char signature[16]; /* = "makedumpfile" */ @@ -176,6 +177,7 @@ typedef struct DumpState { off_t offset_page; /* offset of page part in vmcore */ size_t num_dumpable; /* number of page that can be dumped */ uint32_t flag_compress; /* indicate the compression format */ + DumpStatus status; /* current dump status */ } DumpState; uint16_t cpu_to_dump16(DumpState *s, uint16_t val); -- cgit v1.1 From ca1fc8c97e9f26690b1ddbbbced5bafb3d65f6b5 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Thu, 18 Feb 2016 13:16:50 +0800 Subject: dump-guest-memory: introduce dump_process() helper function. No functional change. Cleanup only. Signed-off-by: Peter Xu Reviewed-by: Fam Zheng Message-Id: <1455772616-8668-6-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- include/sysemu/dump.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/sysemu') diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 21fc02d..1da3ddb 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -178,6 +178,9 @@ typedef struct DumpState { size_t num_dumpable; /* number of page that can be dumped */ uint32_t flag_compress; /* indicate the compression format */ DumpStatus status; /* current dump status */ + + bool has_format; /* whether format is provided */ + DumpGuestMemoryFormat format; /* valid only if has_format == true */ } DumpState; uint16_t cpu_to_dump16(DumpState *s, uint16_t val); -- cgit v1.1 From 1fbeff72c2ba17aedfbf0d57caf8945862725c54 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Thu, 18 Feb 2016 13:16:52 +0800 Subject: dump-guest-memory: add "detach" support If "detach" is provided, one thread is created to do the dump work, while main thread will return immediately. For each GuestPhysBlock, adding one more field "mr" to points to MemoryRegion that it belongs, also ref the mr before use. Signed-off-by: Peter Xu Reviewed-by: Fam Zheng Message-Id: <1455772616-8668-8-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- include/sysemu/dump.h | 1 + include/sysemu/memory_mapping.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'include/sysemu') diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 1da3ddb..06393c3 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -181,6 +181,7 @@ typedef struct DumpState { bool has_format; /* whether format is provided */ DumpGuestMemoryFormat format; /* valid only if has_format == true */ + QemuThread dump_thread; /* thread for detached dump */ } DumpState; uint16_t cpu_to_dump16(DumpState *s, uint16_t val); diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h index a75d59a..d46d879 100644 --- a/include/sysemu/memory_mapping.h +++ b/include/sysemu/memory_mapping.h @@ -16,6 +16,7 @@ #include "qemu/queue.h" #include "qemu/typedefs.h" +#include "exec/memory.h" typedef struct GuestPhysBlock { /* visible to guest, reflects PCI hole, etc */ @@ -27,6 +28,9 @@ typedef struct GuestPhysBlock { /* points into host memory */ uint8_t *host_addr; + /* points to the MemoryRegion that this block belongs to */ + MemoryRegion *mr; + QTAILQ_ENTRY(GuestPhysBlock) next; } GuestPhysBlock; -- cgit v1.1 From 2264c2c96e0a1f0913412da73e9bcaf9f8fa4427 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Thu, 18 Feb 2016 13:16:53 +0800 Subject: DumpState: adding total_size and written_size fields Here, total_size is the size in bytes to be dumped (raw data, which means before compression), while written_size are bytes handled (raw size too). Signed-off-by: Peter Xu Message-Id: <1455772616-8668-9-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- include/sysemu/dump.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/sysemu') diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 06393c3..ef931be 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -182,6 +182,15 @@ typedef struct DumpState { bool has_format; /* whether format is provided */ DumpGuestMemoryFormat format; /* valid only if has_format == true */ QemuThread dump_thread; /* thread for detached dump */ + + int64_t total_size; /* total memory size (in bytes) to + * be dumped. When filter is + * enabled, this will only count + * those to be written. */ + int64_t written_size; /* written memory size (in bytes), + * this could be used to calculate + * how much work we have + * finished. */ } DumpState; uint16_t cpu_to_dump16(DumpState *s, uint16_t val); -- cgit v1.1 From 21a933ea33c820515f331c162c9f7053ca6f4129 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 19 Feb 2016 17:19:31 -0700 Subject: chardev: Properly initialize ChardevCommon components Commit d0d7708b forgot to parse logging for spice chardevs and virtual consoles. This requires making qemu_chr_parse_common() non-static. While at it, use a temporary variable to make the code shorter, as well as reduce the churn when a later patch alters the layout of simple unions. Signed-off-by: Eric Blake CC: Daniel P. Berrange Message-Id: <1455927587-28033-2-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- include/sysemu/char.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/sysemu') diff --git a/include/sysemu/char.h b/include/sysemu/char.h index e035d1c..e46884f 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -115,6 +115,16 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, Error **errp); /** + * @qemu_chr_parse_common: + * + * Parse the common options available to all character backends. + * + * @opts the options that still need parsing + * @backend a new backend + */ +void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); + +/** * @qemu_chr_new: * * Create a new character backend from a URI. -- cgit v1.1