[libvirt] [PATCH 00/12] Drop KVM assignment

The KVM style of PCI assignment is not used, and it hasn't been for a while. Any attempt to start a domain with it would result in error as kernel dropped its support in 4.12.0 (after being deprecated for 1.5 years). Michal Prívozník (12): qemu: Drop KVM assignment tests: Remove 'kvm' PCI backend from domaincapstest virhostdev: Unify virDomainHostdevDef to virPCIDevice translation qemu: Drop unused qemuOpenPCIConfig() virhostdev: Disable legacy kvm assignment virpci: Drop 'pci-stub' driver virpci: Remove unused virPCIDeviceWaitForCleanup virpci: Drop newid style of PCI device detach virpcimock: Don't create "pci-stub" driver virpcimock: Don't create new_id or remove_id files virpcimock: Drop @driverActions enum news: Document KVM assignment removal docs/news.xml | 13 + src/libvirt_private.syms | 1 - src/qemu/qemu_capabilities.c | 6 - src/qemu/qemu_command.c | 48 +-- src/qemu/qemu_command.h | 3 - src/qemu/qemu_driver.c | 14 +- src/qemu/qemu_hostdev.c | 44 +- src/qemu/qemu_hostdev.h | 1 - src/qemu/qemu_hotplug.c | 20 +- src/util/virhostdev.c | 97 +++-- src/util/virpci.c | 403 +----------------- src/util/virpci.h | 2 - .../qemu_1.7.0.x86_64.xml | 1 - .../qemu_2.12.0-virt.aarch64.xml | 1 - .../qemu_2.12.0.ppc64.xml | 1 - .../qemu_2.12.0.s390x.xml | 1 - .../qemu_2.12.0.x86_64.xml | 1 - .../qemu_2.6.0-virt.aarch64.xml | 1 - .../qemu_2.6.0.aarch64.xml | 1 - .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 - .../qemu_2.6.0.x86_64.xml | 1 - .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 - .../qemu_2.8.0-tcg.x86_64.xml | 1 - .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 - .../qemu_2.8.0.x86_64.xml | 1 - .../qemu_2.9.0-q35.x86_64.xml | 1 - .../qemu_2.9.0-tcg.x86_64.xml | 1 - .../qemu_2.9.0.x86_64.xml | 1 - .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 - .../qemu_3.1.0.x86_64.xml | 1 - .../domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 - .../qemu_4.0.0.x86_64.xml | 1 - .../qemu_4.1.0.x86_64.xml | 1 - tests/domaincapstest.c | 4 +- tests/virpcimock.c | 137 +----- 35 files changed, 92 insertions(+), 722 deletions(-) -- 2.21.0

KVM style of PCI devices assignment was dropped in kernel in favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since vfio is around for quite some time now and is far superior discourage people in using KVM style. Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns out qemu-3.0.0 doesn't support vfio-pci device for RISC-V. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_capabilities.c | 6 ----- src/qemu/qemu_command.c | 26 ++------------------- src/qemu/qemu_command.h | 1 - src/qemu/qemu_driver.c | 14 ++++-------- src/qemu/qemu_hostdev.c | 44 +++--------------------------------- src/qemu/qemu_hostdev.h | 1 - src/qemu/qemu_hotplug.c | 20 ++-------------- tests/domaincapstest.c | 3 +-- 8 files changed, 12 insertions(+), 103 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c9677315ab..73300128ea 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5338,7 +5338,6 @@ static int virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceHostdevPtr hostdev) { - bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy(); bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); hostdev->supported = VIR_TRISTATE_BOOL_YES; @@ -5374,11 +5373,6 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, 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; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e3f4ef624b..f7b5430db8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4904,7 +4904,6 @@ char * 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; @@ -4913,16 +4912,11 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, /* 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: @@ -5676,7 +5670,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, } } - char *configfd_name = NULL; unsigned int bootIndex = hostdev->info->bootIndex; /* bootNet will be non-0 if boot order was set and no other @@ -5686,27 +5679,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, 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); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 7e2dc5a60a..e3983bedb2 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -148,7 +148,6 @@ char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, unsigned int bootIndex, - const char *configfd, virQEMUCapsPtr qemuCaps); char *qemuBuildRNGDevStr(const virDomainDef *def, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 11f97dbc65..eb373c14d7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13517,7 +13517,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, int ret = -1; virNodeDeviceDefPtr def = NULL; char *xml = NULL; - bool legacy = qemuHostdevHostSupportsPassthroughLegacy(); bool vfio = qemuHostdevHostSupportsPassthroughVFIO(); virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr; @@ -13544,8 +13543,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, 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 " @@ -13563,13 +13560,10 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, } 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 currently not " + "supported on this system")); + goto cleanup; } else { virReportError(VIR_ERR_INVALID_ARG, _("unknown driver name '%s'"), driverName); diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 92b037e1ed..af41c32679 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -133,44 +133,11 @@ qemuHostdevHostSupportsPassthroughVFIO(void) } -#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; @@ -189,8 +156,6 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, 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 " @@ -209,12 +174,9 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, 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: diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index f6d76c1c2a..e99c204961 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -24,7 +24,6 @@ #include "qemu_conf.h" #include "domain_conf.h" -bool qemuHostdevHostSupportsPassthroughLegacy(void); bool qemuHostdevHostSupportsPassthroughVFIO(void); int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d8be63b71c..63acb9c451 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1465,8 +1465,6 @@ qemuDomainAttachHostPCIDevice(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; @@ -1547,13 +1545,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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", @@ -1561,8 +1552,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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); @@ -1570,10 +1560,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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) @@ -1586,8 +1574,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, vm->def->hostdevs[vm->def->nhostdevs++] = hostdev; VIR_FREE(devstr); - VIR_FREE(configfd_name); - VIR_FORCE_CLOSE(configfd); return 0; @@ -1607,8 +1593,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1); VIR_FREE(devstr); - VIR_FREE(configfd_name); - VIR_FORCE_CLOSE(configfd); cleanup: return -1; diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 45ecfe61ac..77acefa6b0 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -111,8 +111,7 @@ fillQemuCaps(virDomainCapsPtr domCaps, 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. */ -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
KVM style of PCI devices assignment was dropped in kernel in favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since vfio is around for quite some time now and is far superior discourage people in using KVM style.
Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns out qemu-3.0.0 doesn't support vfio-pci device for RISC-V.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_capabilities.c | 6 ----- src/qemu/qemu_command.c | 26 ++------------------- src/qemu/qemu_command.h | 1 - src/qemu/qemu_driver.c | 14 ++++-------- src/qemu/qemu_hostdev.c | 44 +++--------------------------------- src/qemu/qemu_hostdev.h | 1 - src/qemu/qemu_hotplug.c | 20 ++-------------- tests/domaincapstest.c | 3 +-- 8 files changed, 12 insertions(+), 103 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c9677315ab..73300128ea 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5338,7 +5338,6 @@ static int virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceHostdevPtr hostdev) { - bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy(); bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
hostdev->supported = VIR_TRISTATE_BOOL_YES; @@ -5374,11 +5373,6 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, 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; }
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e3f4ef624b..f7b5430db8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4904,7 +4904,6 @@ char * 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; @@ -4913,16 +4912,11 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
/* 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: @@ -5676,7 +5670,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, } }
- char *configfd_name = NULL; unsigned int bootIndex = hostdev->info->bootIndex;
/* bootNet will be non-0 if boot order was set and no other @@ -5686,27 +5679,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, 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); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 7e2dc5a60a..e3983bedb2 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -148,7 +148,6 @@ char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, unsigned int bootIndex, - const char *configfd, virQEMUCapsPtr qemuCaps);
char *qemuBuildRNGDevStr(const virDomainDef *def, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 11f97dbc65..eb373c14d7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13517,7 +13517,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, int ret = -1; virNodeDeviceDefPtr def = NULL; char *xml = NULL; - bool legacy = qemuHostdevHostSupportsPassthroughLegacy(); bool vfio = qemuHostdevHostSupportsPassthroughVFIO(); virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
@@ -13544,8 +13543,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, 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 "
Right here comes the error message: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("neither VFIO nor KVM device assignment is " "currently supported on this system")); goto cleanup; I think this message should refer only to VFIO in this case - there's already a KVM device assignment message down below. Thanks, DHB
@@ -13563,13 +13560,10 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, } 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 currently not " + "supported on this system")); + goto cleanup; } else { virReportError(VIR_ERR_INVALID_ARG, _("unknown driver name '%s'"), driverName); diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 92b037e1ed..af41c32679 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -133,44 +133,11 @@ qemuHostdevHostSupportsPassthroughVFIO(void) }
-#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;
@@ -189,8 +156,6 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, 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 " @@ -209,12 +174,9 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, 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: diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index f6d76c1c2a..e99c204961 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -24,7 +24,6 @@ #include "qemu_conf.h" #include "domain_conf.h"
-bool qemuHostdevHostSupportsPassthroughLegacy(void); bool qemuHostdevHostSupportsPassthroughVFIO(void);
int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d8be63b71c..63acb9c451 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1465,8 +1465,6 @@ qemuDomainAttachHostPCIDevice(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; @@ -1547,13 +1545,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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", @@ -1561,8 +1552,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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); @@ -1570,10 +1560,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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) @@ -1586,8 +1574,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
VIR_FREE(devstr); - VIR_FREE(configfd_name); - VIR_FORCE_CLOSE(configfd);
return 0;
@@ -1607,8 +1593,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);
VIR_FREE(devstr); - VIR_FREE(configfd_name); - VIR_FORCE_CLOSE(configfd);
cleanup: return -1; diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 45ecfe61ac..77acefa6b0 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -111,8 +111,7 @@ fillQemuCaps(virDomainCapsPtr domCaps, 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. */

