Skip to contentSkip to conversation

Add basic "detach" support for dump-guest-memory

PATCH Superseded Peter Xu 3 participants 38 messages Nov 30, 2015 – Dec 2, 2015

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

v3 cover Add basic "detach" support for dump-guest-memory

v3 changes (patch number corresponds to v2 patch set):
- patch 1
- fix commit message. no memory leak, only code cleanup [Fam]
- patch 2
- better documentation for "dump-guest-memory" (new patch 9) [Fam]
- patch 3
- remove rcu lock/unlock in dump_init() [Fam, Paolo]
- embed mr pointer into GuestPhysBlock [Paolo]
- remove global dump state [Paolo]
- patch 4
- fix memory leak for error [Fam]
- evt DUMP_COMPLETED data: change to an optional "*error" [Paolo]
- patch 5
- fix documents [Fam]
- change "dump-query" to "query-dump", HMP to "info dump" [Paolo]
- patch 6
- for query-dump command: define enum for DumpStatus, use "int" for written/total [Paolo]
- all
- reorder the commits as suggested, no fake values [Paolo]
- split big commit into smaller ones [me]

v2 changes:
- fixed English errors [Drew]
- reordered the "detach" field, first make it optional, then make sure it's order is consistent [Drew, Fam]
- added doc for new detach flag [Eric]
- collected error msg even detached [Drew]
- added qmp event DUMP_COMPLETED to notify user [Eric, Fam]
- added "dump-query" QMP & HMP commands to query dump status [Eric]
- "stop" is not allowed when dump in background (also include "cont" and "dump-guest-memory") [Fam]
- added codes to calculate how many dump work finished, which could be queried from "dump-query" [Laszlo]
- added list to track all used MemoryRegion objects, also ref before use [Paolo]
- dump-guest-memory will be forbidden during incoming migrate [Paolo]
- taking rcu lock when collecting memory info [Paolo]

Test Done:
- QMP & HMP
- test default dump (sync), work as usual
- test detached dump, command return immediately. When dump finished, will receive event DUMP_COMPLETED with a message.
- test query-dump before/during/after dump
- test kdump with zlib compression, w/ and w/o detach
- libvirt
- test "virsh dump --memory-only" with default format and kdump-zlib format, work as usual

Peter Xu (12):
dump-guest-memory: cleanup: removing dump_{error|cleanup}().
dump-guest-memory: add "detach" flag for QMP/HMP interfaces.
dump-guest-memory: using static DumpState, add DumpStatus
dump-guest-memory: add dump_in_progress() helper function
dump-guest-memory: introduce dump_process() helper function.
dump-guest-memory: disable dump when in INMIGRATE state
dump-guest-memory: add "detach" support
dump-guest-memory: add qmp event DUMP_COMPLETED
DumpState: adding total_size and written_size fields
Dump: add qmp command "query-dump"
Dump: add hmp command "info dump"
Dump: enhance the documentations.

 docs/qmp-events.txt             |  14 +++
 dump.c                          | 218 ++++++++++++++++++++++++++++++----------
 hmp-commands-info.hx            |  14 +++
 hmp-commands.hx                 |   5 +-
 hmp.c                           |  27 ++++-
 hmp.h                           |   1 +
 include/qemu-common.h           |   4 +
 include/sysemu/dump.h           |  15 +++
 include/sysemu/memory_mapping.h |   4 +
 memory_mapping.c                |   3 +
 qapi-schema.json                |  58 ++++++++++-
 qapi/event.json                 |  10 ++
 qmp-commands.hx                 |  34 ++++++-
 qmp.c                           |  14 +++
 14 files changed, 357 insertions(+), 64 deletions(-)
Signature · 1 line
2.4.3
author
#1 lore raw

PATCH v3 1/12 dump-guest-memory: cleanup: removing dump_{error|cleanup}().

It might be a little bit confusing to do dump_cleanup() in these two functions and error prone. A better way is to do dump_cleanup() before dump finish, no matter whether dump has succeeded or not.

---
 dump.c | 78 +++++++++++++++++++++++++++---------------------------------------
 1 file changed, 32 insertions(+), 46 deletions(-)
dump.c +32 -46
index 78b7d84..445e739 100644
@@ -82,12 +82,6 @@ static int dump_cleanup(DumpState *s)
     return 0;
 }
 
-static void dump_error(DumpState *s, const char *reason, Error **errp)
-{
-    dump_cleanup(s);
-    error_setg(errp, "%s", reason);
-}
-
 static int fd_write_vmcore(const void *buf, size_t size, void *opaque)
 {
     DumpState *s = opaque;
@@ -128,7 +122,7 @@ static void write_elf64_header(DumpState *s, Error **errp)
 
     ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write elf header", errp);
+        error_setg(errp, "dump: failed to write elf header");
     }
 }
 
@@ -159,7 +153,7 @@ static void write_elf32_header(DumpState *s, Error **errp)
 
     ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write elf header", errp);
+        error_setg(errp, "dump: failed to write elf header");
     }
 }
 
@@ -182,7 +176,7 @@ static void write_elf64_load(DumpState *s, MemoryMapping *memory_mapping,
 
     ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write program header table", errp);
+        error_setg(errp, "dump: failed to write program header table");
     }
 }
 
@@ -205,7 +199,7 @@ static void write_elf32_load(DumpState *s, MemoryMapping *memory_mapping,
 
     ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write program header table", errp);
+        error_setg(errp, "dump: failed to write program header table");
     }
 }
 
@@ -225,7 +219,7 @@ static void write_elf64_note(DumpState *s, Error **errp)
 
     ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write program header table", errp);
+        error_setg(errp, "dump: failed to write program header table");
     }
 }
 
@@ -245,7 +239,7 @@ static void write_elf64_notes(WriteCoreDumpFunction f, DumpState *s,
         id = cpu_index(cpu);
         ret = cpu_write_elf64_note(f, cpu, id, s);
         if (ret < 0) {
-            dump_error(s, "dump: failed to write elf notes", errp);
+            error_setg(errp, "dump: failed to write elf notes");
             return;
         }
     }
@@ -253,7 +247,7 @@ static void write_elf64_notes(WriteCoreDumpFunction f, DumpState *s,
     CPU_FOREACH(cpu) {
         ret = cpu_write_elf64_qemunote(f, cpu, s);
         if (ret < 0) {
-            dump_error(s, "dump: failed to write CPU status", errp);
+            error_setg(errp, "dump: failed to write CPU status");
             return;
         }
     }
@@ -275,7 +269,7 @@ static void write_elf32_note(DumpState *s, Error **errp)
 
     ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write program header table", errp);
+        error_setg(errp, "dump: failed to write program header table");
     }
 }
 
@@ -290,7 +284,7 @@ static void write_elf32_notes(WriteCoreDumpFunction f, DumpState *s,
         id = cpu_index(cpu);
         ret = cpu_write_elf32_note(f, cpu, id, s);
         if (ret < 0) {
-            dump_error(s, "dump: failed to write elf notes", errp);
+            error_setg(errp, "dump: failed to write elf notes");
             return;
         }
     }
@@ -298,7 +292,7 @@ static void write_elf32_notes(WriteCoreDumpFunction f, DumpState *s,
     CPU_FOREACH(cpu) {
         ret = cpu_write_elf32_qemunote(f, cpu, s);
         if (ret < 0) {
-            dump_error(s, "dump: failed to write CPU status", errp);
+            error_setg(errp, "dump: failed to write CPU status");
             return;
         }
     }
@@ -326,7 +320,7 @@ static void write_elf_section(DumpState *s, int type, Error **errp)
 
     ret = fd_write_vmcore(&shdr, shdr_size, s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write section header table", errp);
+        error_setg(errp, "dump: failed to write section header table");
     }
 }
 
@@ -336,7 +330,7 @@ static void write_data(DumpState *s, void *buf, int length, Error **errp)
 
     ret = fd_write_vmcore(buf, length, s);
     if (ret < 0) {
-        dump_error(s, "dump: failed to save memory", errp);
+        error_setg(errp, "dump: failed to save memory");
     }
 }
 
@@ -568,11 +562,6 @@ static void dump_begin(DumpState *s, Error **errp)
     }
 }
 
-static void dump_completed(DumpState *s)
-{
-    dump_cleanup(s);
-}
-
 static int get_next_block(DumpState *s, GuestPhysBlock *block)
 {
     while (1) {
@@ -624,8 +613,6 @@ static void dump_iterate(DumpState *s, Error **errp)
         }
 
     } while (!get_next_block(s, block));
-
-    dump_completed(s);
 }
 
 static void create_vmcore(DumpState *s, Error **errp)
@@ -765,7 +752,7 @@ static void create_header32(DumpState *s, Error **errp)
     dh->status = cpu_to_dump32(s, status);
 
     if (write_buffer(s->fd, 0, dh, size) < 0) {
-        dump_error(s, "dump: failed to write disk dump header", errp);
+        error_setg(errp, "dump: failed to write disk dump header");
         goto out;
     }
 
@@ -784,7 +771,7 @@ static void create_header32(DumpState *s, Error **errp)
 
     if (write_buffer(s->fd, DISKDUMP_HEADER_BLOCKS *
                      block_size, kh, size) < 0) {
-        dump_error(s, "dump: failed to write kdump sub header", errp);
+        error_setg(errp, "dump: failed to write kdump sub header");
         goto out;
     }
 
@@ -800,7 +787,7 @@ static void create_header32(DumpState *s, Error **errp)
     }
     if (write_buffer(s->fd, offset_note, s->note_buf,
                      s->note_size) < 0) {
-        dump_error(s, "dump: failed to write notes", errp);
+        error_setg(errp, "dump: failed to write notes");
         goto out;
     }
 
@@ -865,7 +852,7 @@ static void create_header64(DumpState *s, Error **errp)
     dh->status = cpu_to_dump32(s, status);
 
     if (write_buffer(s->fd, 0, dh, size) < 0) {
-        dump_error(s, "dump: failed to write disk dump header", errp);
+        error_setg(errp, "dump: failed to write disk dump header");
         goto out;
     }
 
@@ -884,7 +871,7 @@ static void create_header64(DumpState *s, Error **errp)
 
     if (write_buffer(s->fd, DISKDUMP_HEADER_BLOCKS *
                      block_size, kh, size) < 0) {
-        dump_error(s, "dump: failed to write kdump sub header", errp);
+        error_setg(errp, "dump: failed to write kdump sub header");
         goto out;
     }
 
@@ -901,7 +888,7 @@ static void create_header64(DumpState *s, Error **errp)
 
     if (write_buffer(s->fd, offset_note, s->note_buf,
                      s->note_size) < 0) {
-        dump_error(s, "dump: failed to write notes", errp);
+        error_setg(errp, "dump: failed to write notes");
         goto out;
     }
 
