diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 18aa4125fa..1f7e066142 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -43,6 +43,10 @@ typedef enum { VIR_ENUM_DECL(virDeviceHostdevPCIDriverName); +struct _virDeviceHostdevPCIDriverInfo { + virDeviceHostdevPCIDriverName name; +}; + typedef enum { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE = 0, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d09a0af9a5..295238894f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6287,7 +6287,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if (virXMLPropEnum(driver_node, "name", virDeviceHostdevPCIDriverNameTypeFromString, VIR_XML_PROP_NONZERO, - &pcisrc->backend) < 0) { + &pcisrc->driver.name) < 0) { return -1; } } @@ -23429,17 +23429,17 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, g_auto(virBuffer) sourceChildBuf = VIR_BUFFER_INIT_CHILD(buf); virDomainHostdevSubsysPCI *pcisrc = &def->source.subsys.u.pci; - if (pcisrc->backend != VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) { - const char *backend = virDeviceHostdevPCIDriverNameTypeToString(pcisrc->backend); + if (pcisrc->driver.name != VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) { + const char *driverName = virDeviceHostdevPCIDriverNameTypeToString(pcisrc->driver.name); - if (!backend) { + if (!driverName) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected pci hostdev driver name type %1$d"), - pcisrc->backend); + _("unexpected pci hostdev driver type %1$d"), + pcisrc->driver.name); return -1; } - virBufferAsprintf(&driverAttrBuf, " name='%s'", backend); + virBufferAsprintf(&driverAttrBuf, " name='%s'", driverName); } virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); @@ -29967,15 +29967,15 @@ virDomainNetDefActualFromNetworkPort(virDomainNetDef *iface, actual->data.hostdev.def.source.subsys.u.pci.addr = port->plug.hostdevpci.addr; switch ((virNetworkForwardDriverNameType)port->plug.hostdevpci.driver) { case VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT: - actual->data.hostdev.def.source.subsys.u.pci.backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT; + actual->data.hostdev.def.source.subsys.u.pci.driver.name = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT; break; case VIR_NETWORK_FORWARD_DRIVER_NAME_KVM: - actual->data.hostdev.def.source.subsys.u.pci.backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM; + actual->data.hostdev.def.source.subsys.u.pci.driver.name = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM; break; case VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO: - actual->data.hostdev.def.source.subsys.u.pci.backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; + actual->data.hostdev.def.source.subsys.u.pci.driver.name = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; break; case VIR_NETWORK_FORWARD_DRIVER_NAME_LAST: @@ -30085,7 +30085,7 @@ virDomainNetDefActualToNetworkPort(virDomainDef *dom, } port->plug.hostdevpci.managed = virTristateBoolFromBool(actual->data.hostdev.def.managed); port->plug.hostdevpci.addr = actual->data.hostdev.def.source.subsys.u.pci.addr; - switch (actual->data.hostdev.def.source.subsys.u.pci.backend) { + switch (actual->data.hostdev.def.source.subsys.u.pci.driver.name) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: port->plug.hostdevpci.driver = VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT; break; @@ -30099,14 +30099,10 @@ virDomainNetDefActualToNetworkPort(virDomainDef *dom, break; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Unexpected PCI backend 'xen'")); - break; - case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: default: virReportEnumRangeError(virDeviceHostdevPCIDriverName, - actual->data.hostdev.def.source.subsys.u.pci.backend); + actual->data.hostdev.def.source.subsys.u.pci.driver.name); return NULL; } @@ -31050,7 +31046,7 @@ virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev) { return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && - hostdev->source.subsys.u.pci.backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; + hostdev->source.subsys.u.pci.driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0c6a57c9a2..9d76dc7c7d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -235,7 +235,7 @@ struct _virDomainHostdevSubsysUSB { struct _virDomainHostdevSubsysPCI { virPCIDeviceAddress addr; /* host address */ - virDeviceHostdevPCIDriverName backend; + virDeviceHostdevPCIDriverInfo driver; virBitmap *origstates; }; diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index 26cb966194..0779bc224b 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -66,6 +66,8 @@ typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel; typedef struct _virCapsStoragePool virCapsStoragePool; +typedef struct _virDeviceHostdevPCIDriverInfo virDeviceHostdevPCIDriverInfo; + typedef struct _virDomainABIStability virDomainABIStability; typedef struct _virDomainActualNetDef virDomainActualNetDef; diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 26c9ac3c28..27b0acdc91 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -243,14 +243,14 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev, virPCIDeviceSetManaged(actual, hostdev->managed); - if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_VFIO); - } else if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN) { + } else if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN) { virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_XEN); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("pci backend driver type '%1$s' is not supported"), - virDeviceHostdevPCIDriverNameTypeToString(pcisrc->backend)); + virDeviceHostdevPCIDriverNameTypeToString(pcisrc->driver.name)); return -1; } diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 88d977e79b..1a7de00704 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -160,8 +160,8 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && - pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) - pcisrc->backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) + pcisrc->driver.name = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; } if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) { @@ -997,7 +997,7 @@ libxlNetworkPrepareDevices(virDomainDef *def) if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) - pcisrc->backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + pcisrc->driver.name = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; if (virDomainHostdevInsert(def, hostdev) < 0) return -1; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d7f79089c3..29fbc823dd 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3397,13 +3397,13 @@ libxlDomainAttachNetDevice(libxlDriverPrivate *driver, virDomainHostdevDef *hostdev = virDomainNetGetActualHostdev(net); virDomainHostdevSubsysPCI *pcisrc = &hostdev->source.subsys.u.pci; - /* For those just allocated from a network pool whose backend is + /* For those just allocated from a network pool whose driver type is * still VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT, we need to set - * backend correctly. + * driver name correctly. */ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) - pcisrc->backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; + pcisrc->driver.name = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN; /* This is really a "smart hostdev", so it should be attached * as a hostdev (the hostdev code will reach over into the diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 73c80339c0..2148419d3f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4707,8 +4707,8 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, g_autofree char *host = virPCIDeviceAddressAsString(&pcisrc->addr); const char *failover_pair_id = NULL; - /* caller has to assign proper passthrough backend type */ - switch (pcisrc->backend) { + /* caller has to assign proper passthrough driver name */ + switch (pcisrc->driver.name) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: break; @@ -4718,7 +4718,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid PCI passthrough type '%1$s'"), - virDeviceHostdevPCIDriverNameTypeToString(pcisrc->backend)); + virDeviceHostdevPCIDriverNameTypeToString(pcisrc->driver.name)); return NULL; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0bda1699d5..642ab78e6c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10534,7 +10534,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDef *dev, case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS: switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { if (!(tmpPath = virPCIDeviceAddressGetIOMMUGroupDev(&pcisrc->addr))) return -1; @@ -11305,7 +11305,7 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev, virQEMUCaps *qemuCaps) { bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); - virDeviceHostdevPCIDriverName *driverName = &hostdev->source.subsys.u.pci.backend; + virDeviceHostdevPCIDriverName *driverName = &hostdev->source.subsys.u.pci.driver.name; /* assign defaults for hostdev passthrough */ switch (*driverName) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index a10ab03cb2..697abb8dc3 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2437,7 +2437,7 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev, const virDomainDef *def, virQEMUCaps *qemuCaps) { - int backend; + virDeviceHostdevPCIDriverName driverName; /* forbid capabilities mode hostdev in this kind of hypervisor */ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) { @@ -2462,9 +2462,9 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev, break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - backend = hostdev->source.subsys.u.pci.backend; + driverName = hostdev->source.subsys.u.pci.driver.name; - if (backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (driverName == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("VFIO PCI device assignment is not supported by this version of qemu")); diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index a1cbbc77e9..c1dc859751 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -869,7 +869,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *mgr, if (!pci) goto done; - if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci); if (!vfioGroupDev) { diff --git a/src/security/security_dac.c b/src/security/security_dac.c index cb8b72b289..4b8130630f 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1257,7 +1257,7 @@ virSecurityDACSetHostdevLabel(virSecurityManager *mgr, if (!pci) return -1; - if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { g_autofree char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci); if (!vfioGroupDev) @@ -1418,7 +1418,7 @@ virSecurityDACRestoreHostdevLabel(virSecurityManager *mgr, if (!pci) return -1; - if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { g_autofree char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci); if (!vfioGroupDev) diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 2ee542f6a4..ffad058d9a 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2201,7 +2201,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManager *mgr, if (!pci) return -1; - if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { g_autofree char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci); if (!vfioGroupDev) @@ -2437,7 +2437,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManager *mgr, if (!pci) return -1; - if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { + if (pcisrc->driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO) { g_autofree char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci); if (!vfioGroupDev) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index d01df8710d..0374581f07 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1092,7 +1092,7 @@ get_files(vahControl * ctl) case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { virPCIDevice *pci = virPCIDeviceNew(&dev->source.subsys.u.pci.addr); - virDeviceHostdevPCIDriverName driverName = dev->source.subsys.u.pci.backend; + virDeviceHostdevPCIDriverName driverName = dev->source.subsys.u.pci.driver.name; if (driverName == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO || driverName == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 63e1f743c3..ed545848af 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10042,9 +10042,9 @@ testDomainAttachHostPCIDevice(testDriver *driver G_GNUC_UNUSED, virDomainObj *vm, virDomainHostdevDef *hostdev) { - int backend = hostdev->source.subsys.u.pci.backend; + int driverName = hostdev->source.subsys.u.pci.driver.name; - switch (backend) { + switch (driverName) { case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: @@ -10054,7 +10054,7 @@ testDomainAttachHostPCIDevice(testDriver *driver G_GNUC_UNUSED, case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("test hypervisor does not support device assignment mode '%1$s'"), - virDeviceHostdevPCIDriverNameTypeToString(backend)); + virDeviceHostdevPCIDriverNameTypeToString(driverName)); return -1; } diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 89b4fb5e7c..aec474a148 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -134,7 +134,7 @@ myInit(void) subsys->u.pci.addr.bus = 0; subsys->u.pci.addr.slot = i + 1; subsys->u.pci.addr.function = 0; - subsys->u.pci.backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; + subsys->u.pci.driver.name = VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; } for (i = 0; i < nhostdevs; i++) {