On 8/20/19 1:52 PM, Daniel Henrique Barboza wrote:
On 8/20/19 11:30 AM, Michal Privoznik wrote:
KVM style of PCI devices assignment was dropped in kernel in favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since vfio is around for quite some time now and is far superior discourage people in using KVM style.
Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns out qemu-3.0.0 doesn't support vfio-pci device for RISC-V.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com> After taking care of that commit message nit I've pointed out below: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_capabilities.c | 6 ----- src/qemu/qemu_command.c | 26 ++------------------- src/qemu/qemu_command.h | 1 - src/qemu/qemu_driver.c | 14 ++++-------- src/qemu/qemu_hostdev.c | 44 +++--------------------------------- src/qemu/qemu_hostdev.h | 1 - src/qemu/qemu_hotplug.c | 20 ++-------------- tests/domaincapstest.c | 3 +-- 8 files changed, 12 insertions(+), 103 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c9677315ab..73300128ea 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5338,7 +5338,6 @@ static int virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceHostdevPtr hostdev) { - bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy(); bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); hostdev->supported = VIR_TRISTATE_BOOL_YES; @@ -5374,11 +5373,6 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, 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; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e3f4ef624b..f7b5430db8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4904,7 +4904,6 @@ char * 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; @@ -4913,16 +4912,11 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, /* 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: @@ -5676,7 +5670,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, } } - char *configfd_name = NULL; unsigned int bootIndex = hostdev->info->bootIndex; /* bootNet will be non-0 if boot order was set and no other @@ -5686,27 +5679,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, 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); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 7e2dc5a60a..e3983bedb2 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -148,7 +148,6 @@ char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, unsigned int bootIndex, - const char *configfd, virQEMUCapsPtr qemuCaps); char *qemuBuildRNGDevStr(const virDomainDef *def, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 11f97dbc65..eb373c14d7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13517,7 +13517,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, int ret = -1; virNodeDeviceDefPtr def = NULL; char *xml = NULL; - bool legacy = qemuHostdevHostSupportsPassthroughLegacy(); bool vfio = qemuHostdevHostSupportsPassthroughVFIO(); virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr; @@ -13544,8 +13543,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, 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 "
Right here comes the error message:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("neither VFIO nor KVM device assignment is " "currently supported on this system")); goto cleanup;
I think this message should refer only to VFIO in this case - there's already a KVM device assignment message down below.
Thanks,
DHB
@@ -13563,13 +13560,10 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, } 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 currently not " + "supported on this system")); + goto cleanup; } else { virReportError(VIR_ERR_INVALID_ARG, _("unknown driver name '%s'"), driverName); diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 92b037e1ed..af41c32679 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -133,44 +133,11 @@ qemuHostdevHostSupportsPassthroughVFIO(void) } -#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; @@ -189,8 +156,6 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, 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 " @@ -209,12 +174,9 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, 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: diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index f6d76c1c2a..e99c204961 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -24,7 +24,6 @@ #include "qemu_conf.h" #include "domain_conf.h" -bool qemuHostdevHostSupportsPassthroughLegacy(void); bool qemuHostdevHostSupportsPassthroughVFIO(void); int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d8be63b71c..63acb9c451 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1465,8 +1465,6 @@ qemuDomainAttachHostPCIDevice(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; @@ -1547,13 +1545,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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", @@ -1561,8 +1552,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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); @@ -1570,10 +1560,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, 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) @@ -1586,8 +1574,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, vm->def->hostdevs[vm->def->nhostdevs++] = hostdev; VIR_FREE(devstr); - VIR_FREE(configfd_name); - VIR_FORCE_CLOSE(configfd); return 0; @@ -1607,8 +1593,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1); VIR_FREE(devstr); - VIR_FREE(configfd_name); - VIR_FORCE_CLOSE(configfd); cleanup: return -1; diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 45ecfe61ac..77acefa6b0 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -111,8 +111,7 @@ fillQemuCaps(virDomainCapsPtr domCaps, 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. */

On Tue, Aug 20, 2019 at 04:30:21PM +0200, Michal Privoznik wrote:
KVM style of PCI devices assignment was dropped in kernel in favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since vfio is around for quite some time now and is far superior discourage people in using KVM style.
Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns out qemu-3.0.0 doesn't support vfio-pci device for RISC-V.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_capabilities.c | 6 ----- src/qemu/qemu_command.c | 26 ++------------------- src/qemu/qemu_command.h | 1 - src/qemu/qemu_driver.c | 14 ++++-------- src/qemu/qemu_hostdev.c | 44 +++--------------------------------- src/qemu/qemu_hostdev.h | 1 - src/qemu/qemu_hotplug.c | 20 ++-------------- tests/domaincapstest.c | 3 +-- 8 files changed, 12 insertions(+), 103 deletions(-)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 7e2dc5a60a..e3983bedb2 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -148,7 +148,6 @@ char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, unsigned int bootIndex, - const char *configfd, virQEMUCapsPtr qemuCaps);
char *qemuBuildRNGDevStr(const virDomainDef *def, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 11f97dbc65..eb373c14d7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13517,7 +13517,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, int ret = -1; virNodeDeviceDefPtr def = NULL; char *xml = NULL; - bool legacy = qemuHostdevHostSupportsPassthroughLegacy(); bool vfio = qemuHostdevHostSupportsPassthroughVFIO(); virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
@@ -13544,8 +13543,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, 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 "
This whole condition can be just: if (!driverName) driverName = "vfio"; now that we would not be able to pick a different one.
@@ -13563,13 +13560,10 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, } 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 currently not " + "supported on this system"));
s/currently not/no longer/ d/on this system/
+ goto cleanup; } else { virReportError(VIR_ERR_INVALID_ARG, _("unknown driver name '%s'"), driverName);
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The KVM assignment was removed in qemu driver in previous commit. Remove it from domaincapstest too which is hard coding it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml | 1 - tests/domaincapstest.c | 1 - 22 files changed, 22 deletions(-) diff --git a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml index f14f245007..a2df336833 100644 --- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml @@ -112,7 +112,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml index cc65977f03..ed1af3224b 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml @@ -116,7 +116,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml index 8c490fa4d1..99de2b0a8e 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml @@ -80,7 +80,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml index 18171f0db4..8d039f3514 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml @@ -172,7 +172,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml index 146041a6c1..109162ffd8 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml @@ -145,7 +145,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml index 778e27582f..13441b9923 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml @@ -113,7 +113,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml index a01f5ef72f..974739c38e 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml @@ -111,7 +111,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml index a74cece8b6..9f628a3652 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml @@ -84,7 +84,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml index 949c5f8723..bb1f784328 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml @@ -119,7 +119,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml index 8c66d6582a..322d12c719 100644 --- a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml @@ -77,7 +77,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml index 6fa74e29b0..b6679a6e64 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml @@ -120,7 +120,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml index d27977242a..c7a4578f61 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml @@ -158,7 +158,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml index b39aecb52b..3af3fcc4a9 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml @@ -120,7 +120,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml index 66b4a84c3f..aac295a20d 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml @@ -129,7 +129,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml index e41571e11a..12537c039b 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml @@ -152,7 +152,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml index f9a8c490aa..80fc7e1657 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml @@ -129,7 +129,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml index 6dd5da07a5..0e81e2ea33 100644 --- a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml @@ -178,7 +178,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml index 1958eb9beb..402848442f 100644 --- a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml @@ -147,7 +147,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml index 30062a2b23..e68f8e8d9a 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml @@ -184,7 +184,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml index 8c6a622afe..1ffd5e3cc0 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -147,7 +147,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml index 80ce931fbf..79b41ef6da 100644 --- a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml @@ -151,7 +151,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 77acefa6b0..dc50b326f3 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -117,7 +117,6 @@ fillQemuCaps(virDomainCapsPtr domCaps, * instead of mocking set the expected values here by hand. */ VIR_DOMAIN_CAPS_ENUM_SET(domCaps->hostdev.pciBackend, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO); /* As of f05b6a918e28 we are expecting to see OVMF_CODE.fd file which -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
The KVM assignment was removed in qemu driver in previous commit. Remove it from domaincapstest too which is hard coding it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml | 1 - tests/domaincapstest.c | 1 - 22 files changed, 22 deletions(-)
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
diff --git a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml index f14f245007..a2df336833 100644 --- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml @@ -112,7 +112,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml index cc65977f03..ed1af3224b 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml @@ -116,7 +116,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml index 8c490fa4d1..99de2b0a8e 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml @@ -80,7 +80,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml index 18171f0db4..8d039f3514 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml @@ -172,7 +172,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml index 146041a6c1..109162ffd8 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml @@ -145,7 +145,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml index 778e27582f..13441b9923 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml @@ -113,7 +113,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml index a01f5ef72f..974739c38e 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml @@ -111,7 +111,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml index a74cece8b6..9f628a3652 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml @@ -84,7 +84,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml index 949c5f8723..bb1f784328 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml @@ -119,7 +119,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml index 8c66d6582a..322d12c719 100644 --- a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml @@ -77,7 +77,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml index 6fa74e29b0..b6679a6e64 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml @@ -120,7 +120,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml index d27977242a..c7a4578f61 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml @@ -158,7 +158,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml index b39aecb52b..3af3fcc4a9 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml @@ -120,7 +120,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml index 66b4a84c3f..aac295a20d 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml @@ -129,7 +129,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml index e41571e11a..12537c039b 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml @@ -152,7 +152,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml index f9a8c490aa..80fc7e1657 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml @@ -129,7 +129,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml index 6dd5da07a5..0e81e2ea33 100644 --- a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml @@ -178,7 +178,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml index 1958eb9beb..402848442f 100644 --- a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml @@ -147,7 +147,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml index 30062a2b23..e68f8e8d9a 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.s390x.xml @@ -184,7 +184,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml index 8c6a622afe..1ffd5e3cc0 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -147,7 +147,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml index 80ce931fbf..79b41ef6da 100644 --- a/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml @@ -151,7 +151,6 @@ <enum name='capsType'/> <enum name='pciBackend'> <value>default</value> - <value>kvm</value> <value>vfio</value> </enum> </hostdev> diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 77acefa6b0..dc50b326f3 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -117,7 +117,6 @@ fillQemuCaps(virDomainCapsPtr domCaps, * instead of mocking set the expected values here by hand. */ VIR_DOMAIN_CAPS_ENUM_SET(domCaps->hostdev.pciBackend, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, - VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
/* As of f05b6a918e28 we are expecting to see OVMF_CODE.fd file which

On Tue, Aug 20, 2019 at 04:30:22PM +0200, Michal Privoznik wrote:
The KVM assignment was removed in qemu driver in previous commit. Remove it from domaincapstest too which is hard coding it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 - tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 - tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml | 1 - tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml | 1 - tests/domaincapstest.c | 1 - 22 files changed, 22 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

There are two places where we need to create virPCIDevice from given virDomainHostdevDef. In both places the code is duplicated. Move them into a single function and call it from those two places. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virhostdev.c | 93 +++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 6861b8a84e..e3f48a9a2e 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -212,6 +212,51 @@ virHostdevManagerGetDefault(void) return virObjectRef(manager); } +/** + * virHostdevGetPCIHostDevice: + * @hostdev: domain hostdev definition + * @pci: returned PCI device + * + * For given @hostdev which represents a PCI device construct its + * virPCIDevice representation and returned it in @pci. If + * @hostdev does not represent a PCI device then @pci is set to + * NULL and 0 is returned. + * + * Returns: 0 on success (@pci might be NULL though), + * -1 otherwise (with error reported). + */ +static int +virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev, + virPCIDevicePtr *pci) +{ + VIR_AUTOPTR(virPCIDevice) actual = NULL; + const virDomainHostdevSubsysPCI *pcisrc = &hostdev->source.subsys.u.pci; + + *pci = NULL; + + if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) + return 0; + + actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, + pcisrc->addr.slot, pcisrc->addr.function); + + if (!actual) + return -1; + + virPCIDeviceSetManaged(actual, hostdev->managed); + + if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) + virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO); + else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) + virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN); + else + virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM); + + VIR_STEAL_PTR(*pci, actual); + return 0; +} + static virPCIDeviceListPtr virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs) { @@ -223,27 +268,13 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs) for (i = 0; i < nhostdevs; i++) { virDomainHostdevDefPtr hostdev = hostdevs[i]; - virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci; VIR_AUTOPTR(virPCIDevice) pci = NULL; - if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) - continue; - if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) - continue; + if (virHostdevGetPCIHostDevice(hostdev, &pci) < 0) + return NULL; - pci = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function); if (!pci) - return NULL; - - virPCIDeviceSetManaged(pci, hostdev->managed); - - if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) - virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_VFIO); - else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) - virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN); - else - virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM); + continue; if (virPCIDeviceListAdd(pcidevs, pci) < 0) return NULL; @@ -253,7 +284,6 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs) VIR_RETURN_PTR(pcidevs); } - static int virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev, char **sysfs_path) @@ -1067,7 +1097,6 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, const char *drv_name, const char *dom_name) { - virDomainHostdevDefPtr hostdev = NULL; size_t i; int ret = -1; @@ -1078,32 +1107,18 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, virObjectLock(mgr->inactivePCIHostdevs); for (i = 0; i < nhostdevs; i++) { + const virDomainHostdevDef *hostdev = hostdevs[i]; VIR_AUTOPTR(virPCIDevice) actual = NULL; - virDomainHostdevSubsysPCIPtr pcisrc; - hostdev = hostdevs[i]; - pcisrc = &hostdev->source.subsys.u.pci; - if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) - continue; - if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) - continue; - - actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function); + if (virHostdevGetPCIHostDevice(hostdev, &actual) < 0) + goto cleanup; if (!actual) + continue; + + if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0) goto cleanup; - virPCIDeviceSetManaged(actual, hostdev->managed); - virPCIDeviceSetUsedBy(actual, drv_name, dom_name); - - if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO); - else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN); - else - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM); - /* Setup the original states for the PCI device */ virPCIDeviceSetUnbindFromStub(actual, hostdev->origstates.states.pci.unbind_from_stub); virPCIDeviceSetRemoveSlot(actual, hostdev->origstates.states.pci.remove_slot); -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
There are two places where we need to create virPCIDevice from given virDomainHostdevDef. In both places the code is duplicated. Move them into a single function and call it from those two places.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/util/virhostdev.c | 93 +++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 39 deletions(-)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 6861b8a84e..e3f48a9a2e 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -212,6 +212,51 @@ virHostdevManagerGetDefault(void) return virObjectRef(manager); }
+/** + * virHostdevGetPCIHostDevice: + * @hostdev: domain hostdev definition + * @pci: returned PCI device + * + * For given @hostdev which represents a PCI device construct its + * virPCIDevice representation and returned it in @pci. If + * @hostdev does not represent a PCI device then @pci is set to + * NULL and 0 is returned. + * + * Returns: 0 on success (@pci might be NULL though), + * -1 otherwise (with error reported). + */ +static int +virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev, + virPCIDevicePtr *pci) +{ + VIR_AUTOPTR(virPCIDevice) actual = NULL; + const virDomainHostdevSubsysPCI *pcisrc = &hostdev->source.subsys.u.pci; + + *pci = NULL; + + if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) + return 0; + + actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, + pcisrc->addr.slot, pcisrc->addr.function); + + if (!actual) + return -1; + + virPCIDeviceSetManaged(actual, hostdev->managed); + + if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) + virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO); + else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) + virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN); + else + virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM); + + VIR_STEAL_PTR(*pci, actual); + return 0; +} + static virPCIDeviceListPtr virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs) { @@ -223,27 +268,13 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
for (i = 0; i < nhostdevs; i++) { virDomainHostdevDefPtr hostdev = hostdevs[i]; - virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci; VIR_AUTOPTR(virPCIDevice) pci = NULL;
- if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) - continue; - if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) - continue; + if (virHostdevGetPCIHostDevice(hostdev, &pci) < 0) + return NULL;
- pci = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function); if (!pci) - return NULL; - - virPCIDeviceSetManaged(pci, hostdev->managed); - - if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) - virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_VFIO); - else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) - virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN); - else - virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM); + continue;
if (virPCIDeviceListAdd(pcidevs, pci) < 0) return NULL; @@ -253,7 +284,6 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs) VIR_RETURN_PTR(pcidevs); }
- static int virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev, char **sysfs_path) @@ -1067,7 +1097,6 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, const char *drv_name, const char *dom_name) { - virDomainHostdevDefPtr hostdev = NULL; size_t i; int ret = -1;
@@ -1078,32 +1107,18 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, virObjectLock(mgr->inactivePCIHostdevs);
for (i = 0; i < nhostdevs; i++) { + const virDomainHostdevDef *hostdev = hostdevs[i]; VIR_AUTOPTR(virPCIDevice) actual = NULL; - virDomainHostdevSubsysPCIPtr pcisrc; - hostdev = hostdevs[i]; - pcisrc = &hostdev->source.subsys.u.pci;
- if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) - continue; - if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) - continue; - - actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function); + if (virHostdevGetPCIHostDevice(hostdev, &actual) < 0) + goto cleanup;
if (!actual) + continue; + + if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0) goto cleanup;
- virPCIDeviceSetManaged(actual, hostdev->managed); - virPCIDeviceSetUsedBy(actual, drv_name, dom_name); - - if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO); - else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN); - else - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM); - /* Setup the original states for the PCI device */ virPCIDeviceSetUnbindFromStub(actual, hostdev->origstates.states.pci.unbind_from_stub); virPCIDeviceSetRemoveSlot(actual, hostdev->origstates.states.pci.remove_slot);

On Tue, Aug 20, 2019 at 04:30:23PM +0200, Michal Privoznik wrote:
There are two places where we need to create virPCIDevice from given virDomainHostdevDef. In both places the code is duplicated. Move them into a single function and call it from those two places.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virhostdev.c | 93 +++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 39 deletions(-)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 6861b8a84e..e3f48a9a2e 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -212,6 +212,51 @@ virHostdevManagerGetDefault(void) return virObjectRef(manager); }
+/** + * virHostdevGetPCIHostDevice: + * @hostdev: domain hostdev definition + * @pci: returned PCI device + * + * For given @hostdev which represents a PCI device construct its + * virPCIDevice representation and returned it in @pci. If
s/returned/return/
+ * @hostdev does not represent a PCI device then @pci is set to + * NULL and 0 is returned. + * + * Returns: 0 on success (@pci might be NULL though), + * -1 otherwise (with error reported). + */
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

After previous commits, the function is not used anymore. Remove it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 22 ---------------------- src/qemu/qemu_command.h | 2 -- 2 files changed, 24 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f7b5430db8..500ffff035 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4878,28 +4878,6 @@ qemuBuildVideoCommandLine(virCommandPtr cmd, } -int -qemuOpenPCIConfig(virDomainHostdevDefPtr dev) -{ - virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci; - char *path = NULL; - int configfd = -1; - - if (virAsprintf(&path, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/config", - pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function) < 0) - return -1; - - configfd = open(path, O_RDWR, 0); - - if (configfd < 0) - virReportSystemError(errno, _("Failed opening %s"), path); - - VIR_FREE(path); - - return configfd; -} - char * qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index e3983bedb2..6f97e7bc0c 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -157,8 +157,6 @@ int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng, virQEMUCapsPtr qemuCaps, virJSONValuePtr *props); -int qemuOpenPCIConfig(virDomainHostdevDefPtr dev); - /* Current, best practice */ char *qemuBuildUSBHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
After previous commits, the function is not used anymore. Remove it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c | 22 ---------------------- src/qemu/qemu_command.h | 2 -- 2 files changed, 24 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f7b5430db8..500ffff035 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4878,28 +4878,6 @@ qemuBuildVideoCommandLine(virCommandPtr cmd, }
-int -qemuOpenPCIConfig(virDomainHostdevDefPtr dev) -{ - virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci; - char *path = NULL; - int configfd = -1; - - if (virAsprintf(&path, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/config", - pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function) < 0) - return -1; - - configfd = open(path, O_RDWR, 0); - - if (configfd < 0) - virReportSystemError(errno, _("Failed opening %s"), path); - - VIR_FREE(path); - - return configfd; -} - char * qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index e3983bedb2..6f97e7bc0c 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -157,8 +157,6 @@ int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng, virQEMUCapsPtr qemuCaps, virJSONValuePtr *props);
-int qemuOpenPCIConfig(virDomainHostdevDefPtr dev); - /* Current, best practice */ char *qemuBuildUSBHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev,

On Tue, Aug 20, 2019 at 04:30:24PM +0200, Michal Privoznik wrote:
After previous commits, the function is not used anymore. Remove it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 22 ---------------------- src/qemu/qemu_command.h | 2 -- 2 files changed, 24 deletions(-)
Beautiful diffstat! Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The KVM assignment is going to be removed shortly. Don't let the hostdev module configure it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virhostdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index e3f48a9a2e..29e75ffc84 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -246,12 +246,16 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev, virPCIDeviceSetManaged(actual, hostdev->managed); - if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) + if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO); - else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) + } else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) { virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN); - else - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("pci backend driver '%s' is not supported"), + virDomainHostdevSubsysPCIBackendTypeToString(pcisrc->backend)); + return -1; + } VIR_STEAL_PTR(*pci, actual); return 0; -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
The KVM assignment is going to be removed shortly. Don't let the hostdev module configure it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/util/virhostdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index e3f48a9a2e..29e75ffc84 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -246,12 +246,16 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev,
virPCIDeviceSetManaged(actual, hostdev->managed);
- if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) + if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO); - else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) + } else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) { virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN); - else - virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("pci backend driver '%s' is not supported"), + virDomainHostdevSubsysPCIBackendTypeToString(pcisrc->backend)); + return -1; + }
VIR_STEAL_PTR(*pci, actual); return 0;

On Tue, Aug 20, 2019 at 04:30:25PM +0200, Michal Privoznik wrote:
The KVM assignment is going to be removed shortly. Don't let the hostdev module configure it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virhostdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Now that no one uses KVM style of PCI assignment we can safely remove 'pci-stub' backend. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virpci.c | 11 ----------- src/util/virpci.h | 1 - 2 files changed, 12 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 4c7c26f981..9c9ffa55c2 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -54,7 +54,6 @@ VIR_ENUM_IMPL(virPCIStubDriver, VIR_PCI_STUB_DRIVER_LAST, "none", "pciback", /* XEN */ - "pci-stub", /* KVM */ "vfio-pci", /* VFIO */ ); @@ -1541,16 +1540,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev, return -1; } - /* Wait for device cleanup if it is qemu/kvm */ - if (virPCIDeviceGetStubDriver(dev) == VIR_PCI_STUB_DRIVER_KVM) { - int retries = 100; - while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device") - && retries) { - usleep(100*1000); - retries--; - } - } - if (virPCIDeviceUnbindFromStub(dev) < 0) return -1; diff --git a/src/util/virpci.h b/src/util/virpci.h index 5074851777..4ac0d230a4 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -59,7 +59,6 @@ struct _virPCIDeviceAddress { typedef enum { VIR_PCI_STUB_DRIVER_NONE = 0, VIR_PCI_STUB_DRIVER_XEN, - VIR_PCI_STUB_DRIVER_KVM, VIR_PCI_STUB_DRIVER_VFIO, VIR_PCI_STUB_DRIVER_LAST } virPCIStubDriver; -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
Now that no one uses KVM style of PCI assignment we can safely remove 'pci-stub' backend.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/util/virpci.c | 11 ----------- src/util/virpci.h | 1 - 2 files changed, 12 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c index 4c7c26f981..9c9ffa55c2 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -54,7 +54,6 @@ VIR_ENUM_IMPL(virPCIStubDriver, VIR_PCI_STUB_DRIVER_LAST, "none", "pciback", /* XEN */ - "pci-stub", /* KVM */ "vfio-pci", /* VFIO */ );
@@ -1541,16 +1540,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev, return -1; }
- /* Wait for device cleanup if it is qemu/kvm */ - if (virPCIDeviceGetStubDriver(dev) == VIR_PCI_STUB_DRIVER_KVM) { - int retries = 100; - while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device") - && retries) { - usleep(100*1000); - retries--; - } - } - if (virPCIDeviceUnbindFromStub(dev) < 0) return -1;
diff --git a/src/util/virpci.h b/src/util/virpci.h index 5074851777..4ac0d230a4 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -59,7 +59,6 @@ struct _virPCIDeviceAddress { typedef enum { VIR_PCI_STUB_DRIVER_NONE = 0, VIR_PCI_STUB_DRIVER_XEN, - VIR_PCI_STUB_DRIVER_KVM, VIR_PCI_STUB_DRIVER_VFIO, VIR_PCI_STUB_DRIVER_LAST } virPCIStubDriver;

On Tue, Aug 20, 2019 at 04:30:26PM +0200, Michal Privoznik wrote:
Now that no one uses KVM style of PCI assignment we can safely remove 'pci-stub' backend.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virpci.c | 11 ----------- src/util/virpci.h | 1 - 2 files changed, 12 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

This function is no longer used after previous commit. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt_private.syms | 1 - src/util/virpci.c | 108 --------------------------------------- src/util/virpci.h | 1 - 3 files changed, 110 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9db4ac7933..6c57351866 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2696,7 +2696,6 @@ virPCIDeviceSetStubDriver; virPCIDeviceSetUnbindFromStub; virPCIDeviceSetUsedBy; virPCIDeviceUnbind; -virPCIDeviceWaitForCleanup; virPCIEDeviceInfoFree; virPCIELinkSpeedTypeFromString; virPCIELinkSpeedTypeToString; diff --git a/src/util/virpci.c b/src/util/virpci.c index 9c9ffa55c2..ea5be62033 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1552,114 +1552,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev, return 0; } -/* Certain hypervisors (like qemu/kvm) map the PCI bar(s) on - * the host when doing device passthrough. This can lead to a race - * condition where the hypervisor is still cleaning up the device while - * libvirt is trying to re-attach it to the host device driver. To avoid - * this situation, we look through /proc/iomem, and if the hypervisor is - * still holding on to the bar (denoted by the string in the matcher - * variable), then we can wait around a bit for that to clear up. - * - * A typical /proc/iomem looks like this (snipped for brevity): - * 00010000-0008efff : System RAM - * 0008f000-0008ffff : reserved - * ... - * 00100000-cc9fcfff : System RAM - * 00200000-00483d3b : Kernel code - * 00483d3c-005c88df : Kernel data - * cc9fd000-ccc71fff : ACPI Non-volatile Storage - * ... - * d0200000-d02fffff : PCI Bus #05 - * d0200000-d021ffff : 0000:05:00.0 - * d0200000-d021ffff : e1000e - * d0220000-d023ffff : 0000:05:00.0 - * d0220000-d023ffff : e1000e - * ... - * f0000000-f0003fff : 0000:00:1b.0 - * f0000000-f0003fff : kvm_assigned_device - * - * Returns 0 if we are clear to continue, and 1 if the hypervisor is still - * holding on to the resource. - */ -int -virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher) -{ - FILE *fp; - char line[160]; - char *tmp; - unsigned long long start, end; - unsigned int domain, bus, slot, function; - bool in_matching_device; - int ret; - size_t match_depth; - - fp = fopen("/proc/iomem", "r"); - if (!fp) { - /* If we failed to open iomem, we just basically ignore the error. The - * unbind might succeed anyway, and besides, it's very likely we have - * no way to report the error - */ - VIR_DEBUG("Failed to open /proc/iomem, trying to continue anyway"); - return 0; - } - - ret = 0; - in_matching_device = false; - match_depth = 0; - while (fgets(line, sizeof(line), fp) != 0) { - /* the logic here is a bit confusing. For each line, we look to - * see if it matches the domain:bus:slot.function we were given. - * If this line matches the DBSF, then any subsequent lines indented - * by 2 spaces are the PCI regions for this device. It's also - * possible that none of the PCI regions are currently mapped, in - * which case we have no indented regions. This code handles all - * of these situations - */ - if (in_matching_device && (strspn(line, " ") == (match_depth + 2))) { - /* expected format: <start>-<end> : <suffix> */ - if (/* start */ - virStrToLong_ull(line, &tmp, 16, &start) < 0 || *tmp != '-' || - /* end */ - virStrToLong_ull(tmp + 1, &tmp, 16, &end) < 0 || - (tmp = STRSKIP(tmp, " : ")) == NULL) - continue; - - if (STRPREFIX(tmp, matcher)) { - ret = 1; - break; - } - } else { - in_matching_device = false; - - /* expected format: <start>-<end> : <domain>:<bus>:<slot>.<function> */ - if (/* start */ - virStrToLong_ull(line, &tmp, 16, &start) < 0 || *tmp != '-' || - /* end */ - virStrToLong_ull(tmp + 1, &tmp, 16, &end) < 0 || - (tmp = STRSKIP(tmp, " : ")) == NULL || - /* domain */ - virStrToLong_ui(tmp, &tmp, 16, &domain) < 0 || *tmp != ':' || - /* bus */ - virStrToLong_ui(tmp + 1, &tmp, 16, &bus) < 0 || *tmp != ':' || - /* slot */ - virStrToLong_ui(tmp + 1, &tmp, 16, &slot) < 0 || *tmp != '.' || - /* function */ - virStrToLong_ui(tmp + 1, &tmp, 16, &function) < 0 || *tmp != '\n') - continue; - - if (domain != dev->address.domain || bus != dev->address.bus || - slot != dev->address.slot || function != dev->address.function) - continue; - in_matching_device = true; - match_depth = strspn(line, " "); - } - } - - VIR_FORCE_FCLOSE(fp); - - return ret; -} - static char * virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name) { diff --git a/src/util/virpci.h b/src/util/virpci.h index 4ac0d230a4..dc20f91710 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -197,7 +197,6 @@ char *virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev); int virPCIDeviceIsAssignable(virPCIDevicePtr dev, int strict_acs_check); -int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher); virPCIDeviceAddressPtr virPCIGetDeviceAddressFromSysfsLink(const char *device_link); -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
This function is no longer used after previous commit.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/libvirt_private.syms | 1 - src/util/virpci.c | 108 --------------------------------------- src/util/virpci.h | 1 - 3 files changed, 110 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9db4ac7933..6c57351866 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2696,7 +2696,6 @@ virPCIDeviceSetStubDriver; virPCIDeviceSetUnbindFromStub; virPCIDeviceSetUsedBy; virPCIDeviceUnbind; -virPCIDeviceWaitForCleanup; virPCIEDeviceInfoFree; virPCIELinkSpeedTypeFromString; virPCIELinkSpeedTypeToString; diff --git a/src/util/virpci.c b/src/util/virpci.c index 9c9ffa55c2..ea5be62033 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1552,114 +1552,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev, return 0; }
-/* Certain hypervisors (like qemu/kvm) map the PCI bar(s) on - * the host when doing device passthrough. This can lead to a race - * condition where the hypervisor is still cleaning up the device while - * libvirt is trying to re-attach it to the host device driver. To avoid - * this situation, we look through /proc/iomem, and if the hypervisor is - * still holding on to the bar (denoted by the string in the matcher - * variable), then we can wait around a bit for that to clear up. - * - * A typical /proc/iomem looks like this (snipped for brevity): - * 00010000-0008efff : System RAM - * 0008f000-0008ffff : reserved - * ... - * 00100000-cc9fcfff : System RAM - * 00200000-00483d3b : Kernel code - * 00483d3c-005c88df : Kernel data - * cc9fd000-ccc71fff : ACPI Non-volatile Storage - * ... - * d0200000-d02fffff : PCI Bus #05 - * d0200000-d021ffff : 0000:05:00.0 - * d0200000-d021ffff : e1000e - * d0220000-d023ffff : 0000:05:00.0 - * d0220000-d023ffff : e1000e - * ... - * f0000000-f0003fff : 0000:00:1b.0 - * f0000000-f0003fff : kvm_assigned_device - * - * Returns 0 if we are clear to continue, and 1 if the hypervisor is still - * holding on to the resource. - */ -int -virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher) -{ - FILE *fp; - char line[160]; - char *tmp; - unsigned long long start, end; - unsigned int domain, bus, slot, function; - bool in_matching_device; - int ret; - size_t match_depth; - - fp = fopen("/proc/iomem", "r"); - if (!fp) { - /* If we failed to open iomem, we just basically ignore the error. The - * unbind might succeed anyway, and besides, it's very likely we have - * no way to report the error - */ - VIR_DEBUG("Failed to open /proc/iomem, trying to continue anyway"); - return 0; - } - - ret = 0; - in_matching_device = false; - match_depth = 0; - while (fgets(line, sizeof(line), fp) != 0) { - /* the logic here is a bit confusing. For each line, we look to - * see if it matches the domain:bus:slot.function we were given. - * If this line matches the DBSF, then any subsequent lines indented - * by 2 spaces are the PCI regions for this device. It's also - * possible that none of the PCI regions are currently mapped, in - * which case we have no indented regions. This code handles all - * of these situations - */ - if (in_matching_device && (strspn(line, " ") == (match_depth + 2))) { - /* expected format: <start>-<end> : <suffix> */ - if (/* start */ - virStrToLong_ull(line, &tmp, 16, &start) < 0 || *tmp != '-' || - /* end */ - virStrToLong_ull(tmp + 1, &tmp, 16, &end) < 0 || - (tmp = STRSKIP(tmp, " : ")) == NULL) - continue; - - if (STRPREFIX(tmp, matcher)) { - ret = 1; - break; - } - } else { - in_matching_device = false; - - /* expected format: <start>-<end> : <domain>:<bus>:<slot>.<function> */ - if (/* start */ - virStrToLong_ull(line, &tmp, 16, &start) < 0 || *tmp != '-' || - /* end */ - virStrToLong_ull(tmp + 1, &tmp, 16, &end) < 0 || - (tmp = STRSKIP(tmp, " : ")) == NULL || - /* domain */ - virStrToLong_ui(tmp, &tmp, 16, &domain) < 0 || *tmp != ':' || - /* bus */ - virStrToLong_ui(tmp + 1, &tmp, 16, &bus) < 0 || *tmp != ':' || - /* slot */ - virStrToLong_ui(tmp + 1, &tmp, 16, &slot) < 0 || *tmp != '.' || - /* function */ - virStrToLong_ui(tmp + 1, &tmp, 16, &function) < 0 || *tmp != '\n') - continue; - - if (domain != dev->address.domain || bus != dev->address.bus || - slot != dev->address.slot || function != dev->address.function) - continue; - in_matching_device = true; - match_depth = strspn(line, " "); - } - } - - VIR_FORCE_FCLOSE(fp); - - return ret; -} - static char * virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name) { diff --git a/src/util/virpci.h b/src/util/virpci.h index 4ac0d230a4..dc20f91710 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -197,7 +197,6 @@ char *virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev);
int virPCIDeviceIsAssignable(virPCIDevicePtr dev, int strict_acs_check); -int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher);
virPCIDeviceAddressPtr virPCIGetDeviceAddressFromSysfsLink(const char *device_link);

On Tue, Aug 20, 2019 at 04:30:27PM +0200, Michal Privoznik wrote:
This function is no longer used after previous commit.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt_private.syms | 1 - src/util/virpci.c | 108 --------------------------------------- src/util/virpci.h | 1 - 3 files changed, 110 deletions(-)
:,-) Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