@@ -1064,7 +1051,7 @@ static void write_dump_bitmap(DumpState *s, Error **errp)
     while (get_next_page(&block_iter, &pfn, NULL, s)) {
         ret = set_dump_bitmap(last_pfn, pfn, true, dump_bitmap_buf, s);
         if (ret < 0) {
-            dump_error(s, "dump: failed to set dump_bitmap", errp);
+            error_setg(errp, "dump: failed to set dump_bitmap");
             goto out;
         }
 
@@ -1081,7 +1068,7 @@ static void write_dump_bitmap(DumpState *s, Error **errp)
         ret = set_dump_bitmap(last_pfn, last_pfn + PFN_BUFBITMAP, false,
                               dump_bitmap_buf, s);
         if (ret < 0) {
-            dump_error(s, "dump: failed to sync dump_bitmap", errp);
+            error_setg(errp, "dump: failed to sync dump_bitmap");
             goto out;
         }
     }
@@ -1214,7 +1201,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
     ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
     g_free(buf);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write page data (zero page)", errp);
+        error_setg(errp, "dump: failed to write page data (zero page)");
         goto out;
     }
 
@@ -1230,7 +1217,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
             ret = write_cache(&page_desc, &pd_zero, sizeof(PageDescriptor),
                               false);
             if (ret < 0) {
-                dump_error(s, "dump: failed to write page desc", errp);
+                error_setg(errp, "dump: failed to write page desc");
                 goto out;
             }
         } else {
@@ -1255,7 +1242,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
 
                 ret = write_cache(&page_data, buf_out, size_out, false);
                 if (ret < 0) {
-                    dump_error(s, "dump: failed to write page data", errp);
+                    error_setg(errp, "dump: failed to write page data");
                     goto out;
                 }
 #ifdef CONFIG_LZO
@@ -1268,7 +1255,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
 
                 ret = write_cache(&page_data, buf_out, size_out, false);
                 if (ret < 0) {
-                    dump_error(s, "dump: failed to write page data", errp);
+                    error_setg(errp, "dump: failed to write page data");
                     goto out;
                 }
 #endif
@@ -1282,7 +1269,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
 
                 ret = write_cache(&page_data, buf_out, size_out, false);
                 if (ret < 0) {
-                    dump_error(s, "dump: failed to write page data", errp);
+                    error_setg(errp, "dump: failed to write page data");
                     goto out;
                 }
 #endif
@@ -1297,7 +1284,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
 
                 ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
                 if (ret < 0) {
-                    dump_error(s, "dump: failed to write page data", errp);
+                    error_setg(errp, "dump: failed to write page data");
                     goto out;
                 }
             }
@@ -1309,7 +1296,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
 
             ret = write_cache(&page_desc, &pd, sizeof(PageDescriptor), false);
             if (ret < 0) {
-                dump_error(s, "dump: failed to write page desc", errp);
+                error_setg(errp, "dump: failed to write page desc");
                 goto out;
             }
         }
@@ -1317,12 +1304,12 @@ static void write_dump_pages(DumpState *s, Error **errp)
 
     ret = write_cache(&page_desc, NULL, 0, true);
     if (ret < 0) {
-        dump_error(s, "dump: failed to sync cache for page_desc", errp);
+        error_setg(errp, "dump: failed to sync cache for page_desc");
         goto out;
     }
     ret = write_cache(&page_data, NULL, 0, true);
     if (ret < 0) {
-        dump_error(s, "dump: failed to sync cache for page_data", errp);
+        error_setg(errp, "dump: failed to sync cache for page_data");
         goto out;
     }
 
@@ -1366,7 +1353,7 @@ static void create_kdump_vmcore(DumpState *s, Error **errp)
 
     ret = write_start_flat_header(s->fd);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write start flat header", errp);
+        error_setg(errp, "dump: failed to write start flat header");
         return;
     }
 
@@ -1390,11 +1377,9 @@ static void create_kdump_vmcore(DumpState *s, Error **errp)
 
     ret = write_end_flat_header(s->fd);
     if (ret < 0) {
-        dump_error(s, "dump: failed to write end flat header", errp);
+        error_setg(errp, "dump: failed to write end flat header");
         return;
     }
-
-    dump_completed(s);
 }
 
 static ram_addr_t get_start_block(DumpState *s)
@@ -1677,6 +1662,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
         create_vmcore(s, errp);
     }
 
+    dump_cleanup(s);
     g_free(s);
 }
 
Signature · 1 line
2.4.3
author
#2 lore raw

PATCH v3 2/12 dump-guest-memory: add "detach" flag for QMP/HMP interfaces.

In reply to Peter Xu

This patch only adds the interfaces, but not implements them. "detach" parameter is made optional, to make sure that all the old dump-guest-memory requests will still be able to work.

---
 dump.c           | 5 +++--
 hmp-commands.hx  | 5 +++--
 hmp.c            | 9 +++++++--
 qapi-schema.json | 8 ++++++--
 qmp-commands.hx  | 6 ++++--
 5 files changed, 23 insertions(+), 10 deletions(-)
dump.c +3 -2
index 445e739..d79e0ed 100644
@@ -1580,8 +1580,9 @@ cleanup:
     dump_cleanup(s);
 }
 
-void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
-                           int64_t begin, bool has_length,
+void qmp_dump_guest_memory(bool paging, const char *file,
+                           bool has_detach, bool detach,
+                           bool has_begin, int64_t begin, bool has_length,
                            int64_t length, bool has_format,
                            DumpGuestMemoryFormat format, Error **errp)
 {
hmp-commands.hx +3 -2
index bb52e4d..664d794 100644
@@ -1056,10 +1056,11 @@ ETEXI
 
     {
         .name       = "dump-guest-memory",
-        .args_type  = "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
-        .params     = "[-p] [-z|-l|-s] filename [begin length]",
+        .args_type  = "paging:-p,detach:-d,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
+        .params     = "[-p] [-d] [-z|-l|-s] filename [begin length]",
         .help       = "dump guest memory into file 'filename'.\n\t\t\t"
                       "-p: do paging to get guest's memory mapping.\n\t\t\t"
+                      "-d: return immediately (do not wait for completion).\n\t\t\t"
                       "-z: dump in kdump-compressed format, with zlib compression.\n\t\t\t"
                       "-l: dump in kdump-compressed format, with lzo compression.\n\t\t\t"
                       "-s: dump in kdump-compressed format, with snappy compression.\n\t\t\t"
hmp.c +7 -2
index 2140605..dccb457 100644
@@ -1586,8 +1586,10 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
     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;
 
@@ -1615,11 +1617,14 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
     if (has_length) {
         length = qdict_get_int(qdict, "length");
     }
+    if (has_detach) {
+        detach = qdict_get_try_bool(qdict, "detach", false);
+    }
 
     prot = g_strconcat("file:", file, NULL);
 
-    qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
-                          true, dump_format, &err);
+    qmp_dump_guest_memory(paging, prot, has_detach, detach, has_begin, begin,
+                          has_length, length, true, dump_format, &err);
     hmp_handle_error(mon, &err);
     g_free(prot);
 }
qapi-schema.json +6 -2
index 8b1a423..fd81ce2 100644
@@ -2115,6 +2115,9 @@
 #            2. fd: the protocol starts with "fd:", and the following string
 #               is the fd's name.
 #
+# @detach: #optional if true, QMP will return immediately rather than
+#          waiting dump to be finished (since 2.6).
+#
 # @begin: #optional if specified, the starting physical address.
 #
 # @length: #optional if specified, the memory size, in bytes. If you don't
@@ -2131,8 +2134,9 @@
 # Since: 1.2
 ##
 { 'command': 'dump-guest-memory',
-  'data': { 'paging': 'bool', 'protocol': 'str', '*begin': 'int',
-            '*length': 'int', '*format': 'DumpGuestMemoryFormat' } }
+  'data': { 'paging': 'bool', 'protocol': 'str', '*detach': 'bool',
+            '*begin': 'int', '*length': 'int',
+            '*format': 'DumpGuestMemoryFormat'} }
 
 ##
 # @DumpGuestMemoryCapability:
qmp-commands.hx +4 -2
index 9d8b42f..bbb08e1 100644
@@ -840,8 +840,8 @@ EQMP
 
     {
         .name       = "dump-guest-memory",
-        .args_type  = "paging:b,protocol:s,begin:i?,end:i?,format:s?",
-        .params     = "-p protocol [begin] [length] [format]",
+        .args_type  = "paging:b,protocol:s,detach:b?,begin:i?,end:i?,format:s?",
+        .params     = "-p protocol [-d] [begin] [length] [format]",
         .help       = "dump guest memory to file",
         .mhandler.cmd_new = qmp_marshal_dump_guest_memory,
     },
@@ -857,6 +857,8 @@ Arguments:
 - "paging": do paging to get guest's memory mapping (json-bool)
 - "protocol": destination file(started with "file:") or destination file
               descriptor (started with "fd:") (json-string)
+- "detach": if specificed, command will return immediately, without waiting
+            for dump to be finished (json-bool)
 - "begin": the starting physical address. It's optional, and should be specified
            with length together (json-int)
 - "length": the memory size, in bytes. It's optional, and should be specified
Signature · 1 line
2.4.3
#3 lore raw

Re: [Qemu-devel] [PATCH v3 02/12] dump-guest-memory: add "detach" flag for QMP/HMP interfaces.

Quoted 15 lines · Peter Xu

This patch only adds the interfaces, but not implements them. "detach" parameter is made optional, to make sure that all the old dump-guest-memory requests will still be able to work.

---
 dump.c           | 5 +++--
 hmp-commands.hx  | 5 +++--
 hmp.c            | 9 +++++++--
 qapi-schema.json | 8 ++++++--
 qmp-commands.hx  | 6 ++++--
 5 files changed, 23 insertions(+), 10 deletions(-)

+++ b/hmp.c

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1589

Quoted 4 lines
hmp.c +1 -0
@@ -1586,8 +1586,10 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
     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");

Here, you probe whether 'detach' is present...

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1592

Quoted 3 lines
hmp.c +1 -0
     int64_t begin = 0;
     int64_t length = 0;
+    bool detach = false;

...here, you default 'detach' to false,..

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1621

Quoted 9 lines
hmp.c +2 -0
     enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
     char *prot;
 
@@ -1615,11 +1617,14 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
     if (has_length) {
         length = qdict_get_int(qdict, "length");
     }
+    if (has_detach) {
+        detach = qdict_get_try_bool(qdict, "detach", false);

...therefore, this line is only reachable if 'detach' is present, which means the default will never be needed.

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1627

Quoted 8 lines
hmp.c +3 -2
+    }
 
     prot = g_strconcat("file:", file, NULL);
 
-    qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
-                          true, dump_format, &err);
+    qmp_dump_guest_memory(paging, prot, has_detach, detach, has_begin, begin,
+                          has_length, length, true, dump_format, &err);

There are two competing ways to simplify this; I don't care which one you choose, although you can't do both:

