Blame SOURCES/libvirt-schema-Fix-guest-timer-specification-schema-according-to-the-docs.patch

c401cc
From ef1d5ee84bbbd3583a373898ed167060adc068e1 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <ef1d5ee84bbbd3583a373898ed167060adc068e1@dist-git>
c401cc
From: Peter Krempa <pkrempa@redhat.com>
c401cc
Date: Mon, 10 Feb 2014 14:02:47 +0100
c401cc
Subject: [PATCH] schema: Fix guest timer specification schema according to the
c401cc
 docs
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1056205
c401cc
c401cc
According to the documentation describing various tunables for domain
c401cc
timers not all the fields are supported by all the driver types. Express
c401cc
these in the RNG:
c401cc
c401cc
- rtc, platform: Only these support the "track" attribute.
c401cc
- tsc: only one to support "frequency" and "mode" attributes
c401cc
- hpet, pit: tickpolicy/catchup attribute/element
c401cc
- kvmclock: no extra attributes are supported
c401cc
c401cc
Additionally the attributes of the <catchup> element for
c401cc
tickpolicy='catchup' are optional according to the parsing code. Express
c401cc
this in the XML and fix a spurious space added while formatting the
c401cc
<catchup> element and add tests for it.
c401cc
c401cc
(cherry picked from commit bbd392ff86249434ca63bb5977d2b1bd2d72a538)
c401cc
c401cc
Conflicts:
c401cc
	tests/qemuxml2argvtest.c - HPET-off test not yet enabled
c401cc
Tweaks:
c401cc
    tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.args: -
c401cc
    QEMU_AUDIO_DRV is not formatted downstream
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 docs/schemas/domaincommon.rng                      | 157 +++++++++++++--------
c401cc
 src/conf/domain_conf.c                             |   2 +-
c401cc
 .../qemuxml2argv-clock-catchup.args                |   5 +
c401cc
 .../qemuxml2argv-clock-catchup.xml                 |  37 +++++
c401cc
 tests/qemuxml2argvtest.c                           |   1 +
c401cc
 tests/qemuxml2xmltest.c                            |   1 +
c401cc
 6 files changed, 142 insertions(+), 61 deletions(-)
c401cc
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.args
c401cc
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.xml
c401cc
c401cc
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
c401cc
index 91b36e2..f75bf78 100644
c401cc
--- a/docs/schemas/domaincommon.rng
c401cc
+++ b/docs/schemas/domaincommon.rng
c401cc
@@ -791,54 +791,68 @@
c401cc
   </define>
c401cc
   <define name="timer">
c401cc
     <element name="timer">