As stated in 84f9358b18346 all kernels that we are interested in have 'drivers_override'. Drop the other, older style of overriding PCI device driver - newid. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virpci.c | 284 +--------------------------------------------- 1 file changed, 2 insertions(+), 282 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index ea5be62033..6724a8ad9e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -218,16 +218,6 @@ virPCIDriverDir(const char *driver) } -static char * -virPCIDriverFile(const char *driver, const char *file) -{ - char *buffer; - - ignore_value(virAsprintf(&buffer, PCI_SYSFS "drivers/%s/%s", driver, file)); - return buffer; -} - - static char * virPCIFile(const char *device, const char *file) { @@ -1145,104 +1135,6 @@ virPCIDeviceBindWithDriverOverride(virPCIDevicePtr dev, return 0; } -static int -virPCIDeviceUnbindFromStubWithNewid(virPCIDevicePtr dev) -{ - int result = -1; - VIR_AUTOFREE(char *) drvdir = NULL; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) driver = NULL; - - /* If the device is currently bound to one of the "well known" - * stub drivers, then unbind it, otherwise ignore it. - */ - if (virPCIDeviceGetDriverPathAndName(dev, &drvdir, &driver) < 0) - goto cleanup; - - if (!driver) { - /* The device is not bound to any driver and we are almost done. */ - VIR_DEBUG("PCI device %s is not bound to any driver", dev->name); - goto reprobe; - } - - if (!dev->unbind_from_stub) { - VIR_DEBUG("Unbind from stub skipped for PCI device %s", dev->name); - goto remove_slot; - } - - /* If the device isn't bound to a known stub, skip the unbind. */ - if (virPCIStubDriverTypeFromString(driver) < 0 || - virPCIStubDriverTypeFromString(driver) == VIR_PCI_STUB_DRIVER_NONE) { - VIR_DEBUG("Unbind from stub skipped for PCI device %s because of " - "unknown stub driver", dev->name); - goto remove_slot; - } - - VIR_DEBUG("Unbinding PCI device %s from stub driver %s", - dev->name, driver); - - if (virPCIDeviceUnbind(dev) < 0) - goto cleanup; - dev->unbind_from_stub = false; - - remove_slot: - if (!dev->remove_slot) { - VIR_DEBUG("Slot removal skipped for PCI device %s", dev->name); - goto reprobe; - } - - VIR_DEBUG("Removing slot for PCI device %s", dev->name); - - /* Xen's pciback.ko wants you to use remove_slot on the specific device */ - if (!(path = virPCIDriverFile(driver, "remove_slot"))) - goto cleanup; - - if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to remove slot for PCI device '%s' from %s"), - dev->name, driver); - goto cleanup; - } - dev->remove_slot = false; - - reprobe: - if (!dev->reprobe) { - VIR_DEBUG("Reprobe skipped for PCI device %s", dev->name); - result = 0; - goto cleanup; - } - - VIR_DEBUG("Reprobing for PCI device %s", dev->name); - - /* Trigger a re-probe of the device is not in the stub's dynamic - * ID table. If the stub is available, but 'remove_id' isn't - * available, then re-probing would just cause the device to be - * re-bound to the stub. - */ - VIR_FREE(path); - if (driver && !(path = virPCIDriverFile(driver, "remove_id"))) - goto cleanup; - - if (!driver || !virFileExists(drvdir) || virFileExists(path)) { - if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to trigger a re-probe for PCI device '%s'"), - dev->name); - goto cleanup; - } - } - - result = 0; - - cleanup: - /* do not do it again */ - dev->unbind_from_stub = false; - dev->remove_slot = false; - dev->reprobe = false; - - return result; -} - static int virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr dev) { @@ -1257,167 +1149,7 @@ virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr dev) static int virPCIDeviceUnbindFromStub(virPCIDevicePtr dev) { - VIR_AUTOFREE(char *) path = NULL; - - /* - * Prefer using the device's driver_override interface, falling back - * to the unpleasant new_id interface. - */ - if (!(path = virPCIFile(dev->name, "driver_override"))) - return -1; - - if (virFileExists(path)) - return virPCIDeviceUnbindFromStubWithOverride(dev); - - return virPCIDeviceUnbindFromStubWithNewid(dev); -} - -static int -virPCIDeviceBindToStubWithNewid(virPCIDevicePtr dev) -{ - int result = -1; - bool reprobe = false; - VIR_AUTOFREE(char *) stubDriverPath = NULL; - VIR_AUTOFREE(char *) driverLink = NULL; - VIR_AUTOFREE(char *) path = NULL; /* reused for different purposes */ - VIR_AUTOPTR(virError) err = NULL; - const char *stubDriverName = NULL; - - /* Check the device is configured to use one of the known stub drivers */ - if (dev->stubDriver == VIR_PCI_STUB_DRIVER_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No stub driver configured for PCI device %s"), - dev->name); - return -1; - } else if (!(stubDriverName = virPCIStubDriverTypeToString(dev->stubDriver))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown stub driver configured for PCI device %s"), - dev->name); - return -1; - } - - if (!(stubDriverPath = virPCIDriverDir(stubDriverName)) || - !(driverLink = virPCIFile(dev->name, "driver"))) - goto cleanup; - - if (virFileExists(driverLink)) { - if (virFileLinkPointsTo(driverLink, stubDriverPath)) { - /* The device is already bound to the correct driver */ - VIR_DEBUG("Device %s is already bound to %s", - dev->name, stubDriverName); - result = 0; - goto cleanup; - } - reprobe = true; - } - - /* Add the PCI device ID to the stub's dynamic ID table; - * this is needed to allow us to bind the device to the stub. - * Note: if the device is not currently bound to any driver, - * stub will immediately be bound to the device. Also, note - * that if a new device with this ID is hotplugged, or if a probe - * is triggered for such a device, it will also be immediately - * bound by the stub. - */ - if (!(path = virPCIDriverFile(stubDriverName, "new_id"))) - goto cleanup; - - if (virFileWriteStr(path, dev->id, 0) < 0) { - virReportSystemError(errno, - _("Failed to add PCI device ID '%s' to %s"), - dev->id, stubDriverName); - goto cleanup; - } - - /* check whether the device is bound to pci-stub when we write dev->id to - * ${stubDriver}/new_id. - */ - if (virFileLinkPointsTo(driverLink, stubDriverPath)) { - dev->unbind_from_stub = true; - dev->remove_slot = true; - result = 0; - goto remove_id; - } - - if (virPCIDeviceUnbind(dev) < 0) - goto remove_id; - - /* If the device was bound to a driver we'll need to reprobe later */ - dev->reprobe = reprobe; - - /* If the device isn't already bound to pci-stub, try binding it now. - */ - if (!virFileLinkPointsTo(driverLink, stubDriverPath)) { - /* Xen's pciback.ko wants you to use new_slot first */ - VIR_FREE(path); - if (!(path = virPCIDriverFile(stubDriverName, "new_slot"))) - goto remove_id; - - if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to add slot for " - "PCI device '%s' to %s"), - dev->name, stubDriverName); - goto remove_id; - } - dev->remove_slot = true; - - VIR_FREE(path); - if (!(path = virPCIDriverFile(stubDriverName, "bind"))) - goto remove_id; - - if (virFileWriteStr(path, dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to bind PCI device '%s' to %s"), - dev->name, stubDriverName); - goto remove_id; - } - dev->unbind_from_stub = true; - } - - result = 0; - - remove_id: - err = virSaveLastError(); - - /* If 'remove_id' exists, remove the device id from pci-stub's dynamic - * ID table so that 'drivers_probe' works below. - */ - VIR_FREE(path); - if (!(path = virPCIDriverFile(stubDriverName, "remove_id"))) { - /* We do not remove PCI ID from pci-stub, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Could not remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, stubDriverName); - } - dev->reprobe = false; - result = -1; - goto cleanup; - } - - if (virFileExists(path) && virFileWriteStr(path, dev->id, 0) < 0) { - virReportSystemError(errno, - _("Failed to remove PCI ID '%s' from %s"), - dev->id, stubDriverName); - - /* remove PCI ID from pci-stub failed, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, stubDriverName); - } - dev->reprobe = false; - result = -1; - goto cleanup; - } - - cleanup: - if (result < 0) - virPCIDeviceUnbindFromStub(dev); - - if (err) - virSetError(err); - - return result; + return virPCIDeviceUnbindFromStubWithOverride(dev); } static int @@ -1463,19 +1195,7 @@ virPCIDeviceBindToStubWithOverride(virPCIDevicePtr dev) static int virPCIDeviceBindToStub(virPCIDevicePtr dev) { - VIR_AUTOFREE(char *) path = NULL; - - /* - * Prefer using the device's driver_override interface, falling back - * to the unpleasant new_id interface. - */ - if (!(path = virPCIFile(dev->name, "driver_override"))) - return -1; - - if (virFileExists(path)) - return virPCIDeviceBindToStubWithOverride(dev); - - return virPCIDeviceBindToStubWithNewid(dev); + return virPCIDeviceBindToStubWithOverride(dev); } /* virPCIDeviceDetach: -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
As stated in 84f9358b18346 all kernels that we are interested in have 'drivers_override'. Drop the other, older style of overriding PCI device driver - newid.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/util/virpci.c | 284 +--------------------------------------------- 1 file changed, 2 insertions(+), 282 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c index ea5be62033..6724a8ad9e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -218,16 +218,6 @@ virPCIDriverDir(const char *driver) }
-static char * -virPCIDriverFile(const char *driver, const char *file) -{ - char *buffer; - - ignore_value(virAsprintf(&buffer, PCI_SYSFS "drivers/%s/%s", driver, file)); - return buffer; -} - - static char * virPCIFile(const char *device, const char *file) { @@ -1145,104 +1135,6 @@ virPCIDeviceBindWithDriverOverride(virPCIDevicePtr dev, return 0; }
-static int -virPCIDeviceUnbindFromStubWithNewid(virPCIDevicePtr dev) -{ - int result = -1; - VIR_AUTOFREE(char *) drvdir = NULL; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) driver = NULL; - - /* If the device is currently bound to one of the "well known" - * stub drivers, then unbind it, otherwise ignore it. - */ - if (virPCIDeviceGetDriverPathAndName(dev, &drvdir, &driver) < 0) - goto cleanup; - - if (!driver) { - /* The device is not bound to any driver and we are almost done. */ - VIR_DEBUG("PCI device %s is not bound to any driver", dev->name); - goto reprobe; - } - - if (!dev->unbind_from_stub) { - VIR_DEBUG("Unbind from stub skipped for PCI device %s", dev->name); - goto remove_slot; - } - - /* If the device isn't bound to a known stub, skip the unbind. */ - if (virPCIStubDriverTypeFromString(driver) < 0 || - virPCIStubDriverTypeFromString(driver) == VIR_PCI_STUB_DRIVER_NONE) { - VIR_DEBUG("Unbind from stub skipped for PCI device %s because of " - "unknown stub driver", dev->name); - goto remove_slot; - } - - VIR_DEBUG("Unbinding PCI device %s from stub driver %s", - dev->name, driver); - - if (virPCIDeviceUnbind(dev) < 0) - goto cleanup; - dev->unbind_from_stub = false; - - remove_slot: - if (!dev->remove_slot) { - VIR_DEBUG("Slot removal skipped for PCI device %s", dev->name); - goto reprobe; - } - - VIR_DEBUG("Removing slot for PCI device %s", dev->name); - - /* Xen's pciback.ko wants you to use remove_slot on the specific device */ - if (!(path = virPCIDriverFile(driver, "remove_slot"))) - goto cleanup; - - if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to remove slot for PCI device '%s' from %s"), - dev->name, driver); - goto cleanup; - } - dev->remove_slot = false; - - reprobe: - if (!dev->reprobe) { - VIR_DEBUG("Reprobe skipped for PCI device %s", dev->name); - result = 0; - goto cleanup; - } - - VIR_DEBUG("Reprobing for PCI device %s", dev->name); - - /* Trigger a re-probe of the device is not in the stub's dynamic - * ID table. If the stub is available, but 'remove_id' isn't - * available, then re-probing would just cause the device to be - * re-bound to the stub. - */ - VIR_FREE(path); - if (driver && !(path = virPCIDriverFile(driver, "remove_id"))) - goto cleanup; - - if (!driver || !virFileExists(drvdir) || virFileExists(path)) { - if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to trigger a re-probe for PCI device '%s'"), - dev->name); - goto cleanup; - } - } - - result = 0; - - cleanup: - /* do not do it again */ - dev->unbind_from_stub = false; - dev->remove_slot = false; - dev->reprobe = false; - - return result; -} - static int virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr dev) { @@ -1257,167 +1149,7 @@ virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr dev) static int virPCIDeviceUnbindFromStub(virPCIDevicePtr dev) { - VIR_AUTOFREE(char *) path = NULL; - - /* - * Prefer using the device's driver_override interface, falling back - * to the unpleasant new_id interface. - */ - if (!(path = virPCIFile(dev->name, "driver_override"))) - return -1; - - if (virFileExists(path)) - return virPCIDeviceUnbindFromStubWithOverride(dev); - - return virPCIDeviceUnbindFromStubWithNewid(dev); -} - -static int -virPCIDeviceBindToStubWithNewid(virPCIDevicePtr dev) -{ - int result = -1; - bool reprobe = false; - VIR_AUTOFREE(char *) stubDriverPath = NULL; - VIR_AUTOFREE(char *) driverLink = NULL; - VIR_AUTOFREE(char *) path = NULL; /* reused for different purposes */ - VIR_AUTOPTR(virError) err = NULL; - const char *stubDriverName = NULL; - - /* Check the device is configured to use one of the known stub drivers */ - if (dev->stubDriver == VIR_PCI_STUB_DRIVER_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No stub driver configured for PCI device %s"), - dev->name); - return -1; - } else if (!(stubDriverName = virPCIStubDriverTypeToString(dev->stubDriver))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown stub driver configured for PCI device %s"), - dev->name); - return -1; - } - - if (!(stubDriverPath = virPCIDriverDir(stubDriverName)) || - !(driverLink = virPCIFile(dev->name, "driver"))) - goto cleanup; - - if (virFileExists(driverLink)) { - if (virFileLinkPointsTo(driverLink, stubDriverPath)) { - /* The device is already bound to the correct driver */ - VIR_DEBUG("Device %s is already bound to %s", - dev->name, stubDriverName); - result = 0; - goto cleanup; - } - reprobe = true; - } - - /* Add the PCI device ID to the stub's dynamic ID table; - * this is needed to allow us to bind the device to the stub. - * Note: if the device is not currently bound to any driver, - * stub will immediately be bound to the device. Also, note - * that if a new device with this ID is hotplugged, or if a probe - * is triggered for such a device, it will also be immediately - * bound by the stub. - */ - if (!(path = virPCIDriverFile(stubDriverName, "new_id"))) - goto cleanup; - - if (virFileWriteStr(path, dev->id, 0) < 0) { - virReportSystemError(errno, - _("Failed to add PCI device ID '%s' to %s"), - dev->id, stubDriverName); - goto cleanup; - } - - /* check whether the device is bound to pci-stub when we write dev->id to - * ${stubDriver}/new_id. - */ - if (virFileLinkPointsTo(driverLink, stubDriverPath)) { - dev->unbind_from_stub = true; - dev->remove_slot = true; - result = 0; - goto remove_id; - } - - if (virPCIDeviceUnbind(dev) < 0) - goto remove_id; - - /* If the device was bound to a driver we'll need to reprobe later */ - dev->reprobe = reprobe; - - /* If the device isn't already bound to pci-stub, try binding it now. - */ - if (!virFileLinkPointsTo(driverLink, stubDriverPath)) { - /* Xen's pciback.ko wants you to use new_slot first */ - VIR_FREE(path); - if (!(path = virPCIDriverFile(stubDriverName, "new_slot"))) - goto remove_id; - - if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to add slot for " - "PCI device '%s' to %s"), - dev->name, stubDriverName); - goto remove_id; - } - dev->remove_slot = true; - - VIR_FREE(path); - if (!(path = virPCIDriverFile(stubDriverName, "bind"))) - goto remove_id; - - if (virFileWriteStr(path, dev->name, 0) < 0) { - virReportSystemError(errno, - _("Failed to bind PCI device '%s' to %s"), - dev->name, stubDriverName); - goto remove_id; - } - dev->unbind_from_stub = true; - } - - result = 0; - - remove_id: - err = virSaveLastError(); - - /* If 'remove_id' exists, remove the device id from pci-stub's dynamic - * ID table so that 'drivers_probe' works below. - */ - VIR_FREE(path); - if (!(path = virPCIDriverFile(stubDriverName, "remove_id"))) { - /* We do not remove PCI ID from pci-stub, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Could not remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, stubDriverName); - } - dev->reprobe = false; - result = -1; - goto cleanup; - } - - if (virFileExists(path) && virFileWriteStr(path, dev->id, 0) < 0) { - virReportSystemError(errno, - _("Failed to remove PCI ID '%s' from %s"), - dev->id, stubDriverName); - - /* remove PCI ID from pci-stub failed, and we cannot reprobe it */ - if (dev->reprobe) { - VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device " - "cannot be probed again.", dev->id, stubDriverName); - } - dev->reprobe = false; - result = -1; - goto cleanup; - } - - cleanup: - if (result < 0) - virPCIDeviceUnbindFromStub(dev); - - if (err) - virSetError(err); - - return result; + return virPCIDeviceUnbindFromStubWithOverride(dev); }
static int @@ -1463,19 +1195,7 @@ virPCIDeviceBindToStubWithOverride(virPCIDevicePtr dev) static int virPCIDeviceBindToStub(virPCIDevicePtr dev) { - VIR_AUTOFREE(char *) path = NULL; - - /* - * Prefer using the device's driver_override interface, falling back - * to the unpleasant new_id interface. - */ - if (!(path = virPCIFile(dev->name, "driver_override"))) - return -1; - - if (virFileExists(path)) - return virPCIDeviceBindToStubWithOverride(dev); - - return virPCIDeviceBindToStubWithNewid(dev); + return virPCIDeviceBindToStubWithOverride(dev); }
/* virPCIDeviceDetach:

On Tue, Aug 20, 2019 at 04:30:28PM +0200, Michal Privoznik wrote:
As stated in 84f9358b18346 all kernels that we are interested in have 'drivers_override'. Drop the other, older style of overriding PCI device driver - newid.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virpci.c | 284 +--------------------------------------------- 1 file changed, 2 insertions(+), 282 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Now that nothing supports "pci-stub" driver (aka KVM style of PCI device assignment) there is no need for virpcimock to create it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/virpcimock.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index c0dcd377d5..bbec77975a 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -992,7 +992,6 @@ init_env(void) MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044); MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047); - MAKE_PCI_DRIVER("pci-stub", -1, -1); pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1); # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
Now that nothing supports "pci-stub" driver (aka KVM style of PCI device assignment) there is no need for virpcimock to create it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
tests/virpcimock.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c index c0dcd377d5..bbec77975a 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -992,7 +992,6 @@ init_env(void)
MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044); MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047); - MAKE_PCI_DRIVER("pci-stub", -1, -1); pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1);
# define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \

On Tue, Aug 20, 2019 at 04:30:29PM +0200, Michal Privoznik wrote:
Now that nothing supports "pci-stub" driver (aka KVM style of PCI device assignment) there is no need for virpcimock to create it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/virpcimock.c | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Now that PCI attach/detach happens solely via driver_override these two files are no longer needed. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/virpcimock.c | 112 --------------------------------------------- 1 file changed, 112 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index bbec77975a..3157037913 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -68,14 +68,6 @@ char *fakerootdir; * created by us. There are some actions that we must take if some special * files are written to. Here's the list of files we watch: * - * /sys/bus/pci/drivers/<driver>/new_id: - * Learn the driver new vendor and device combination. - * Data in format "VVVV DDDD". - * - * /sys/bus/pci/drivers/<driver>/remove_id - * Make the driver forget about vendor and device. - * Data in format "VVVV DDDD". - * * /sys/bus/pci/drivers/<driver>/bind * Check if driver supports the device and bind driver to it (create symlink * called 'driver' pointing to the /sys/but/pci/drivers/<driver>). @@ -168,8 +160,6 @@ static int pci_driver_unbind(struct pciDriver *driver, struct pciDevice *dev); static int pci_driver_handle_change(int fd, const char *path); static int pci_driver_handle_bind(const char *path); static int pci_driver_handle_unbind(const char *path); -static int pci_driver_handle_new_id(const char *path); -static int pci_driver_handle_remove_id(const char *path); /* @@ -640,8 +630,6 @@ pci_driver_new(const char *name, int fail, ...) make_file(driverpath, "bind", NULL, -1); make_file(driverpath, "unbind", NULL, -1); - make_file(driverpath, "new_id", NULL, -1); - make_file(driverpath, "remove_id", NULL, -1); if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver) < 0) ABORT_OOM(); @@ -801,10 +789,6 @@ pci_driver_handle_change(int fd ATTRIBUTE_UNUSED, const char *path) ret = pci_driver_handle_bind(path); else if (STREQ(file, "unbind")) ret = pci_driver_handle_unbind(path); - else if (STREQ(file, "new_id")) - ret = pci_driver_handle_new_id(path); - else if (STREQ(file, "remove_id")) - ret = pci_driver_handle_remove_id(path); else if (STREQ(file, "drivers_probe")) ret = pci_driver_handle_drivers_probe(path); else if (STREQ(file, "driver_override")) @@ -849,102 +833,6 @@ pci_driver_handle_unbind(const char *path) return ret; } -static int -pci_driver_handle_new_id(const char *path) -{ - int ret = -1; - struct pciDriver *driver = pci_driver_find_by_path(path); - size_t i; - int vendor, device; - char buf[32]; - - if (!driver || PCI_ACTION_NEW_ID & driver->fail) { - errno = ENODEV; - goto cleanup; - } - - if (pci_read_file(path, buf, sizeof(buf), true) < 0) - goto cleanup; - - if (sscanf(buf, "%x %x", &vendor, &device) < 2) { - errno = EINVAL; - goto cleanup; - } - - for (i = 0; i < driver->len; i++) { - if (driver->vendor[i] == vendor && - driver->device[i] == device) - break; - } - - if (i == driver->len) { - if (VIR_REALLOC_N_QUIET(driver->vendor, driver->len + 1) < 0 || - VIR_REALLOC_N_QUIET(driver->device, driver->len + 1) < 0) { - errno = ENOMEM; - goto cleanup; - } - - driver->vendor[driver->len] = vendor; - driver->device[driver->len] = device; - driver->len++; - } - - for (i = 0; i < nPCIDevices; i++) { - struct pciDevice *dev = pciDevices[i]; - - if (!dev->driver && - dev->vendor == vendor && - dev->device == device && - pci_driver_bind(driver, dev) < 0) - goto cleanup; - } - - ret = 0; - cleanup: - return ret; -} - -static int -pci_driver_handle_remove_id(const char *path) -{ - int ret = -1; - struct pciDriver *driver = pci_driver_find_by_path(path); - size_t i; - int vendor, device; - char buf[32]; - - if (!driver || PCI_ACTION_REMOVE_ID & driver->fail) { - errno = ENODEV; - goto cleanup; - } - - if (pci_read_file(path, buf, sizeof(buf), true) < 0) - goto cleanup; - - if (sscanf(buf, "%x %x", &vendor, &device) < 2) { - errno = EINVAL; - goto cleanup; - } - - for (i = 0; i < driver->len; i++) { - if (driver->vendor[i] == vendor && - driver->device[i] == device) - continue; - } - - if (i != driver->len) { - if (VIR_DELETE_ELEMENT(driver->vendor, i, driver->len) < 0) - goto cleanup; - driver->len++; - if (VIR_DELETE_ELEMENT(driver->device, i, driver->len) < 0) - goto cleanup; - } - - ret = 0; - cleanup: - return ret; -} - /* * Functions to load the symbols and init the environment -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
Now that PCI attach/detach happens solely via driver_override these two files are no longer needed.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
tests/virpcimock.c | 112 --------------------------------------------- 1 file changed, 112 deletions(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c index bbec77975a..3157037913 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -68,14 +68,6 @@ char *fakerootdir; * created by us. There are some actions that we must take if some special * files are written to. Here's the list of files we watch: * - * /sys/bus/pci/drivers/<driver>/new_id: - * Learn the driver new vendor and device combination. - * Data in format "VVVV DDDD". - * - * /sys/bus/pci/drivers/<driver>/remove_id - * Make the driver forget about vendor and device. - * Data in format "VVVV DDDD". - * * /sys/bus/pci/drivers/<driver>/bind * Check if driver supports the device and bind driver to it (create symlink * called 'driver' pointing to the /sys/but/pci/drivers/<driver>). @@ -168,8 +160,6 @@ static int pci_driver_unbind(struct pciDriver *driver, struct pciDevice *dev); static int pci_driver_handle_change(int fd, const char *path); static int pci_driver_handle_bind(const char *path); static int pci_driver_handle_unbind(const char *path); -static int pci_driver_handle_new_id(const char *path); -static int pci_driver_handle_remove_id(const char *path);
/* @@ -640,8 +630,6 @@ pci_driver_new(const char *name, int fail, ...)
make_file(driverpath, "bind", NULL, -1); make_file(driverpath, "unbind", NULL, -1); - make_file(driverpath, "new_id", NULL, -1); - make_file(driverpath, "remove_id", NULL, -1);
if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver) < 0) ABORT_OOM(); @@ -801,10 +789,6 @@ pci_driver_handle_change(int fd ATTRIBUTE_UNUSED, const char *path) ret = pci_driver_handle_bind(path); else if (STREQ(file, "unbind")) ret = pci_driver_handle_unbind(path); - else if (STREQ(file, "new_id")) - ret = pci_driver_handle_new_id(path); - else if (STREQ(file, "remove_id")) - ret = pci_driver_handle_remove_id(path); else if (STREQ(file, "drivers_probe")) ret = pci_driver_handle_drivers_probe(path); else if (STREQ(file, "driver_override")) @@ -849,102 +833,6 @@ pci_driver_handle_unbind(const char *path) return ret; }
-static int -pci_driver_handle_new_id(const char *path) -{ - int ret = -1; - struct pciDriver *driver = pci_driver_find_by_path(path); - size_t i; - int vendor, device; - char buf[32]; - - if (!driver || PCI_ACTION_NEW_ID & driver->fail) { - errno = ENODEV; - goto cleanup; - } - - if (pci_read_file(path, buf, sizeof(buf), true) < 0) - goto cleanup; - - if (sscanf(buf, "%x %x", &vendor, &device) < 2) { - errno = EINVAL; - goto cleanup; - } - - for (i = 0; i < driver->len; i++) { - if (driver->vendor[i] == vendor && - driver->device[i] == device) - break; - } - - if (i == driver->len) { - if (VIR_REALLOC_N_QUIET(driver->vendor, driver->len + 1) < 0 || - VIR_REALLOC_N_QUIET(driver->device, driver->len + 1) < 0) { - errno = ENOMEM; - goto cleanup; - } - - driver->vendor[driver->len] = vendor; - driver->device[driver->len] = device; - driver->len++; - } - - for (i = 0; i < nPCIDevices; i++) { - struct pciDevice *dev = pciDevices[i]; - - if (!dev->driver && - dev->vendor == vendor && - dev->device == device && - pci_driver_bind(driver, dev) < 0) - goto cleanup; - } - - ret = 0; - cleanup: - return ret; -} - -static int -pci_driver_handle_remove_id(const char *path) -{ - int ret = -1; - struct pciDriver *driver = pci_driver_find_by_path(path); - size_t i; - int vendor, device; - char buf[32]; - - if (!driver || PCI_ACTION_REMOVE_ID & driver->fail) { - errno = ENODEV; - goto cleanup; - } - - if (pci_read_file(path, buf, sizeof(buf), true) < 0) - goto cleanup; - - if (sscanf(buf, "%x %x", &vendor, &device) < 2) { - errno = EINVAL; - goto cleanup; - } - - for (i = 0; i < driver->len; i++) { - if (driver->vendor[i] == vendor && - driver->device[i] == device) - continue; - } - - if (i != driver->len) { - if (VIR_DELETE_ELEMENT(driver->vendor, i, driver->len) < 0) - goto cleanup; - driver->len++; - if (VIR_DELETE_ELEMENT(driver->device, i, driver->len) < 0) - goto cleanup; - } - - ret = 0; - cleanup: - return ret; -} -
/* * Functions to load the symbols and init the environment

On Tue, Aug 20, 2019 at 04:30:30PM +0200, Michal Privoznik wrote:
Now that PCI attach/detach happens solely via driver_override these two files are no longer needed.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/virpcimock.c | 112 --------------------------------------------- 1 file changed, 112 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

This enum was introduced to model how RHEL-7 kernel behaves - for some reason going with the old way (via new_id + bind) fails but using driver_override succeeds. Well, we don't need to care about that anymore since we don't create new_id file. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/virpcimock.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 3157037913..a5045ed97c 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -98,19 +98,11 @@ char *fakerootdir; * */ -enum driverActions { - PCI_ACTION_BIND = 1 << 0, - PCI_ACTION_UNBIND = 1 << 1, - PCI_ACTION_NEW_ID = 1 << 2, - PCI_ACTION_REMOVE_ID = 1 << 3, -}; - struct pciDriver { char *name; int *vendor; /* List of vendor:device IDs the driver can handle */ int *device; size_t len; /* @len is used for both @vendor and @device */ - unsigned int fail; /* Bitwise-OR of driverActions that should fail */ }; struct pciDeviceAddress { @@ -151,7 +143,7 @@ static void pci_device_new_from_stub(const struct pciDevice *data); static struct pciDevice *pci_device_find_by_id(struct pciDeviceAddress const *addr); static struct pciDevice *pci_device_find_by_content(const char *path); -static void pci_driver_new(const char *name, int fail, ...); +static void pci_driver_new(const char *name, ...); static struct pciDriver *pci_driver_find_by_dev(struct pciDevice *dev); static struct pciDriver *pci_driver_find_by_path(const char *path); static struct pciDriver *pci_driver_find_by_driver_override(struct pciDevice *dev); @@ -594,7 +586,7 @@ pci_driver_get_path(const struct pciDriver *driver, static void -pci_driver_new(const char *name, int fail, ...) +pci_driver_new(const char *name, ...) { struct pciDriver *driver; va_list args; @@ -606,12 +598,10 @@ pci_driver_new(const char *name, int fail, ...) !(driverpath = pci_driver_get_path(driver, NULL, true))) ABORT_OOM(); - driver->fail = fail; - if (virFileMakePath(driverpath) < 0) ABORT("Unable to create: %s", driverpath); - va_start(args, fail); + va_start(args, name); while ((vendor = va_arg(args, int)) != -1) { if ((device = va_arg(args, int)) == -1) @@ -805,7 +795,7 @@ pci_driver_handle_bind(const char *path) struct pciDevice *dev = pci_device_find_by_content(path); struct pciDriver *driver = pci_driver_find_by_path(path); - if (!driver || !dev || PCI_ACTION_BIND & driver->fail) { + if (!driver || !dev) { /* No driver, no device or failing driver requested */ errno = ENODEV; goto cleanup; @@ -822,7 +812,7 @@ pci_driver_handle_unbind(const char *path) int ret = -1; struct pciDevice *dev = pci_device_find_by_content(path); - if (!dev || !dev->driver || PCI_ACTION_UNBIND & dev->driver->fail) { + if (!dev || !dev->driver) { /* No device, device not binded or failing driver requested */ errno = ENODEV; goto cleanup; @@ -876,11 +866,11 @@ init_env(void) make_file(tmp, "drivers_probe", NULL, -1); # define MAKE_PCI_DRIVER(name, ...) \ - pci_driver_new(name, 0, __VA_ARGS__, -1, -1) + pci_driver_new(name, __VA_ARGS__, -1, -1) MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044); MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047); - pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1); + MAKE_PCI_DRIVER("vfio-pci", -1, -1); # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ do { \ -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
This enum was introduced to model how RHEL-7 kernel behaves - for some reason going with the old way (via new_id + bind) fails but using driver_override succeeds. Well, we don't need to care about that anymore since we don't create new_id file.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
tests/virpcimock.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 3157037913..a5045ed97c 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -98,19 +98,11 @@ char *fakerootdir; * */
-enum driverActions { - PCI_ACTION_BIND = 1 << 0, - PCI_ACTION_UNBIND = 1 << 1, - PCI_ACTION_NEW_ID = 1 << 2, - PCI_ACTION_REMOVE_ID = 1 << 3, -}; - struct pciDriver { char *name; int *vendor; /* List of vendor:device IDs the driver can handle */ int *device; size_t len; /* @len is used for both @vendor and @device */ - unsigned int fail; /* Bitwise-OR of driverActions that should fail */ };
struct pciDeviceAddress { @@ -151,7 +143,7 @@ static void pci_device_new_from_stub(const struct pciDevice *data); static struct pciDevice *pci_device_find_by_id(struct pciDeviceAddress const *addr); static struct pciDevice *pci_device_find_by_content(const char *path);
-static void pci_driver_new(const char *name, int fail, ...); +static void pci_driver_new(const char *name, ...); static struct pciDriver *pci_driver_find_by_dev(struct pciDevice *dev); static struct pciDriver *pci_driver_find_by_path(const char *path); static struct pciDriver *pci_driver_find_by_driver_override(struct pciDevice *dev); @@ -594,7 +586,7 @@ pci_driver_get_path(const struct pciDriver *driver,
static void -pci_driver_new(const char *name, int fail, ...) +pci_driver_new(const char *name, ...) { struct pciDriver *driver; va_list args; @@ -606,12 +598,10 @@ pci_driver_new(const char *name, int fail, ...) !(driverpath = pci_driver_get_path(driver, NULL, true))) ABORT_OOM();
- driver->fail = fail; - if (virFileMakePath(driverpath) < 0) ABORT("Unable to create: %s", driverpath);
- va_start(args, fail); + va_start(args, name);
while ((vendor = va_arg(args, int)) != -1) { if ((device = va_arg(args, int)) == -1) @@ -805,7 +795,7 @@ pci_driver_handle_bind(const char *path) struct pciDevice *dev = pci_device_find_by_content(path); struct pciDriver *driver = pci_driver_find_by_path(path);
- if (!driver || !dev || PCI_ACTION_BIND & driver->fail) { + if (!driver || !dev) { /* No driver, no device or failing driver requested */ errno = ENODEV; goto cleanup; @@ -822,7 +812,7 @@ pci_driver_handle_unbind(const char *path) int ret = -1; struct pciDevice *dev = pci_device_find_by_content(path);
- if (!dev || !dev->driver || PCI_ACTION_UNBIND & dev->driver->fail) { + if (!dev || !dev->driver) { /* No device, device not binded or failing driver requested */ errno = ENODEV; goto cleanup; @@ -876,11 +866,11 @@ init_env(void) make_file(tmp, "drivers_probe", NULL, -1);
# define MAKE_PCI_DRIVER(name, ...) \ - pci_driver_new(name, 0, __VA_ARGS__, -1, -1) + pci_driver_new(name, __VA_ARGS__, -1, -1)
MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044); MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047); - pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1); + MAKE_PCI_DRIVER("vfio-pci", -1, -1);
# define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ do { \

On Tue, Aug 20, 2019 at 04:30:31PM +0200, Michal Privoznik wrote:
This enum was introduced to model how RHEL-7 kernel behaves - for some reason going with the old way (via new_id + bind) fails but using driver_override succeeds. Well, we don't need to care about that anymore since we don't create new_id file.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/virpcimock.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/news.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index d63fca3b48..6137ebd943 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -51,6 +51,19 @@ </description> </change> </section> + <section title="Removed features"> + <change> + <summary> + Remove KVM assignment support + </summary> + <description> + The KVM style of PCI device assignment was removed from + kernel in kernel 4.12.0 after being deprecated since 4.2.0. + Libvirt defaults to VFIO for a long time. Remove support for + KVM device assignment then. + </description> + </change> + </section> <section title="Improvements"> </section> <section title="Bug fixes"> -- 2.21.0

On 8/20/19 11:30 AM, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
docs/news.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml index d63fca3b48..6137ebd943 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -51,6 +51,19 @@ </description> </change> </section> + <section title="Removed features"> + <change> + <summary> + Remove KVM assignment support + </summary> + <description> + The KVM style of PCI device assignment was removed from + kernel in kernel 4.12.0 after being deprecated since 4.2.0. + Libvirt defaults to VFIO for a long time. Remove support for + KVM device assignment then. + </description> + </change> + </section> <section title="Improvements"> </section> <section title="Bug fixes">

On Tue, Aug 20, 2019 at 04:30:32PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/news.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml index d63fca3b48..6137ebd943 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -51,6 +51,19 @@ </description> </change> </section> + <section title="Removed features"> + <change> + <summary> + Remove KVM assignment support + </summary> + <description> + The KVM style of PCI device assignment was removed from + kernel in kernel 4.12.0 after being deprecated since 4.2.0.
s/kernel in kernel/the kernel in version/
+ Libvirt defaults to VFIO for a long time. Remove support for + KVM device assignment then.
s/then/from libvirt too/ Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On 8/20/19 11:30 AM, Michal Privoznik wrote:
The KVM style of PCI assignment is not used, and it hasn't been for a while. Any attempt to start a domain with it would result in error as kernel dropped its support in 4.12.0 (after being deprecated for 1.5 years).
LGTM. Just a comment in patch 01. After applying the whole series I tried to find the remaining references of 'pci-assign'. This is what git grep returns: $ git grep 'pci-assign' src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_CONFIGFD, /* pci-assign.configfd */ src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_BOOTINDEX, /* pci-assign.bootindex */ tests/qemucapabilitiesdata/caps_1.5.3.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_1.6.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_1.7.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.1.1.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.10.0.x86_64.replies: "name": "kvm-pci-assign", tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies: "name": "kvm-pci-assign" And with 'configfd': $ git grep 'configfd' docs/news-2011.html.in: qemu: simplify PCI configfd handling in monitor (Eric Blake),<br/> src/qemu/qemu_capabilities.c: "pci-configfd", src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_CONFIGFD, /* pci-assign.configfd */ tests/qemustatusxml2xmldata/migration-in-params-in.xml: <flag name='pci-configfd'/> tests/qemustatusxml2xmldata/migration-out-params-in.xml: <flag name='pci-configfd'/> Do we still need X_QEMU_CAPS_PCI_CONFIGFD and X_QEMU_CAPS_PCI_BOOTINDEX after this series? Thanks, DHB
Michal Prívozník (12): qemu: Drop KVM assignment tests: Remove 'kvm' PCI backend from domaincapstest virhostdev: Unify virDomainHostdevDef to virPCIDevice translation qemu: Drop unused qemuOpenPCIConfig() virhostdev: Disable legacy kvm assignment virpci: Drop 'pci-stub' driver virpci: Remove unused virPCIDeviceWaitForCleanup virpci: Drop newid style of PCI device detach virpcimock: Don't create "pci-stub" driver virpcimock: Don't create new_id or remove_id files virpcimock: Drop @driverActions enum news: Document KVM assignment removal
docs/news.xml | 13 + src/libvirt_private.syms | 1 - src/qemu/qemu_capabilities.c | 6 - src/qemu/qemu_command.c | 48 +-- src/qemu/qemu_command.h | 3 - src/qemu/qemu_driver.c | 14 +- src/qemu/qemu_hostdev.c | 44 +- src/qemu/qemu_hostdev.h | 1 - src/qemu/qemu_hotplug.c | 20 +- src/util/virhostdev.c | 97 +++-- src/util/virpci.c | 403 +----------------- src/util/virpci.h | 2 - .../qemu_1.7.0.x86_64.xml | 1 - .../qemu_2.12.0-virt.aarch64.xml | 1 - .../qemu_2.12.0.ppc64.xml | 1 - .../qemu_2.12.0.s390x.xml | 1 - .../qemu_2.12.0.x86_64.xml | 1 - .../qemu_2.6.0-virt.aarch64.xml | 1 - .../qemu_2.6.0.aarch64.xml | 1 - .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 - .../qemu_2.6.0.x86_64.xml | 1 - .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 - .../qemu_2.8.0-tcg.x86_64.xml | 1 - .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 - .../qemu_2.8.0.x86_64.xml | 1 - .../qemu_2.9.0-q35.x86_64.xml | 1 - .../qemu_2.9.0-tcg.x86_64.xml | 1 - .../qemu_2.9.0.x86_64.xml | 1 - .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 - .../qemu_3.1.0.x86_64.xml | 1 - .../domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 - .../qemu_4.0.0.x86_64.xml | 1 - .../qemu_4.1.0.x86_64.xml | 1 - tests/domaincapstest.c | 4 +- tests/virpcimock.c | 137 +----- 35 files changed, 92 insertions(+), 722 deletions(-)

On Tue, Aug 20, 2019 at 02:53:32PM -0300, Daniel Henrique Barboza wrote:
On 8/20/19 11:30 AM, Michal Privoznik wrote:
The KVM style of PCI assignment is not used, and it hasn't been for a while. Any attempt to start a domain with it would result in error as kernel dropped its support in 4.12.0 (after being deprecated for 1.5 years).
LGTM. Just a comment in patch 01.
After applying the whole series I tried to find the remaining references of 'pci-assign'. This is what git grep returns:
Yes, the 'kvm-pci-assign' device was present in those QEMU versions so it was listed in the replies.
$ git grep 'pci-assign' src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_CONFIGFD, /* pci-assign.configfd */ src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_BOOTINDEX, /* pci-assign.bootindex */ tests/qemucapabilitiesdata/caps_1.5.3.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_1.6.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_1.7.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.1.1.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.10.0.x86_64.replies: "name": "kvm-pci-assign", tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies: "name": "kvm-pci-assign"
And with 'configfd':
$ git grep 'configfd' docs/news-2011.html.in: qemu: simplify PCI configfd handling in monitor (Eric Blake),<br/> src/qemu/qemu_capabilities.c: "pci-configfd", src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_CONFIGFD, /* pci-assign.configfd */ tests/qemustatusxml2xmldata/migration-in-params-in.xml: <flag name='pci-configfd'/> tests/qemustatusxml2xmldata/migration-out-params-in.xml: <flag name='pci-configfd'/>
Do we still need X_QEMU_CAPS_PCI_CONFIGFD and X_QEMU_CAPS_PCI_BOOTINDEX after this series?
We need to be capable of parsing the qemu capability flags produced by older libvirt even though we aren't taking them into account. When upgrading libvirt while a domain is running, or migrating to a host with newer libvirt, rejecting the capability might break existing guests even though they did not use that particular capability. So we keep it around with an X- prefix and the corresponding string representation unchanged and just quietly ignore it. Jano

On 8/21/19 9:53 AM, Ján Tomko wrote:
On Tue, Aug 20, 2019 at 02:53:32PM -0300, Daniel Henrique Barboza wrote:
On 8/20/19 11:30 AM, Michal Privoznik wrote:
The KVM style of PCI assignment is not used, and it hasn't been for a while. Any attempt to start a domain with it would result in error as kernel dropped its support in 4.12.0 (after being deprecated for 1.5 years).
LGTM. Just a comment in patch 01.
After applying the whole series I tried to find the remaining references of 'pci-assign'. This is what git grep returns:
Yes, the 'kvm-pci-assign' device was present in those QEMU versions so it was listed in the replies.
$ git grep 'pci-assign' src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_CONFIGFD, /* pci-assign.configfd */ src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_BOOTINDEX, /* pci-assign.bootindex */ tests/qemucapabilitiesdata/caps_1.5.3.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_1.6.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_1.7.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.1.1.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.10.0.x86_64.replies: "name": "kvm-pci-assign", tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies: "name": "kvm-pci-assign" tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies: "name": "kvm-pci-assign"
And with 'configfd':
$ git grep 'configfd' docs/news-2011.html.in: qemu: simplify PCI configfd handling in monitor (Eric Blake),<br/> src/qemu/qemu_capabilities.c: "pci-configfd", src/qemu/qemu_capabilities.h: X_QEMU_CAPS_PCI_CONFIGFD, /* pci-assign.configfd */ tests/qemustatusxml2xmldata/migration-in-params-in.xml: <flag name='pci-configfd'/> tests/qemustatusxml2xmldata/migration-out-params-in.xml: <flag name='pci-configfd'/>
Do we still need X_QEMU_CAPS_PCI_CONFIGFD and X_QEMU_CAPS_PCI_BOOTINDEX after this series?
We need to be capable of parsing the qemu capability flags produced by older libvirt even though we aren't taking them into account.
When upgrading libvirt while a domain is running, or migrating to a host with newer libvirt, rejecting the capability might break existing guests even though they did not use that particular capability.
So we keep it around with an X- prefix and the corresponding string representation unchanged and just quietly ignore it.
Got it. Thanks for the explanation! DHB
Jano
participants (3)
-
Daniel Henrique Barboza
-
Ján Tomko
-
Michal Privoznik