9119d9
From 321333e5be4da74a158e9607d310605a8b44679b Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <321333e5be4da74a158e9607d310605a8b44679b@dist-git>
9119d9
From: Eric Blake <eblake@redhat.com>
9119d9
Date: Thu, 18 Sep 2014 09:29:57 -0400
9119d9
Subject: [PATCH] cputune: allow interleaved xml
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1101574
9119d9
9119d9
I noticed this with the recent iothread pinning code, but the
9119d9
problem existed longer than that. The XML validation required
9119d9
users to supply <cputune> children in a strict order, even though
9119d9
there was no conceptual reason why they can't occur in any order.
9119d9
9119d9
docs/ changes best viewed with -w
9119d9
9119d9
* docs/schemas/domaincommon.rng (cputune): Add interleave.
9119d9
* tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreads.xml: Swap
9119d9
up order, copying canonical form...
9119d9
* tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune-iothreads.xml:
9119d9
...here.
9119d9
* tests/qemuxml2xmltest.c (mymain): Mark the difference.
9119d9
9119d9
Signed-off-by: Eric Blake <eblake@redhat.com>
9119d9
(cherry picked from commit 7e8feed4a74b623eca0580a3db140eab2b5fa2b9)
9119d9
Signed-off-by: John Ferlan <jferlan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 docs/schemas/domaincommon.rng                      | 106 +++++++++++----------
9119d9
 .../qemuxml2argv-cputune-iothreads.xml             |  15 +--
9119d9
 .../qemuxml2xmlout-cputune-iothreads.xml           |  38 ++++++++
9119d9
 tests/qemuxml2xmltest.c                            |   2 +-
9119d9
 4 files changed, 101 insertions(+), 60 deletions(-)
9119d9
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune-iothreads.xml
9119d9
9119d9
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
9119d9
index d61d3ad..badc17b 100644
9119d9
--- a/docs/schemas/domaincommon.rng
9119d9
+++ b/docs/schemas/domaincommon.rng
9119d9
@@ -768,58 +768,60 @@
9119d9
   
9119d9
   <define name="cputune">
9119d9
     <element name="cputune">
9119d9
-      <optional>
9119d9
-        <element name="shares">
9119d9
-          <ref name="cpushares"/>
9119d9
-        </element>
9119d9
-      </optional>
9119d9
-      <optional>
9119d9
-        <element name="period">
9119d9
-          <ref name="cpuperiod"/>
9119d9
-        </element>
9119d9
-      </optional>
9119d9
-      <optional>
9119d9
-        <element name="quota">
9119d9
-          <ref name="cpuquota"/>
9119d9
-        </element>
9119d9
-      </optional>
9119d9
-      <optional>
9119d9
-        <element name="emulator_period">
9119d9
-          <ref name="cpuperiod"/>
9119d9
-        </element>
9119d9
-      </optional>
9119d9
-      <optional>
9119d9
-        <element name="emulator_quota">
9119d9
-          <ref name="cpuquota"/>
9119d9
-        </element>
9119d9
-      </optional>
9119d9
-      <zeroOrMore>
9119d9
-        <element name="vcpupin">
9119d9
-          <attribute name="vcpu">
9119d9
-            <ref name="vcpuid"/>
9119d9
-          </attribute>
9119d9
-          <attribute name="cpuset">
9119d9
-            <ref name="cpuset"/>
9119d9
-          </attribute>
9119d9
-        </element>
9119d9
-      </zeroOrMore>
9119d9
-      <optional>
9119d9
-        <element name="emulatorpin">
9119d9
-          <attribute name="cpuset">
9119d9
-            <ref name="cpuset"/>
9119d9
-          </attribute>
9119d9
-        </element>
9119d9
-      </optional>
9119d9
-      <zeroOrMore>
9119d9
-        <element name="iothreadpin">
9119d9
-          <attribute name="iothread">
9119d9
-            <ref name="unsignedInt"/>
9119d9
-          </attribute>
9119d9
-          <attribute name="cpuset">
9119d9
-            <ref name="cpuset"/>
9119d9
-          </attribute>
9119d9
-        </element>
9119d9
-      </zeroOrMore>
9119d9
+      <interleave>
9119d9
+        <optional>
9119d9
+          <element name="shares">
9119d9
+            <ref name="cpushares"/>
9119d9
+          </element>
9119d9
+        </optional>
9119d9
+        <optional>
9119d9
+          <element name="period">
9119d9
+            <ref name="cpuperiod"/>
9119d9
+          </element>
9119d9
+        </optional>
9119d9
+        <optional>
9119d9
+          <element name="quota">
9119d9
+            <ref name="cpuquota"/>
9119d9
+          </element>
9119d9
+        </optional>
9119d9
+        <optional>
9119d9
+          <element name="emulator_period">
9119d9
+            <ref name="cpuperiod"/>
9119d9
+          </element>
9119d9
+        </optional>
9119d9
+        <optional>
9119d9
+          <element name="emulator_quota">
9119d9
+            <ref name="cpuquota"/>
9119d9
+          </element>
9119d9
+        </optional>
9119d9
+        <zeroOrMore>
9119d9
+          <element name="vcpupin">
9119d9
+            <attribute name="vcpu">
9119d9
+              <ref name="vcpuid"/>
9119d9
+            </attribute>
9119d9
+            <attribute name="cpuset">
9119d9
+              <ref name="cpuset"/>
9119d9
+            </attribute>
9119d9
+          </element>
9119d9
+        </zeroOrMore>
9119d9
+        <optional>
9119d9
+          <element name="emulatorpin">
9119d9
+            <attribute name="cpuset">
9119d9
+              <ref name="cpuset"/>
9119d9
+            </attribute>
9119d9
+          </element>
9119d9
+        </optional>
9119d9
+        <zeroOrMore>
9119d9
+          <element name="iothreadpin">
9119d9
+            <attribute name="iothread">
9119d9
+              <ref name="unsignedInt"/>
9119d9
+            </attribute>
9119d9
+            <attribute name="cpuset">
9119d9
+              <ref name="cpuset"/>
9119d9
+            </attribute>
9119d9
+          </element>
9119d9
+        </zeroOrMore>
9119d9
+      </interleave>
9119d9
     </element>
