render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3e5111
From abbea18f4b3747d738d05f36884dda3202128b65 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <abbea18f4b3747d738d05f36884dda3202128b65@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Tue, 16 May 2017 10:44:52 +0200
3e5111
Subject: [PATCH] conf: add <ioapic driver> to <features>
3e5111
MIME-Version: 1.0
3e5111
Content-Type: text/plain; charset=UTF-8
3e5111
Content-Transfer-Encoding: 8bit
3e5111
3e5111
Add a new <ioapic> element with a driver attribute.
3e5111
3e5111
Possible values are qemu and kvm. With 'qemu', the I/O
3e5111
APIC can be put in the userspace even for KVM domains.
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1427005
3e5111
(cherry picked from commit 8023b21a95f271e51810de7f1362e609eaadc1e4)
3e5111
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 docs/formatdomain.html.in                          |  9 ++++++
3e5111
 docs/schemas/domaincommon.rng                      | 15 ++++++++++
3e5111
 src/conf/domain_conf.c                             | 33 +++++++++++++++++++++-
3e5111
 src/conf/domain_conf.h                             | 11 ++++++++
3e5111
 .../qemuxml2argv-intel-iommu-ioapic.xml            | 29 +++++++++++++++++++
3e5111
 .../qemuxml2xmlout-intel-iommu-ioapic.xml          |  1 +
3e5111
 tests/qemuxml2xmltest.c                            |  1 +
3e5111
 7 files changed, 98 insertions(+), 1 deletion(-)
3e5111
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
3e5111
 create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml
3e5111
3e5111
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
3e5111
index 7e55b0327..869c1f73e 100644
3e5111
--- a/docs/formatdomain.html.in
3e5111
+++ b/docs/formatdomain.html.in
3e5111
@@ -1675,6 +1675,7 @@
3e5111
   </kvm>
3e5111
   <pvspinlock state='on'/>
3e5111
   <gic version='2'/>
3e5111
+  <ioapic driver='qemu'/>
3e5111
 
3e5111
 </features>
3e5111
 ...
3e5111
@@ -1836,6 +1837,14 @@
3e5111
           for hypervisor to decide.
3e5111
           Since 2.1.0
3e5111
       
3e5111
+      
ioapic
3e5111
+      
Tune the I/O APIC. Possible values for the
3e5111
+          driver attribute are:
3e5111
+          kvm (default for KVM domains)
3e5111
+          and qemu which puts I/O APIC in userspace
3e5111
+          which is also known as a split I/O APIC mode.
3e5111
+          Since 3.4.0 (QEMU/KVM only)
3e5111
+      
3e5111
     
3e5111
 
3e5111
     

Time keeping

3e5111
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
3e5111
index 7271f0113..c72ba7e97 100644
3e5111
--- a/docs/schemas/domaincommon.rng
3e5111
+++ b/docs/schemas/domaincommon.rng
3e5111
@@ -4515,6 +4515,9 @@
3e5111
               </optional>
3e5111
             </element>
3e5111
           </optional>
3e5111
+          <optional>
3e5111
+            <ref name="ioapic"/>
3e5111
+          </optional>
3e5111
         </interleave>
3e5111
       </element>
3e5111
     </optional>
3e5111
@@ -4693,6 +4696,18 @@
3e5111
     </element>
3e5111
   </define>
3e5111
 
3e5111
+  <define name="ioapic">
3e5111
+    <element name="ioapic">
3e5111
+      <attribute name="driver">
3e5111
+        <choice>
3e5111
+          <value>qemu</value>
3e5111
+          <value>kvm</value>
3e5111
+        </choice>
3e5111
+      </attribute>
3e5111
+      <empty/>
3e5111
+    </element>
3e5111
+  </define>
3e5111
+
3e5111
   <define name="address">
3e5111
     <element name="address">
3e5111
       <choice>
3e5111
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
3e5111
index 4096b9caf..d5c4f6ddd 100644
3e5111
--- a/src/conf/domain_conf.c
3e5111
+++ b/src/conf/domain_conf.c
3e5111
@@ -141,7 +141,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
3e5111
               "pmu",
3e5111
               "vmport",
3e5111
               "gic",
3e5111
-              "smm")
3e5111
+              "smm",
3e5111
+              "ioapic")
3e5111
 
3e5111
 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
3e5111
               "default",
3e5111
@@ -859,6 +860,11 @@ VIR_ENUM_IMPL(virDomainLoader,
3e5111
               "rom",
3e5111
               "pflash")
3e5111
 
3e5111
+VIR_ENUM_IMPL(virDomainIOAPIC,
3e5111
+              VIR_DOMAIN_IOAPIC_LAST,
3e5111
+              "qemu",
3e5111
+              "kvm")
3e5111
+
3e5111
 /* Internal mapping: subset of block job types that can be present in
3e5111
  * <mirror> XML (remaining types are not two-phase). */
3e5111
 VIR_ENUM_DECL(virDomainBlockJob)
3e5111
@@ -17518,6 +17524,24 @@ virDomainDefParseXML(xmlDocPtr xml,
3e5111
             ctxt->node = node;
3e5111
             break;
3e5111
 
3e5111
+        case VIR_DOMAIN_FEATURE_IOAPIC:
3e5111
+            node = ctxt->node;
3e5111
+            ctxt->node = nodes[i];
3e5111
+            tmp = virXPathString("string(./@driver)", ctxt);
3e5111
+            if (tmp) {
3e5111
+                int value = virDomainIOAPICTypeFromString(tmp);
3e5111
+                if (value < 0) {
3e5111
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
3e5111
+                                   _("Unknown driver mode: %s"),
3e5111
+                                   tmp);
3e5111
+                    goto error;
3e5111
+                }
3e5111
+                def->ioapic = value;
3e5111
+                def->features[val] = VIR_TRISTATE_SWITCH_ON;
3e5111
+            }
3e5111
+            ctxt->node = node;
3e5111
+            break;
3e5111
+
3e5111
         /* coverity[dead_error_begin] */
