[PATCH 05/10] tests: qemuhotplug: Use DEVICE_DELETED event in all hotunplug tests

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

 



Currently all supported qemu versions now have support for the
DEVICE_DELETED event. This means that testing the old approach is a
waste of time.

Always add the QEMU_CAPS_DEVICE_DEL_EVENT capability in the hotplug test
and fix existing test cases.

The 'disk-virtio', 'disk-usb', 'disk-scsi', and 'disk-scsi-2' already
had variants that used the event, so the non-event variants will be
removed.

For all other cases the QMP_DEVICE_DELETED macro is used to add the
correct reply.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/qemuhotplugtest.c | 59 +++++++++--------------------------------
 1 file changed, 12 insertions(+), 47 deletions(-)

diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 0356d87092..3318931b9b 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -59,7 +59,7 @@ static int
 qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
                          virDomainObjPtr *vm,
                          const char *domxml,
-                         bool event)
+                         bool event ATTRIBUTE_UNUSED)
 {
     int ret = -1;
     qemuDomainObjPrivatePtr priv = NULL;
@@ -79,8 +79,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_PLAIN);
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_SCSI_DISK_WWN);
-    if (event)
-        virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);
+    virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);

     if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0)
         goto cleanup;
@@ -683,16 +682,9 @@ mymain(void)
                    "device_add", QMP_OK);

     DO_TEST_DETACH("console-compat-2-live", "console-virtio", false, false,
-                   "device_del", QMP_OK,
+                   "device_del", QMP_DEVICE_DELETED("console1") QMP_OK,
                    "chardev-remove", QMP_OK);

-    DO_TEST_ATTACH("base-live", "disk-virtio", false, true,
-                   "human-monitor-command", HMP("OK\\r\\n"),
-                   "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-virtio", false, false,
-                   "device_del", QMP_OK,
-                   "human-monitor-command", HMP(""));
-
     DO_TEST_ATTACH_EVENT("base-live", "disk-virtio", false, true,
                          "human-monitor-command", HMP("OK\\r\\n"),
                          "device_add", QMP_OK);
@@ -703,13 +695,6 @@ mymain(void)
                    "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK,
                    "human-monitor-command", HMP(""));

-    DO_TEST_ATTACH("base-live", "disk-usb", false, true,
-                   "human-monitor-command", HMP("OK\\r\\n"),
-                   "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-usb", false, false,
-                   "device_del", QMP_OK,
-                   "human-monitor-command", HMP(""));
-
     DO_TEST_ATTACH_EVENT("base-live", "disk-usb", false, true,
                          "human-monitor-command", HMP("OK\\r\\n"),
                          "device_add", QMP_OK);
@@ -720,13 +705,6 @@ mymain(void)
                    "device_del", QMP_DEVICE_DELETED("usb-disk16") QMP_OK,
                    "human-monitor-command", HMP(""));

-    DO_TEST_ATTACH("base-live", "disk-scsi", false, true,
-                   "human-monitor-command", HMP("OK\\r\\n"),
-                   "device_add", QMP_OK);
-    DO_TEST_DETACH("base-live", "disk-scsi", false, false,
-                   "device_del", QMP_OK,
-                   "human-monitor-command", HMP(""));
-
     DO_TEST_ATTACH_EVENT("base-live", "disk-scsi", false, true,
                          "human-monitor-command", HMP("OK\\r\\n"),
                          "device_add", QMP_OK);
@@ -737,19 +715,6 @@ mymain(void)
                    "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,
-                   /* Four controllers added */
-                   "device_add", QMP_OK,
-                   "device_add", QMP_OK,
-                   "device_add", QMP_OK,
-                   "device_add", QMP_OK,
-                   "human-monitor-command", HMP("OK\\r\\n"),
-                   /* Disk added */
-                   "device_add", QMP_OK);
-    DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", false, false,
-                   "device_del", QMP_OK,
-                   "human-monitor-command", HMP(""));
-
     DO_TEST_ATTACH_EVENT("base-without-scsi-controller-live", "disk-scsi-2", false, true,
                          /* Four controllers added */
                          "device_add", QMP_OK,
@@ -770,14 +735,14 @@ mymain(void)
                    "chardev-add", QMP_OK,
                    "device_add", QMP_OK);
     DO_TEST_DETACH("base-live", "qemu-agent-detach", false, false,
-                   "device_del", QMP_OK,
+                   "device_del", QMP_DEVICE_DELETED("channel0") QMP_OK,
                    "chardev-remove", QMP_OK);

     DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true,
                    "human-monitor-command", HMP("OK\\r\\n"),
                    "device_add", QMP_OK);
     DO_TEST_DETACH("base-ccw-live", "ccw-virtio", false, false,
-                   "device_del", QMP_OK,
+                   "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,
@@ -785,7 +750,7 @@ mymain(void)
                    "device_add", QMP_OK);

     DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, false,
-                   "device_del", QMP_OK,
+                   "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,
@@ -793,7 +758,7 @@ mymain(void)
                    "device_add", QMP_OK);

     DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, false,
-                   "device_del", QMP_OK,
+                   "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. */
@@ -802,7 +767,7 @@ mymain(void)
                    "device_add", QMP_OK);

     DO_TEST_DETACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-explicit", false, true,
-                   "device_del", QMP_OK,
+                   "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,
@@ -816,10 +781,10 @@ mymain(void)
                    "chardev-add", QMP_OK,
                    "device_add", QMP_OK);
     DO_TEST_DETACH("base-live+ivshmem-plain", "ivshmem-doorbell-detach", false, true,
-                   "device_del", QMP_OK,
+                   "device_del", QMP_DEVICE_DELETED("shmem1") QMP_OK,
                    "chardev-remove", QMP_OK);
     DO_TEST_DETACH("base-live", "ivshmem-plain-detach", false, false,
-                   "device_del", QMP_OK,
+                   "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,
@@ -830,13 +795,13 @@ mymain(void)
                    "watchdog-set-action", QMP_OK,
                    "device_add", QMP_OK);
     DO_TEST_DETACH("base-live", "watchdog-full", false, false,
-                   "device_del", QMP_OK);
+                   "device_del", QMP_DEVICE_DELETED("watchdog0") QMP_OK);

     DO_TEST_ATTACH("base-live", "watchdog-user-alias", false, true,
                    "watchdog-set-action", QMP_OK,
                    "device_add", QMP_OK);
     DO_TEST_DETACH("base-live", "watchdog-user-alias-full", false, false,
-                   "device_del", QMP_OK);
+                   "device_del", QMP_DEVICE_DELETED("ua-UserWatchdog") QMP_OK);

 #define DO_TEST_CPU_GROUP(prefix, vcpus, modernhp, expectfail) \
     do { \
-- 
2.20.1

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

  Powered by Linux