From: Pavel Hrdina Date: Mon, 16 Feb 2026 15:53:57 +0000 (+0100) Subject: tests: properly mock VFIO and IOMMU checks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;p=thirdparty%2Flibvirt.git tests: properly mock VFIO and IOMMU checks Fixes: 63434db800b921e96fec424a667b7161af1f02de Signed-off-by: Pavel Hrdina --- diff --git a/src/util/virutil.h b/src/util/virutil.h index ca6fd95363..7e1705e7ce 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -141,7 +141,7 @@ unsigned long long virMemoryLimitTruncate(unsigned long long value); bool virMemoryLimitIsSet(unsigned long long value); unsigned long long virMemoryMaxValue(bool ulong) ATTRIBUTE_MOCKABLE; -bool virHostHasIOMMU(void); +bool virHostHasIOMMU(void) ATTRIBUTE_MOCKABLE; char *virHostGetDRMRenderNode(void) ATTRIBUTE_MOCKABLE; diff --git a/tests/domaincapsdata/qemu_9.0.0.sparc.xml b/tests/domaincapsdata/qemu_9.0.0.sparc.xml index 062e55718b..93d8d40c2c 100644 --- a/tests/domaincapsdata/qemu_9.0.0.sparc.xml +++ b/tests/domaincapsdata/qemu_9.0.0.sparc.xml @@ -86,10 +86,7 @@ scsi - - default - vfio - + no diff --git a/tests/domaincapsdata/qemu_9.2.0-hvf.aarch64+hvf.xml b/tests/domaincapsdata/qemu_9.2.0-hvf.aarch64+hvf.xml index db51e7b120..a65d9d36fd 100644 --- a/tests/domaincapsdata/qemu_9.2.0-hvf.aarch64+hvf.xml +++ b/tests/domaincapsdata/qemu_9.2.0-hvf.aarch64+hvf.xml @@ -147,10 +147,7 @@ scsi - - default - vfio - + no diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c index 370ce35709..aa13deb324 100644 --- a/tests/domaincapsmock.c +++ b/tests/domaincapsmock.c @@ -21,6 +21,7 @@ #include "virhostmem.h" #include "viriommufd.h" #include "virmock.h" +#include "virutil.h" #if WITH_QEMU # include "qemu/qemu_capabilities.h" @@ -91,5 +92,14 @@ virFileExists(const char *path) if (STREQ(path, VIR_IOMMU_DEV_PATH)) return true; + if (STREQ(path, "/dev/vfio/vfio")) + return true; + return real_virFileExists(path); } + +bool +virHostHasIOMMU(void) +{ + return true; +} diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 71e181d179..5b2fc80f0a 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -104,14 +104,6 @@ fillQemuCaps(virDomainCaps *domCaps, false) < 0) return -1; - /* The function above tries to query host's VFIO capabilities by calling - * virHostdevHostSupportsPassthroughVFIO() which, however, can't be - * successfully mocked as they are not exposed as internal APIs. Therefore, - * instead of mocking set the expected values here by hand. */ - VIR_DOMAIN_CAPS_ENUM_SET(domCaps->hostdev.pciBackend, - VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT, - VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO); - /* As of f05b6a918e28 we are expecting to see OVMF_CODE.fd file which * may not exists everywhere. */ while (loader->values.nvalues)