#include "virhostdev.h"
#include "viralloc.h"
#include "virerror.h"
+#include "virfile.h"
#include "virlog.h"
#include "virutil.h"
#include "virnetdev.h"
VIR_LOG_INIT("util.hostdev");
+#define VIR_DEV_VFIO "/dev/vfio/vfio"
#define HOSTDEV_STATE_DIR RUNSTATEDIR "/libvirt/hostdevmgr"
static virHostdevManager *manager; /* global hostdev manager, never freed */
return virHostdevIsPCIDevice(hostdev) ||
virHostdevIsMdevDevice(hostdev);
}
+
+bool
+virHostdevHostSupportsPassthroughVFIO(void)
+{
+ /* condition 1 - host has IOMMU */
+ if (!virHostHasIOMMU())
+ return false;
+
+ /* condition 2 - /dev/vfio/vfio exists */
+ if (!virFileExists(VIR_DEV_VFIO))
+ return false;
+
+ return true;
+}
bool
virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev);
+
+bool virHostdevHostSupportsPassthroughVFIO(void);
# hypervisor/virhostdev.h
virHostdevFindUSBDevice;
+virHostdevHostSupportsPassthroughVFIO;
virHostdevManagerGetDefault;
virHostdevNeedsVFIO;
virHostdevPCINodeDeviceDetach;
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCaps *qemuCaps,
virDomainCapsDeviceHostdev *hostdev)
{
- bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
+ bool supportsPassthroughVFIO = virHostdevHostSupportsPassthroughVFIO();
hostdev->supported = VIR_TRISTATE_BOOL_YES;
hostdev->mode.report = true;
qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev,
virQEMUCaps *qemuCaps)
{
- bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
+ bool supportsPassthroughVFIO = virHostdevHostSupportsPassthroughVFIO();
virDeviceHostdevPCIDriverName *driverName = &hostdev->source.subsys.u.pci.driver.name;
/* assign defaults for hostdev passthrough */
* further validation until then.
*/
- if (!qemuHostdevHostSupportsPassthroughVFIO()) {
+ if (!virHostdevHostSupportsPassthroughVFIO()) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("VFIO device assignment is currently not supported on this system"));
return -1;
}
-bool
-qemuHostdevHostSupportsPassthroughVFIO(void)
-{
- /* condition 1 - host has IOMMU */
- if (!virHostHasIOMMU())
- return false;
-
- /* condition 2 - /dev/vfio/vfio exists */
- if (!virFileExists(QEMU_DEV_VFIO))
- return false;
-
- return true;
-}
-
-
int
qemuHostdevPrepareOneNVMeDisk(virQEMUDriver *driver,
const char *name,
#include "qemu_conf.h"
-bool qemuHostdevHostSupportsPassthroughVFIO(void);
-
int qemuHostdevUpdateActiveNVMeDisks(virQEMUDriver *driver,
virDomainDef *def);
int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriver *driver,
return -1;
/* The function above tries to query host's VFIO capabilities by calling
- * qemuHostdevHostSupportsPassthroughVFIO() which, however, can't be
+ * 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,