[PATCH 04/10] tests/qemuhotplugtest: Add qemu caps flags to the argument of DO_TEST

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

 



From: Masayoshi Mizuma <m.mizuma@xxxxxxxxxxxxxx>

Add additional qemu cap flags to the argument of DO_TEST*() so that
we can test with specific qemu caps, for example, QEMU_CAPS_BLOCKDEV.

Signed-off-by: Masayoshi Mizuma <m.mizuma@xxxxxxxxxxxxxx>
---
 tests/qemuhotplugtest.c | 133 +++++++++++++++++++++-------------------
 1 file changed, 71 insertions(+), 62 deletions(-)

diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index df5c9c9059..6750b33d51 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -31,6 +31,7 @@
 #include "virstring.h"
 #include "virthread.h"
 #include "virfile.h"
+#include "qemu/qemu_block.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -53,12 +54,14 @@ struct qemuHotplugTestData {
     bool keep;
     virDomainObjPtr vm;
     bool deviceDeletedEvent;
+    virQEMUCapsFlags flags;
 };
 
 static int
 qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
                          virDomainObjPtr *vm,
-                         const char *domxml)
+                         const char *domxml,
+                         virQEMUCapsFlags additionalFlags)
 {
     qemuDomainObjPrivatePtr priv = NULL;
     const unsigned int parseFlags = 0;
@@ -92,6 +95,9 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_KBD);
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_NETDEV_VHOST_VDPA);
 
+    if (additionalFlags)
+        virQEMUCapsSet(priv->qemuCaps, additionalFlags);
+
     if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0)
         return -1;
 
@@ -253,6 +259,7 @@ testQemuHotplug(const void *data)
     g_autoptr(virCaps) caps = NULL;
     qemuMonitorTestPtr test_mon = NULL;
     qemuDomainObjPrivatePtr priv = NULL;
+    virQEMUCapsFlags additionalFlags = test->flags;
 
     domain_filename = g_strdup_printf("%s/qemuhotplugtestdomains/qemuhotplug-%s.xml",
                                       abs_srcdir, test->domain_filename);
@@ -280,7 +287,8 @@ testQemuHotplug(const void *data)
             goto cleanup;
         }
     } else {
-        if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml) < 0)
+        if (qemuHotplugCreateObjects(driver.xmlopt, &vm,
+                                     domain_xml, additionalFlags) < 0)
             goto cleanup;
     }
 
@@ -431,7 +439,7 @@ testQemuHotplugCpuPrepare(const char *test,
     if (virTestLoadFile(data->file_xml_dom, &data->xml_dom) < 0)
         goto error;
 
-    if (qemuHotplugCreateObjects(driver.xmlopt, &data->vm, data->xml_dom) < 0)
+    if (qemuHotplugCreateObjects(driver.xmlopt, &data->vm, data->xml_dom, 0) < 0)
         goto error;
 
     if (!(caps = virQEMUDriverGetCapabilities(&driver, false)))
@@ -646,7 +654,7 @@ mymain(void)
     }
 
 
-#define DO_TEST(file, ACTION, dev, fail_, keep_, ...) \
+#define DO_TEST(file, ACTION, dev, fail_, keep_, flags_, ...) \
     do { \
         const char *my_mon[] = { __VA_ARGS__, NULL}; \
         const char *name = file " " #ACTION " " dev; \
@@ -656,19 +664,19 @@ mymain(void)
         data.fail = fail_; \
         data.mon = my_mon; \
         data.keep = keep_; \
+        data.flags = flags_; \
         if (virTestRun(name, testQemuHotplug, &data) < 0) \
             ret = -1; \
     } while (0)
 
-#define DO_TEST_ATTACH(file, dev, fail, keep, ...) \
-    DO_TEST(file, ATTACH, dev, fail, keep, __VA_ARGS__)
-
-#define DO_TEST_DETACH(file, dev, fail, keep, ...) \
-    DO_TEST(file, DETACH, dev, fail, keep, __VA_ARGS__)
+#define DO_TEST_ATTACH(file, dev, fail, keep, flags, ...) \
+    DO_TEST(file, ATTACH, dev, fail, keep, flags,  __VA_ARGS__)
 
-#define DO_TEST_UPDATE(file, dev, fail, keep, ...) \
-    DO_TEST(file, UPDATE, dev, fail, keep, __VA_ARGS__)
+#define DO_TEST_DETACH(file, dev, fail, keep, flags, ...) \
+    DO_TEST(file, DETACH, dev, fail, keep, flags,  __VA_ARGS__)
 
+#define DO_TEST_UPDATE(file, dev, fail, keep, flags, ...) \
+    DO_TEST(file, UPDATE, dev, fail, keep, flags, __VA_ARGS__)
 
 #define QMP_OK      "{\"return\": {}}"
 #define HMP(msg)    "{\"return\": \"" msg "\"}"
@@ -687,54 +695,55 @@ mymain(void)
     "}\r\n"
 
     cfg->spiceTLS = true;
