]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Validate capabilities for virtio-iommu
authorAndrea Bolognani <abologna@redhat.com>
Thu, 7 Oct 2021 17:35:45 +0000 (19:35 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 1 Apr 2022 17:30:59 +0000 (19:30 +0200)
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_validate.c
tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-6.1.0.err [new file with mode: 0644]
tests/qemuxml2argvtest.c

index eb3200712cf5bdc258f548d202a10ab1a0c649d8..f67c802cbf72fa6a261ad2e73da924fa96c7506d 100644 (file)
@@ -4874,6 +4874,14 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
                            virDomainIOMMUModelTypeToString(iommu->model));
             return -1;
         }
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_IOMMU_PCI) ||
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_IOMMU_BOOT_BYPASS)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("IOMMU device: '%s' is not supported with "
+                             "this QEMU binary"),
+                           virDomainIOMMUModelTypeToString(iommu->model));
+            return -1;
+        }
         break;
 
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
diff --git a/tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-6.1.0.err b/tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-6.1.0.err
new file mode 100644 (file)
index 0000000..e76e154
--- /dev/null
@@ -0,0 +1 @@
+unsupported configuration: IOMMU device: 'virtio' is not supported with this QEMU binary
index f4c5c5bb3129db3ba949dd2b8f3a675130b2021c..bc01d60e12d9bf33ef09d91e2c30b66eb9aaba11 100644 (file)
@@ -3248,6 +3248,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
     DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
     DO_TEST_CAPS_LATEST("virtio-iommu-x86_64");
+    DO_TEST_CAPS_VER_PARSE_ERROR("virtio-iommu-x86_64", "6.1.0");
     DO_TEST_CAPS_ARCH_LATEST("virtio-iommu-aarch64", "aarch64");
     DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-iommu-wrong-machine");