c401cc
-      <attribute name="name">
c401cc
-        <choice>
c401cc
-          <value>platform</value>
c401cc
-          <value>hpet</value>
c401cc
-          <value>kvmclock</value>
c401cc
-          <value>pit</value>
c401cc
-          <value>rtc</value>
c401cc
-          <value>tsc</value>
c401cc
-        </choice>
c401cc
-      </attribute>
c401cc
-      <optional>
c401cc
-        <attribute name="track">
c401cc
-          <choice>
c401cc
-            <value>boot</value>
c401cc
-            <value>guest</value>
c401cc
-            <value>wall</value>
c401cc
-          </choice>
c401cc
-        </attribute>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <attribute name="tickpolicy">
c401cc
-          <choice>
c401cc
-            <value>delay</value>
c401cc
-            <value>catchup</value>
c401cc
-            <value>merge</value>
c401cc
-            <value>discard</value>
c401cc
-          </choice>
c401cc
-        </attribute>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <ref name="catchup"/>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <attribute name="frequency">
c401cc
-          <ref name="unsignedInt"/>
c401cc
-        </attribute>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <attribute name="mode">
c401cc
-          <choice>
c401cc
-            <value>auto</value>
c401cc
-            <value>native</value>
c401cc
-            <value>emulate</value>
c401cc
-            <value>paravirt</value>
c401cc
-            <value>smpsafe</value>
c401cc
-          </choice>
c401cc
-        </attribute>
c401cc
-      </optional>
c401cc
+      <choice>
c401cc
+        <group>
c401cc
+          <attribute name="name">
c401cc
+            <choice>
c401cc
+              <value>platform</value>
c401cc
+              <value>rtc</value>
c401cc
+            </choice>
c401cc
+          </attribute>
c401cc
+          <optional>
c401cc
+            <attribute name="track">
c401cc
+              <choice>
c401cc
+                <value>boot</value>
c401cc
+                <value>guest</value>
c401cc
+                <value>wall</value>
c401cc
+              </choice>
c401cc
+            </attribute>
c401cc
+          </optional>
c401cc
+          <optional>
c401cc
+            <ref name="tickpolicy"/>
c401cc
+          </optional>
c401cc
+        </group>
c401cc
+        <group>
c401cc
+          <attribute name="name">
c401cc
+            <value>tsc</value>
c401cc
+          </attribute>
c401cc
+          <optional>
c401cc
+            <ref name="tickpolicy"/>
c401cc
+          </optional>
c401cc
+          <optional>
c401cc
+            <attribute name="frequency">
c401cc
+              <ref name="unsignedInt"/>
c401cc
+            </attribute>
c401cc
+          </optional>
c401cc
+          <optional>
c401cc
+            <attribute name="mode">
c401cc
+              <choice>
c401cc
+                <value>auto</value>
c401cc
+                <value>native</value>
c401cc
+                <value>emulate</value>
c401cc
+                <value>paravirt</value>
c401cc
+                <value>smpsafe</value>
c401cc
+              </choice>
c401cc
+            </attribute>
c401cc
+          </optional>
c401cc
+        </group>
c401cc
+        <group>
c401cc
+          <attribute name="name">
c401cc
+            <choice>
c401cc
+              <value>hpet</value>
c401cc
+              <value>pit</value>
c401cc
+            </choice>
c401cc
+          </attribute>
c401cc
+          <optional>
c401cc
+            <ref name="tickpolicy"/>
c401cc
+          </optional>
c401cc
+        </group>
c401cc
+        <group>
c401cc
+          <attribute name="name">
c401cc
+            <value>kvmclock</value>
c401cc
+          </attribute>
c401cc
+        </group>
c401cc
+      </choice>
c401cc
       <optional>
c401cc
         <attribute name="present">
c401cc
           <choice>
c401cc
@@ -850,20 +864,43 @@
c401cc
       <empty/>
c401cc
     </element>
c401cc
   </define>
c401cc
-  <define name="catchup">
c401cc
-    <element name="catchup">
c401cc
-      <optional>
c401cc
-        <attribute name="threshold">
c401cc
-          <ref name="unsignedInt"/>
c401cc
-        </attribute>
c401cc
-        <attribute name="slew">
c401cc
-          <ref name="unsignedInt"/>
c401cc
+
c401cc
+  <define name="tickpolicy">
c401cc
+    <choice>
c401cc
+      <group>
c401cc
+        <attribute name="tickpolicy">
c401cc
+          <choice>
c401cc
+            <value>delay</value>
c401cc
+            <value>merge</value>
c401cc
+            <value>discard</value>
c401cc
+          </choice>
c401cc
         </attribute>
c401cc
-        <attribute name="limit">
c401cc
-          <ref name="unsignedInt"/>
c401cc
+      </group>
c401cc
+      <group>
c401cc
+        <attribute name="tickpolicy">
c401cc
+          <value>catchup</value>
c401cc
         </attribute>
c401cc
-      </optional>
c401cc
-    </element>
c401cc
+        <optional>
c401cc
+          <element name="catchup">
c401cc
+            <optional>
c401cc
+              <attribute name="threshold">
c401cc
+                <ref name="unsignedInt"/>
c401cc
+              </attribute>
c401cc
+            </optional>
c401cc
+            <optional>
c401cc
+              <attribute name="slew">
c401cc
+                <ref name="unsignedInt"/>
c401cc
+              </attribute>
c401cc
+            </optional>
c401cc
+            <optional>
c401cc
+              <attribute name="limit">
c401cc
+                <ref name="unsignedInt"/>
c401cc
+              </attribute>
c401cc
+            </optional>
c401cc
+          </element>
c401cc
+        </optional>
c401cc
+      </group>
c401cc
+    </choice>
c401cc
   </define>
c401cc
 
c401cc
       A bootloader may be used to extract the OS information instead of
