virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsDeviceHostdevPtr hostdev)
{
- bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
hostdev->supported = VIR_TRISTATE_BOOL_YES;
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
}
- if (supportsPassthroughKVM) {
- VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
- }
return 0;
}
qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev,
unsigned int bootIndex, /* used iff dev->info->bootIndex == 0 */
- const char *configfd,
virQEMUCapsPtr qemuCaps)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
/* caller has to assign proper passthrough backend type */
switch ((virDomainHostdevSubsysPCIBackendType)backend) {
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
- virBufferAddLit(&buf, "pci-assign");
- if (configfd && *configfd)
- virBufferAsprintf(&buf, ",configfd=%s", configfd);
- break;
-
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO:
virBufferAddLit(&buf, "vfio-pci");
break;
+ case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
}
}
- char *configfd_name = NULL;
unsigned int bootIndex = hostdev->info->bootIndex;
/* bootNet will be non-0 if boot order was set and no other
bootIndex = *bootHostdevNet;
*bootHostdevNet = 0;
}
- if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
- int configfd = qemuOpenPCIConfig(hostdev);
-
- if (configfd >= 0) {
- if (virAsprintf(&configfd_name, "%d", configfd) < 0) {
- VIR_FORCE_CLOSE(configfd);
- return -1;
- }
-
- virCommandPassFD(cmd, configfd,
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
- }
- }
if (qemuCommandAddExtDevice(cmd, hostdev->info) < 0)
return -1;
virCommandAddArg(cmd, "-device");
- devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex,
- configfd_name, qemuCaps);
- VIR_FREE(configfd_name);
+ devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex, qemuCaps);
if (!devstr)
return -1;
virCommandAddArg(cmd, devstr);
char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev,
unsigned int bootIndex,
- const char *configfd,
virQEMUCapsPtr qemuCaps);
char *qemuBuildRNGDevStr(const virDomainDef *def,
int ret = -1;
virNodeDeviceDefPtr def = NULL;
char *xml = NULL;
- bool legacy = qemuHostdevHostSupportsPassthroughLegacy();
bool vfio = qemuHostdevHostSupportsPassthroughVFIO();
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
if (!pci)
goto cleanup;
- if (!driverName) {
- if (vfio) {
- driverName = "vfio";
- } else if (legacy) {
- driverName = "kvm";
- } else {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("neither VFIO nor KVM device assignment is "
- "currently supported on this system"));
- goto cleanup;
- }
- }
+ if (!driverName)
+ driverName = "vfio";
if (STREQ(driverName, "vfio")) {
if (!vfio) {
}
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_VFIO);
} else if (STREQ(driverName, "kvm")) {
- if (!legacy) {
- virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("KVM device assignment is currently not "
- "supported on this system"));
- goto cleanup;
- }
- virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM);
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("KVM device assignment is no longer "
+ "supported on this system"));
+ goto cleanup;
} else {
virReportError(VIR_ERR_INVALID_ARG,
_("unknown driver name '%s'"), driverName);
}
-#if HAVE_LINUX_KVM_H
-# include <linux/kvm.h>
-bool
-qemuHostdevHostSupportsPassthroughLegacy(void)
-{
- int kvmfd = -1;
- bool ret = false;
-
- if ((kvmfd = open("/dev/kvm", O_RDONLY)) < 0)
- goto cleanup;
-
-# ifdef KVM_CAP_IOMMU
- if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <= 0)
- goto cleanup;
-
- ret = true;
-# endif
-
- cleanup:
- VIR_FORCE_CLOSE(kvmfd);
-
- return ret;
-}
-#else
-bool
-qemuHostdevHostSupportsPassthroughLegacy(void)
-{
- return false;
-}
-#endif
-
-
static bool
qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs,
size_t nhostdevs,
virQEMUCapsPtr qemuCaps)
{
- bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
size_t i;
if (supportsPassthroughVFIO &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
- } else if (supportsPassthroughKVM) {
- *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("host doesn't support passthrough of "
break;
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
- if (!supportsPassthroughKVM) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("host doesn't support legacy PCI passthrough"));
- return false;
- }
-
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("host doesn't support legacy PCI passthrough"));
+ return false;
break;
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
#include "qemu_conf.h"
#include "domain_conf.h"
-bool qemuHostdevHostSupportsPassthroughLegacy(void);
bool qemuHostdevHostSupportsPassthroughVFIO(void);
int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver,
virDomainDeviceInfoPtr info = hostdev->info;
int ret;
char *devstr = NULL;
- int configfd = -1;
- char *configfd_name = NULL;
bool releaseaddr = false;
bool teardowncgroup = false;
bool teardownlabel = false;
if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0)
goto error;
releaseaddr = true;
- if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
- configfd = qemuOpenPCIConfig(hostdev);
- if (configfd >= 0) {
- if (virAsprintf(&configfd_name, "fd-%s", info->alias) < 0)
- goto error;
- }
- }
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
goto error;
}
- if (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, 0,
- configfd_name, priv->qemuCaps)))
+ if (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, 0, priv->qemuCaps)))
goto error;
qemuDomainObjEnterMonitor(driver, vm);
if ((ret = qemuDomainAttachExtensionDevice(priv->mon, hostdev->info)) < 0)
goto exit_monitor;
- if ((ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
- configfd, configfd_name)) < 0) {
+ if ((ret = qemuMonitorAddDevice(priv->mon, devstr)) < 0)
ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info));
- }
exit_monitor:
if (qemuDomainObjExitMonitor(driver, vm) < 0)
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
VIR_FREE(devstr);
- VIR_FREE(configfd_name);
- VIR_FORCE_CLOSE(configfd);
return 0;
qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);
VIR_FREE(devstr);
- VIR_FREE(configfd_name);
- VIR_FORCE_CLOSE(configfd);
cleanup:
return -1;
cfg->nfirmwares) < 0)
goto cleanup;
- /* The function above tries to query host's KVM & VFIO capabilities by
- * calling qemuHostdevHostSupportsPassthroughLegacy() and
+ /* The function above tries to query host's VFIO capabilities by calling
* qemuHostdevHostSupportsPassthroughVFIO() 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. */