[PATCH 2/2] qemu: format address wdith on intel-iommu command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Format the address width attribute. Depending on the version of
QEMU it is named 'aw-bits' or 'x-aw-bits'.

Signed-off-by: Menno Lageman <menno.lageman@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c                  |  6 ++++
 src/qemu/qemu_capabilities.h                  |  4 +++
 src/qemu/qemu_command.c                       |  6 ++++
 src/qemu/qemu_validate.c                      |  9 ++++-
 .../caps_2.12.0.x86_64.xml                    |  1 +
 .../caps_3.0.0.x86_64.xml                     |  1 +
 .../caps_3.1.0.x86_64.xml                     |  1 +
 .../caps_4.0.0.x86_64.xml                     |  1 +
 .../caps_4.1.0.x86_64.xml                     |  1 +
 .../caps_4.2.0.x86_64.xml                     |  1 +
 .../caps_5.0.0.x86_64.xml                     |  1 +
 .../caps_5.1.0.x86_64.xml                     |  1 +
 .../intel-iommu-aw-bits.x86_64-latest.args    | 33 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  1 +
 14 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f12769635a86..fa305bf67f33 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -582,6 +582,10 @@ VIR_ENUM_IMPL(virQEMUCaps,
               "tcg",
               "virtio-blk-pci.scsi.default.disabled",
               "pvscsi",
+
+              /* 370 */
+              "intel-iommu.x-aw-bits",
+              "intel-iommu.aw-bits",
     );
 
 
@@ -1469,6 +1473,8 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsIntelIOMMU[] = {
     { "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE, NULL },
     { "eim", QEMU_CAPS_INTEL_IOMMU_EIM, NULL },
     { "device-iotlb", QEMU_CAPS_INTEL_IOMMU_DEVICE_IOTLB, NULL },
+    { "x-aw-bits", QEMU_CAPS_INTEL_IOMMU_X_AW_BITS, NULL },
+    { "aw-bits", QEMU_CAPS_INTEL_IOMMU_AW_BITS, NULL },
 };
 
 static struct virQEMUCapsDevicePropsFlags virQEMUCapsObjectPropsVirtualCSSBridge[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 076ecad0f73b..c14561a4e70c 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -564,6 +564,10 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     QEMU_CAPS_VIRTIO_BLK_SCSI_DEFAULT_DISABLED, /* virtio-blk-pci.scsi disabled by default */
     QEMU_CAPS_SCSI_PVSCSI, /* -device pvscsi */
 
+    /* 370 */
+    QEMU_CAPS_INTEL_IOMMU_X_AW_BITS, /* intel-iommu.x-aw-bits */
+    QEMU_CAPS_INTEL_IOMMU_AW_BITS, /* intel-iommu.aw-bits */
+
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 419eca5675cc..adcb48a66f18 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6157,6 +6157,12 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
             virBufferAsprintf(&opts, ",device-iotlb=%s",
                               virTristateSwitchTypeToString(iommu->iotlb));
         }
+        if (iommu->aw_bits > 0) {
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_AW_BITS))
+                virBufferAsprintf(&opts, ",aw-bits=%d", iommu->aw_bits);
+            else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_X_AW_BITS))
+                virBufferAsprintf(&opts, ",x-aw-bits=%d", iommu->aw_bits);
+        }
 
         virCommandAddArg(cmd, "-device");
         virCommandAddArgBuffer(cmd, &opts);
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 584d1375b857..c7bcb77013b5 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -3858,7 +3858,14 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
                          "with this QEMU binary"));
         return -1;
     }
-
+    if (iommu->aw_bits > 0 &&
+        !(virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_X_AW_BITS) ||
+        virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_AW_BITS))) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("iommu: aw_bits is not supported "
+                         "with this QEMU binary"));
+        return -1;
+    }
     return 0;
 }
 
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
index 319dd6f2c3a5..9b632f025956 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
@@ -200,6 +200,7 @@
   <flag name='i8042'/>
   <flag name='tcg'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.x-aw-bits'/>
   <version>2011090</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100289</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
index 40cff641a89a..babbb5c0eec5 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
@@ -206,6 +206,7 @@
   <flag name='storage.werror'/>
   <flag name='tcg'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.x-aw-bits'/>
   <version>3000000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100239</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml
index 3dbda4b3f30c..73f8927a1e9d 100644
--- a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml
@@ -209,6 +209,7 @@
   <flag name='storage.werror'/>
   <flag name='tcg'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.x-aw-bits'/>
   <version>3000092</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100240</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
index bf7735caf340..bae15e771da9 100644
--- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
@@ -214,6 +214,7 @@
   <flag name='storage.werror'/>
   <flag name='tcg'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.aw-bits'/>
   <version>4000000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100240</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
index 8ce0f80e8a2c..e17ae7ffb04c 100644
--- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
@@ -220,6 +220,7 @@
   <flag name='storage.werror'/>
   <flag name='tcg'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.aw-bits'/>
   <version>4001000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100241</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
index 50ed35f092b3..e0685887e10a 100644
--- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
@@ -228,6 +228,7 @@
   <flag name='virtio.packed'/>
   <flag name='tcg'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.aw-bits'/>
   <version>4002000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100242</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml
index ba39fef7135d..538c8a8c8bcd 100644
--- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml
@@ -234,6 +234,7 @@
   <flag name='tcg'/>
   <flag name='virtio-blk-pci.scsi.default.disabled'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.aw-bits'/>
   <version>5000000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100241</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml
index c2bc121f737c..2380618fed6f 100644
--- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml
@@ -234,6 +234,7 @@
   <flag name='tcg'/>
   <flag name='virtio-blk-pci.scsi.default.disabled'/>
   <flag name='pvscsi'/>
+  <flag name='intel-iommu.aw-bits'/>
   <version>5000050</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100242</microcodeVersion>
diff --git a/tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args b/tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args
new file mode 100644
index 000000000000..0ce0952b5152
--- /dev/null
+++ b/tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args
@@ -0,0 +1,33 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine q35,accel=kvm,usb=off,dump-guest-core=off,kernel_irqchip=split \
+-cpu qemu64 \
+-m 214 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device intel-iommu,intremap=on,aw-bits=48 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3103cac884d7..c5eda14b3bf9 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -3122,6 +3122,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST("intel-iommu-caching-mode");
     DO_TEST_CAPS_LATEST("intel-iommu-eim");
     DO_TEST_CAPS_LATEST("intel-iommu-device-iotlb");
+    DO_TEST_CAPS_LATEST("intel-iommu-aw-bits");
     DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine");
     DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
 
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux