Skip to contentSkip to conversation

tests/qtest: add some tests for virtio-net failover

PATCH Superseded Laurent Vivier 1 participant 3 messages Nov 17, 2021 Arm/Amlogic Meson SoC support

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover tests/qtest: add some tests for virtio-net failover

This series adds a qtest entry to test virtio-net failover feature.

We check following error cases:

- check missing id on device with failover_pair_id triggers an error
- check a primary device plugged on a bus that doesn't support hotplug triggers an error

We check the status of the machine before and after hotplugging cards and feature negotiation:

- check we don't see the primary device at boot if failover is on
- check we see the primary device at boot if failover is off
- check we don't see the primary device if failover is on
but failover_pair_id is not the one with on (I think this should be changed)
- check the primary device is plugged after the feature negotiation
- check the result if the primary device is plugged before standby device and vice-versa
- check the if the primary device is coldplugged and the standy device hotplugged and vice-versa
- check the migration triggers the unplug and the hotplug

There is one preliminary patch in the series:

- PATCH 1 introduces a function to enable PCI bridge. Failover needs to be plugged on a pcie-root-port and while the root port is not configured the cards behind it are not available

v2:
- remove PATCH 1 that introduced a function that can be replaced by qobject_to_json_pretty() (Markus)
- Add migration to a file and from the file to check the card is correctly unplugged on the source, and hotplugged on the dest
- Add an ACPI call to eject the card as the kernel would do

Laurent Vivier (2):
qtest/libqos: add a function to initialize secondary PCI buses tests/qtest: add some tests for virtio-net failover

 include/hw/pci/pci_bridge.h       |   8 +
 tests/qtest/libqos/pci.c          | 118 ++++++
 tests/qtest/libqos/pci.h          |   1 +
 tests/qtest/meson.build           |   3 +
 tests/qtest/virtio-net-failover.c | 635 ++++++++++++++++++++++++++++++
 5 files changed, 765 insertions(+)
 create mode 100644 tests/qtest/virtio-net-failover.c
Signature · 1 line
2.33.1
#1 lore raw

PATCH v2 1/2 qtest/libqos: add a function to initialize secondary PCI buses

Scan the PCI devices to find bridge and set PCI_SECONDARY_BUS and PCI_SUBORDINATE_BUS (algorithm from seabios)

---
 include/hw/pci/pci_bridge.h |   8 +++
 tests/qtest/libqos/pci.c    | 118 ++++++++++++++++++++++++++++++++++++
 tests/qtest/libqos/pci.h    |   1 +
 3 files changed, 127 insertions(+)
include/hw/pci/pci_bridge.h +8 -0
index a94d350034bf..30691a6e5728 100644
@@ -138,6 +138,7 @@ typedef struct PCIBridgeQemuCap {
     uint64_t mem_pref_64; /* Prefetchable memory to reserve (64-bit MMIO) */
 } PCIBridgeQemuCap;
 
+#define REDHAT_PCI_CAP_TYPE_OFFSET      3
 #define REDHAT_PCI_CAP_RESOURCE_RESERVE 1
 
 /*
@@ -152,6 +153,13 @@ typedef struct PCIResReserve {
     uint64_t mem_pref_64;
 } PCIResReserve;
 
+#define REDHAT_PCI_CAP_RES_RESERVE_BUS_RES     4
+#define REDHAT_PCI_CAP_RES_RESERVE_IO          8
+#define REDHAT_PCI_CAP_RES_RESERVE_MEM         16
+#define REDHAT_PCI_CAP_RES_RESERVE_PREF_MEM_32 20
+#define REDHAT_PCI_CAP_RES_RESERVE_PREF_MEM_64 24
+#define REDHAT_PCI_CAP_RES_RESERVE_CAP_SIZE    32
+
 int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
                                PCIResReserve res_reserve, Error **errp);
 
tests/qtest/libqos/pci.c +118 -0

130 lines not on this page · raw message

tests/qtest/libqos/pci.h +1 -0
index ee64fdecbda8..becb800f9e6a 100644
@@ -81,6 +81,7 @@ void qpci_device_foreach(QPCIBus *bus, int vendor_id, int device_id,
                          void *data);
 QPCIDevice *qpci_device_find(QPCIBus *bus, int devfn);
 void qpci_device_init(QPCIDevice *dev, QPCIBus *bus, QPCIAddress *addr);
+int qpci_secondary_buses_init(QPCIBus *bus);
 
 bool qpci_has_buggy_msi(QPCIDevice *dev);
 bool qpci_check_buggy_msi(QPCIDevice *dev);
Signature · 1 line
2.33.1
#2 lore raw

PATCH v2 2/2 tests/qtest: add some tests for virtio-net failover

In reply to Laurent Vivier

Add test cases to test several error cases that must be generated by invalid failover configuration.

Add a combination of coldplug and hotplug test cases to be sure the primary is correctly managed according the presence or not of the STANDBY feature.

---
 tests/qtest/meson.build           |   3 +
 tests/qtest/virtio-net-failover.c | 635 ++++++++++++++++++++++++++++++
 2 files changed, 638 insertions(+)
 create mode 100644 tests/qtest/virtio-net-failover.c
tests/qtest/meson.build +3 -0
index c9d8458062ff..6d66bf522156 100644
@@ -22,6 +22,9 @@ qtests_generic = \
   (config_all_devices.has_key('CONFIG_VIRTIO_SCSI') ? ['fuzz-virtio-scsi-test'] : []) + \
   (config_all_devices.has_key('CONFIG_SB16') ? ['fuzz-sb16-test'] : []) + \
   (config_all_devices.has_key('CONFIG_SDHCI_PCI') ? ['fuzz-sdcard-test'] : []) + \
+  (config_all_devices.has_key('CONFIG_VIRTIO_NET') and \
+   config_all_devices.has_key('CONFIG_Q35') and \
+   config_all_devices.has_key('CONFIG_VIRTIO_PCI') ? ['virtio-net-failover'] : []) + \
   [
   'cdrom-test',
   'device-introspect-test',
tests/qtest/virtio-net-failover.c new file +635 -0

635 lines not on this page · raw message

Signature · 1 line
2.33.1