1. Note that since the second assignment to detach only happens if has_detach is true, you can use the simpler:

if (has_detach) {
    detach = qdict_get_bool(qdict, "detach");
}

If you go with this approach, you could even get away without initializing 'detach' outside of the 'if (has_detach)' conditional (although it's still probably wiser to avoid uninitialized memory than to rely on qmp_dump_guest_memory() correctly ignoring 'detach' when 'has_detach' is false).

2. Note that since qdict_get_try_bool() lets you specify a default, you can eliminate the has_detach variable and instead just do:

bool detach = qdict_get_try_bool(qdict, "detach", false);
...
qmp_dump_guest_memory(paging, prot, true, detach, ...);

qapi-schema.json line 2119

Quoted 7 lines
qapi-schema.json +3 -0
+++ b/qapi-schema.json
@@ -2115,6 +2115,9 @@
 #            2. fd: the protocol starts with "fd:", and the following string
 #               is the fd's name.
 #
+# @detach: #optional if true, QMP will return immediately rather than
+#          waiting dump to be finished (since 2.6).

s/dump/for the dump/
s/be finished/finish/

qmp-commands.hx Arguments: · line 860

Quoted 5 lines
qmp-commands.hx +1 -0
@@ -857,6 +857,8 @@ Arguments:
 - "paging": do paging to get guest's memory mapping (json-bool)
 - "protocol": destination file(started with "file:") or destination file
               descriptor (started with "fd:") (json-string)
+- "detach": if specificed, command will return immediately, without waiting

s/specificed/specified/

qmp-commands.hx Arguments: · line 861

Quoted 1 line
qmp-commands.hx +1 -0
+            for dump to be finished (json-bool)

s/dump/the dump/
s/be finished/finish/

Quoted 4 lines
qmp-commands.hx +0 -0
 - "begin": the starting physical address. It's optional, and should be specified
            with length together (json-int)
 - "length": the memory size, in bytes. It's optional, and should be specified
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#4 lore raw

Re: [Qemu-devel] [PATCH v3 02/12] dump-guest-memory: add "detach" flag for QMP/HMP interfaces.

Quoted 67 lines · Eric Blake
Quoted 15 lines · Peter Xu

This patch only adds the interfaces, but not implements them. "detach" parameter is made optional, to make sure that all the old dump-guest-memory requests will still be able to work.

---
 dump.c           | 5 +++--
 hmp-commands.hx  | 5 +++--
 hmp.c            | 9 +++++++--
 qapi-schema.json | 8 ++++++--
 qmp-commands.hx  | 6 ++++--
 5 files changed, 23 insertions(+), 10 deletions(-)

+++ b/hmp.c

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1589

Quoted 4 lines
hmp.c +1 -0
@@ -1586,8 +1586,10 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
     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");

Here, you probe whether 'detach' is present...

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1592

Quoted 3 lines
hmp.c +1 -0
     int64_t begin = 0;
     int64_t length = 0;
+    bool detach = false;

...here, you default 'detach' to false,..

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1621

Quoted 9 lines
hmp.c +2 -0
     enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
     char *prot;
 
@@ -1615,11 +1617,14 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
     if (has_length) {
         length = qdict_get_int(qdict, "length");
     }
+    if (has_detach) {
+        detach = qdict_get_try_bool(qdict, "detach", false);

...therefore, this line is only reachable if 'detach' is present, which means the default will never be needed.

hmp.c void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) · line 1627

Quoted 8 lines
hmp.c +3 -2
+    }
 
     prot = g_strconcat("file:", file, NULL);
 
-    qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
-                          true, dump_format, &err);
+    qmp_dump_guest_memory(paging, prot, has_detach, detach, has_begin, begin,
+                          has_length, length, true, dump_format, &err);

There are two competing ways to simplify this; I don't care which one you choose, although you can't do both:

1. Note that since the second assignment to detach only happens if has_detach is true, you can use the simpler:

if (has_detach) {
    detach = qdict_get_bool(qdict, "detach");
}

If you go with this approach, you could even get away without initializing 'detach' outside of the 'if (has_detach)' conditional (although it's still probably wiser to avoid uninitialized memory than to rely on qmp_dump_guest_memory() correctly ignoring 'detach' when 'has_detach' is false).

Quoted 6 lines

2. Note that since qdict_get_try_bool() lets you specify a default, you can eliminate the has_detach variable and instead just do:

bool detach = qdict_get_try_bool(qdict, "detach", false);
...
qmp_dump_guest_memory(paging, prot, true, detach, ...);

Yes, the default is lost. Thanks.

I think (2) is better in term of lines of codes (and also clear). However I may need to keep the QMP interface (to keep the has_detach parameter in qmp_dump_guest_memory), so I'd like to choose (1).

Quoted 20 lines

qapi-schema.json line 2119

Quoted 8 lines
qapi-schema.json +3 -0
+++ b/qapi-schema.json
@@ -2115,6 +2115,9 @@
 #            2. fd: the protocol starts with "fd:", and the following string
 #               is the fd's name.
 #
+# @detach: #optional if true, QMP will return immediately rather than
+#          waiting dump to be finished (since 2.6).

s/dump/for the dump/
s/be finished/finish/

qmp-commands.hx Arguments: · line 860

Quoted 5 lines
qmp-commands.hx +1 -0
@@ -857,6 +857,8 @@ Arguments:
 - "paging": do paging to get guest's memory mapping (json-bool)
 - "protocol": destination file(started with "file:") or destination file
               descriptor (started with "fd:") (json-string)
+- "detach": if specificed, command will return immediately, without waiting

s/specificed/specified/

Quoted 4 lines

qmp-commands.hx Arguments: · line 861

Quoted 1 line
qmp-commands.hx +1 -0
+            for dump to be finished (json-bool)

s/dump/the dump/
s/be finished/finish/

Thanks for review again on the English!

Peter

Quoted 10 lines
Quoted 5 lines
qmp-commands.hx +0 -0
 - "begin": the starting physical address. It's optional, and should be specified
            with length together (json-int)
 - "length": the memory size, in bytes. It's optional, and should be specified
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw

Re: [Qemu-devel] [PATCH v3 02/12] dump-guest-memory: add "detach" flag for QMP/HMP interfaces.

Quoted 4 lines · Peter Xu

I think (2) is better in term of lines of codes (and also clear). However I may need to keep the QMP interface (to keep the has_detach parameter in qmp_dump_guest_memory), so I'd like to choose (1).

It's also okay to also pass has_detach = true to qmp_dump_guest_memory.

Paolo

author
#6 lore raw

Re: [Qemu-devel] [PATCH v3 02/12] dump-guest-memory: add "detach" flag for QMP/HMP interfaces.

Quoted 9 lines · Paolo Bonzini
Quoted 4 lines · Peter Xu

I think (2) is better in term of lines of codes (and also clear). However I may need to keep the QMP interface (to keep the has_detach parameter in qmp_dump_guest_memory), so I'd like to choose (1).

It's also okay to also pass has_detach = true to qmp_dump_guest_memory.

Yes. That's more clear. Will put it into v5.

Thanks.
Peter

Quoted 2 lines

Paolo

author
#7 lore raw

PATCH v3 3/12 dump-guest-memory: using static DumpState, add DumpStatus

In reply to Peter Xu

Instead of malloc/free each time for DumpState, make it static. Added DumpStatus to show status for dump.

This is to be used for detach dump.

---
 dump.c                | 30 +++++++++++++++++++++++++++---
 include/sysemu/dump.h |  2 ++
 qapi-schema.json      | 18 ++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)
dump.c +27 -3
index d79e0ed..c9ea878 100644
@@ -1418,6 +1418,24 @@ static void get_max_mapnr(DumpState *s)
     s->max_mapnr = paddr_to_pfn(last_block->target_end);
 }
 
+/* init dump state with specific status */
+static void dump_state_prepare(DumpState *s, DumpStatus status)
+{
+    bzero(s, sizeof(*s));
+    s->status = status;
+}
+
+static DumpState *dump_state_get_global(void)
+{
+    static DumpState state;
+    static bool init = false;
+    if (!init) {
+        dump_state_prepare(&state, DUMP_STATUS_NONE);
+        init = true;
+    }
+    return &state;
+}
+
 static void dump_init(DumpState *s, int fd, bool has_format,
                       DumpGuestMemoryFormat format, bool paging, bool has_filter,
                       int64_t begin, int64_t length, Error **errp)
@@ -1647,13 +1665,14 @@ void qmp_dump_guest_memory(bool paging, const char *file,
         return;
     }
 
-    s = g_malloc0(sizeof(DumpState));
+    s = dump_state_get_global();
+    dump_state_prepare(s, DUMP_STATUS_ACTIVE);
 
     dump_init(s, fd, has_format, format, paging, has_begin,
               begin, length, &local_err);
     if (local_err) {
-        g_free(s);
         error_propagate(errp, local_err);
+        s->status = DUMP_STATUS_FAILED;
         return;
     }
 
@@ -1663,8 +1682,13 @@ void qmp_dump_guest_memory(bool paging, const char *file,
         create_vmcore(s, errp);
     }
 
+    if (*errp) {
+        s->status = DUMP_STATUS_FAILED;
+    } else {
+        s->status = DUMP_STATUS_COMPLETED;
+    }
+
     dump_cleanup(s);
-    g_free(s);
 }
 
 DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
include/sysemu/dump.h +2 -0
index 7e4ec5c..affef38 100644
@@ -45,6 +45,7 @@
 
 #include "sysemu/dump-arch.h"
 #include "sysemu/memory_mapping.h"
+#include "qapi-types.h"
 
 typedef struct QEMU_PACKED MakedumpfileHeader {
     char signature[16];     /* = "makedumpfile" */
@@ -183,6 +184,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);
qapi-schema.json +18 -0
index fd81ce2..3728bfc 100644
@@ -2139,6 +2139,24 @@
             '*format': 'DumpGuestMemoryFormat'} }
 
 ##
+# @DumpStatus
+#
+# Define the status for dump guest memory.
+#
+# @none: not started any dump-guest-memory yet.
+#
+# @active: there is one dump running in background.
+#
+# @completed: the last dump has finished sucessfully
+#
+# @failed: the last dump has failed.
+#
+# Since 2.6
+##
+{ 'enum': 'DumpStatus',
+  'data': [ 'none', 'active', 'completed', 'failed' ] }
+
+##
 # @DumpGuestMemoryCapability:
 #
 # A list of the available formats for dump-guest-memory
Signature · 1 line
2.4.3
#8 lore raw

Re: [Qemu-devel] [PATCH v3 03/12] dump-guest-memory: using static DumpState, add DumpStatus

Quoted 17 lines · Peter Xu

Instead of malloc/free each time for DumpState, make it static. Added DumpStatus to show status for dump.

This is to be used for detach dump.