-    DO_TEST_UPDATE("graphics-spice", "graphics-spice-nochange", false, false, NULL);
-    DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-nochange", false, false,
+    DO_TEST_UPDATE("graphics-spice", "graphics-spice-nochange", false, false, 0, NULL);
+    DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-nochange", false, false, 0,
                    "set_password", QMP_OK, "expire_password", QMP_OK);
-    DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-password", false, false,
+    DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-password", false, false, 0,
                    "set_password", QMP_OK, "expire_password", QMP_OK);
-    DO_TEST_UPDATE("graphics-spice", "graphics-spice-listen", true, false, NULL);
-    DO_TEST_UPDATE("graphics-spice-listen-network", "graphics-spice-listen-network-password", false, false,
+    DO_TEST_UPDATE("graphics-spice", "graphics-spice-listen", true, false, 0, NULL);
+    DO_TEST_UPDATE("graphics-spice-listen-network", "graphics-spice-listen-network-password",
+                   false, false, 0,
                    "set_password", QMP_OK, "expire_password", QMP_OK);
     cfg->spiceTLS = false;
     /* Strange huh? Currently, only graphics can be updated :-P */
-    DO_TEST_UPDATE("disk-cdrom", "disk-cdrom-nochange", true, false, NULL);
+    DO_TEST_UPDATE("disk-cdrom", "disk-cdrom-nochange", true, false, 0, NULL);
 
-    DO_TEST_ATTACH("console-compat-2-live", "console-virtio", false, true,
+    DO_TEST_ATTACH("console-compat-2-live", "console-virtio", false, true, 0,
                    "chardev-add", "{\"return\": {\"pty\": \"/dev/pts/26\"}}",
                    "device_add", QMP_OK);
 
-    DO_TEST_DETACH("console-compat-2-live", "console-virtio", false, false,
+    DO_TEST_DETACH("console-compat-2-live", "console-virtio", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("console1") QMP_OK,
                    "chardev-remove", QMP_OK);
 
-    DO_TEST_ATTACH("base-live", "disk-virtio", false, true,
+    DO_TEST_ATTACH("base-live", "disk-virtio", false, true, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-virtio", true, true,
+    DO_TEST_DETACH("base-live", "disk-virtio", true, true, 0,
                    "device_del", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-virtio", false, false,
+    DO_TEST_DETACH("base-live", "disk-virtio", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK,
                    "human-monitor-command", HMP(""));
 
-    DO_TEST_ATTACH("base-live", "disk-usb", false, true,
+    DO_TEST_ATTACH("base-live", "disk-usb", false, true, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-usb", true, true,
+    DO_TEST_DETACH("base-live", "disk-usb", true, true, 0,
                    "device_del", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-usb", false, false,
+    DO_TEST_DETACH("base-live", "disk-usb", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("usb-disk16") QMP_OK,
                    "human-monitor-command", HMP(""));
 
-    DO_TEST_ATTACH("base-live", "disk-scsi", false, true,
+    DO_TEST_ATTACH("base-live", "disk-scsi", false, true, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-scsi", true, true,
+    DO_TEST_DETACH("base-live", "disk-scsi", true, true, 0,
                    "device_del", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-scsi", false, false,
+    DO_TEST_DETACH("base-live", "disk-scsi", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK,
                    "human-monitor-command", HMP(""));
 
-    DO_TEST_ATTACH("base-without-scsi-controller-live", "disk-scsi-2", false, true,
+    DO_TEST_ATTACH("base-without-scsi-controller-live", "disk-scsi-2", false, true, 0,
                    /* Four controllers added */
                    "device_add", QMP_OK,
                    "device_add", QMP_OK,
@@ -743,96 +752,96 @@ mymain(void)
                    "human-monitor-command", HMP("OK\\r\\n"),
                    /* Disk added */
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", true, true,
+    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", true, true, 0,
                    "device_del", QMP_OK);
-    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", false, false,
+    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("scsi3-0-5-6") QMP_OK,
                    "human-monitor-command", HMP(""));
 
-    DO_TEST_ATTACH("base-live", "disk-scsi-multipath", false, true,
+    DO_TEST_ATTACH("base-live", "disk-scsi-multipath", false, true, 0,
                    "object-add", QMP_OK,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-scsi-multipath", true, true,
+    DO_TEST_DETACH("base-live", "disk-scsi-multipath", true, true, 0,
                    "device_del", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-scsi-multipath", false, false,
+    DO_TEST_DETACH("base-live", "disk-scsi-multipath", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("scsi0-0-0-0") QMP_OK,
                    "human-monitor-command", HMP(""),
                    "object-del", QMP_OK);
 
-    DO_TEST_ATTACH("base-live", "qemu-agent", false, true,
+    DO_TEST_ATTACH("base-live", "qemu-agent", false, true, 0,
                    "chardev-add", QMP_OK,
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "qemu-agent-detach", false, false,
+    DO_TEST_DETACH("base-live", "qemu-agent-detach", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("channel0") QMP_OK,
                    "chardev-remove", QMP_OK);
 
-    DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true,
+    DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-ccw-live", "ccw-virtio", false, false,
+    DO_TEST_DETACH("base-ccw-live", "ccw-virtio", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK,
                    "human-monitor-command", HMP(""));
 
-    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, true,
+    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, true, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
 
-    DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, false,
+    DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("virtio-disk0") QMP_OK,
                    "human-monitor-command", HMP(""));
 
-    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true,
+    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
 
-    DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, false,
+    DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("virtio-disk0") QMP_OK,
                    "human-monitor-command", HMP(""));
 
     /* Attach a second device, then detach the first one. Then attach the first one again. */
-    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true,
+    DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
 
-    DO_TEST_DETACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-explicit", false, true,
+    DO_TEST_DETACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-explicit", false, true, 0,
                    "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK,
                    "human-monitor-command", HMP(""));
 
-    DO_TEST_ATTACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-reverse", false, false,
+    DO_TEST_ATTACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-reverse", false, false, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
 
-    DO_TEST_ATTACH("base-live", "ivshmem-plain", false, true,
+    DO_TEST_ATTACH("base-live", "ivshmem-plain", false, true, 0,
                    "object-add", QMP_OK,
                    "device_add", QMP_OK);
-    DO_TEST_ATTACH("base-live", "ivshmem-doorbell", false, true,
+    DO_TEST_ATTACH("base-live", "ivshmem-doorbell", false, true, 0,
                    "chardev-add", QMP_OK,
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live+ivshmem-plain", "ivshmem-doorbell-detach", false, true,
+    DO_TEST_DETACH("base-live+ivshmem-plain", "ivshmem-doorbell-detach", false, true, 0,
                    "device_del", QMP_DEVICE_DELETED("shmem1") QMP_OK,
                    "chardev-remove", QMP_OK);
-    DO_TEST_DETACH("base-live", "ivshmem-plain-detach", false, false,
+    DO_TEST_DETACH("base-live", "ivshmem-plain-detach", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("shmem0") QMP_OK,
                    "object-del", QMP_OK);
     DO_TEST_ATTACH("base-live+disk-scsi-wwn",
-                   "disk-scsi-duplicate-wwn", false, false,
+                   "disk-scsi-duplicate-wwn", false, false, 0,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
 
-    DO_TEST_ATTACH("base-live", "hostdev-pci", false, true,
+    DO_TEST_ATTACH("base-live", "hostdev-pci", false, true, 0,
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "hostdev-pci", false, false,
+    DO_TEST_DETACH("base-live", "hostdev-pci", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK);
-    DO_TEST_ATTACH("pseries-base-live", "hostdev-pci", false, true,
+    DO_TEST_ATTACH("pseries-base-live", "hostdev-pci", false, true, 0,
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("pseries-base-live", "hostdev-pci", false, false,
+    DO_TEST_DETACH("pseries-base-live", "hostdev-pci", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK);
 
-    DO_TEST_ATTACH("base-live", "interface-vdpa", false, true,
+    DO_TEST_ATTACH("base-live", "interface-vdpa", false, true, 0,
                    "add-fd", "{ \"return\": { \"fdset-id\": 1, \"fd\": 95 }}",
                    "netdev_add", QMP_OK, "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "interface-vdpa", false, false,
+    DO_TEST_DETACH("base-live", "interface-vdpa", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("net0") QMP_OK,
                    "netdev_del", QMP_OK,
                    "query-fdsets",
@@ -840,22 +849,22 @@ mymain(void)
                    "remove-fd", QMP_OK
                    );
 
-    DO_TEST_ATTACH("base-live", "watchdog", false, true,
+    DO_TEST_ATTACH("base-live", "watchdog", false, true, 0,
                    "watchdog-set-action", QMP_OK,
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "watchdog-full", false, false,
+    DO_TEST_DETACH("base-live", "watchdog-full", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("watchdog0") QMP_OK);
 
-    DO_TEST_ATTACH("base-live", "watchdog-user-alias", false, true,
+    DO_TEST_ATTACH("base-live", "watchdog-user-alias", false, true, 0,
                    "watchdog-set-action", QMP_OK,
                    "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "watchdog-user-alias-full", false, false,
+    DO_TEST_DETACH("base-live", "watchdog-user-alias-full", false, false, 0,
                    "device_del", QMP_DEVICE_DELETED("ua-UserWatchdog") QMP_OK);
 
-    DO_TEST_ATTACH("base-live", "guestfwd", false, true,
+    DO_TEST_ATTACH("base-live", "guestfwd", false, true, 0,
                    "chardev-add", QMP_OK,
                    "netdev_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "guestfwd", false, false,
+    DO_TEST_DETACH("base-live", "guestfwd", false, false, 0,
                    "netdev_del", QMP_OK);
 
 #define DO_TEST_CPU_GROUP(prefix, vcpus, modernhp, expectfail) \
-- 
2.27.0




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

  Powered by Linux