]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemumonitorjsontest: add test for getting multithread compress params
authorEli Qiao <liyong.qiao@intel.com>
Thu, 14 Apr 2016 10:33:50 +0000 (13:33 +0300)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 14 Apr 2016 12:57:41 +0000 (14:57 +0200)
Signed-off-by: Eli Qiao <liyong.qiao@intel.com>
Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
tests/qemumonitorjsontest.c

index 1be0beeb25b60e7ed6a9d5418add539d2792fdbd..829de909f6fde2952356dbe6074802030e3d04c6 100644 (file)
@@ -1592,6 +1592,66 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data)
     return ret;
 }
 
+static int
+testQemuMonitorJSONqemuMonitorJSONGetMigrationCompression(const void *data)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+    qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
+    qemuMonitorMigrationCompression compress;
+    int ret = -1;
+
+    if (!test)
+        return -1;
+
+    if (qemuMonitorTestAddItem(test, "query-migrate-parameters",
+                               "{"
+                               "    \"return\": {"
+                               "        \"decompress-threads\": 2,"
+                               "        \"compress-threads\": 8,"
+                               "        \"compress-level\": 1"
+                               "    }"
+                               "}") < 0) {
+        goto cleanup;
+    }
+
+    if (qemuMonitorJSONGetMigrationCompression(qemuMonitorTestGetMonitor(test),
+                                               &compress) < 0)
+        goto cleanup;
+
+    if (!compress.level_set ||
+        !compress.threads_set ||
+        !compress.dthreads_set) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       "One of level, threads or dthreads flags is not set");
+        return -1;
+    }
+
+    if (compress.level != 1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "Invalid decompress-threads: %d, expected 1",
+                       compress.level);
+        goto cleanup;
+    }
+    if (compress.threads != 8) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "Invalid decompress-threads: %d, expected 8",
+                       compress.threads);
+        goto cleanup;
+    }
+    if (compress.dthreads != 2) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "Invalid decompress-threads: %d, expected 2",
+                       compress.dthreads);
+        goto cleanup;
+    }
+    ret = 0;
+
+ cleanup:
+    qemuMonitorTestFree(test);
+    return ret;
+}
+
+
 static int
 testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSize(const void *data)
 {
@@ -2333,6 +2393,7 @@ mymain(void)
     DO_TEST(qemuMonitorJSONGetBlockInfo);
     DO_TEST(qemuMonitorJSONGetBlockStatsInfo);
     DO_TEST(qemuMonitorJSONGetMigrationCacheSize);
+    DO_TEST(qemuMonitorJSONGetMigrationCompression);
     DO_TEST(qemuMonitorJSONGetMigrationStats);
     DO_TEST(qemuMonitorJSONGetChardevInfo);
     DO_TEST(qemuMonitorJSONSetBlockIoThrottle);