---
 dump.c                | 30 +++++++++++++++++++++++++++---
 include/sysemu/dump.h |  2 ++
 qapi-schema.json      | 18 ++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)
dump.c +0 -0
index d79e0ed..c9ea878 100644

dump.c static void get_max_mapnr(DumpState *s) · line 1425

Quoted 8 lines
dump.c +5 -0
@@ -1418,6 +1418,24 @@ static void get_max_mapnr(DumpState *s)
     s->max_mapnr = paddr_to_pfn(last_block->target_end);
 }
 
+/* init dump state with specific status */
+static void dump_state_prepare(DumpState *s, DumpStatus status)
+{
+    bzero(s, sizeof(*s));
+    s->status = status;

Either use memcpy, or

    s = (DumpState) { .status = status };

The latter is C99 and it's quite common in QEMU.

dump.c static void get_max_mapnr(DumpState *s) · line 1428

Quoted 3 lines
dump.c +3 -0
+}
+
+static DumpState *dump_state_get_global(void)

No need for dump_state_get_global, just use a static variable. Then you can use &dump_state in qmp_dump_guest_memory.

dump.c static void get_max_mapnr(DumpState *s) · line 1430

Quoted 2 lines
dump.c +2 -0
+{
+    static DumpState state;

You can also initialize it together with the definition, using

    static DumpState state = { .status = DUMP_STATUS_NONE };
Quoted 93 lines
dump.c +17 -3
+    static bool init = false;
+    if (!init) {
+        dump_state_prepare(&state, DUMP_STATUS_NONE);
+        init = true;
+    }
+    return &state;
+}
+
 static void dump_init(DumpState *s, int fd, bool has_format,
                       DumpGuestMemoryFormat format, bool paging, bool has_filter,
                       int64_t begin, int64_t length, Error **errp)
@@ -1647,13 +1665,14 @@ void qmp_dump_guest_memory(bool paging, const char *file,
         return;
     }
 
-    s = g_malloc0(sizeof(DumpState));
+    s = dump_state_get_global();
+    dump_state_prepare(s, DUMP_STATUS_ACTIVE);
 
     dump_init(s, fd, has_format, format, paging, has_begin,
               begin, length, &local_err);
     if (local_err) {
-        g_free(s);
         error_propagate(errp, local_err);
+        s->status = DUMP_STATUS_FAILED;
         return;
     }
 
@@ -1663,8 +1682,13 @@ void qmp_dump_guest_memory(bool paging, const char *file,
         create_vmcore(s, errp);
     }
 
+    if (*errp) {
+        s->status = DUMP_STATUS_FAILED;
+    } else {
+        s->status = DUMP_STATUS_COMPLETED;
+    }
+
     dump_cleanup(s);
-    g_free(s);
 }
 
 DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
include/sysemu/dump.h +2 -0
index 7e4ec5c..affef38 100644
@@ -45,6 +45,7 @@
 
 #include "sysemu/dump-arch.h"
 #include "sysemu/memory_mapping.h"
+#include "qapi-types.h"
 
 typedef struct QEMU_PACKED MakedumpfileHeader {
     char signature[16];     /* = "makedumpfile" */
@@ -183,6 +184,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);
qapi-schema.json +18 -0
index fd81ce2..3728bfc 100644
@@ -2139,6 +2139,24 @@
             '*format': 'DumpGuestMemoryFormat'} }
 
 ##
+# @DumpStatus
+#
+# Define the status for dump guest memory.
+#
+# @none: not started any dump-guest-memory yet.
+#
+# @active: there is one dump running in background.
+#
+# @completed: the last dump has finished sucessfully
+#
+# @failed: the last dump has failed.
+#
+# Since 2.6
+##
+{ 'enum': 'DumpStatus',
+  'data': [ 'none', 'active', 'completed', 'failed' ] }
+
+##
 # @DumpGuestMemoryCapability:
 #
 # A list of the available formats for dump-guest-memory
author
#9 lore raw

Re: [Qemu-devel] [PATCH v3 03/12] dump-guest-memory: using static DumpState, add DumpStatus

Quoted 11 lines · Paolo Bonzini

dump.c static void get_max_mapnr(DumpState *s) · line 1425

Quoted 5 lines
dump.c +5 -0
+/* init dump state with specific status */
+static void dump_state_prepare(DumpState *s, DumpStatus status)
+{
+    bzero(s, sizeof(*s));
+    s->status = status;

Either use memcpy, or

    s = (DumpState) { .status = status };

The latter is C99 and it's quite common in QEMU.

Thanks to let me know this. :) Will use it in v4.

Quoted 7 lines

dump.c static void get_max_mapnr(DumpState *s) · line 1428

Quoted 4 lines
dump.c +3 -0
+}
+
+static DumpState *dump_state_get_global(void)

No need for dump_state_get_global, just use a static variable. Then you can use &dump_state in qmp_dump_guest_memory.

Ok.

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+{
+    static DumpState state;

You can also initialize it together with the definition, using

    static DumpState state = { .status = DUMP_STATUS_NONE };

Yes. Thanks.

Peter

#10 lore raw

Re: [Qemu-devel] [PATCH v3 03/12] dump-guest-memory: using static DumpState, add DumpStatus

In reply to Peter Xu
Quoted 4 lines · Peter Xu

Instead of malloc/free each time for DumpState, make it static. Added DumpStatus to show status for dump.

This is to be used for detach dump.

s/detach/detached/

Quoted 8 lines
---
 dump.c                | 30 +++++++++++++++++++++++++++---
 include/sysemu/dump.h |  2 ++
 qapi-schema.json      | 18 ++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)

In addition to Paolo's review,

qapi-schema.json line 2144

Quoted 8 lines

+++ b/qapi-schema.json

qapi-schema.json +3 -0
@@ -2139,6 +2139,24 @@
             '*format': 'DumpGuestMemoryFormat'} }
 
 ##
+# @DumpStatus
+#
+# Define the status for dump guest memory.

Reads awkwardly. Maybe:

Describe the status of a long-running background guest memory dump.

Review line 2146

Quoted 2 lines
(quoted diff) +2 -0
+#
+# @none: not started any dump-guest-memory yet.

@none: no dump-guest-memory has started yet

qapi-schema.json line 2150

Quoted 4 lines
qapi-schema.json +4 -0
+#
+# @active: there is one dump running in background.
+#
+# @completed: the last dump has finished sucessfully

s/sucessfully/successfully/

Inconsistent on whether your lines end in '.'

Quoted 13 lines
qapi-schema.json +9 -0
+#
+# @failed: the last dump has failed.
+#
+# Since 2.6
+##
+{ 'enum': 'DumpStatus',
+  'data': [ 'none', 'active', 'completed', 'failed' ] }
+
+##
 # @DumpGuestMemoryCapability:
 #
 # A list of the available formats for dump-guest-memory
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#11 lore raw

Re: [Qemu-devel] [PATCH v3 03/12] dump-guest-memory: using static DumpState, add DumpStatus

Quoted 37 lines · Eric Blake
Quoted 4 lines · Peter Xu

Instead of malloc/free each time for DumpState, make it static. Added DumpStatus to show status for dump.

This is to be used for detach dump.

s/detach/detached/

Quoted 8 lines
---
 dump.c                | 30 +++++++++++++++++++++++++++---
 include/sysemu/dump.h |  2 ++
 qapi-schema.json      | 18 ++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)

In addition to Paolo's review,

qapi-schema.json line 2144

Quoted 8 lines

+++ b/qapi-schema.json

qapi-schema.json +3 -0
@@ -2139,6 +2139,24 @@
             '*format': 'DumpGuestMemoryFormat'} }
 
 ##
+# @DumpStatus
+#
+# Define the status for dump guest memory.

Reads awkwardly. Maybe:

Describe the status of a long-running background guest memory dump.

Review line 2146

Quoted 2 lines
(quoted diff) +2 -0
+#
+# @none: not started any dump-guest-memory yet.

@none: no dump-guest-memory has started yet

Quoted 8 lines

qapi-schema.json line 2150

Quoted 4 lines
qapi-schema.json +4 -0
+#
+# @active: there is one dump running in background.
+#
+# @completed: the last dump has finished sucessfully

s/sucessfully/successfully/

Inconsistent on whether your lines end in '.'

Will fix above all in v4.

Thanks!
Peter

Quoted 19 lines
Quoted 14 lines
qapi-schema.json +9 -0
+#
+# @failed: the last dump has failed.
+#
+# Since 2.6
+##
+{ 'enum': 'DumpStatus',
+  'data': [ 'none', 'active', 'completed', 'failed' ] }
+
+##
 # @DumpGuestMemoryCapability:
 #
 # A list of the available formats for dump-guest-memory
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#12 lore raw

PATCH v3 4/12 dump-guest-memory: add dump_in_progress() helper function

In reply to Peter Xu

For now, it has no effect. It will be used in dump detach support.

---
 dump.c                | 13 +++++++++++++
 include/qemu-common.h |  4 ++++
 qmp.c                 | 14 ++++++++++++++
 3 files changed, 31 insertions(+)
dump.c +13 -0
index c9ea878..110dbf9 100644
@@ -1436,6 +1436,12 @@ static DumpState *dump_state_get_global(void)
     return &state;
 }
 
+bool dump_in_progress(void)
+{
+    DumpState *state = dump_state_get_global();
+    return (state->status == DUMP_STATUS_ACTIVE);
+}
+
 static void dump_init(DumpState *s, int fd, bool has_format,
                       DumpGuestMemoryFormat format, bool paging, bool has_filter,
                       int64_t begin, int64_t length, Error **errp)