9119d9
   </define>
9119d9
 
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreads.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreads.xml
9119d9
index 435d0ae..c8cc025 100644
9119d9
--- a/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreads.xml
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreads.xml
9119d9
@@ -6,14 +6,15 @@
9119d9
   <vcpu placement='static'>2</vcpu>
9119d9
   <iothreads>2</iothreads>
9119d9
   <cputune>
9119d9
-    <shares>2048</shares>
9119d9
-    <period>1000000</period>
9119d9
-    <quota>-1</quota>
9119d9
-    <vcpupin vcpu='0' cpuset='0'/>
9119d9
-    <vcpupin vcpu='1' cpuset='1'/>
9119d9
-    <emulatorpin cpuset='1'/>
9119d9
-    <iothreadpin iothread='1' cpuset='2'/>
9119d9
+    
9119d9
     <iothreadpin iothread='2' cpuset='3'/>
9119d9
+    <iothreadpin iothread='1' cpuset='2'/>
9119d9
+    <emulatorpin cpuset='1'/>
9119d9
+    <vcpupin vcpu='1' cpuset='1'/>
9119d9
+    <vcpupin vcpu='0' cpuset='0'/>
9119d9
+    <quota>-1</quota>
9119d9
+    <period>1000000</period>
9119d9
+    <shares>2048</shares>
9119d9
   </cputune>
9119d9
   <os>
9119d9
     <type arch='i686' machine='pc'>hvm</type>
9119d9
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune-iothreads.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune-iothreads.xml
9119d9
new file mode 100644
9119d9
index 0000000..3684483
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune-iothreads.xml
9119d9
@@ -0,0 +1,38 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>219136</memory>
9119d9
+  <currentMemory unit='KiB'>219136</currentMemory>
9119d9
+  <vcpu placement='static'>2</vcpu>
9119d9
+  <iothreads>2</iothreads>
9119d9
+  <cputune>
9119d9
+    <shares>2048</shares>
9119d9
+    <period>1000000</period>
9119d9
+    <quota>-1</quota>
9119d9
+    <vcpupin vcpu='1' cpuset='1'/>
9119d9
+    <vcpupin vcpu='0' cpuset='0'/>
9119d9
+    <emulatorpin cpuset='1'/>
9119d9
+    <iothreadpin iothread='2' cpuset='3'/>
9119d9
+    <iothreadpin iothread='1' cpuset='2'/>
9119d9
+  </cputune>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='block' device='disk'>
9119d9
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='usb' index='0'/>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <controller type='pci' index='0' model='pci-root'/>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
9119d9
index 843e66d..3ca64d4 100644
9119d9
--- a/tests/qemuxml2xmltest.c
9119d9
+++ b/tests/qemuxml2xmltest.c
9119d9
@@ -303,7 +303,7 @@ mymain(void)
9119d9
 
9119d9
     DO_TEST("smp");
9119d9
     DO_TEST("iothreads");
9119d9
-    DO_TEST("cputune-iothreads");
9119d9
+    DO_TEST_DIFFERENT("cputune-iothreads");
9119d9
     DO_TEST("iothreads-disk");
9119d9
     DO_TEST("lease");
9119d9
     DO_TEST("event_idx");
9119d9
-- 
9119d9
2.1.0
9119d9