[PATCH v2 5/9] qemu: Deny all but VFIO PCI backends in hostdev prepare phase

Martin Kletzander mkletzan at redhat.com
Mon Apr 24 11:11:40 UTC 2023


On Mon, Apr 24, 2023 at 12:41:44PM +0200, Michal Privoznik wrote:
>We used to support KVM and VFIO style of PCI assignment. The
>former was dropped in v5.7.0-rc1~103 and thus we only support
>VFIO. All other backends lead to an error (see
>qemuBuildPCIHostdevDevProps(), or qemuBuildPCIHostdevDevStr() as
>it used to be called in the era of aforementioned commit).
>
>Might as well report the error in prepare phase and save hassle
>of proceeding with device preparation (e.g. in case of hotplug
>overriding the device's driver, setting seclabels, etc.).
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> src/qemu/qemu_domain.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
>diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>index 58cd3dd710..72f36c807b 100644
>--- a/src/qemu/qemu_domain.c
>+++ b/src/qemu/qemu_domain.c
>@@ -11326,12 +11326,11 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev,
>         break;
>
>     case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
>-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>-                       _("host doesn't support legacy PCI passthrough"));
>-        return false;
>-
>     case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
>     case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
>+        virReportError(VIR_ERR_INTERNAL_ERROR,
>+                       _("invalid PCI passthrough type '%1$s'"),
>+                       virDomainHostdevSubsysPCIBackendTypeToString(*backend));

This is a bit misleading as it is not "invalid", it's just unsupported,
and on top of that you're changing it to internal error and I think it
should still be CONFIG_UNSUPPORTED, at least for KVM and XEN.  _LAST
(and possibly default:) is still an internal error of course.

>         break;
>     }
>
>-- 
>2.39.2
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230424/327107ac/attachment.sig>


More information about the libvir-list mailing list