[PATCH] networkxmlconftest: Expect success for "hostdev" case only on Linux

Michal Privoznik via Devel posted 1 patch 2 days, 16 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1d1affcbf41e81513de4b695f1bf27100cf91a3e.1769774408.git.mprivozn@redhat.com
tests/networkxmlconftest.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] networkxmlconftest: Expect success for "hostdev" case only on Linux
Posted by Michal Privoznik via Devel 2 days, 16 hours ago
From: Michal Privoznik <mprivozn@redhat.com>

Our network has multiple means of forwarding the traffic and
'hostdev' is one of them. This mode means that the network is
configured to use a set of PCI devices which are then assigned to
individual domains to use (PCI device assignment). Now, as of
v12.0.0-61-gecb2e06bdf our test runners
(testCompareXMLToXMLFiles() and testCompareXMLToConfFiles()) call
networkValidateTests(). For aforementioned type of network this
means checking that the specified set of devices contains only
VFs (see v3.2.0-rc1~24 for more info). It is true that our
virpcimock is preloaded which mimics VFs, but our utils module
(virpci.c specifically) talks to sysfs to check various PCI
device attributes, including whether it's a VF.

This obviously works on Linux and doesn't work anywhere else.
Therefore, until our utils module is taught how to check PCI
attribs on other systems, make the "hostdev" test case expect
validation failure on non-Linux systems.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/networkxmlconftest.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/networkxmlconftest.c b/tests/networkxmlconftest.c
index b32a39c553..b74d5b14f5 100644
--- a/tests/networkxmlconftest.c
+++ b/tests/networkxmlconftest.c
@@ -313,7 +313,16 @@ mymain(void)
     DO_TEST("bandwidth-network");
     DO_TEST("openvswitch-net");
     DO_TEST_VALIDATE_ERROR("passthrough-pf");
+#ifdef __linux__
     DO_TEST("hostdev");
+#else
+    /* Our test runners call networkValidateTests() which for
+     * <forward mode='hostdev'/> means validating that PCI
+     * devices are VFs. It's done so by querying sysfs which
+     * obviously works on Linux only. Thus, expect a validation
+     * error elsewhere. */
+    DO_TEST_VALIDATE_ERROR("hostdev");
+#endif
     DO_TEST_FLAGS("hostdev-pf", VIR_NETWORK_XML_INACTIVE);
     DO_TEST_FLAGS("hostdev-pf-driver-model", VIR_NETWORK_XML_INACTIVE);
     DO_TEST("ptr-domains-auto");
-- 
2.52.0
Re: [PATCH] networkxmlconftest: Expect success for "hostdev" case only on Linux
Posted by Martin Kletzander via Devel 2 days, 14 hours ago
On Fri, Jan 30, 2026 at 01:00:08PM +0100, Michal Privoznik via Devel wrote:
>From: Michal Privoznik <mprivozn@redhat.com>
>
>Our network has multiple means of forwarding the traffic and
>'hostdev' is one of them. This mode means that the network is
>configured to use a set of PCI devices which are then assigned to
>individual domains to use (PCI device assignment). Now, as of
>v12.0.0-61-gecb2e06bdf our test runners
>(testCompareXMLToXMLFiles() and testCompareXMLToConfFiles()) call
>networkValidateTests(). For aforementioned type of network this
>means checking that the specified set of devices contains only
>VFs (see v3.2.0-rc1~24 for more info). It is true that our
>virpcimock is preloaded which mimics VFs, but our utils module
>(virpci.c specifically) talks to sysfs to check various PCI
>device attributes, including whether it's a VF.
>
>This obviously works on Linux and doesn't work anywhere else.
>Therefore, until our utils module is taught how to check PCI
>attribs on other systems, make the "hostdev" test case expect
>validation failure on non-Linux systems.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>