]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: don't check hyperv spinlock retries if disabled
authorJán Tomko <jtomko@redhat.com>
Thu, 4 Jul 2013 10:12:57 +0000 (12:12 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 4 Jul 2013 16:39:56 +0000 (18:39 +0200)
<hyperv>
  <spinlocks state='off'/>
</hyperv>

results in:
error: XML error: missing HyperV spinlock retry count

Don't require retries when state is off and use virXPathUInt
instead of virXPathString to simplify parsing.

https://bugzilla.redhat.com/show_bug.cgi?id=784836#c19

docs/schemas/domaincommon.rng
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index 6fe1f96e41e8796f66c33775073995705246d791..c1355300a501cded520b5cc4b274c42be91065c9 100644 (file)
         <optional>
           <element name="spinlocks">
             <ref name="hypervtristate"/>
-            <attribute name="retries">
-              <data type="integer"/>
-            </attribute>
+            <optional>
+              <attribute name="retries">
+                <data type="unsignedInt"/>
+              </attribute>
+            </optional>
           </element>
         </optional>
       </interleave>
index f80b69074f3a67587099856ae3795a757c2f361a..402e6e97fa04efa3587cd46ca3919ab24966ce5f 100644 (file)
@@ -11211,27 +11211,21 @@ virDomainDefParseXML(xmlDocPtr xml,
                     }
 
                     VIR_FREE(tmp);
-                    if (!(tmp = virXPathString("string(./@retries)", ctxt))) {
-                        virReportError(VIR_ERR_XML_ERROR, "%s",
-                                       _("missing HyperV spinlock retry count"));
-                        goto error;
-                    }
-
-                    if (virStrToLong_ui(tmp, NULL, 0,
-                                        &def->hyperv_spinlocks) < 0) {
-                        virReportError(VIR_ERR_XML_ERROR, "%s",
-                                       _("Cannot parse HyperV spinlock retry "
-                                         "count"));
-                        goto error;
-                    }
+                    if (value == VIR_DOMAIN_FEATURE_STATE_ON) {
+                        if (virXPathUInt("string(./@retries)", ctxt,
+                                     &def->hyperv_spinlocks) < 0) {
+                            virReportError(VIR_ERR_XML_ERROR, "%s",
+                                           _("invalid HyperV spinlock retry count"));
+                            goto error;
+                        }
 
-                    if (def->hyperv_spinlocks < 0xFFF) {
-                        virReportError(VIR_ERR_XML_ERROR, "%s",
-                                       _("HyperV spinlock retry count must be "
-                                         "at least 4095"));
-                        goto error;
+                        if (def->hyperv_spinlocks < 0xFFF) {
+                            virReportError(VIR_ERR_XML_ERROR, "%s",
+                                           _("HyperV spinlock retry count must be "
+                                             "at least 4095"));
+                            goto error;
+                        }
                     }
-                    VIR_FREE(tmp);
                     def->hyperv_features[feature] = value;
                     break;
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args
new file mode 100644 (file)
index 0000000..23d9ecc
--- /dev/null
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \
+-S -M pc -cpu qemu32 -m 214 -smp 6 -nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-boot n -usb -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml
new file mode 100644 (file)
index 0000000..4ec16d5
--- /dev/null
@@ -0,0 +1,29 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>6</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='network'/>
+  </os>
+  <features>
+    <acpi/>
+    <hyperv>
+      <relaxed state='off'/>
+      <vapic state='off'/>
+      <spinlocks state='off'/>
+    </hyperv>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index 2c7fd01e25f91b010eec9ceb9d4e7707bc4c9ca3..d0d9cad92d950206e37ab53328caaaa45d379d80 100644 (file)
@@ -438,6 +438,7 @@ mymain(void)
     DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM);
 
     DO_TEST("hyperv", NONE);
+    DO_TEST("hyperv-off", NONE);
 
     DO_TEST("hugepages", QEMU_CAPS_MEM_PATH);
     DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
index 65e95911472a129baa4ae392974dbb3c23f53b72..f8daff9eb05cfce032916f7f9435c547d720d044 100644 (file)
@@ -156,6 +156,7 @@ mymain(void)
     DO_TEST("eoi-enabled");
 
     DO_TEST("hyperv");
+    DO_TEST("hyperv-off");
 
     DO_TEST("hugepages");
     DO_TEST("nosharepages");