[PATCH] qemuhotplugtest: Run "interface-hostdev" test cases only on Linux

Michal Privoznik via Devel posted 1 patch 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/23fbf1d358c6b2d421c1d13b783922af021d4855.1773069049.git.mprivozn@redhat.com
tests/qemuhotplugtest.c | 8 ++++++++
1 file changed, 8 insertions(+)
[PATCH] qemuhotplugtest: Run "interface-hostdev" test cases only on Linux
Posted by Michal Privoznik via Devel 2 weeks ago
From: Michal Privoznik <mprivozn@redhat.com>

In one of my previous commits, I've introduced
"interface-hostdev" attach and detach test cases to
qemuhotplugtest. And they work flawlessly, on Linux. But on
anything else they fail because our virpci.c module is basically
just a bunch of stub functions that do nothing but report an
error, rendering my changes to virpcimock futile.

BTW: this is similar to what I had done in v12.1.0-rc1~199.

Fixes: f9bb819fc4841dbdff801629bf58f9fd6d7d93eb
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

Verified in my FreeBSD VM.

 tests/qemuhotplugtest.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 6cb616c59b..146e9e33c1 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -697,10 +697,18 @@ mymain(void)
     DO_TEST_DETACH("ppc64", "pseries-base-live", "hostdev-pci", false, false,
                    "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK);
 
+#ifdef __linux__
+    /* While <interface type='hostdev'/> is nearly the same as <hostdev/>,
+     * there are subtle differences, e.g. checking that PCI device specified in
+     * <interface/> is a VF. Checks like these are done by walking sysfs which
+     * is limited to Linux, obviously. And while our virpcimock creates
+     * necessary structure, on non-Linux the virpci.c is compiled with stubs
+     * that do nothing but report an error. */
     DO_TEST_ATTACH("x86_64", "base-live", "interface-hostdev", false, true,
                    "device_add", QMP_OK);
     DO_TEST_DETACH("x86_64", "base-live", "interface-hostdev", false, false,
                    "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK);
+#endif
     DO_TEST_ATTACH("x86_64", "base-live", "interface-vdpa", false, true,
                    "query-fdsets", "{\"return\":[{\"fdset-id\":99999}]}",
                    "add-fd", "{ \"return\": { \"fdset-id\": 1, \"fd\": 95 }}",
-- 
2.52.0
Re: [PATCH] qemuhotplugtest: Run "interface-hostdev" test cases only on Linux
Posted by Pavel Hrdina via Devel 2 weeks ago
On Mon, Mar 09, 2026 at 04:11:10PM +0100, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
> 
> In one of my previous commits, I've introduced
> "interface-hostdev" attach and detach test cases to
> qemuhotplugtest. And they work flawlessly, on Linux. But on
> anything else they fail because our virpci.c module is basically
> just a bunch of stub functions that do nothing but report an
> error, rendering my changes to virpcimock futile.
> 
> BTW: this is similar to what I had done in v12.1.0-rc1~199.
> 
> Fixes: f9bb819fc4841dbdff801629bf58f9fd6d7d93eb
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
> 
> Verified in my FreeBSD VM.
> 
>  tests/qemuhotplugtest.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>