This is needed so that IOMMU devices can have addresses.
Existing IOMMU devices (intel-iommu and SMMUv3) are system
devices and as such don't have an address associated to them, but
virtio-iommu is a PCI device and needs one.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/domain_conf.c | 37 ++++++++++++------
src/conf/domain_conf.h | 1 +
src/conf/schemas/domaincommon.rng | 63 +++++++++++++++++--------------
3 files changed, 60 insertions(+), 41 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2295d73ff2..77671c233f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2581,6 +2581,7 @@ virDomainIOMMUDefFree(virDomainIOMMUDef *iommu)
if (!iommu)
return;
+ virDomainDeviceInfoClear(&iommu->info);
g_free(iommu);
}
@@ -4276,13 +4277,14 @@ virDomainDeviceGetInfo(const virDomainDeviceDef *device)
return &device->data.panic->info;
case VIR_DOMAIN_DEVICE_MEMORY:
return &device->data.memory->info;
+ case VIR_DOMAIN_DEVICE_IOMMU:
+ return &device->data.iommu->info;
case VIR_DOMAIN_DEVICE_VSOCK:
return &device->data.vsock->info;
/* The following devices do not contain virDomainDeviceInfo */
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_GRAPHICS:
- case VIR_DOMAIN_DEVICE_IOMMU:
case VIR_DOMAIN_DEVICE_AUDIO:
case VIR_DOMAIN_DEVICE_LAST:
case VIR_DOMAIN_DEVICE_NONE:
@@ -4578,6 +4580,13 @@ virDomainDeviceInfoIterateFlags(virDomainDef *def,
return rc;
}
+ device.type = VIR_DOMAIN_DEVICE_IOMMU;
+ if (def->iommu) {
+ device.data.iommu = def->iommu;
+ if ((rc = cb(def, &device, &def->iommu->info, opaque)) != 0)
+ return rc;
+ }
+
device.type = VIR_DOMAIN_DEVICE_VSOCK;
if (def->vsock) {
device.data.vsock = def->vsock;
@@ -4605,12 +4614,6 @@ virDomainDeviceInfoIterateFlags(virDomainDef *def,
if ((rc = cb(def, &device, NULL, opaque)) != 0)
return rc;
}
- device.type = VIR_DOMAIN_DEVICE_IOMMU;
- if (def->iommu) {
- device.data.iommu = def->iommu;
- if ((rc = cb(def, &device, NULL, opaque)) != 0)
- return rc;
- }
}
/* Coverity is not very happy with this - all dead_error_condition */
@@ -14797,8 +14800,10 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xmlopt,
static virDomainIOMMUDef *
-virDomainIOMMUDefParseXML(xmlNodePtr node,
- xmlXPathContextPtr ctxt)
+virDomainIOMMUDefParseXML(virDomainXMLOption *xmlopt,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ unsigned int flags)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr driver;
@@ -14834,6 +14839,10 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
return NULL;
}
+ if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt,
+ &iommu->info, flags) < 0)
+ return NULL;
+
return g_steal_pointer(&iommu);
}
@@ -15031,7 +15040,8 @@ virDomainDeviceDefParse(const char *xmlStr,
return NULL;
break;
case VIR_DOMAIN_DEVICE_IOMMU:
- if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node, ctxt)))
+ if (!(dev->data.iommu = virDomainIOMMUDefParseXML(xmlopt, node,
+ ctxt, flags)))
return NULL;
break;
case VIR_DOMAIN_DEVICE_VSOCK:
@@ -20166,7 +20176,8 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
}
if (n > 0) {
- if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0], ctxt)))
+ if (!(def->iommu = virDomainIOMMUDefParseXML(xmlopt, nodes[0],
+ ctxt, flags)))
return NULL;
}
VIR_FREE(nodes);
@@ -22030,7 +22041,7 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDef *src,
return false;
}
- return true;
+ return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
}
@@ -27432,6 +27443,8 @@ virDomainIOMMUDefFormat(virBuffer *buf,
virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL);
+ virDomainDeviceInfoFormat(&childBuf, &iommu->info, 0);
+
virBufferAsprintf(&attrBuf, " model='%s'",
virDomainIOMMUModelTypeToString(iommu->model));
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bad0004b3c..1ef3dc8a2b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2767,6 +2767,7 @@ struct _virDomainIOMMUDef {
virTristateSwitch eim;
virTristateSwitch iotlb;
unsigned int aw_bits;
+ virDomainDeviceInfo info;
};
typedef enum {
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 3951ef3e04..8345976e81 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -5460,35 +5460,40 @@
<value>virtio</value>
</choice>
</attribute>
- <optional>
- <element name="driver">
- <optional>
- <attribute name="intremap">
- <ref name="virOnOff"/>
- </attribute>
- </optional>
- <optional>
- <attribute name="caching_mode">
- <ref name="virOnOff"/>
- </attribute>
- </optional>
- <optional>
- <attribute name="eim">
- <ref name="virOnOff"/>
- </attribute>
- </optional>
- <optional>
- <attribute name="iotlb">
- <ref name="virOnOff"/>
- </attribute>
- </optional>
- <optional>
- <attribute name="aw_bits">
- <ref name="uint8"/>
- </attribute>
- </optional>
- </element>
- </optional>
+ <interleave>
+ <optional>
+ <element name="driver">
+ <optional>
+ <attribute name="intremap">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="caching_mode">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="eim">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="iotlb">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="aw_bits">
+ <ref name="uint8"/>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
+ <optional>
+ <ref name="address"/>
+ </optional>
+ </interleave>
</element>
</define>
--
2.35.1