qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 05/12] dump-guest-memory: introduce dump_process(


From: Peter Xu
Subject: [Qemu-devel] [PATCH v3 05/12] dump-guest-memory: introduce dump_process() helper function.
Date: Mon, 30 Nov 2015 19:32:13 +0800

No functional change. Cleanup only.

Signed-off-by: Peter Xu <address@hidden>
---
 dump.c                | 19 ++++++++++++++-----
 include/sysemu/dump.h |  3 +++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/dump.c b/dump.c
index 110dbf9..c8ae5c3 100644
--- a/dump.c
+++ b/dump.c
@@ -1451,6 +1451,9 @@ static void dump_init(DumpState *s, int fd, bool 
has_format,
     Error *err = NULL;
     int ret;
 
+    s->has_format = has_format;
+    s->format = format;
+
     /* kdump-compressed is conflict with paging and filter */
     if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
         assert(!paging && !has_filter);
@@ -1604,6 +1607,16 @@ cleanup:
     dump_cleanup(s);
 }
 
+/* this operation might be time consuming. */
+static void dump_process(DumpState *s, Error **errp)
+{
+    if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
+        create_kdump_vmcore(s, errp);
+    } else {
+        create_vmcore(s, errp);
+    }
+}
+
 void qmp_dump_guest_memory(bool paging, const char *file,
                            bool has_detach, bool detach,
                            bool has_begin, int64_t begin, bool has_length,
@@ -1689,11 +1702,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,
         return;
     }
 
-    if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
-        create_kdump_vmcore(s, errp);
-    } else {
-        create_vmcore(s, errp);
-    }
+    dump_process(s, errp);
 
     if (*errp) {
         s->status = DUMP_STATUS_FAILED;
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
index affef38..d6f4a9c 100644
--- a/include/sysemu/dump.h
+++ b/include/sysemu/dump.h
@@ -185,6 +185,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);
-- 
2.4.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]