diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 1be0beeb25..829de909f6 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -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);