diff mbox series

[v3,5/5] tests/libqtest: update virtio-net failover test

Message ID 20211118133225.324937-6-lvivier@redhat.com
State New
Headers show
Series tests/qtest: add some tests for virtio-net failover | expand

Commit Message

Laurent Vivier Nov. 18, 2021, 1:32 p.m. UTC
Update the migration test to check we correctly wait the end
of the card unplug before doing the migration.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 tests/qtest/virtio-net-failover.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/tests/qtest/virtio-net-failover.c b/tests/qtest/virtio-net-failover.c
index 576d4454c3c3..7cc276e6ffc1 100644
--- a/tests/qtest/virtio-net-failover.c
+++ b/tests/qtest/virtio-net-failover.c
@@ -478,6 +478,7 @@  static void test_outmigrate(gconstpointer opaque)
     QTestState *qts;
     QDict *resp, *args, *data;
     g_autofree gchar *uri = g_strdup_printf("exec: cat > %s", (gchar *)opaque);
+    struct timeval timeout;
 
     qts = machine_start(BASE_MACHINE
                      "-netdev user,id=hs0 "
@@ -525,11 +526,19 @@  static void test_outmigrate(gconstpointer opaque)
 
     qobject_unref(resp);
 
-    qtest_outl(qts, ACPI_PCIHP_ADDR_ICH9 + PCI_EJ_BASE, 1);
+    /*
+     * The migration cannot start if the card is not ejected,
+     * so we check it cannot end ("STOP") before the card is ejected
+     */
+    /* 10s is enough for ACPI, PCIe native would need at least 30s */
+    timeout.tv_sec = 10;
+    timeout.tv_usec = 0;
+    resp = qtest_qmp_eventwait_timeout(qts, &timeout, "STOP");
+    g_assert_null(resp);
 
-    resp = qtest_qmp_eventwait_ref(qts, "STOP");
-    qobject_unref(resp);
+    qtest_outl(qts, ACPI_PCIHP_ADDR_ICH9 + PCI_EJ_BASE, 1);
 
+    qtest_qmp_eventwait(qts, "STOP");
     /*
      * in fact, the card is ejected from the point of view of kernel
      * but not really from QEMU to be able to hotplug it back if