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>
---
docs/schemas/domaincommon.rng | 63 +++++++++++++++++++----------------
src/conf/domain_conf.c | 37 +++++++++++++-------
src/conf/domain_conf.h | 1 +
3 files changed, 60 insertions(+), 41 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4d6bf906fb..f19c4eeb21 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5418,35 +5418,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>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5102857d5e..146c11bb47 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2552,6 +2552,7 @@ virDomainIOMMUDefFree(virDomainIOMMUDef *iommu)
if (!iommu)
return;
+ virDomainDeviceInfoClear(&iommu->info);
g_free(iommu);
}
@@ -4241,13 +4242,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:
@@ -4543,6 +4545,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;
@@ -4570,12 +4579,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 */
@@ -14940,8 +14943,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;
@@ -14977,6 +14982,10 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
return NULL;
}
+ if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt,
+ &iommu->info, flags) < 0)
+ return NULL;
+
return g_steal_pointer(&iommu);
}
@@ -15174,7 +15183,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:
@@ -20325,7 +20335,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);
@@ -22179,7 +22190,7 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDef *src,
return false;
}
- return true;
+ return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
}
@@ -27566,6 +27577,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 486f2f7a2e..d8621e2d4f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2715,6 +2715,7 @@ struct _virDomainIOMMUDef {
virTristateSwitch eim;
virTristateSwitch iotlb;
unsigned int aw_bits;
+ virDomainDeviceInfo info;
};
typedef enum {
--
2.31.1