[PATCH 7/9] qemu: format intremap= on intel-iommu command line

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

 



Add the intremap= option to QEMU command line, corresponding
to the <driver intremap> attribute of the iommu device.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
---
 src/qemu/qemu_capabilities.c                       |  8 ++++
 src/qemu/qemu_capabilities.h                       |  1 +
 src/qemu/qemu_command.c                            | 11 +++++
 .../qemucapabilitiesdata/caps_2.4.0.x86_64.replies | 22 +++++++---
 .../qemucapabilitiesdata/caps_2.5.0.x86_64.replies | 24 +++++++----
 .../qemucapabilitiesdata/caps_2.6.0.x86_64.replies | 24 +++++++----
 .../qemucapabilitiesdata/caps_2.7.0.x86_64.replies | 28 +++++++++----
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |  1 +
 .../qemucapabilitiesdata/caps_2.8.0.x86_64.replies | 37 ++++++++++++----
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |  1 +
 .../qemucapabilitiesdata/caps_2.9.0.x86_64.replies | 49 ++++++++++++++++++----
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
 .../qemuxml2argv-intel-iommu-irqchip.args          |  2 +-
 tests/qemuxml2argvtest.c                           |  1 +
 14 files changed, 166 insertions(+), 44 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 278badf..e9cc754 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -364,6 +364,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
 
               "query-cpu-definitions", /* 250 */
               "kernel-irqchip",
+              "intel-iommu-intremap",
     );
 
 
@@ -1732,6 +1733,10 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBNECXHCI[] = {
     { "p3", QEMU_CAPS_NEC_USB_XHCI_PORTS },
 };
 
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
+    { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
+};
+
 /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
 static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
     { "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
@@ -1839,6 +1844,9 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
     { "nec-usb-xhci", virQEMUCapsObjectPropsUSBNECXHCI,
       ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI),
       -1 },
+    { "intel-iommu", virQEMUCapsObjectPropsIntelIOMMU,
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIntelIOMMU),
+      QEMU_CAPS_DEVICE_INTEL_IOMMU},
 };
 
 struct virQEMUCapsPropTypeObjects {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index b9efab8..16db17f 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -400,6 +400,7 @@ typedef enum {
     /* 250 */
     QEMU_CAPS_QUERY_CPU_DEFINITIONS, /* qmp query-cpu-definitions */
     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
+    QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */
 
     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 c1c7f1a..ddd889d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6652,6 +6652,16 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
             return -1;
         }
         virBufferAddLit(&opts, "intel-iommu");
+        if (iommu->intremap) {
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_INTREMAP)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("iommu: interrupt remapping is not supported "
+                                 "with this QEMU binary"));
+                goto cleanup;
+            }
+            virBufferAsprintf(&opts, ",intremap=%s",
+                              virTristateSwitchTypeToString(iommu->intremap));
+        }
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
         break;
     }
@@ -6659,6 +6669,7 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
     virCommandAddArgBuffer(cmd, &opts);
 
     ret = 0;
