[PATCH 12/18] qemumonitorjsontest: Test qemuMonitorJSONGetMigrationStatus

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/qemumonitorjsontest.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 52df486..576288b 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1639,6 +1639,55 @@ cleanup:
 }
 
 static int
+testQemuMonitorJSONqemuMonitorJSONGetMigrationStatus(const void *data)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+    qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
+    int ret = -1;
+    qemuMonitorMigrationStatus status, expectedStatus;
+
+    if (!test)
+        return -1;
+
+    memset(&expectedStatus, 0, sizeof(expectedStatus));
+
+    expectedStatus.status = QEMU_MONITOR_MIGRATION_STATUS_ACTIVE;
+    expectedStatus.total_time = 47;
+    expectedStatus.ram_total = 1611038720;
+    expectedStatus.ram_remaining = 1605013504;
+    expectedStatus.ram_transferred = 3625548;
+
+    if (qemuMonitorTestAddItem(test, "query-migrate",
+                               "{"
+                               "    \"return\": {"
+                               "        \"status\": \"active\","
+                               "        \"total-time\": 47,"
+                               "        \"ram\": {"
+                               "            \"total\": 1611038720,"
+                               "            \"remaining\": 1605013504,"
+                               "            \"transferred\": 3625548"
+                               "        }"
+                               "    },"
+                               "    \"id\": \"libvirt-13\""
+                               "}") < 0)
+        goto cleanup;
+
+    if (qemuMonitorJSONGetMigrationStatus(qemuMonitorTestGetMonitor(test), &status) < 0)
+        goto cleanup;
+
+    if (memcmp(&status, &expectedStatus, sizeof(status)) != 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       "Invalid migration status");
+        goto cleanup;
+    }
+
+    ret = 0;
+cleanup:
+    qemuMonitorTestFree(test);
+    return ret;
+}
+
+static int
 mymain(void)
 {
     int ret = 0;
@@ -1727,6 +1776,7 @@ mymain(void)
     DO_TEST(qemuMonitorJSONGetBlockInfo);
     DO_TEST(qemuMonitorJSONGetBlockStatsInfo);
     DO_TEST(qemuMonitorJSONGetMigrationCacheSize);
+    DO_TEST(qemuMonitorJSONGetMigrationStatus);
 
     virObjectUnref(xmlopt);
 
-- 
1.8.1.5

--
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]