3e5111
         case VIR_DOMAIN_FEATURE_LAST:
3e5111
             break;
3e5111
@@ -24598,6 +24622,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
3e5111
                 }
3e5111
                 break;
3e5111
 
3e5111
+            case VIR_DOMAIN_FEATURE_IOAPIC:
3e5111
+                if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
3e5111
+                    virBufferAsprintf(buf, "<ioapic driver='%s'/>\n",
3e5111
+                                      virDomainIOAPICTypeToString(def->ioapic));
3e5111
+                }
3e5111
+                break;
3e5111
+
3e5111
             /* coverity[dead_error_begin] */
3e5111
             case VIR_DOMAIN_FEATURE_LAST:
3e5111
                 break;
3e5111
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
3e5111
index f1e9fc2ba..4cb37b1fc 100644
3e5111
--- a/src/conf/domain_conf.h
3e5111
+++ b/src/conf/domain_conf.h
3e5111
@@ -1670,6 +1670,7 @@ typedef enum {
3e5111
     VIR_DOMAIN_FEATURE_VMPORT,
3e5111
     VIR_DOMAIN_FEATURE_GIC,
3e5111
     VIR_DOMAIN_FEATURE_SMM,
3e5111
+    VIR_DOMAIN_FEATURE_IOAPIC,
3e5111
 
3e5111
     VIR_DOMAIN_FEATURE_LAST
3e5111
 } virDomainFeature;
3e5111
@@ -1809,6 +1810,15 @@ struct _virDomainLoaderDef {
3e5111
 
3e5111
 void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);
3e5111
 
3e5111
+typedef enum {
3e5111
+    VIR_DOMAIN_IOAPIC_QEMU = 0,
3e5111
+    VIR_DOMAIN_IOAPIC_KVM,
3e5111
+
3e5111
+    VIR_DOMAIN_IOAPIC_LAST
3e5111
+} virDomainIOAPIC;
3e5111
+
3e5111
+VIR_ENUM_DECL(virDomainIOAPIC);
3e5111
+
3e5111
 /* Operating system configuration data & machine / arch */
3e5111
 typedef struct _virDomainOSDef virDomainOSDef;
3e5111
 typedef virDomainOSDef *virDomainOSDefPtr;
3e5111
@@ -2258,6 +2268,7 @@ struct _virDomainDef {
3e5111
     unsigned int hyperv_spinlocks;
3e5111
     virGICVersion gic_version;
3e5111
     char *hyperv_vendor_id;
3e5111
+    virDomainIOAPIC ioapic;
3e5111
 
3e5111
     /* These options are of type virTristateSwitch: ON = keep, OFF = drop */
3e5111
     int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
3e5111
new file mode 100644
3e5111
index 000000000..284d63a30
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
3e5111
@@ -0,0 +1,29 @@
3e5111
+<domain type='kvm'>
3e5111
+  <name>QEMUGuest1</name>
3e5111
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
3e5111
+  <memory unit='KiB'>219100</memory>
3e5111
+  <currentMemory unit='KiB'>219100</currentMemory>
3e5111
+  <vcpu placement='static'>1</vcpu>
3e5111
+  <os>
3e5111
+    <type arch='x86_64' machine='q35'>hvm</type>
3e5111
+    <boot dev='hd'/>
3e5111
+  </os>
3e5111
+  <features>
3e5111
+    <ioapic driver='qemu'/>
3e5111
+  </features>
3e5111
+  <clock offset='utc'/>
3e5111
+  <on_poweroff>destroy</on_poweroff>
3e5111
+  <on_reboot>restart</on_reboot>
3e5111
+  <on_crash>destroy</on_crash>
3e5111
+  <devices>
3e5111
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
3e5111
+    <controller type='pci' index='0' model='pcie-root'/>
3e5111
+    <controller type='sata' index='0'>
3e5111
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
3e5111
+    </controller>
3e5111
+    <input type='mouse' bus='ps2'/>
3e5111
+    <input type='keyboard' bus='ps2'/>
3e5111
+    <memballoon model='none'/>
3e5111
+    <iommu model='intel'/>
3e5111
+  </devices>
3e5111
+</domain>
3e5111
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml
3e5111
new file mode 120000
3e5111
index 000000000..42d17b2c0
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml
3e5111
@@ -0,0 +1 @@
3e5111
+../qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml
3e5111
\ No newline at end of file
3e5111
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
3e5111
index ff533ab19..0482ad9cb 100644
3e5111
--- a/tests/qemuxml2xmltest.c
3e5111
+++ b/tests/qemuxml2xmltest.c
3e5111
@@ -1128,6 +1128,7 @@ mymain(void)
3e5111
     DO_TEST("intel-iommu-machine",
3e5111
             QEMU_CAPS_MACHINE_OPT,
3e5111
             QEMU_CAPS_MACHINE_IOMMU);
3e5111
+    DO_TEST("intel-iommu-ioapic", NONE);
3e5111
 
3e5111
     DO_TEST("cpu-check-none", NONE);
3e5111
     DO_TEST("cpu-check-partial", NONE);
3e5111
-- 
3e5111
2.13.0
3e5111