From 3b296a98aaf43310f85f7e51d89791b985204173 Mon Sep 17 00:00:00 2001 From: Han Han Date: Wed, 25 Sep 2024 15:59:52 +0800 Subject: [PATCH] domain_validate: Validate dma_translation for iommu models The attribute dma_translation is only supported by intel-iommu device. Report an error when it is used for the other iommu devices. Fixes: 6866f958c1 Signed-off-by: Han Han Reviewed-by: Martin Kletzander --- src/conf/domain_validate.c | 3 ++- ...io-iommu-dma-translation.x86_64-latest.err | 1 + .../virtio-iommu-dma-translation.xml | 20 +++++++++++++++++++ tests/qemuxmlconftest.c | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err create mode 100644 tests/qemuxmlconfdata/virtio-iommu-dma-translation.xml diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index eddb4a5e74..b8ae9ed79d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2980,7 +2980,8 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu) iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT || iommu->eim != VIR_TRISTATE_SWITCH_ABSENT || iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT || - iommu->aw_bits != 0) { + iommu->aw_bits != 0 || + iommu->dma_translation != VIR_TRISTATE_SWITCH_ABSENT) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%1$s' doesn't support additional attributes"), virDomainIOMMUModelTypeToString(iommu->model)); diff --git a/tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err b/tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err new file mode 100644 index 0000000000..2c3a272725 --- /dev/null +++ b/tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err @@ -0,0 +1 @@ +XML error: iommu model 'virtio' doesn't support additional attributes diff --git a/tests/qemuxmlconfdata/virtio-iommu-dma-translation.xml b/tests/qemuxmlconfdata/virtio-iommu-dma-translation.xml new file mode 100644 index 0000000000..a3723f266b --- /dev/null +++ b/tests/qemuxmlconfdata/virtio-iommu-dma-translation.xml @@ -0,0 +1,20 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 1 + + hvm + + + + + + /usr/bin/qemu-system-x86_64 + + + + + + + diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 61eb4cda75..dfcf67d2d0 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -2766,6 +2766,7 @@ mymain(void) DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-iommu-no-acpi"); DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-iommu-invalid-address-type"); DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-iommu-invalid-address"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-iommu-dma-translation"); DO_TEST_CAPS_LATEST("cpu-hotplug-startup"); DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("cpu-hotplug-granularity", "ppc64"); -- 2.39.5