@@ -1609,6 +1615,13 @@ void qmp_dump_guest_memory(bool paging, const char *file,
     DumpState *s;
     Error *local_err = NULL;
 
+    /* if there is a dump in background, we should wait until the dump
+     * finished */
+    if (dump_in_progress()) {
+        error_setg(errp, "There is a dump in process, please wait.");
+        return;
+    }
+
     /*
      * kdump-compressed format need the whole memory dumped, so paging or
      * filter is not supported here.
include/qemu-common.h +4 -0
index 405364f..7b74961 100644
@@ -501,4 +501,8 @@ int parse_debug_env(const char *name, int max, int initial);
 const char *qemu_ether_ntoa(const MACAddr *mac);
 void page_size_init(void);
 
+/* returns non-zero if dump is in progress, otherwise zero is
+ * returned. */
+bool dump_in_progress(void);
+
 #endif
qmp.c +14 -0
index 0a1fa19..055586d 100644
@@ -102,6 +102,13 @@ void qmp_quit(Error **errp)
 
 void qmp_stop(Error **errp)
 {
+    /* if there is a dump in background, we should wait until the dump
+     * finished */
+    if (dump_in_progress()) {
+        error_setg(errp, "There is a dump in process, please wait.");
+        return;
+    }
+
     if (runstate_check(RUN_STATE_INMIGRATE)) {
         autostart = 0;
     } else {
@@ -174,6 +181,13 @@ void qmp_cont(Error **errp)
     BlockBackend *blk;
     BlockDriverState *bs;
 
+    /* if there is a dump in background, we should wait until the dump
+     * finished */
+    if (dump_in_progress()) {
+        error_setg(errp, "There is a dump in process, please wait.");
+        return;
+    }
+
     if (runstate_needs_reset()) {
         error_setg(errp, "Resetting the Virtual Machine is required");
         return;
Signature · 1 line
2.4.3
author
#13 lore raw

PATCH v3 5/12 dump-guest-memory: introduce dump_process() helper function.

In reply to Peter Xu

No functional change. Cleanup only.

---
 dump.c                | 19 ++++++++++++++-----
 include/sysemu/dump.h |  3 +++
 2 files changed, 17 insertions(+), 5 deletions(-)
dump.c +14 -5
index 110dbf9..c8ae5c3 100644
@@ -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;
include/sysemu/dump.h +3 -0
index affef38..d6f4a9c 100644
@@ -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);
Signature · 1 line
2.4.3
#14 lore raw

Re: [Qemu-devel] [PATCH v3 05/12] dump-guest-memory: introduce dump_process() helper function.

Quoted 2 lines · Peter Xu
     if (*errp) {
         s->status = DUMP_STATUS_FAILED;

Why not move this "if" to dump_process as well?

Paolo

author
#15 lore raw

Re: [Qemu-devel] [PATCH v3 05/12] dump-guest-memory: introduce dump_process() helper function.

Quoted 7 lines · Paolo Bonzini
Quoted 2 lines · Peter Xu
     if (*errp) {
         s->status = DUMP_STATUS_FAILED;

Why not move this "if" to dump_process as well?

Yes. I did that in another patch. I will move it to this patch, which should be better.

Thanks.
Peter

Quoted 2 lines

Paolo

author
#16 lore raw

PATCH v3 6/12 dump-guest-memory: disable dump when in INMIGRATE state

In reply to Peter Xu
---
 dump.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
dump.c +5 -1
index c8ae5c3..5b9def3 100644
@@ -1628,13 +1628,17 @@ void qmp_dump_guest_memory(bool paging, const char *file,
     DumpState *s;
     Error *local_err = NULL;
 
+    if (runstate_check(RUN_STATE_INMIGRATE)) {
+        error_setg(errp, "Dump not allowed during incoming migration.");
+        return;
+    }
+
     /* if there is a dump in background, we should wait until the dump
      * finished */
     if (dump_in_progress()) {
         error_setg(errp, "There is a dump in process, please wait.");
         return;
     }
-
     /*
      * kdump-compressed format need the whole memory dumped, so paging or
      * filter is not supported here.
Signature · 1 line
2.4.3
author
#17 lore raw

PATCH v3 7/12 dump-guest-memory: add "detach" support

In reply to Peter Xu

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.

---
 dump.c                          | 39 ++++++++++++++++++++++++++++++++-------
 include/sysemu/dump.h           |  1 +
 include/sysemu/memory_mapping.h |  4 ++++
 memory_mapping.c                |  3 +++
 4 files changed, 40 insertions(+), 7 deletions(-)
dump.c +32 -7
index 5b9def3..14fd41f 100644
@@ -1615,6 +1615,28 @@ static void dump_process(DumpState *s, Error **errp)
     } else {
         create_vmcore(s, errp);
     }
+
+    if (*errp) {
+        s->status = DUMP_STATUS_FAILED;
+    } else {
+        s->status = DUMP_STATUS_COMPLETED;
+    }
+
+    dump_cleanup(s);
+}
+
+static void *dump_thread(void *data)
+{
+    Error *err = NULL;
+    DumpState *s = (DumpState *)data;
+
+    dump_process(s, &err);
+
+    if (err) {
+        /* TODO: notify user the error */
+        error_free(err);
+    }
+    return NULL;
 }
 
 void qmp_dump_guest_memory(bool paging, const char *file,
@@ -1627,6 +1649,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,
     int fd = -1;
     DumpState *s;
     Error *local_err = NULL;
+    bool detach_p = false;
 
     if (runstate_check(RUN_STATE_INMIGRATE)) {
         error_setg(errp, "Dump not allowed during incoming migration.");
@@ -1657,6 +1680,9 @@ void qmp_dump_guest_memory(bool paging, const char *file,
         error_setg(errp, QERR_MISSING_PARAMETER, "begin");
         return;
     }
+    if (has_detach) {
+        detach_p = detach;
+    }
 
     /* check whether lzo/snappy is supported */
 #ifndef CONFIG_LZO
@@ -1706,15 +1732,14 @@ void qmp_dump_guest_memory(bool paging, const char *file,
         return;
     }
 
-    dump_process(s, errp);
-
-    if (*errp) {
-        s->status = DUMP_STATUS_FAILED;
+    if (detach_p) {
+        /* detached dump */
+        qemu_thread_create(&s->dump_thread, "dump_thread", dump_thread,
+                           s, QEMU_THREAD_DETACHED);
     } else {
-        s->status = DUMP_STATUS_COMPLETED;
+        /* sync dump */
+        dump_process(s, errp);
     }
-
-    dump_cleanup(s);
 }
 
 DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
include/sysemu/dump.h +1 -0
index d6f4a9c..31930c6 100644
@@ -188,6 +188,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);
include/sysemu/memory_mapping.h +4 -0
index a75d59a..d46d879 100644
@@ -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;
 
memory_mapping.c +3 -0
index 36d6b26..f4f0622 100644
@@ -177,6 +177,7 @@ void guest_phys_blocks_free(GuestPhysBlockList *list)
 
     QTAILQ_FOREACH_SAFE(p, &list->head, next, q) {
         QTAILQ_REMOVE(&list->head, p, next);
+        memory_region_unref(p->mr);
         g_free(p);
     }
     list->num = 0;
@@ -240,6 +241,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
         block->target_start = target_start;
         block->target_end   = target_end;
         block->host_addr    = host_addr;
+        block->mr           = section->mr;
+        memory_region_ref(section->mr);
 
         QTAILQ_INSERT_TAIL(&g->list->head, block, next);
         ++g->list->num;
Signature · 1 line
2.4.3
author
#18 lore raw

PATCH v3 8/12 dump-guest-memory: add qmp event DUMP_COMPLETED

In reply to Peter Xu

One new QMP event DUMP_COMPLETED is added. It is used when user specified "detach" in dump, and triggered when the dump finishes (either succeeded or failed). If failed, one "err" data will be passed with specific error message.

---
 docs/qmp-events.txt | 14 ++++++++++++++
 dump.c              |  6 +++++-
 qapi/event.json     | 10 ++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)
docs/qmp-events.txt +14 -0
index d2f1ce4..7b9f835 100644
@@ -674,3 +674,17 @@ Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is
 followed respectively by the RESET, SHUTDOWN, or STOP events.
 
 Note: this event is rate-limited.
+
+DUMP_COMPLETED
+--------------
+
+Emitted when the guest has finished one memory dump.
+
+Data:
+
+- "error": Error message when dump failed (json-string, optional)
+
+Example:
+
+{ "event": "DUMP_COMPLETED",
+  "data": {} }
dump.c +5 -1
index 14fd41f..43f565d 100644
@@ -25,6 +25,7 @@
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "qmp-commands.h"
+#include "qapi-event.h"
 
 #include <zlib.h>
 #ifdef CONFIG_LZO
@@ -1633,8 +1634,11 @@ static void *dump_thread(void *data)
     dump_process(s, &err);
 
     if (err) {
-        /* TODO: notify user the error */
+        qapi_event_send_dump_completed(true, error_get_pretty(err),
+                                       &error_abort);
         error_free(err);
+    } else {
+        qapi_event_send_dump_completed(false, NULL, &error_abort);
     }
     return NULL;
 }
qapi/event.json +10 -0
index f0cef01..c46214b 100644
@@ -356,3 +356,13 @@
 ##
 { 'event': 'MEM_UNPLUG_ERROR',
   'data': { 'device': 'str', 'msg': 'str' } }
+
+##
+# @DUMP_COMPLETED
+#
+# Emitted when background dump has completed
+#
+# Since: 2.6
+##
+{ 'event': 'DUMP_COMPLETED' ,
+  'data': { '*error': 'str' } }
Signature · 1 line
2.4.3
#19 lore raw

Re: [Qemu-devel] [PATCH v3 08/12] dump-guest-memory: add qmp event DUMP_COMPLETED

Quoted 24 lines · Peter Xu

One new QMP event DUMP_COMPLETED is added. It is used when user specified "detach" in dump, and triggered when the dump finishes (either succeeded or failed). If failed, one "err" data will be passed with specific error message.

---
 docs/qmp-events.txt | 14 ++++++++++++++
 dump.c              |  6 +++++-
 qapi/event.json     | 10 ++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)
docs/qmp-events.txt +4 -0
index d2f1ce4..7b9f835 100644
@@ -674,3 +674,17 @@ Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is
 followed respectively by the RESET, SHUTDOWN, or STOP events.
 
 Note: this event is rate-limited.
+
+DUMP_COMPLETED
+--------------
+

docs/qmp-events.txt Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is · line 690

Quoted 10 lines
docs/qmp-events.txt +10 -0
+Emitted when the guest has finished one memory dump.
+
+Data:
+
+- "error": Error message when dump failed (json-string, optional)
+
+Example:
+
+{ "event": "DUMP_COMPLETED",
+  "data": {} }

Please keep this file sorted. The insertion should be between DEVICE_TRAY_MOVED and GUEST_PANICKED.

Quoted 13 lines
dump.c +1 -0
index 14fd41f..43f565d 100644
@@ -25,6 +25,7 @@
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "qmp-commands.h"
+#include "qapi-event.h"
 
 #include <zlib.h>
 #ifdef CONFIG_LZO

dump.c static void *dump_thread(void *data) · line 1642

Quoted 10 lines
dump.c +4 -1
@@ -1633,8 +1634,11 @@ static void *dump_thread(void *data)
     dump_process(s, &err);
 
     if (err) {
-        /* TODO: notify user the error */
+        qapi_event_send_dump_completed(true, error_get_pretty(err),
+                                       &error_abort);
         error_free(err);
+    } else {
+        qapi_event_send_dump_completed(false, NULL, &error_abort);
     }

Hmmm. I wonder if error_get_pretty() should be improved to return NULL when there is no error. Then we could write:

qapi_event_send_dump_completed(!!err, error_get_pretty(err),

                               &error_abort);

error_free(err);

But that doesn't affect the correctness of your patch.

Quoted 7 lines
dump.c +0 -0
     return NULL;
 }
qapi/event.json +0 -0
index f0cef01..c46214b 100644

qapi/event.json line 365

Quoted 10 lines
qapi/event.json +7 -0
@@ -356,3 +356,13 @@
 ##
 { 'event': 'MEM_UNPLUG_ERROR',
   'data': { 'device': 'str', 'msg': 'str' } }
+
+##
+# @DUMP_COMPLETED
+#
+# Emitted when background dump has completed
+#
+# Since: 2.6

Missing documentation of 'error'.

Quoted 4 lines
qapi/event.json +3 -0
+##
+{ 'event': 'DUMP_COMPLETED' ,
+  'data': { '*error': 'str' } }
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#20 lore raw

Re: [Qemu-devel] [PATCH v3 08/12] dump-guest-memory: add qmp event DUMP_COMPLETED

Quoted 8 lines · Eric Blake

docs/qmp-events.txt Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is · line 690

Quoted 4 lines · Peter Xu
docs/qmp-events.txt +4 -0
+Example:
+
+{ "event": "DUMP_COMPLETED",
+  "data": {} }

Please keep this file sorted. The insertion should be between DEVICE_TRAY_MOVED and GUEST_PANICKED.

Sorry for the incaution to miss that. Will fix in v4.

Quoted 28 lines
Quoted 14 lines
dump.c +1 -0
index 14fd41f..43f565d 100644
@@ -25,6 +25,7 @@
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "qmp-commands.h"
+#include "qapi-event.h"
 
 #include <zlib.h>
 #ifdef CONFIG_LZO

dump.c static void *dump_thread(void *data) · line 1642

Quoted 10 lines
dump.c +4 -1
@@ -1633,8 +1634,11 @@ static void *dump_thread(void *data)
     dump_process(s, &err);
 
     if (err) {
-        /* TODO: notify user the error */
+        qapi_event_send_dump_completed(true, error_get_pretty(err),
+                                       &error_abort);
         error_free(err);
+    } else {
+        qapi_event_send_dump_completed(false, NULL, &error_abort);
     }

Hmmm. I wonder if error_get_pretty() should be improved to return NULL when there is no error. Then we could write:

Quoted 5 lines

qapi_event_send_dump_completed(!!err, error_get_pretty(err),

                               &error_abort);

error_free(err);

But that doesn't affect the correctness of your patch.

After seeing that improving error_get_pretty() is simple (and also will not break the other callers), I'd like to take your advice, which is clean enough. Thanks.

Quoted 12 lines
Quoted 12 lines
dump.c +0 -0
     return NULL;
 }
