]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: add migration parameters accessors
authorShaoHe Feng <shaohe.feng@intel.com>
Thu, 14 Apr 2016 10:33:49 +0000 (13:33 +0300)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 14 Apr 2016 12:57:40 +0000 (14:57 +0200)
Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index ac9befa4e5c9a295f32bcaebe112196444f096a2..83551a83f2e818241f52467bb7e2de6503109539 100644 (file)
@@ -2176,6 +2176,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)
index 78efcd7e4ee7ab217d5e8e201c72e8d3b23bf433..bd5d006750ba23c4ca7b02627721f7befe8fe636 100644 (file)
@@ -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,
index 78af83e0c6f65495089a0d05cad2ed65c6c56c8d..29d6c8c5b8e3adff33a2437d12a8423fc105ed47 100644 (file)
@@ -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)
index d155f52e5a2b0bf3da3933a82c4ceb46fb44ee3a..5cbee1a439800f6a995d21abb3028489727efee0 100644 (file)
@@ -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);