From: Ján Tomko <jto...@redhat.com> For the newly supported AMD device.
Signed-off-by: Ján Tomko <jto...@redhat.com> --- docs/formatdomain.rst | 8 ++++++++ src/conf/domain_conf.c | 30 +++++++++++++++++++++++++++++ src/conf/domain_conf.h | 2 ++ src/conf/schemas/domaincommon.rng | 10 ++++++++++ tests/qemuxmlconfdata/amd-iommu.xml | 2 +- 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1fa814931f..7af14c656f 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -9092,6 +9092,14 @@ Example: example to efficiently enable more than 255 vCPUs. :since:`Since 10.7.0` (QEMU/KVM and ``intel`` model only) + ``passthrough`` + Enable passthrough. In this mode, DMA read/writes are not translated. + :since:`Since 11.5.0` (QEMU/KVM and ``amd`` model only) + + ``xtsup`` + Enable x2APIC mode. Useful for higher number of guest CPUs. + :since:`Since 11.5.0` (QEMU/KVM and ``amd`` model only) + The ``virtio`` IOMMU devices can further have ``address`` element as described in `Device addresses`_ (address has to by type of ``pci``). diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2e7454f4d6..c20fe0e241 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14333,6 +14333,14 @@ virDomainIOMMUDefParseXML(virDomainXMLOption *xmlopt, if (virXMLPropTristateSwitch(driver, "dma_translation", VIR_XML_PROP_NONE, &iommu->dma_translation) < 0) return NULL; + + if (virXMLPropTristateSwitch(driver, "xtsup", VIR_XML_PROP_NONE, + &iommu->xtsup) < 0) + return NULL; + + if (virXMLPropTristateSwitch(driver, "passthrough", VIR_XML_PROP_NONE, + &iommu->pt) < 0) + return NULL; } if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, @@ -21963,6 +21971,20 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDef *src, virTristateSwitchTypeToString(src->dma_translation)); return false; } + if (src->pt != dst->pt) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device dma translation '%1$s' does not match source '%2$s'"), + virTristateSwitchTypeToString(dst->pt), + virTristateSwitchTypeToString(src->pt)); + return false; + } + if (src->xtsup != dst->xtsup) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device dma translation '%1$s' does not match source '%2$s'"), + virTristateSwitchTypeToString(dst->xtsup), + virTristateSwitchTypeToString(src->xtsup)); + return false; + } return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } @@ -28190,6 +28212,14 @@ virDomainIOMMUDefFormat(virBuffer *buf, virBufferAsprintf(&driverAttrBuf, " dma_translation='%s'", virTristateSwitchTypeToString(iommu->dma_translation)); } + if (iommu->pt != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " passthrough='%s'", + virTristateSwitchTypeToString(iommu->pt)); + } + if (iommu->xtsup != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " xtsup='%s'", + virTristateSwitchTypeToString(iommu->xtsup)); + } virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bcac061aa6..d1ee598eb0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3019,6 +3019,8 @@ struct _virDomainIOMMUDef { unsigned int aw_bits; virDomainDeviceInfo info; virTristateSwitch dma_translation; + virTristateSwitch xtsup; + virTristateSwitch pt; }; typedef enum { diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index f135e6f1d7..b180ab46c7 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6226,6 +6226,16 @@ <ref name="virOnOff"/> </attribute> </optional> + <optional> + <attribute name="xtsup"> + <ref name="virOnOff"/> + </attribute> + </optional> + <optional> + <attribute name="passthrough"> + <ref name="virOnOff"/> + </attribute> + </optional> </element> </optional> <optional> diff --git a/tests/qemuxmlconfdata/amd-iommu.xml b/tests/qemuxmlconfdata/amd-iommu.xml index 0668ed4237..4ad79ce4ae 100644 --- a/tests/qemuxmlconfdata/amd-iommu.xml +++ b/tests/qemuxmlconfdata/amd-iommu.xml @@ -32,7 +32,7 @@ <watchdog model='itco' action='reset'/> <memballoon model='none'/> <iommu model='amd'> - <driver intremap='on' iotlb='on'/> + <driver intremap='on' iotlb='on' passthrough='on' xtsup='on'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> </iommu> </devices> -- 2.49.0