]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemumonitorjsontest: Add test case for 'blockdev-reopen'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Feb 2021 16:59:28 +0000 (17:59 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 26 Jul 2021 18:25:22 +0000 (20:25 +0200)
Export 'qemuBlockReopenFormatMon' and use it in a new test case wich
will validate the arguments against the QMP schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_block.c
src/qemu/qemu_block.h
tests/qemumonitorjsontest.c

index 3d54901eaabeeb97b7036f757e4411e04b51b07a..1610f72d07aaacf2b845fd947872f0cf39b22a3a 100644 (file)
@@ -3286,7 +3286,7 @@ qemuBlockBitmapsHandleCommitFinish(virStorageSource *topsrc,
 }
 
 
-static int
+int
 qemuBlockReopenFormatMon(qemuMonitor *mon,
                          virStorageSource *src)
 {
index ff7048eb6c7cfd42db642c840b6310f98f0cdb97..54601a48a95d775626e6d8050c7170a3fa825202 100644 (file)
@@ -265,6 +265,11 @@ qemuBlockBitmapsHandleCommitFinish(virStorageSource *topsrc,
                                    GHashTable *blockNamedNodeData,
                                    virJSONValue **actions);
 
+/* only for use in qemumonitorjsontest */
+int
+qemuBlockReopenFormatMon(qemuMonitor *mon,
+                         virStorageSource *src);
+
 int
 qemuBlockReopenReadWrite(virDomainObj *vm,
                          virStorageSource *src,
index 0b321e8ed89eb1507c220ea6776376928d21c688..2122d9d9999c2709fabfeec9935e07e3573fe473 100644 (file)
@@ -2800,6 +2800,33 @@ testQemuMonitorJSONBlockExportAdd(const void *opaque)
     return 0;
 }
 
+
+static int
+testQemuMonitorJSONBlockdevReopen(const void *opaque)
+{
+    const testGenericData *data = opaque;
+    g_autoptr(qemuMonitorTest) test = NULL;
+    g_autoptr(virStorageSource) src = virStorageSourceNew();
+
+    if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
+        return -1;
+
+    src->format = VIR_STORAGE_FILE_QCOW2;
+    src->readonly = true;
+    src->nodeformat = g_strdup("test node");
+    src->nodestorage = g_strdup("backing nodename");
+    src->backingStore = virStorageSourceNew();
+
+    if (qemuMonitorTestAddItem(test, "blockdev-reopen", "{\"return\":{}}") < 0)
+        return -1;
+
+    if (qemuBlockReopenFormatMon(qemuMonitorTestGetMonitor(test), src) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 static int
 testQemuMonitorJSONqemuMonitorJSONGetCPUModelComparison(const void *opaque)
 {
@@ -2997,6 +3024,7 @@ mymain(void)
     DO_TEST(GetIOThreads);
     DO_TEST(Transaction);
     DO_TEST(BlockExportAdd);
+    DO_TEST(BlockdevReopen);
     DO_TEST_SIMPLE("qmp_capabilities", qemuMonitorJSONSetCapabilities);
     DO_TEST_SIMPLE("system_powerdown", qemuMonitorJSONSystemPowerdown);
     DO_TEST_SIMPLE("system_reset", qemuMonitorJSONSystemReset);