+ cleanup:
     virBufferFreeAndReset(&opts);
     return ret;
 }
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
index 6822181..9f256c4 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies
@@ -3123,6 +3123,16 @@
 {
   "return": [
     {
+      "name": "version",
+      "type": "uint32"
+    }
+  ],
+  "id": "libvirt-41"
+}
+
+{
+  "return": [
+    {
       "name": "pc-i440fx-2.4",
       "is-default": true,
       "cpu-max": 255,
@@ -3246,7 +3256,7 @@
       "cpu-max": 255
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -3336,21 +3346,21 @@
       "name": "qemu64"
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "return": [
     "tpm-tis"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
   "return": [
     "passthrough"
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -4358,7 +4368,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -4388,7 +4398,7 @@
       "capability": "events"
     }
   ],
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies
index 2eeed7d..876bc2f 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies
@@ -3286,6 +3286,16 @@
 {
   "return": [
     {
+      "name": "version",
+      "type": "uint32"
+    }
+  ],
+  "id": "libvirt-41"
+}
+
+{
+  "return": [
+    {
       "name": "pc-i440fx-2.4",
       "cpu-max": 255
     },
@@ -3417,7 +3427,7 @@
       "cpu-max": 255
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -3507,21 +3517,21 @@
       "name": "qemu64"
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "return": [
     "tpm-tis"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
   "return": [
     "passthrough"
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -4566,7 +4576,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -4600,7 +4610,7 @@
       "capability": "x-postcopy-ram"
     }
   ],
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
@@ -12145,7 +12155,7 @@
       "meta-type": "array"
     }
   ],
-  "id": "libvirt-47"
+  "id": "libvirt-48"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies
index 0c285cd..d6d0b57 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies
@@ -3368,6 +3368,16 @@
 {
   "return": [
     {
+      "name": "version",
+      "type": "uint32"
+    }
+  ],
+  "id": "libvirt-41"
+}
+
+{
+  "return": [
+    {
       "name": "pc-0.12",
       "cpu-max": 255
     },
@@ -3475,7 +3485,7 @@
       "cpu-max": 255
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -3565,21 +3575,21 @@
       "name": "qemu64"
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "return": [
     "tpm-tis"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
   "return": [
     "passthrough"
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -4673,7 +4683,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -4707,7 +4717,7 @@
       "capability": "postcopy-ram"
     }
   ],
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
@@ -12712,7 +12722,7 @@
       "meta-type": "array"
     }
   ],
-  "id": "libvirt-47"
+  "id": "libvirt-48"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies
index 4a87237..671a958 100644
--- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies
@@ -3559,6 +3559,20 @@
 {
   "return": [
     {
+      "name": "version",
+      "type": "uint32"
+    },
+    {
+      "name": "intremap",
+      "type": "bool"
+    }
+  ],
+  "id": "libvirt-41"
+}
+
+{
+  "return": [
+    {
       "hotpluggable-cpus": true,
       "name": "pc-0.12",
       "cpu-max": 255
@@ -3702,7 +3716,7 @@
       "cpu-max": 255
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -3795,21 +3809,21 @@
       "name": "qemu64"
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "return": [
     "tpm-tis"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
   "return": [
     "passthrough"
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -4907,7 +4921,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -4941,7 +4955,7 @@
       "capability": "postcopy-ram"
     }
   ],
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
@@ -13297,7 +13311,7 @@
       "meta-type": "object"
     }
   ],
-  "id": "libvirt-47"
+  "id": "libvirt-48"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
index 0bc3dcd..5399afe 100644
--- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
@@ -201,6 +201,7 @@
   <flag name='drive-iotune-group'/>
   <flag name='query-cpu-definitions'/>
   <flag name='kernel-irqchip'/>
+  <flag name='intel-iommu-intremap'/>
   <version>2007000</version>
   <kvmVersion>0</kvmVersion>
   <package> (v2.7.0)</package>
diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies
index b3ad912..3087d76 100644
--- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies
@@ -3692,6 +3692,29 @@
 {
   "return": [
     {
+      "name": "eim",
+      "description": "on/off/auto",
+      "type": "OnOffAuto"
+    },
+    {
+      "name": "x-buggy-eim",
+      "type": "bool"
+    },
+    {
+      "name": "intremap",
+      "type": "bool"
+    },
+    {
+      "name": "version",
+      "type": "uint32"
+    }
+  ],
+  "id": "libvirt-41"
+}
+
+{
+  "return": [
+    {
       "hotpluggable-cpus": true,
       "name": "pc-0.12",
       "cpu-max": 255
@@ -3855,7 +3878,7 @@
       "cpu-max": 255
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -4061,21 +4084,21 @@
       "static": false
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "return": [
     "tpm-tis"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
   "return": [
     "passthrough"
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -5198,7 +5221,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -5236,7 +5259,7 @@
       "capability": "x-colo"
     }
   ],
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
@@ -14006,7 +14029,7 @@
       "meta-type": "object"
     }
   ],
-  "id": "libvirt-47"
+  "id": "libvirt-48"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
index fd0c927..07dbc08 100644
--- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
@@ -202,6 +202,7 @@
   <flag name='drive-iotune-group'/>
   <flag name='query-cpu-definitions'/>
   <flag name='kernel-irqchip'/>
+  <flag name='intel-iommu-intremap'/>
   <version>2008000</version>
   <kvmVersion>0</kvmVersion>
   <package> (v2.8.0)</package>
diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies
index b6fd750..7a25ba8 100644
--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies
@@ -4003,6 +4003,37 @@
 {
   "return": [
     {
+      "name": "eim",
+      "description": "on/off/auto",
+      "type": "OnOffAuto"
+    },
+    {
+      "name": "caching-mode",
+      "type": "bool"
+    },
+    {
+      "name": "x-buggy-eim",
+      "type": "bool"
+    },
+    {
+      "name": "intremap",
+      "type": "bool"
+    },
+    {
+      "name": "version",
+      "type": "uint32"
+    },
+    {
+      "name": "device-iotlb",
+      "type": "bool"
+    }
+  ],
+  "id": "libvirt-41"
+}
+
+{
+  "return": [
+    {
       "hotpluggable-cpus": true,
       "name": "pc-0.12",
       "cpu-max": 255
@@ -4176,7 +4207,7 @@
       "cpu-max": 255
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -4458,21 +4489,21 @@
       "migration-safe": true
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "return": [
     "tpm-tis"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
   "return": [
     "passthrough"
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -5721,7 +5752,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -5763,7 +5794,7 @@
       "capability": "release-ram"
     }
   ],
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
@@ -14888,7 +14919,7 @@
       "meta-type": "object"
     }
   ],
-  "id": "libvirt-47"
+  "id": "libvirt-48"
 }
 
 {
@@ -15067,7 +15098,7 @@
       }
     }
   },
-  "id": "libvirt-48"
+  "id": "libvirt-49"
 }
 
 {
@@ -15308,7 +15339,7 @@
       }
     }
   },
-  "id": "libvirt-49"
+  "id": "libvirt-50"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
index 9dcb84e..0798b7d 100644
--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
@@ -206,6 +206,7 @@
   <flag name='pcie-root-port'/>
   <flag name='query-cpu-definitions'/>
   <flag name='kernel-irqchip'/>
+  <flag name='intel-iommu-intremap'/>
   <version>2008090</version>
   <kvmVersion>0</kvmVersion>
   <package> (v2.9.0-rc0-142-g940a8ce)</package>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args
index ebf9c3e..d704ee4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-irqchip.args
@@ -16,4 +16,4 @@ QEMU_AUDIO_DRV=none \
 -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
 -no-acpi \
 -boot c \
--device intel-iommu
+-device intel-iommu,intremap=on
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 11f6130..2051af9 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2478,6 +2478,7 @@ mymain(void)
     DO_TEST("intel-iommu-irqchip",
             QEMU_CAPS_MACHINE_OPT,
             QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
+            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
             QEMU_CAPS_DEVICE_INTEL_IOMMU);
 
     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
-- 
2.10.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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