qapi/event.json +1 -0
index f0cef01..c46214b 100644
@@ -356,3 +356,13 @@
 ##
 { 'event': 'MEM_UNPLUG_ERROR',
   'data': { 'device': 'str', 'msg': 'str' } }
+
Quoted 8 lines

qapi/event.json line 365

Quoted 6 lines
qapi/event.json +6 -0
+##
+# @DUMP_COMPLETED
+#
+# Emitted when background dump has completed
+#
+# Since: 2.6

Missing documentation of 'error'.

Added.

Thanks!
Peter

Quoted 10 lines
Quoted 5 lines
qapi/event.json +3 -0
+##
+{ 'event': 'DUMP_COMPLETED' ,
+  'data': { '*error': 'str' } }
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#21 lore raw

PATCH v3 9/12 DumpState: adding total_size and written_size fields

In reply to Peter Xu

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).

---
 dump.c                | 32 ++++++++++++++++++++++++++++++++
 include/sysemu/dump.h |  9 +++++++++
 2 files changed, 41 insertions(+)
dump.c +32 -0
index 43f565d..56a2d7e 100644
@@ -333,6 +333,8 @@ static void write_data(DumpState *s, void *buf, int length, Error **errp)
     if (ret < 0) {
         error_setg(errp, "dump: failed to save memory");
     }
+
+    s->written_size += length;
 }
 
 /* write the memory to vmcore. 1 page per I/O. */
@@ -1301,6 +1303,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
                 goto out;
             }
         }
+        s->written_size += TARGET_PAGE_SIZE;
     }
 
     ret = write_cache(&page_desc, NULL, 0, true);
@@ -1443,6 +1446,30 @@ bool dump_in_progress(void)
     return (state->status == DUMP_STATUS_ACTIVE);
 }
 
+/* calculate total size of memory to be dumped (taking filter into
+ * acoount.) */
+static size_t dump_calculate_size(DumpState *s)
+{
+    GuestPhysBlock *block;
+    int64_t size = 0, total = 0, left = 0, right = 0;
+
+    QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
+        if (s->has_filter) {
+            /* calculate the overlapped region. */
+            left = MAX(s->begin, block->target_start);
+            right = MIN(s->begin + s->length, block->target_end);
+            size = right - left;
+            size = size > 0 ? size : 0;
+        } else {
+            /* count the whole region in */
+            size = (block->target_end - block->target_start);
+        }
+        total += size;
+    }
+
+    return total;
+}
+
 static void dump_init(DumpState *s, int fd, bool has_format,
                       DumpGuestMemoryFormat format, bool paging, bool has_filter,
                       int64_t begin, int64_t length, Error **errp)
@@ -1454,6 +1481,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
 
     s->has_format = has_format;
     s->format = format;
+    s->written_size = 0;
 
     /* kdump-compressed is conflict with paging and filter */
     if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
@@ -1485,6 +1513,10 @@ static void dump_init(DumpState *s, int fd, bool has_format,
 
     guest_phys_blocks_init(&s->guest_phys_blocks);
     guest_phys_blocks_append(&s->guest_phys_blocks);
+    s->total_size = dump_calculate_size(s);
+#ifdef DEBUG_DUMP_GUEST_MEMORY
+    fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
+#endif
 
     s->start = get_start_block(s);
     if (s->start == -1) {
include/sysemu/dump.h +9 -0
index 31930c6..9c5a46b 100644
@@ -189,6 +189,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 */
+
+    size_t total_size;          /* total memory size (in bytes) to
+                                 * be dumped. When filter is
+                                 * enabled, this will only count
+                                 * those to be written. */
+    size_t written_size;        /* written memory size (in bytes),
+                                 * this could be used to calculate
+                                 * how many work we have
+                                 * finished. */
 } DumpState;
 
 uint16_t cpu_to_dump16(DumpState *s, uint16_t val);
Signature · 1 line
2.4.3
author
#22 lore raw

PATCH v3 10/12 Dump: add qmp command "query-dump"

In reply to Peter Xu

When dump-guest-memory is requested with detach flag, after its return, user could query its status using "query-dump" command (with no argument). The result for now contains:

- status: current dump status
- written_bytes: bytes written in latest dump
- total_bytes: bytes to write in latest dump

Quoted 1 line

From written_bytes and total_bytes, we could see how much work

finished by calculating:

100.0 * written_bytes / total_bytes (%)

---
 dump.c           | 10 ++++++++++
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 qmp-commands.hx  | 26 +++++++++++++++++++++++++-
 3 files changed, 64 insertions(+), 1 deletion(-)
dump.c +10 -0
index 56a2d7e..6596bc8 100644
@@ -1675,6 +1675,16 @@ static void *dump_thread(void *data)
     return NULL;
 }
 
+DumpQueryResult *qmp_query_dump(Error **errp)
+{
+    DumpQueryResult *result = g_malloc0(sizeof(*result));
+    DumpState *state = dump_state_get_global();
+    result->status = state->status;
+    result->written_bytes = state->written_size;
+    result->total_bytes = state->total_size;
+    return result;
+}
+
 void qmp_dump_guest_memory(bool paging, const char *file,
                            bool has_detach, bool detach,
                            bool has_begin, int64_t begin, bool has_length,
qapi-schema.json +29 -0
index 3728bfc..577c381 100644
@@ -2157,6 +2157,35 @@
   'data': [ 'none', 'active', 'completed', 'failed' ] }
 
 ##
+# @DumpQueryResult
+#
+# The result format for 'query-dump'.
+#
+# @status: enum of @DumpStatus, which shows current dump status
+#
+# @written_bytes: bytes written in latest dump (uncompressed)
+#
+# @total_bytes: total bytes to be write in latest dump (uncompressed)
+#
+# Since 2.6
+##
+{ 'struct': 'DumpQueryResult',
+  'data': { 'status': 'DumpStatus',
+            'written_bytes': 'int',
+            'total_bytes': 'int' } }
+
+##
+# @query-dump
+#
+# Query latest dump status.
+#
+# Returns: A @DumpStatus object showing the dump status.
+#
+# Since: 2.6
+##
+{ 'command': 'query-dump', 'returns': 'DumpQueryResult' }
+
+##
 # @DumpGuestMemoryCapability:
 #
 # A list of the available formats for dump-guest-memory
qmp-commands.hx +25 -1
index bbb08e1..ac6d2da 100644
@@ -881,7 +881,7 @@ EQMP
     {
         .name       = "query-dump-guest-memory-capability",
         .args_type  = "",
-    .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
+        .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
     },
 
 SQMP
@@ -898,6 +898,30 @@ Example:
 
 EQMP
 