c401cc
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
c401cc
index 06ec82d..99b505b 100644
c401cc
--- a/src/conf/domain_conf.c
c401cc
+++ b/src/conf/domain_conf.c
c401cc
@@ -15963,7 +15963,7 @@ virDomainTimerDefFormat(virBufferPtr buf,
c401cc
         virBufferAddLit(buf, "/>\n");
c401cc
     } else {
c401cc
         virBufferAddLit(buf, ">\n");
c401cc
-        virBufferAddLit(buf, "      
c401cc
+        virBufferAddLit(buf, "      
c401cc
         if (def->catchup.threshold > 0) {
c401cc
             virBufferAsprintf(buf, " threshold='%lu'", def->catchup.threshold);
c401cc
         }
c401cc
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.args b/tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.args
c401cc
new file mode 100644
c401cc
index 0000000..290f268
c401cc
--- /dev/null
c401cc
+++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.args
c401cc
@@ -0,0 +1,5 @@
c401cc
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
c401cc
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic \
c401cc
+-monitor unix:/tmp/test-monitor,server,nowait -rtc base=utc,driftfix=slew \
c401cc
+-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
c401cc
+-net none -serial none -parallel none
c401cc
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.xml b/tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.xml
c401cc
new file mode 100644
c401cc
index 0000000..7b3cb88
c401cc
--- /dev/null
c401cc
+++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-catchup.xml
c401cc
@@ -0,0 +1,37 @@
c401cc
+<domain type='qemu'>
c401cc
+  <name>QEMUGuest1</name>
c401cc
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
c401cc
+  <memory unit='KiB'>219100</memory>
c401cc
+  <currentMemory unit='KiB'>219100</currentMemory>
c401cc
+  <vcpu placement='static'>1</vcpu>
c401cc
+  <os>
c401cc
+    <type arch='i686' machine='pc'>hvm</type>
c401cc
+    <boot dev='hd'/>
c401cc
+  </os>
c401cc
+  <clock offset='utc'>
c401cc
+    <timer name='rtc' tickpolicy='catchup'>
c401cc
+      <catchup slew='4636'/>
c401cc
+    </timer>
c401cc
+    <timer name='pit' tickpolicy='catchup'>
c401cc
+      <catchup threshold='123'/>
c401cc
+    </timer>
c401cc
+    <timer name='hpet' tickpolicy='catchup'>
c401cc
+      <catchup limit='2342'/>
c401cc
+    </timer>
c401cc
+  </clock>
c401cc
+  <on_poweroff>destroy</on_poweroff>
c401cc
+  <on_reboot>restart</on_reboot>
c401cc
+  <on_crash>destroy</on_crash>
c401cc
+  <devices>
c401cc
+    <emulator>/usr/bin/qemu</emulator>
c401cc
+    <disk type='block' device='disk'>
c401cc
+      <source dev='/dev/HostVG/QEMUGuest1'/>
c401cc
+      <target dev='hda' bus='ide'/>
c401cc
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
c401cc
+    </disk>
c401cc
+    <controller type='usb' index='0'/>
c401cc
+    <controller type='ide' index='0'/>
c401cc
+    <controller type='pci' index='0' model='pci-root'/>
c401cc
+    <memballoon model='virtio'/>
c401cc
+  </devices>
c401cc
+</domain>
c401cc
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
c401cc
index 790d610..88ebc18 100644
c401cc
--- a/tests/qemuxml2argvtest.c
c401cc
+++ b/tests/qemuxml2argvtest.c
c401cc
@@ -436,6 +436,7 @@ mymain(void)
c401cc
     DO_TEST("clock-variable", QEMU_CAPS_RTC);
c401cc
     */
c401cc
     DO_TEST("clock-france", QEMU_CAPS_RTC);
c401cc
+    DO_TEST("clock-catchup", QEMU_CAPS_RTC, QEMU_CAPS_NO_KVM_PIT);
c401cc
     DO_TEST("cpu-kvmclock", QEMU_CAPS_ENABLE_KVM);
c401cc
     DO_TEST("cpu-host-kvmclock", QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_CPU_HOST);
c401cc
     DO_TEST("kvmclock", QEMU_CAPS_KVM);
c401cc
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
c401cc
index 1f655ef..92504ad 100644
c401cc
--- a/tests/qemuxml2xmltest.c
c401cc
+++ b/tests/qemuxml2xmltest.c
c401cc
@@ -150,6 +150,7 @@ mymain(void)
c401cc
     DO_TEST("clock-localtime");
c401cc
     DO_TEST("cpu-kvmclock");
c401cc
     DO_TEST("cpu-host-kvmclock");
c401cc
+    DO_TEST("clock-catchup");
c401cc
     DO_TEST("kvmclock");
c401cc
 
c401cc
     DO_TEST("cpu-eoi-disabled");
c401cc
-- 
c401cc
1.8.5.4
c401cc