render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 2c6067b5f21f5965912c115d0b5e3afd2d1f6ddd Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <2c6067b5f21f5965912c115d0b5e3afd2d1f6ddd@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Fri, 26 May 2017 08:52:57 +0200
3e5111
Subject: [PATCH] qemu: format eim on intel-iommu command line
3e5111
MIME-Version: 1.0
3e5111
Content-Type: text/plain; charset=UTF-8
3e5111
Content-Transfer-Encoding: 8bit
3e5111
3e5111
This option turns on extended interrupt mode,
3e5111
which allows more than 255 vCPUs.
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1451282
3e5111
3e5111
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3e5111
(cherry picked from commit 381e638d81fd13475112ec9ae2cc4fdbe546ed4d)
3e5111
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3e5111
3e5111
Also:
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1289153
3e5111
3e5111
Conflicts:
3e5111
    tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
3e5111
      that QEMU version again
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
 src/qemu/qemu_domain.c                              | 21 +++++++++++++++++++++
3e5111
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml    |  1 +
3e5111
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml    |  1 +
3e5111
 .../qemuxml2argv-intel-iommu-eim.args               | 19 +++++++++++++++++++
3e5111
 tests/qemuxml2argvtest.c                            |  7 +++++++
3e5111
 8 files changed, 63 insertions(+)
3e5111
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args
3e5111
3e5111
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
3e5111
index c970d70e3..80db60bc4 100644
3e5111
--- a/src/qemu/qemu_capabilities.c
3e5111
+++ b/src/qemu/qemu_capabilities.c
3e5111
@@ -371,6 +371,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
3e5111
               "kernel-irqchip.split",
3e5111
               "intel-iommu.intremap",
3e5111
               "intel-iommu.caching-mode",
3e5111
+              "intel-iommu.eim",
3e5111
     );
3e5111
 
3e5111
 
3e5111
@@ -1726,6 +1727,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBNECXHCI[] = {
3e5111
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIntelIOMMU[] = {
3e5111
     { "intremap", QEMU_CAPS_INTEL_IOMMU_INTREMAP },
3e5111
     { "caching-mode", QEMU_CAPS_INTEL_IOMMU_CACHING_MODE },
3e5111
+    { "eim", QEMU_CAPS_INTEL_IOMMU_EIM },
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 4e322b5c2..1c64364af 100644
3e5111
--- a/src/qemu/qemu_capabilities.h
3e5111
+++ b/src/qemu/qemu_capabilities.h
3e5111
@@ -409,6 +409,7 @@ typedef enum {
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
+    QEMU_CAPS_INTEL_IOMMU_EIM, /* intel-iommu.eim */
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 d4d0c00d5..9c0d151da 100644
3e5111
--- a/src/qemu/qemu_command.c
3e5111
+++ b/src/qemu/qemu_command.c
3e5111
@@ -6687,6 +6687,13 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
3e5111
                              "with this QEMU binary"));
3e5111
             return -1;
3e5111
         }
3e5111
+        if (iommu->eim != VIR_TRISTATE_SWITCH_ABSENT &&
3e5111
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_EIM))  {
3e5111
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
3e5111
+                           _("iommu: eim is not supported "
3e5111
+                             "with this QEMU binary"));
3e5111
+            return -1;
3e5111
+        }
3e5111
         break;
3e5111
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
3e5111
         break;
3e5111
@@ -6720,6 +6727,10 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
3e5111
             virBufferAsprintf(&opts, ",caching-mode=%s",
3e5111
                               virTristateSwitchTypeToString(iommu->caching_mode));
3e5111
         }
3e5111
+        if (iommu->eim != VIR_TRISTATE_SWITCH_ABSENT) {
3e5111
+            virBufferAsprintf(&opts, ",eim=%s",
3e5111
+                              virTristateSwitchTypeToString(iommu->eim));
3e5111
+        }
3e5111
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
3e5111
         break;
3e5111
     }