+    {
+        .name       = "query-dump",
+        .args_type  = "",
+        .params     = "",
+        .help       = "query background dump status",
+        .mhandler.cmd_new = qmp_marshal_query_dump,
+    },
+
+SQMP
+query-dump
+----------
+
+Query background dump status.
+
+Arguments: None.
+
+Example:
+
+-> { "execute": "query-dump" }
+<- { "return": { "status": "active", "written_bytes": 1024000,
+                 "total_bytes": 2048000 } }
+
+EQMP
+
 #if defined TARGET_S390X
     {
         .name       = "dump-skeys",
Signature · 1 line
2.4.3
#23 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

dump.c static void *dump_thread(void *data) · line 1683

Quoted 5 lines · Peter Xu
dump.c +5 -0
+{
+    DumpQueryResult *result = g_malloc0(sizeof(*result));
+    DumpState *state = dump_state_get_global();
+    result->status = state->status;
+    result->written_bytes = state->written_size;

You need a mutex around the reads of ->status and ->written_size.

Paolo

Quoted 2 lines
dump.c +2 -0
+    result->total_bytes = state->total_size;
+    return result;
author
#24 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 10 lines · Paolo Bonzini

dump.c static void *dump_thread(void *data) · line 1683

Quoted 5 lines · Peter Xu
dump.c +5 -0
+{
+    DumpQueryResult *result = g_malloc0(sizeof(*result));
+    DumpState *state = dump_state_get_global();
+    result->status = state->status;
+    result->written_bytes = state->written_size;

You need a mutex around the reads of ->status and ->written_size.

Could I avoid using mutex here? Let me try to explain what I thought.

The concurrency of this should only happen when:

- detached dump thread is working (dump thread)
- user queries dump status (main thread)

What the dump thread is doing should be something like:

- [start dumping]
- inc written_size
- inc written_size
- ...
- inc written_size
- set ->status to COMPLETED|FAILED
- [end dumping]

Now if the main thread tries to fetch dump status during it's working, the worst thing is that, the ->written_size fetched by main thread is not exactly the one when it was fetching ->status. Or say, we might get some kind of inaccuracy (which should be really small) without the lock. Meanwhile, we could avoid a lock if we could allow the very small difference in written_size.

Another thing could happen is when user queries duing it's finishing (or say, user query between dump thread modify written_size and status), we might got this:

{ "status": "active", "written": "100", "total": "100" }

Rather than:

{ "status": "completed", "written": "100", "total": "100" }

As long as we make sure we fetch "status" first rather than "written_size" (that's what I did in current codes). It should still be acceptable?

Here, the reason I would like to avoid using lock is that: if I use lock here, I need to use it whenever dump thread increases the ->written_size. That's a operation very frequently happens in dump thread. I could enhance it though by updating ->written_bytes in periods, but it might be awkward comparing to directly drop the lock (if possible) by losing some kind of accuracy.

Not sure whether I missed anything. Also, please let me know if you still suggest using lock here.

(btw, if using lock, would spinlock be better?)

Thanks!
Peter

Quoted 5 lines

Paolo

Quoted 2 lines
dump.c +2 -0
+    result->total_bytes = state->total_size;
+    return result;
#25 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 11 lines · Peter Xu
Quoted 1 line
Quoted 1 line

You need a mutex around the reads of ->status and ->written_size.

Could I avoid using mutex here? Let me try to explain what I thought.

The concurrency of this should only happen when:

- detached dump thread is working (dump thread)
- user queries dump status (main thread)

What the dump thread is doing should be something like:

Quoted 7 lines

- [start dumping]
- inc written_size
- inc written_size
- ...
- inc written_size
- set ->status to COMPLETED|FAILED
- [end dumping]

Yes, it's possible but you need to use atomic_mb_read/atomic_mb_set to write ->status. Otherwise a CPU can see the write to ->status before some of the final writes to ->written_size.

Paolo

author
#26 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 22 lines · Paolo Bonzini
Quoted 11 lines · Peter Xu
Quoted 1 line
Quoted 1 line

You need a mutex around the reads of ->status and ->written_size.

Could I avoid using mutex here? Let me try to explain what I thought.

The concurrency of this should only happen when:

- detached dump thread is working (dump thread)
- user queries dump status (main thread)

What the dump thread is doing should be something like:

Quoted 7 lines

- [start dumping]
- inc written_size
- inc written_size
- ...
- inc written_size
- set ->status to COMPLETED|FAILED
- [end dumping]

Quoted 3 lines

Yes, it's possible but you need to use atomic_mb_read/atomic_mb_set to write ->status. Otherwise a CPU can see the write to ->status before some of the final writes to ->written_size.

Hi, Paolo,

Thanks to point out. However, would it be confusing to use atomic_mb_{read|set} rather than directly use smp_rmb() and smp_wmb()? Like:

In dump thread:

- inc written_size
- inc written_size
- ...
- inc written_size
- smp_wmb()
- atomic_set(status, COMPLETED|FAILED)

In main thread:

- atomic_read(status)
- smp_rmb()
- read written_size

What I understand from the doc (seems written by you, thanks :) ) is
that: atomic_mb_{read|set} is the pair of helper functions for _one_ specific variable, to make sure its operations are always in order as long as we are using atomic_mb_* functions to access it all the time. However, in the dump thread case, it's related to read/write order of two variables (status and written_size).

Thanks!
Peter

Quoted 2 lines

Paolo

#27 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 48 lines · Peter Xu
Quoted 22 lines · Paolo Bonzini
Quoted 11 lines · Peter Xu
Quoted 1 line
Quoted 1 line

You need a mutex around the reads of ->status and ->written_size.

Could I avoid using mutex here? Let me try to explain what I thought.

The concurrency of this should only happen when:

- detached dump thread is working (dump thread)
- user queries dump status (main thread)

What the dump thread is doing should be something like:

Quoted 7 lines

- [start dumping]
- inc written_size
- inc written_size
- ...
- inc written_size
- set ->status to COMPLETED|FAILED
- [end dumping]

Quoted 3 lines

Yes, it's possible but you need to use atomic_mb_read/atomic_mb_set to write ->status. Otherwise a CPU can see the write to ->status before some of the final writes to ->written_size.

Hi, Paolo,

Thanks to point out. However, would it be confusing to use atomic_mb_{read|set} rather than directly use smp_rmb() and smp_wmb()? Like:

In dump thread:

- inc written_size
- inc written_size
- ...
- inc written_size
- smp_wmb()
- atomic_set(status, COMPLETED|FAILED)

In main thread:

- atomic_read(status)
- smp_rmb()
- read written_size

Quoted 6 lines

What I understand from the doc (seems written by you, thanks :) ) is
that: atomic_mb_{read|set} is the pair of helper functions for _one_ specific variable, to make sure its operations are always in order as long as we are using atomic_mb_* functions to access it all the time. However, in the dump thread case, it's related to read/write order of two variables (status and written_size).

atomic_mb_{read,set} does order accesses to the variable against all other accesses. In this case I'd prefer it to smp_wmb/rmb, because the writes to written_size are far from the writes to status.

Compare with thread-pool.c:

        req->ret = ret;
        /* Write ret before state.  */
        smp_wmb();
        req->state = THREAD_DONE;

        /* Read state before ret.  */
        smp_rmb();

        /* Schedule ourselves in case elem->common.cb() calls aio_poll() to
         * wait for another request that completed at the same time.
         */
        qemu_bh_schedule(pool->completion_bh);

        elem->common.cb(elem->common.opaque, elem->ret);

It's a matter of taste though. What you wrote above is certainly okay as well.

Paolo

author
#28 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 3 lines · Paolo Bonzini

atomic_mb_{read,set} does order accesses to the variable against all other accesses. In this case I'd prefer it to smp_wmb/rmb, because the writes to written_size are far from the writes to status.

Yes... It should be again all the other variables.

Quoted 18 lines

Compare with thread-pool.c:

        req->ret = ret;
        /* Write ret before state.  */
        smp_wmb();
        req->state = THREAD_DONE;

        /* Read state before ret.  */
        smp_rmb();

        /* Schedule ourselves in case elem->common.cb() calls aio_poll() to
         * wait for another request that completed at the same time.
         */
        qemu_bh_schedule(pool->completion_bh);

        elem->common.cb(elem->common.opaque, elem->ret);
Quoted 2 lines

It's a matter of taste though. What you wrote above is certainly okay as well.

Thanks for the explanation. Then I will choose smp_*() this time and post v4 later.

Peter

Quoted 2 lines

Paolo

#29 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 4 lines · Peter Xu
Quoted 2 lines
Quoted 2 lines

It's a matter of taste though. What you wrote above is certainly okay as well.

Thanks for the explanation. Then I will choose smp_*() this time and post v4 later.

In that case, remember to add a comment before each smp_*(), similar to the one in thread-pool.c.

Paolo

author
#30 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 10 lines · Paolo Bonzini
Quoted 4 lines · Peter Xu
Quoted 2 lines
Quoted 2 lines

It's a matter of taste though. What you wrote above is certainly okay as well.

Thanks for the explanation. Then I will choose smp_*() this time and post v4 later.

In that case, remember to add a comment before each smp_*(), similar to the one in thread-pool.c.

Ok.

Thanks.
Peter

Quoted 2 lines

Paolo

#31 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

In reply to Peter Xu
Quoted 25 lines · Peter Xu

When dump-guest-memory is requested with detach flag, after its return, user could query its status using "query-dump" command (with no argument). The result for now contains:

- status: current dump status
- written_bytes: bytes written in latest dump
- total_bytes: bytes to write in latest dump

Quoted 1 line

From written_bytes and total_bytes, we could see how much work

finished by calculating:

100.0 * written_bytes / total_bytes (%)

---
 dump.c           | 10 ++++++++++
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 qmp-commands.hx  | 26 +++++++++++++++++++++++++-
 3 files changed, 64 insertions(+), 1 deletion(-)
dump.c +0 -0
index 56a2d7e..6596bc8 100644

dump.c static void *dump_thread(void *data) · line 1680

Quoted 6 lines
dump.c +3 -0
@@ -1675,6 +1675,16 @@ static void *dump_thread(void *data)
     return NULL;
 }
 
+DumpQueryResult *qmp_query_dump(Error **errp)
+{
+    DumpQueryResult *result = g_malloc0(sizeof(*result));

Might be nicer as g_new0(DumpQueryResult, 1). Markus has been switching to g_new0 where a type name was already mentioned, although here you used *result rather than a typename.

Quoted 4 lines
dump.c +1 -0
+++ b/qapi-schema.json
@@ -2157,6 +2157,35 @@
   'data': [ 'none', 'active', 'completed', 'failed' ] }
 

dump.c line 2168

Quoted 10 lines
dump.c +9 -0
 ##
+# @DumpQueryResult
+#
+# The result format for 'query-dump'.
+#
+# @status: enum of @DumpStatus, which shows current dump status
+#
+# @written_bytes: bytes written in latest dump (uncompressed)
+#
+# @total_bytes: total bytes to be write in latest dump (uncompressed)

s/be write/written/

dump.c line 2175

Quoted 7 lines
dump.c +7 -0
+#
+# Since 2.6
+##
+{ 'struct': 'DumpQueryResult',
+  'data': { 'status': 'DumpStatus',
+            'written_bytes': 'int',
+            'total_bytes': 'int' } }

Prefer '-' over '_' in new QMP (as in 'total-bytes' rather than 'total_bytes'). Furthermore, QMP already defaults to bytes, so it would be sufficient to name these merely 'written'/'total' or even 'complete'/'total'.

dump.c EQMP · line 885

Quoted 8 lines
dump.c +2 -1
+++ b/qmp-commands.hx
@@ -881,7 +881,7 @@ EQMP
     {
         .name       = "query-dump-guest-memory-capability",
         .args_type  = "",
-    .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
+        .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
     },

Unrelated hunk.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#32 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 8 lines · Eric Blake

dump.c static void *dump_thread(void *data) · line 1680

Quoted 3 lines · Peter Xu
dump.c +3 -0
+DumpQueryResult *qmp_query_dump(Error **errp)
+{
+    DumpQueryResult *result = g_malloc0(sizeof(*result));

Might be nicer as g_new0(DumpQueryResult, 1). Markus has been switching to g_new0 where a type name was already mentioned, although here you used *result rather than a typename.

Sure. Thanks.

Quoted 19 lines
Quoted 6 lines

+++ b/qapi-schema.json

qapi-schema.json +0 -0
@@ -2157,6 +2157,35 @@
   'data': [ 'none', 'active', 'completed', 'failed' ] }
 

qapi-schema.json line 2168

Quoted 10 lines
qapi-schema.json +9 -0
 ##
+# @DumpQueryResult
+#
+# The result format for 'query-dump'.
+#
+# @status: enum of @DumpStatus, which shows current dump status
+#
+# @written_bytes: bytes written in latest dump (uncompressed)
+#
+# @total_bytes: total bytes to be write in latest dump (uncompressed)

s/be write/written/

Quoted 12 lines

qapi-schema.json line 2175

Quoted 7 lines
qapi-schema.json +7 -0
+#
+# Since 2.6
+##
+{ 'struct': 'DumpQueryResult',
+  'data': { 'status': 'DumpStatus',
+            'written_bytes': 'int',
+            'total_bytes': 'int' } }

Prefer '-' over '_' in new QMP (as in 'total-bytes' rather than 'total_bytes'). Furthermore, QMP already defaults to bytes, so it would be sufficient to name these merely 'written'/'total' or even 'complete'/'total'.

I will directly take "completed" and "total" then.

Quoted 11 lines

qmp-commands.hx EQMP · line 885

Quoted 9 lines
qmp-commands.hx +2 -1
+++ b/qmp-commands.hx
@@ -881,7 +881,7 @@ EQMP
     {
         .name       = "query-dump-guest-memory-capability",
         .args_type  = "",
-    .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
+        .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
     },

Unrelated hunk.

Is it ok to have this line here? I just saw it and fixed it. Please let me know if I should move it out of this patch.

Thanks.
Peter

Quoted 5 lines
Signature · 3 lines
-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#33 lore raw

Re: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"

Quoted 11 lines · Peter Xu
Quoted 10 lines

qmp-commands.hx EQMP · line 885

Quoted 8 lines

+++ b/qmp-commands.hx

qmp-commands.hx +1 -1
@@ -881,7 +881,7 @@ EQMP
     {
         .name       = "query-dump-guest-memory-capability",
         .args_type  = "",
-    .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
+        .mhandler.cmd_new = qmp_marshal_query_dump_guest_memory_capability,
     },

Unrelated hunk.

Quoted 2 lines

Is it ok to have this line here? I just saw it and fixed it. Please let me know if I should move it out of this patch.

It's small enough that you could separate that hunk into its own patch and cc qemu-trivial.

As it is, Marc-Andre has queued patches that get rid of qmp-commands.hx; so if Markus and I can get through the backlog of qapi patches, this problem may just disappear on its own.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#34 lore raw

PATCH v3 11/12 Dump: add hmp command "info dump"

In reply to Peter Xu

It will calculate percentage of finished work from written_bytes and total_bytes.

---
 hmp-commands-info.hx | 14 ++++++++++++++
 hmp.c                | 18 ++++++++++++++++++
 hmp.h                |  1 +
 3 files changed, 33 insertions(+)
hmp-commands-info.hx +14 -0
index 9b71351..52539c3 100644
@@ -786,6 +786,20 @@ STEXI
 Display the value of a storage key (s390 only)
 ETEXI
 
+    {
+        .name       = "dump",
+        .args_type  = "",
+        .params     = "",
+        .help       = "Display the latest dump status",
+        .mhandler.cmd = hmp_info_dump,
+    },
+
+STEXI
+@item info dump
+@findex dump
+Display the latest dump status.
+ETEXI
+
 STEXI
 @end table
 ETEXI
hmp.c +18 -0
index dccb457..dee2cb5 100644
@@ -2383,3 +2383,21 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
 
     qapi_free_RockerOfDpaGroupList(list);
 }
