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

Time keeping

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