3e5111
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
3e5111
index a8a68aedd..89698d4fc 100644
3e5111
--- a/src/qemu/qemu_domain.c
3e5111
+++ b/src/qemu/qemu_domain.c
3e5111
@@ -2941,6 +2941,9 @@ qemuDomainDefValidateVideo(const virDomainDef *def)
3e5111
 }
3e5111
 
3e5111
 
3e5111
+#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
3e5111
+
3e5111
+
3e5111
 static int
3e5111
 qemuDomainDefValidate(const virDomainDef *def,
3e5111
                       virCapsPtr caps,
3e5111
@@ -3020,6 +3023,24 @@ qemuDomainDefValidate(const virDomainDef *def,
3e5111
         }
3e5111
     }
3e5111
 
3e5111
+    if (ARCH_IS_X86(def->os.arch) &&
3e5111
+        virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) {
3e5111
+        if (!qemuDomainIsQ35(def)) {
3e5111
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
3e5111
+                           _("more than %d vCPUs are only supported on "
3e5111
+                             "q35-based machine types"),
3e5111
+                           QEMU_MAX_VCPUS_WITHOUT_EIM);
3e5111
+            goto cleanup;
3e5111
+        }
3e5111
+        if (!def->iommu || def->iommu->eim != VIR_TRISTATE_SWITCH_ON) {
3e5111
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
3e5111
+                           _("more than %d vCPUs require extended interrupt "
3e5111
+                             "mode enabled on the iommu device"),
3e5111
+                           QEMU_MAX_VCPUS_WITHOUT_EIM);
3e5111
+            goto cleanup;
3e5111
+        }
3e5111
+    }
3e5111
+
3e5111
     if (qemuDomainDefValidateVideo(def) < 0)
3e5111
         goto cleanup;
3e5111
 
3e5111
diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
3e5111
index e51567817..01edbc88d 100644
3e5111
--- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
3e5111
+++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml
3e5111
@@ -206,6 +206,7 @@
3e5111
   <flag name='kernel-irqchip'/>
3e5111
   <flag name='kernel-irqchip.split'/>
3e5111
   <flag name='intel-iommu.intremap'/>
3e5111
+  <flag name='intel-iommu.eim'/>
3e5111
   <version>2008000</version>
3e5111
   <kvmVersion>0</kvmVersion>
3e5111
   <package> (v2.8.0)</package>
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 b5649d8d7..2002dc7c0 100644
3e5111
--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
3e5111
+++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
3e5111
@@ -213,6 +213,7 @@
3e5111
   <flag name='kernel-irqchip.split'/>
3e5111
   <flag name='intel-iommu.intremap'/>
3e5111
   <flag name='intel-iommu.caching-mode'/>
3e5111
+  <flag name='intel-iommu.eim'/>
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-eim.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args
3e5111
new file mode 100644
3e5111
index 000000000..ebf7c49bf
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.args
3e5111
@@ -0,0 +1,19 @@
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=kvm,kernel_irqchip=split \
3e5111
+-m 214 \
3e5111
+-smp 288,sockets=288,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,eim=on
3e5111
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
3e5111
index e3d6d757b..ecdda2db9 100644
3e5111
--- a/tests/qemuxml2argvtest.c
3e5111
+++ b/tests/qemuxml2argvtest.c
3e5111
@@ -2534,6 +2534,13 @@ mymain(void)
3e5111
             QEMU_CAPS_DEVICE_INTEL_IOMMU,
3e5111
             QEMU_CAPS_INTEL_IOMMU_INTREMAP,
3e5111
             QEMU_CAPS_INTEL_IOMMU_CACHING_MODE);
3e5111
+    DO_TEST("intel-iommu-eim",
3e5111
+            QEMU_CAPS_MACHINE_OPT,
3e5111
+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP,
3e5111
+            QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT,
3e5111
+            QEMU_CAPS_INTEL_IOMMU_INTREMAP,
3e5111
+            QEMU_CAPS_INTEL_IOMMU_EIM,
3e5111
+            QEMU_CAPS_DEVICE_INTEL_IOMMU);
3e5111
 
3e5111
     DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
3e5111
 
3e5111
-- 
3e5111
2.13.0
3e5111