render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3e5111
From d5e2a0cc600ea90645df6161b662cf32a16a7a1b Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <d5e2a0cc600ea90645df6161b662cf32a16a7a1b@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Tue, 16 May 2017 10:44:57 +0200
3e5111
Subject: [PATCH] qemu: format caching-mode on iommu command line
3e5111
MIME-Version: 1.0
3e5111
Content-Type: text/plain; charset=UTF-8
3e5111
Content-Transfer-Encoding: 8bit
3e5111
3e5111
Format the caching-mode option for the intel-iommu device,
3e5111
based on its <driver caching> attribute value.
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1427005
3e5111
(cherry picked from commit a56914486ca67f921ee6e3ce26b5787fccb47155)
3e5111
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3e5111
3e5111
Conflicts:
3e5111
	tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
3e5111
        - downstream did not update qemu version to 2.9.0
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_capabilities.c                       |  2 ++
3e5111
 src/qemu/qemu_capabilities.h                       |  1 +
3e5111
 src/qemu/qemu_command.c                            | 11 ++++++++++
3e5111
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |  1 +
3e5111
 .../qemuxml2argv-intel-iommu-caching-mode.args     | 25 ++++++++++++++++++++++
3e5111
 tests/qemuxml2argvtest.c                           | 11 ++++++++++
3e5111
 6 files changed, 51 insertions(+)
3e5111
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
3e5111
3e5111
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
3e5111
index 4fd0df260..c970d70e3 100644
3e5111
--- a/src/qemu/qemu_capabilities.c
3e5111
+++ b/src/qemu/qemu_capabilities.c
3e5111
@@ -370,6 +370,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
3e5111
               "kernel-irqchip", /* 255 */
3e5111
               "kernel-irqchip.split",
3e5111
               "intel-iommu.intremap",
3e5111
+              "intel-iommu.caching-mode",
3e5111
     );
3e5111
 
3e5111
 
3e5111
@@ -1724,6 +1725,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBNECXHCI[] = {
3e5111
 
3e5111
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
3e5111
     { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
3e5111
+    { "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
3e5111
 };
3e5111
 
3e5111
 /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
3e5111
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
3e5111
index d1730a725..4e322b5c2 100644
3e5111
--- a/src/qemu/qemu_capabilities.h
3e5111
+++ b/src/qemu/qemu_capabilities.h
3e5111
@@ -408,6 +408,7 @@ typedef enum {
3e5111
     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP, /* -machine kernel_irqchip */
3e5111
     QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT, /* -machine kernel_irqchip=split */
3e5111
     QEMU_CAPS_INTEL_IOMMU_INTREMAP, /* intel-iommu.intremap */
3e5111
+    QEMU_CAPS_INTEL_IOMMU_CACHING_MODE, /* intel-iommu.caching-mode */
3e5111
 
3e5111
     QEMU_CAPS_LAST /* this must always be the last item */
3e5111
 } virQEMUCapsFlags;
3e5111
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
3e5111
index a8dac1489..d4d0c00d5 100644
3e5111
--- a/src/qemu/qemu_command.c
3e5111
+++ b/src/qemu/qemu_command.c
3e5111
@@ -6680,6 +6680,13 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
3e5111
                              "with this QEMU binary"));
3e5111
             return -1;
3e5111
         }
3e5111
+        if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT &&
3e5111
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_CACHING_MODE))  {
3e5111
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
3e5111
+                           _("iommu: caching mode is not supported "
3e5111
+                             "with this QEMU binary"));
3e5111
+            return -1;
3e5111
+        }
3e5111
         break;
3e5111
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
3e5111
         break;
3e5111
@@ -6709,6 +6716,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
3e5111
             virBufferAsprintf(&opts, ",intremap=%s",
3e5111
                               virTristateSwitchTypeToString(iommu->intremap));
3e5111
         }
3e5111
+        if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
3e5111
+            virBufferAsprintf(&opts, ",caching-mode=%s",
3e5111
+                              virTristateSwitchTypeToString(iommu->caching_mode));
3e5111
+        }
3e5111
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
3e5111
         break;
3e5111
     }
3e5111
diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
3e5111
index 5a88cf505..b5649d8d7 100644
3e5111
--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
3e5111
+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
3e5111
@@ -212,6 +212,7 @@
3e5111
   <flag name='kernel-irqchip'/>
3e5111
   <flag name='kernel-irqchip.split'/>
3e5111
   <flag name='intel-iommu.intremap'/>
3e5111
+  <flag name='intel-iommu.caching-mode'/>
3e5111
   <version>2008090</version>
3e5111
   <kvmVersion>0</kvmVersion>
3e5111
   <package> (v2.9.0-rc0-142-g940a8ce)</package>
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
3e5111
new file mode 100644
3e5111
index 000000000..1bec6d00b
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.args
3e5111
@@ -0,0 +1,25 @@
3e5111
+LC_ALL=C \
3e5111
+PATH=/bin \
3e5111
+HOME=/home/test \
3e5111
+USER=test \
3e5111
+LOGNAME=test \
3e5111
+QEMU_AUDIO_DRV=none \
3e5111
+/usr/bin/qemu-system-x86_64 \
3e5111
+-name QEMUGuest1 \
3e5111
+-S \
3e5111
+-machine q35,accel=tcg \
3e5111
+-m 214 \
3e5111
+-smp 1,sockets=1,cores=1,threads=1 \
3e5111
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
3e5111
+-nographic \
3e5111
+-nodefaults \
3e5111
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
3e5111
+-no-acpi \
3e5111
+-boot c \
3e5111
+-device intel-iommu,intremap=on,caching-mode=on \
3e5111
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
3e5111
+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
3e5111
+-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
3e5111
+-device ich9-usb-ehci1,id=usb,bus=pci.2,addr=0x2.0x7 \
3e5111
+-device rtl8139,vlan=0,id=net0,mac=52:54:00:ab:0c:5c,bus=pci.2,addr=0x1 \
3e5111
+-net user,vlan=0,name=hostnet0
3e5111
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
3e5111
index 8061292b3..e3d6d757b 100644
3e5111
--- a/tests/qemuxml2argvtest.c
3e5111
+++ b/tests/qemuxml2argvtest.c
3e5111
@@ -2523,6 +2523,17 @@ mymain(void)
3e5111
             QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
3e5111
             QEMU_CAPS_INTEL_IOMMU_INTREMAP,
3e5111
             QEMU_CAPS_DEVICE_INTEL_IOMMU);
3e5111
+    DO_TEST("intel-iommu-caching-mode",
3e5111
+            QEMU_CAPS_MACHINE_OPT,
3e5111
+            QEMU_CAPS_DEVICE_PCI_BRIDGE,
3e5111
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
3e5111
+            QEMU_CAPS_DEVICE_IOH3420,
3e5111
+            QEMU_CAPS_ICH9_AHCI,
3e5111
+            QEMU_CAPS_PCI_MULTIFUNCTION,
3e5111
+            QEMU_CAPS_ICH9_USB_EHCI1,
3e5111
+            QEMU_CAPS_DEVICE_INTEL_IOMMU,
3e5111
+            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
3e5111
+            QEMU_CAPS_INTEL_IOMMU_CACHING_MODE);
3e5111
 
3e5111
     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
3e5111
 
3e5111
-- 
3e5111
2.13.0
3e5111