From 2e4dd4107e78dfff5d470602e1d18a2a0a40444b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Thu, 4 Jul 2013 12:12:57 +0200 Subject: [PATCH] conf: don't check hyperv spinlock retries if disabled 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 | 8 +++-- src/conf/domain_conf.c | 32 ++++++++----------- .../qemuxml2argv-hyperv-off.args | 4 +++ .../qemuxml2argv-hyperv-off.xml | 29 +++++++++++++++++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmltest.c | 1 + 6 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6fe1f96e41..c1355300a5 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4054,9 +4054,11 @@ - - - + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f80b69074f..402e6e97fa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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 (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 (virStrToLong_ui(tmp, NULL, 0, - &def->hyperv_spinlocks) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Cannot parse 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 index 0000000000..23d9eccd82 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.args @@ -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 index 0000000000..4ec16d511d --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml @@ -0,0 +1,29 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2c7fd01e25..d0d9cad92d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -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); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 65e9591147..f8daff9eb0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -156,6 +156,7 @@ mymain(void) DO_TEST("eoi-enabled"); DO_TEST("hyperv"); + DO_TEST("hyperv-off"); DO_TEST("hugepages"); DO_TEST("nosharepages");