The new struct is virDeviceHostdevPCIDriverInfo, and the "backend"
enum in the hostdevDef will be replaced with a
virDeviceHostdevPCIDriverInfo named "driver'. Since the enum value in
this new struct is called "name", it means that all references to
"backend" will become "driver.name".
This will allow easily adding other items for new attributes in the
<driver> element / C struct, which will be useful once we are using
this new struct in multiple places.
Signed-off-by: Laine Stump <laine(a)redhat.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
---
Change from V2: names have changed, extra line breaks removed
src/conf/device_conf.h | 4 ++++
src/conf/domain_conf.c | 30 +++++++++++++-----------------
src/conf/domain_conf.h | 2 +-
src/conf/virconftypes.h | 2 ++
src/hypervisor/virhostdev.c | 6 +++---
src/libxl/libxl_domain.c | 6 +++---
src/libxl/libxl_driver.c | 6 +++---
src/qemu/qemu_command.c | 6 +++---
src/qemu/qemu_domain.c | 4 ++--
src/qemu/qemu_validate.c | 6 +++---
src/security/security_apparmor.c | 2 +-
src/security/security_dac.c | 4 ++--
src/security/security_selinux.c | 4 ++--
src/security/virt-aa-helper.c | 2 +-
src/test/test_driver.c | 6 +++---
tests/virhostdevtest.c | 2 +-
16 files changed, 47 insertions(+), 45 deletions(-)
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 35a9138a95..887b871589 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6285,7 +6285,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
if (virXMLPropEnum(driver_node, "name",
virDeviceHostdevPCIDriverNameTypeFromString,
VIR_XML_PROP_NONZERO,
- &pcisrc->backend) < 0) {
+ &pcisrc->driver.name) < 0) {
return -1;
}
}
@@ -23378,17 +23378,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);
@@ -29916,15 +29916,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:
@@ -30034,7 +30034,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;
@@ -30048,14 +30048,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;
}
@@ -30999,7 +30995,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 0582cc928d..ee8bcbc6b3 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 2f0b1d0acd..b3ebf711e5 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 1e2b74af02..1aeeb74503 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -10531,7 +10531,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;
@@ -11302,7 +11302,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 2aab0d9db2..4d388bbcc4 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++) {
--
2.43.0