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 "type", it means that all references to
"backend" will become "driver.type".
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>
---
src/conf/device_conf.h | 4 ++++
src/conf/domain_conf.c | 32 ++++++++++++++------------------
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 | 4 ++--
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 +-
tests/virhostdevtest.c | 2 +-
15 files changed, 44 insertions(+), 42 deletions(-)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 7513beb5e1..3a7a6c3f99 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -43,6 +43,10 @@ typedef enum {
VIR_ENUM_DECL(virDeviceHostdevPCIDriver);
+struct _virDeviceHostdevPCIDriverInfo {
+ virDeviceHostdevPCIDriverType type;
+};
+
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 1d3e46604a..e322f1ffa7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6271,7 +6271,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
if (virXMLPropEnum(driver_node, "name",
virDeviceHostdevPCIDriverTypeFromString,
VIR_XML_PROP_NONZERO,
- &pcisrc->backend) < 0) {
+ &pcisrc->driver.type) < 0) {
return -1;
}
}
@@ -23333,18 +23333,18 @@ 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_TYPE_DEFAULT) {
- const char *backend
- = virDeviceHostdevPCIDriverTypeToString(pcisrc->backend);
+ if (pcisrc->driver.type != VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT) {
+ const char *driverType
+ = virDeviceHostdevPCIDriverTypeToString(pcisrc->driver.type);
- if (!backend) {
+ if (!driverType) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected pci hostdev driver name type %1$d"),
- pcisrc->backend);
+ _("unexpected pci hostdev driver type %1$d"),
+ pcisrc->driver.type);
return -1;
}
- virBufferAsprintf(&driverAttrBuf, " name='%s'", backend);
+ virBufferAsprintf(&driverAttrBuf, " name='%s'",
driverType);
}
virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
@@ -29838,17 +29838,17 @@ 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 =
+ actual->data.hostdev.def.source.subsys.u.pci.driver.type =
VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT;
break;
case VIR_NETWORK_FORWARD_DRIVER_NAME_KVM:
- actual->data.hostdev.def.source.subsys.u.pci.backend =
+ actual->data.hostdev.def.source.subsys.u.pci.driver.type =
VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_KVM;
break;
case VIR_NETWORK_FORWARD_DRIVER_NAME_VFIO:
- actual->data.hostdev.def.source.subsys.u.pci.backend =
+ actual->data.hostdev.def.source.subsys.u.pci.driver.type =
VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO;
break;
@@ -29959,7 +29959,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.type) {
case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT:
port->plug.hostdevpci.driver = VIR_NETWORK_FORWARD_DRIVER_NAME_DEFAULT;
break;
@@ -29973,14 +29973,10 @@ virDomainNetDefActualToNetworkPort(virDomainDef *dom,
break;
case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Unexpected PCI backend 'xen'"));
- break;
-
case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST:
default:
virReportEnumRangeError(virDeviceHostdevPCIDriverType,
-
actual->data.hostdev.def.source.subsys.u.pci.backend);
+
actual->data.hostdev.def.source.subsys.u.pci.driver.type);
return NULL;
}
@@ -30924,7 +30920,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_TYPE_VFIO;
+ hostdev->source.subsys.u.pci.driver.type ==
VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 57e06dd935..855e09d236 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 */
- virDeviceHostdevPCIDriverType 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 ce7189ffcd..a33b3b604f 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_TYPE_VFIO) {
+ if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO) {
virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_VFIO);
- } else if (pcisrc->backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN) {
+ } else if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN) {
virPCIDeviceSetStubDriverType(actual, VIR_PCI_STUB_DRIVER_XEN);
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("pci backend driver type '%1$s' is not
supported"),
- virDeviceHostdevPCIDriverTypeToString(pcisrc->backend));
+ virDeviceHostdevPCIDriverTypeToString(pcisrc->driver.type));
return -1;
}
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 904f40914c..22482adfa6 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_TYPE_DEFAULT)
- pcisrc->backend = VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN;
+ pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT)
+ pcisrc->driver.type = VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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_TYPE_XEN;
+ pcisrc->driver.type = VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_XEN;
if (virDomainHostdevInsert(def, hostdev) < 0)
return -1;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index d04ec7f6ea..7f12b11b8d 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_TYPE_DEFAULT, we need to set
- * backend correctly.
+ * driver type 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_TYPE_XEN;
+ pcisrc->driver.type = VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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 3bcd0d3aa8..5847d5549d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4711,7 +4711,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
const char *failover_pair_id = NULL;
/* caller has to assign proper passthrough backend type */
- switch (pcisrc->backend) {
+ switch (pcisrc->driver.type) {
case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO:
break;
@@ -4721,7 +4721,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
case VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid PCI passthrough type '%1$s'"),
- virDeviceHostdevPCIDriverTypeToString(pcisrc->backend));
+ virDeviceHostdevPCIDriverTypeToString(pcisrc->driver.type));
return NULL;
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index cf95b2cce3..09735ba710 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -10568,7 +10568,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_TYPE_VFIO) {
+ if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO) {
if (!(tmpPath =
virPCIDeviceAddressGetIOMMUGroupDev(&pcisrc->addr)))
return -1;
@@ -11333,7 +11333,7 @@ qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev,
{
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
virDeviceHostdevPCIDriverType *driverType
- = &hostdev->source.subsys.u.pci.backend;
+ = &hostdev->source.subsys.u.pci.driver.type;
/* assign defaults for hostdev passthrough */
switch (*driverType) {
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 83365f6685..d958d01638 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;
+ virDeviceHostdevPCIDriverType driverType;
/* 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;
+ driverType = hostdev->source.subsys.u.pci.driver.type;
- if (backend == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO) {
+ if (driverType == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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 515d68ec6b..5ccc294773 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_TYPE_VFIO) {
+ if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO) {
char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci);
if (!vfioGroupDev) {
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index ff28e17136..31997474a4 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_TYPE_VFIO) {
+ if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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_TYPE_VFIO) {
+ if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO) {
g_autofree char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci);
if (!vfioGroupDev)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 89ceaf48d7..9a65c3a9f1 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_TYPE_VFIO) {
+ if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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_TYPE_VFIO) {
+ if (pcisrc->driver.type == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_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 ac4225a783..dab181de47 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1093,7 +1093,7 @@ get_files(vahControl * ctl)
virPCIDevice *pci =
virPCIDeviceNew(&dev->source.subsys.u.pci.addr);
virDeviceHostdevPCIDriverType driverType
- = dev->source.subsys.u.pci.backend;
+ = dev->source.subsys.u.pci.driver.type;
if (driverType == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO ||
driverType == VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_DEFAULT) {
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index d9ff992e91..e375fb2833 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_TYPE_VFIO;
+ subsys->u.pci.driver.type = VIR_DEVICE_HOSTDEV_PCI_DRIVER_TYPE_VFIO;
}
for (i = 0; i < nhostdevs; i++) {
--
2.41.0