Add the query-dump API's in order to allow the dump-guest-memory
to be used to monitor progress. This will use the dump stats
extraction helper to fill a return buffer.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_monitor.c | 9 +++++++++
src/qemu/qemu_monitor.h | 2 ++
src/qemu/qemu_monitor_json.c | 37 +++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 +++
4 files changed, 51 insertions(+)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 23153967c..a8ca9a566 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2773,6 +2773,15 @@ qemuMonitorMigrateCancel(qemuMonitorPtr mon)
}
+qemuMonitorDumpStatsPtr
+qemuMonitorQueryDump(qemuMonitorPtr mon)
+{
+ QEMU_CHECK_MONITOR_JSON_NULL(mon);
+
+ return qemuMonitorJSONQueryDump(mon);
+}
+
+
/**
* Returns 1 if @capability is supported, 0 if it's not, or -1 on error.
*/
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 37f335e9f..5749af168 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -787,6 +787,8 @@ int qemuMonitorMigrateCancel(qemuMonitorPtr mon);
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
const char *capability);
+qemuMonitorDumpStatsPtr qemuMonitorQueryDump(qemuMonitorPtr mon);
+
int qemuMonitorDumpToFd(qemuMonitorPtr mon,
int fd,
const char *dumpformat);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a8cb8ce6b..33ec3347e 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3170,6 +3170,43 @@ int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon)
return ret;
}
+
+/* qemuMonitorJSONQueryDump:
+ * @mon: Monitor pointer
+ *
+ * Attempt to make a "query-dump" call, check for errors, and get/return
+ * the current from the reply
+ *
+ * Returns: @stats on success, NULL on failure
+ */
+qemuMonitorDumpStatsPtr
+qemuMonitorJSONQueryDump(qemuMonitorPtr mon)
+{
+ virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-dump", NULL);
+ virJSONValuePtr reply = NULL;
+ virJSONValuePtr result = NULL;
+ qemuMonitorDumpStatsPtr ret = NULL;
+
+ if (!cmd)
+ return NULL;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ goto cleanup;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ goto cleanup;
+
+ result = virJSONValueObjectGetObject(reply, "return");
+
+ ret = qemuMonitorJSONExtractDumpStats(result);
+
+ cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
int
qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
const char *capability)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 739a99293..f9fcba77f 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -162,6 +162,9 @@ int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr mon,
int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
+qemuMonitorDumpStatsPtr
+qemuMonitorJSONQueryDump(qemuMonitorPtr mon);
+
int qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
const char *capability);
--
2.13.6