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>
---
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 deef019ded..f8786fe31c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5450,35 +5450,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 99e82bc5f9..315feb4b0d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2578,6 +2578,7 @@ virDomainIOMMUDefFree(virDomainIOMMUDef *iommu)
if (!iommu)
return;
+ virDomainDeviceInfoClear(&iommu->info);
g_free(iommu);
}
@@ -4273,13 +4274,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:
@@ -4575,6 +4577,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;
@@ -4602,12 +4611,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 */
@@ -14794,8 +14797,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;
@@ -14831,6 +14836,10 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
return NULL;
}
+ if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt,
+ &iommu->info, flags) < 0)
+ return NULL;
+
return g_steal_pointer(&iommu);
}
@@ -15028,7 +15037,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:
@@ -20156,7 +20166,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);
@@ -22020,7 +22031,7 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDef *src,
return false;
}
- return true;
+ return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
}
@@ -27422,6 +27433,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 f6ffcf985c..8eafdb0c30 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2765,6 +2765,7 @@ struct _virDomainIOMMUDef {
virTristateSwitch eim;
virTristateSwitch iotlb;
unsigned int aw_bits;
+ virDomainDeviceInfo info;
};
typedef enum {
--
2.35.1