[PATCH v6 2/5] qemu: monitor: add migration parameters accessors

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

 



From: ShaoHe Feng <shaohe.feng@xxxxxxxxx>

Signed-off-by: ShaoHe Feng <shaohe.feng@xxxxxxxxx>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/qemu/qemu_monitor.c      |  22 +++++++++
 src/qemu/qemu_monitor.h      |  17 +++++++
 src/qemu/qemu_monitor_json.c | 110 +++++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_monitor_json.h |   5 ++
 4 files changed, 154 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index ac9befa..83551a8 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2177,6 +2177,28 @@ qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
 
 
 int
+qemuMonitorGetMigrationCompression(qemuMonitorPtr mon,
+                                   qemuMonitorMigrationCompressionPtr compress)
+{
+    QEMU_CHECK_MONITOR_JSON(mon);
+
+    return qemuMonitorJSONGetMigrationCompression(mon, compress);
+}
+
+int
+qemuMonitorSetMigrationCompression(qemuMonitorPtr mon,
+                                   qemuMonitorMigrationCompressionPtr compress)
+{
+    VIR_DEBUG("level=%d threads=%d dthreads=%d",
+              compress->level, compress->threads, compress->dthreads);
+
+    QEMU_CHECK_MONITOR_JSON(mon);
+
+    return qemuMonitorJSONSetMigrationCompression(mon, compress);
+}
+
+
+int
 qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
                              qemuMonitorMigrationStatsPtr stats)
 {
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 78efcd7..bd5d006 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -487,6 +487,23 @@ int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
 int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                      unsigned long long cacheSize);
 
+typedef struct _qemuMonitorMigrationCompression qemuMonitorMigrationCompression;
+typedef qemuMonitorMigrationCompression *qemuMonitorMigrationCompressionPtr;
+struct _qemuMonitorMigrationCompression {
+    bool level_set;
+    bool threads_set;
+    bool dthreads_set;
+
+    int level;
+    int threads;
+    int dthreads;
+};
+
+int qemuMonitorGetMigrationCompression(qemuMonitorPtr mon,
+                                       qemuMonitorMigrationCompressionPtr compress);
+int qemuMonitorSetMigrationCompression(qemuMonitorPtr mon,
+                                       qemuMonitorMigrationCompressionPtr compress);
+
 typedef enum {
     QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
     QEMU_MONITOR_MIGRATION_STATUS_SETUP,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 78af83e..29d6c8c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2521,6 +2521,116 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorJSONGetMigrationCompression(qemuMonitorPtr mon,
+                                       qemuMonitorMigrationCompressionPtr compress)
+{
+    int ret = -1;
+    virJSONValuePtr result;
+    virJSONValuePtr cmd = NULL;
+    virJSONValuePtr reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("query-migrate-parameters", NULL)))
+        return -1;
+
+    if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
+        goto cleanup;
+
+    if ((ret = qemuMonitorJSONCheckError(cmd, reply)) < 0)
+        goto cleanup;
+
+    if (!(result = virJSONValueObjectGet(reply, "return"))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("query-migrate-parameters reply was missing "
+                         "'return' data"));
+        goto cleanup;
+    }
+
+    if (virJSONValueObjectGetNumberInt(result, "compress-level",
+                                       &compress->level) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("malformed/missing compress-level "
+                         "in migrate parameters"));
+        goto cleanup;
+    }
+    compress->level_set = true;
+
+    if (virJSONValueObjectGetNumberInt(result, "compress-threads",
+                                       &compress->threads) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("malformed/missing compress-threads "
+                         "in migrate parameters"));
+        goto cleanup;
+    }
+    compress->threads_set = true;
+
+    if (virJSONValueObjectGetNumberInt(result, "decompress-threads",
+                                       &compress->dthreads) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("malformed/missing decompress-threads "
+                         "in migrate parameters"));
+        goto cleanup;
+    }
+    compress->dthreads_set = true;
+
+    ret = 0;
+ cleanup:
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
+
+int
+qemuMonitorJSONSetMigrationCompression(qemuMonitorPtr mon,
+                                       qemuMonitorMigrationCompressionPtr compress)
+{
+    int ret = -1;
+    virJSONValuePtr cmd = NULL;
+    virJSONValuePtr args = NULL;
+    virJSONValuePtr reply = NULL;
+
+    if (!(cmd = virJSONValueNewObject()))
+        goto cleanup;
+
+    if (virJSONValueObjectAppendString(cmd, "execute",
+                                       "migrate-set-parameters") < 0)
+        goto cleanup;
+
+    if (!(args = virJSONValueNewObject()))
+        goto cleanup;
+
+    if (compress->level_set &&
+        virJSONValueObjectAppendNumberInt(args, "compress-level",
+                                          compress->level) < 0)
+        goto cleanup;
+
+    if (compress->threads_set &&
+        virJSONValueObjectAppendNumberInt(args, "compress-threads",
+                                          compress->threads) < 0)
+        goto cleanup;
+
+    if (compress->dthreads_set &&
+        virJSONValueObjectAppendNumberInt(args, "decompress-threads",
+                                          compress->dthreads) < 0)
+        goto cleanup;
+
+    if (virJSONValueObjectAppend(cmd, "arguments", args) < 0)
+        goto cleanup;
+    args = NULL;
+
+    if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
+        goto cleanup;
+
+    ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ cleanup:
+    virJSONValueFree(cmd);
+    virJSONValueFree(args);
+    virJSONValueFree(reply);
+    return ret;
+}
+
+
 static int
 qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
                                       qemuMonitorMigrationStatsPtr stats)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index d155f52..5cbee1a 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -126,6 +126,11 @@ int qemuMonitorJSONGetMigrationCacheSize(qemuMonitorPtr mon,
 int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
                                          unsigned long long cacheSize);
 
+int qemuMonitorJSONGetMigrationCompression(qemuMonitorPtr mon,
+                                           qemuMonitorMigrationCompressionPtr compress);
+int qemuMonitorJSONSetMigrationCompression(qemuMonitorPtr mon,
+                                           qemuMonitorMigrationCompressionPtr compress);
+
 int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
                                      qemuMonitorMigrationStatsPtr stats);
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]