From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>
Subject: [PULL 08/25] tests/qtest: failover: check the feature is correctly provided
Date: Mon, 21 Feb 2022 12:59:51 +0100 [thread overview]
Message-ID: <20220221120008.600114-9-thuth@redhat.com> (raw)
In-Reply-To: <20220221120008.600114-1-thuth@redhat.com>
From: Laurent Vivier <lvivier@redhat.com>
Check QEMU provides the VIRTIO_NET_F_STANDBY if failover is on,
and doesn't if failover is off
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20220203141537.972317-4-lvivier@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/virtio-net-failover.c | 139 ++++++++++++++++++------------
1 file changed, 86 insertions(+), 53 deletions(-)
diff --git a/tests/qtest/virtio-net-failover.c b/tests/qtest/virtio-net-failover.c
index 070e53de12..4236796368 100644
--- a/tests/qtest/virtio-net-failover.c
+++ b/tests/qtest/virtio-net-failover.c
@@ -18,6 +18,8 @@
#include "libqos/virtio-pci.h"
#include "hw/pci/pci.h"
+#define VIRTIO_NET_F_STANDBY 62
+
#define ACPI_PCIHP_ADDR_ICH9 0x0cc0
#define PCI_EJ_BASE 0x0008
#define PCI_SEL_BASE 0x0010
@@ -246,6 +248,65 @@ do { \
qobject_unref(bus); \
} while (0)
+static QDict *get_failover_negociated_event(QTestState *qts)
+{
+ QDict *resp;
+ QDict *data;
+
+ resp = qtest_qmp_eventwait_ref(qts, "FAILOVER_NEGOTIATED");
+ g_assert(qdict_haskey(resp, "data"));
+
+ data = qdict_get_qdict(resp, "data");
+ g_assert(qdict_haskey(data, "device-id"));
+ qobject_ref(data);
+ qobject_unref(resp);
+
+ return data;
+}
+
+static QVirtioPCIDevice *start_virtio_net_internal(QTestState *qts,
+ int bus, int slot,
+ uint64_t *features)
+{
+ QVirtioPCIDevice *dev;
+ QPCIAddress addr;
+
+ addr.devfn = QPCI_DEVFN((bus << 5) + slot, 0);
+ dev = virtio_pci_new(pcibus, &addr);
+ g_assert_nonnull(dev);
+ qvirtio_pci_device_enable(dev);
+ qvirtio_start_device(&dev->vdev);
+ *features &= qvirtio_get_features(&dev->vdev);
+ qvirtio_set_features(&dev->vdev, *features);
+ qvirtio_set_driver_ok(&dev->vdev);
+ return dev;
+}
+
+static QVirtioPCIDevice *start_virtio_net(QTestState *qts, int bus, int slot,
+ const char *id, bool failover)
+{
+ QVirtioPCIDevice *dev;
+ uint64_t features;
+
+ features = ~(QVIRTIO_F_BAD_FEATURE |
+ (1ull << VIRTIO_RING_F_INDIRECT_DESC) |
+ (1ull << VIRTIO_RING_F_EVENT_IDX));
+
+ dev = start_virtio_net_internal(qts, bus, slot, &features);
+
+ g_assert(!!(features & (1ull << VIRTIO_NET_F_STANDBY)) == failover);
+
+ if (failover) {
+ QDict *resp;
+
+ resp = get_failover_negociated_event(qts);
+ g_assert_cmpstr(qdict_get_str(resp, "device-id"), ==, id);
+ qobject_unref(resp);
+ }
+
+ return dev;
+}
+
static void test_on(void)
{
QTestState *qts;
@@ -254,6 +315,7 @@ static void test_on(void)
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=on,netdev=hs0,mac="MAC_STANDBY0" "
+ "-netdev user,id=hs1 "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby0,netdev=hs1,mac="MAC_PRIMARY0,
2);
@@ -267,6 +329,7 @@ static void test_on(void)
static void test_on_mismatch(void)
{
QTestState *qts;
+ QVirtioPCIDevice *vdev;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
@@ -280,12 +343,19 @@ static void test_on_mismatch(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
+
+ check_one_card(qts, true, "standby0", MAC_STANDBY0);
+ check_one_card(qts, true, "primary0", MAC_PRIMARY0);
+
+ qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_off(void)
{
QTestState *qts;
+ QVirtioPCIDevice *vdev;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
@@ -299,50 +369,13 @@ static void test_off(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
- machine_stop(qts);
-}
+ vdev = start_virtio_net(qts, 1, 0, "standby0", false);
-static QDict *get_failover_negociated_event(QTestState *qts)
-{
- QDict *resp;
- QDict *data;
-
- resp = qtest_qmp_eventwait_ref(qts, "FAILOVER_NEGOTIATED");
- g_assert(qdict_haskey(resp, "data"));
-
- data = qdict_get_qdict(resp, "data");
- g_assert(qdict_haskey(data, "device-id"));
- qobject_ref(data);
- qobject_unref(resp);
-
- return data;
-}
-
-static QVirtioPCIDevice *start_virtio_net(QTestState *qts, int bus, int slot,
- const char *id)
-{
- QVirtioPCIDevice *dev;
- uint64_t features;
- QPCIAddress addr;
- QDict *resp;
-
- addr.devfn = QPCI_DEVFN((bus << 5) + slot, 0);
- dev = virtio_pci_new(pcibus, &addr);
- g_assert_nonnull(dev);
- qvirtio_pci_device_enable(dev);
- qvirtio_start_device(&dev->vdev);
- features = qvirtio_get_features(&dev->vdev);
- features = features & ~(QVIRTIO_F_BAD_FEATURE |
- (1ull << VIRTIO_RING_F_INDIRECT_DESC) |
- (1ull << VIRTIO_RING_F_EVENT_IDX));
- qvirtio_set_features(&dev->vdev, features);
- qvirtio_set_driver_ok(&dev->vdev);
-
- resp = get_failover_negociated_event(qts);
- g_assert_cmpstr(qdict_get_str(resp, "device-id"), ==, id);
- qobject_unref(resp);
+ check_one_card(qts, true, "standby0", MAC_STANDBY0);
+ check_one_card(qts, true, "primary0", MAC_PRIMARY0);
- return dev;
+ qos_object_destroy((QOSGraphObject *)vdev);
+ machine_stop(qts);
}
static void test_enabled(void)
@@ -362,7 +395,7 @@ static void test_enabled(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@@ -385,7 +418,7 @@ static void test_hotplug_1(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@@ -427,7 +460,7 @@ static void test_hotplug_1_reverse(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@@ -458,7 +491,7 @@ static void test_hotplug_2(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@@ -514,7 +547,7 @@ static void test_hotplug_2_reverse(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@@ -579,7 +612,7 @@ static void test_migrate_out(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@@ -775,7 +808,7 @@ static void test_migrate_abort_wait_unplug(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@@ -865,7 +898,7 @@ static void test_migrate_abort_active(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@@ -959,7 +992,7 @@ static void test_migrate_abort_timeout(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
- vdev = start_virtio_net(qts, 1, 0, "standby0");
+ vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@@ -1070,7 +1103,7 @@ static void test_multi_out(gconstpointer opaque)
check_one_card(qts, false, "standby1", MAC_STANDBY1);
check_one_card(qts, false, "primary1", MAC_PRIMARY1);
- vdev0 = start_virtio_net(qts, 1, 0, "standby0");
+ vdev0 = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@@ -1101,7 +1134,7 @@ static void test_multi_out(gconstpointer opaque)
check_one_card(qts, true, "standby1", MAC_STANDBY1);
check_one_card(qts, false, "primary1", MAC_PRIMARY1);
- vdev1 = start_virtio_net(qts, 3, 0, "standby1");
+ vdev1 = start_virtio_net(qts, 3, 0, "standby1", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
--
2.27.0
next prev parent reply other threads:[~2022-02-21 12:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 11:59 [PULL 00/25] qtest patches and misc header clean-ups Thomas Huth
2022-02-21 11:59 ` [PULL 01/25] tests/x86: Use 'pc' machine type for old hardware tests Thomas Huth
2022-02-21 11:59 ` [PULL 02/25] tests/x86: Use 'pc' machine type for hotplug tests Thomas Huth
2022-02-21 11:59 ` [PULL 03/25] erst: drop cast to long long Thomas Huth
2022-02-21 11:59 ` [PULL 04/25] tests/qtest/vhost-user-test.c: Use vhostforce=on Thomas Huth
2022-02-21 11:59 ` [PULL 05/25] tests/qtest/ide-test: Remove bad retry_isa test Thomas Huth
2022-02-21 11:59 ` [PULL 06/25] tests/qtest: failover: clean up pathname of tests Thomas Huth
2022-02-21 11:59 ` [PULL 07/25] tests/qtest: failover: use a macro for check_one_card() Thomas Huth
2022-02-21 11:59 ` Thomas Huth [this message]
2022-02-21 11:59 ` [PULL 09/25] tests/qtest: failover: check missing guest feature Thomas Huth
2022-02-21 11:59 ` [PULL 10/25] tests/qtest: failover: check migration with failover off Thomas Huth
2022-02-21 11:59 ` [PULL 11/25] tests/qtest: failover: test migration if the guest doesn't support failover Thomas Huth
2022-02-21 11:59 ` [PULL 12/25] tests/qtest: failover: migration abort test with failover off Thomas Huth
2022-02-21 11:59 ` [PULL 13/25] scripts: Remove the old switch-timer-api script Thomas Huth
2022-02-21 11:59 ` [PULL 14/25] hw/tpm: Clean includes Thomas Huth
2022-02-21 11:59 ` [PULL 15/25] hw/remote: Add missing include Thomas Huth
2022-02-21 11:59 ` [PULL 16/25] hw/acpi/memory_hotplug: Remove unused 'hw/acpi/pc-hotplug.h' header Thomas Huth
2022-02-21 12:00 ` [PULL 17/25] qtest: Add missing 'hw/qdev-core.h' include Thomas Huth
2022-02-21 12:00 ` [PULL 18/25] exec/ramblock: Add missing includes Thomas Huth
2022-02-21 12:00 ` [PULL 19/25] core/ptimers: Remove unnecessary 'sysemu/cpus.h' include Thomas Huth
2022-02-21 12:00 ` [PULL 20/25] target: Add missing "qemu/timer.h" include Thomas Huth
2022-02-21 12:00 ` [PULL 21/25] linux-user: " Thomas Huth
2022-02-21 12:00 ` [PULL 22/25] softmmu/runstate: Clean headers Thomas Huth
2022-02-21 12:00 ` [PULL 23/25] exec/exec-all: Move 'qemu/log.h' include in units requiring it Thomas Huth
2022-02-21 12:00 ` [PULL 24/25] hw/m68k/mcf: Add missing 'exec/hwaddr.h' header Thomas Huth
2022-02-21 12:00 ` [PULL 25/25] hw/tricore: Remove unused and incorrect header Thomas Huth
2022-02-21 12:21 ` [PULL 00/25] qtest patches and misc header clean-ups Philippe Mathieu-Daudé
2022-02-22 20:16 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220221120008.600114-9-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=lvivier@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).