+
+void hmp_info_dump(Monitor *mon, const QDict *qdict)
+{
+    Error *not_used = NULL;
+    DumpQueryResult *result = qmp_query_dump(&not_used);
+
+    assert(result->status < DUMP_STATUS_MAX);
+    monitor_printf(mon, "Status: %s\n", DumpStatus_lookup[result->status]);
+
+    if (result->status == DUMP_STATUS_ACTIVE) {
+        float percent = 0;
+        assert(result->total_bytes != 0);
+        percent = 100.0 * result->written_bytes / result->total_bytes;
+        monitor_printf(mon, "Finished: %.2f %%\n", percent);
+    }
+
+    qapi_free_DumpQueryResult(result);
+}
hmp.h +1 -0
index a8c5b5a..093d65f 100644
@@ -131,5 +131,6 @@ void hmp_rocker(Monitor *mon, const QDict *qdict);
 void hmp_rocker_ports(Monitor *mon, const QDict *qdict);
 void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict);
 void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict);
+void hmp_info_dump(Monitor *mon, const QDict *qdict);
 
 #endif
Signature · 1 line
2.4.3
author
#35 lore raw

PATCH v3 12/12 Dump: enhance the documentations.

In reply to Peter Xu

Add more documents to mention about "query-dump" and DUMP_COMPLETED events.

---
 qapi-schema.json | 7 +++++--
 qmp-commands.hx  | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)
qapi-schema.json +5 -2
index 577c381..ce4acb2 100644
@@ -2115,8 +2115,11 @@
 #            2. fd: the protocol starts with "fd:", and the following string
 #               is the fd's name.
 #
-# @detach: #optional if true, QMP will return immediately rather than
-#          waiting dump to be finished (since 2.6).
+# @detach: #optional if true, QMP will return immediately rather
+#          than waiting dump to be finished. If this is specified,
+#          user could later use "query-dump" to check latest dump
+#          status. When dump finishes, one event DUMP_COMPLETED will
+#          be sent to the user to notify the completion (since 2.6).
 #
 # @begin: #optional if specified, the starting physical address.
 #
qmp-commands.hx +3 -1
index ac6d2da..cd097d4 100644
@@ -858,7 +858,9 @@ Arguments:
 - "protocol": destination file(started with "file:") or destination file
               descriptor (started with "fd:") (json-string)
 - "detach": if specificed, command will return immediately, without waiting
-            for dump to be finished (json-bool)
+            for dump to be finished. After command return, user
+            could query for latest dump status using "query-dump". When dump
+            finishes, an event DUMP_COMPLETED will be sent (json-bool)
 - "begin": the starting physical address. It's optional, and should be specified
            with length together (json-int)
 - "length": the memory size, in bytes. It's optional, and should be specified
Signature · 1 line
2.4.3
#36 lore raw

Re: [Qemu-devel] [PATCH v3 12/12] Dump: enhance the documentations.

Quoted 8 lines · Peter Xu

Add more documents to mention about "query-dump" and DUMP_COMPLETED events.

---
 qapi-schema.json | 7 +++++--
 qmp-commands.hx  | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

Why not squash this in to the patch that introduces the options? No need to have churn within the series by tweaking the documentation more than once.

Quoted 6 lines
qapi-schema.json +0 -0
index 577c381..ce4acb2 100644

qapi-schema.json line 2121

Quoted 9 lines
qapi-schema.json +4 -2
@@ -2115,8 +2115,11 @@
 #            2. fd: the protocol starts with "fd:", and the following string
 #               is the fd's name.
 #
-# @detach: #optional if true, QMP will return immediately rather than
-#          waiting dump to be finished (since 2.6).
+# @detach: #optional if true, QMP will return immediately rather
+#          than waiting dump to be finished. If this is specified,
+#          user could later use "query-dump" to check latest dump
+#          status. When dump finishes, one event DUMP_COMPLETED will

s/one event DUMP_COMPLETED/a DUMP_COMPLETED event/

qapi-schema.json line 2122

Quoted 1 line
qapi-schema.json +1 -0
+#          be sent to the user to notify the completion (since 2.6).

s/to the user to notify the completion//

Quoted 8 lines
qapi-schema.json +0 -0
 #
 # @begin: #optional if specified, the starting physical address.
 #
qmp-commands.hx +0 -0
index ac6d2da..cd097d4 100644

qmp-commands.hx Arguments: · line 863

Quoted 7 lines
qmp-commands.hx +3 -1
@@ -858,7 +858,9 @@ Arguments:
 - "protocol": destination file(started with "file:") or destination file
               descriptor (started with "fd:") (json-string)
 - "detach": if specificed, command will return immediately, without waiting
-            for dump to be finished (json-bool)
+            for dump to be finished. After command return, user
+            could query for latest dump status using "query-dump". When dump
+            finishes, an event DUMP_COMPLETED will be sent (json-bool)

Awkward. How about:

- "detach": if specified, the command will return immediately rather than waiting for the dump completion. The user can track progress with "query-dump", and a DUMP_COMPLETED event will occur at the end. (json-bool)

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#37 lore raw

Re: [Qemu-devel] [PATCH v3 12/12] Dump: enhance the documentations.

Quoted 10 lines · Eric Blake
Quoted 8 lines · Peter Xu

Add more documents to mention about "query-dump" and DUMP_COMPLETED events.

---
 qapi-schema.json | 7 +++++--
 qmp-commands.hx  | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)
Quoted 3 lines

Why not squash this in to the patch that introduces the options? No need to have churn within the series by tweaking the documentation more than once.

Ok. Will do that.

Quoted 41 lines
Quoted 7 lines
qapi-schema.json +0 -0
index 577c381..ce4acb2 100644

qapi-schema.json line 2121

Quoted 9 lines
qapi-schema.json +4 -2
@@ -2115,8 +2115,11 @@
 #            2. fd: the protocol starts with "fd:", and the following string
 #               is the fd's name.
 #
-# @detach: #optional if true, QMP will return immediately rather than
-#          waiting dump to be finished (since 2.6).
+# @detach: #optional if true, QMP will return immediately rather
+#          than waiting dump to be finished. If this is specified,
+#          user could later use "query-dump" to check latest dump
+#          status. When dump finishes, one event DUMP_COMPLETED will

s/one event DUMP_COMPLETED/a DUMP_COMPLETED event/

qapi-schema.json line 2122

Quoted 1 line
qapi-schema.json +1 -0
+#          be sent to the user to notify the completion (since 2.6).

s/to the user to notify the completion//

Quoted 8 lines
qapi-schema.json +0 -0
 #
 # @begin: #optional if specified, the starting physical address.
 #
qmp-commands.hx +0 -0
index ac6d2da..cd097d4 100644

qmp-commands.hx Arguments: · line 863

Quoted 7 lines
qmp-commands.hx +3 -1
@@ -858,7 +858,9 @@ Arguments:
 - "protocol": destination file(started with "file:") or destination file
               descriptor (started with "fd:") (json-string)
 - "detach": if specificed, command will return immediately, without waiting
-            for dump to be finished (json-bool)
+            for dump to be finished. After command return, user
+            could query for latest dump status using "query-dump". When dump
+            finishes, an event DUMP_COMPLETED will be sent (json-bool)

Awkward. How about:

Quoted 3 lines

- "detach": if specified, the command will return immediately rather than waiting for the dump completion. The user can track progress with "query-dump", and a DUMP_COMPLETED event will occur at the end. (json-bool)

Sorry for the awkward English...

Will take your version. Thanks. :)

Peter

Quoted 5 lines
Signature · 3 lines
-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org