qemu-devel
[Top][All Lists]
Advanced

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

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


From: Peter Xu
Subject: [Qemu-devel] [PATCH v3 10/12] Dump: add qmp command "query-dump"
Date: Mon, 30 Nov 2015 19:32:18 +0800

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

>From written_bytes and total_bytes, we could see how much work
finished by calculating:

  100.0 * written_bytes / total_bytes (%)

Signed-off-by: Peter Xu <address@hidden>
---
 dump.c           | 10 ++++++++++
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 qmp-commands.hx  | 26 +++++++++++++++++++++++++-
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/dump.c b/dump.c
index 56a2d7e..6596bc8 100644
--- a/dump.c
+++ b/dump.c
@@ -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,
diff --git a/qapi-schema.json b/qapi-schema.json
index 3728bfc..577c381 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -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
diff --git a/qmp-commands.hx b/qmp-commands.hx
index bbb08e1..ac6d2da 100644
--- a/qmp-commands.hx
+++ 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,
     },
 
 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",
-- 
2.4.3




reply via email to

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