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

[libvirt] [PATCH v4 2/5] qemu monitor: add multithread compress parameters accessors



From: ShaoHe Feng <shaohe feng intel com>

Signed-off-by: ShaoHe Feng <shaohe feng intel com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy virtuozzo com>
---
 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 5e4461a..21c1df6 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2157,6 +2157,28 @@ qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
 
 
 int
+qemuMonitorGetMigrationParameters(qemuMonitorPtr mon,
+                                  qemuMonitorMigrationParametersPtr params)
+{
+    QEMU_CHECK_MONITOR_JSON(mon);
+
+    return qemuMonitorJSONGetMigrationParameters(mon, params);
+}
+
+int
+qemuMonitorSetMigrationParameters(qemuMonitorPtr mon,
+                                  qemuMonitorMigrationParametersPtr params)
+{
+    VIR_DEBUG("level=%d threads=%d dthreads=%d",
+              params->level, params->threads, params->dthreads);
+
+    QEMU_CHECK_MONITOR_JSON(mon);
+
+    return qemuMonitorJSONSetMigrationParameters(mon, params);
+}
+
+
+int
 qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
                              qemuMonitorMigrationStatsPtr stats)
 {
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 28620b5..b28b431 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -469,6 +469,23 @@ int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
 int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                      unsigned long long cacheSize);
 
+typedef struct _qemuMonitorMigrationParameters qemuMonitorMigrationParameters;
+typedef qemuMonitorMigrationParameters *qemuMonitorMigrationParametersPtr;
+struct _qemuMonitorMigrationParameters {
+    unsigned int level_set : 1;
+    unsigned int threads_set : 1;
+    unsigned int dthreads_set : 1;
+
+    int level;
+    int threads;
+    int dthreads;
+};
+
+int qemuMonitorGetMigrationParameters(qemuMonitorPtr mon,
+                                      qemuMonitorMigrationParametersPtr params);
+int qemuMonitorSetMigrationParameters(qemuMonitorPtr mon,
+                                      qemuMonitorMigrationParametersPtr params);
+
 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 8352e53..999c644 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2492,6 +2492,116 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorJSONGetMigrationParameters(qemuMonitorPtr mon,
+                                      qemuMonitorMigrationParametersPtr params)
+{
+    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",
+                                       &params->level) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("malformed/missing compress-level "
+                         "in migrate parameters"));
+        goto cleanup;
+    }
+    params->level_set = 1;
+
+    if (virJSONValueObjectGetNumberInt(result, "compress-threads",
+                                       &params->threads) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("malformed/missing compress-threads "
+                         "in migrate parameters"));
+        goto cleanup;
+    }
+    params->threads_set = 1;
+
+    if (virJSONValueObjectGetNumberInt(result, "decompress-threads",
+                                       &params->dthreads) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("malformed/missing decompress-threads "
+                         "in migrate parameters"));
+        goto cleanup;
+    }
+    params->dthreads_set = 1;
+
+    ret = 0;
+ cleanup:
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
+
+int
+qemuMonitorJSONSetMigrationParameters(qemuMonitorPtr mon,
+                                      qemuMonitorMigrationParametersPtr params)
+{
+    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 (params->level_set &&
+        virJSONValueObjectAppendNumberInt(args, "compress-level",
+                                          params->level) < 0)
+        goto cleanup;
+
+    if (params->threads_set &&
+        virJSONValueObjectAppendNumberInt(args, "compress-threads",
+                                          params->threads) < 0)
+        goto cleanup;
+
+    if (params->dthreads_set &&
+        virJSONValueObjectAppendNumberInt(args, "compress-dthreads",
+                                          params->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 4068187..115882c 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 qemuMonitorJSONGetMigrationParameters(qemuMonitorPtr mon,
+                                          qemuMonitorMigrationParametersPtr params);
+int qemuMonitorJSONSetMigrationParameters(qemuMonitorPtr mon,
+                                          qemuMonitorMigrationParametersPtr params);
+
 int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
                                      qemuMonitorMigrationStatsPtr stats);
 
-- 
1.8.3.1


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