[libvirt] [PATCH 0/3] Add support for HyperV Enlightenment features

This series adds framework to deal with various HyperV Enlightenment features that improve behavior of Microsoft Windows guests. First of the features implemented is "relaxed" that changes the behavior of timers. The series is designed to ease addition of other hyperv features in the future. Peter Krempa (3): conf: Make tri-state feature options more universal conf: Add support for HyperV Enlightenment features qemu: Add support for HyperV Enlightenment feature "relaxed" docs/formatdomain.html.in | 21 +++++++ docs/schemas/domaincommon.rng | 28 ++++++++- src/conf/domain_conf.c | 80 +++++++++++++++++++++++-- src/conf/domain_conf.h | 24 +++++--- src/libvirt_private.syms | 6 +- src/qemu/qemu_command.c | 44 +++++++++++++- tests/qemuxml2argvdata/qemuxml2argv-hyperv.args | 4 ++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 28 +++++++++ tests/qemuxml2argvtest.c | 2 + tests/qemuxml2xmltest.c | 2 + 10 files changed, 221 insertions(+), 18 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml -- 1.7.12.3

The apic-eoi feature enum and implementation can be made more universal to allow re-use of the enum for other features. --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 14 +++++++------- src/libvirt_private.syms | 4 ++-- src/qemu/qemu_command.c | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f0c5d50..b6bb080 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -115,7 +115,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, "viridian", "privnet") -VIR_ENUM_IMPL(virDomainApicEoi, VIR_DOMAIN_APIC_EOI_LAST, +VIR_ENUM_IMPL(virDomainFeatureState, VIR_DOMAIN_FEATURE_STATE_LAST, "default", "on", "off") @@ -9060,7 +9060,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, tmp = virXPathString("string(./features/apic/@eoi)", ctxt); if (tmp) { int eoi; - if ((eoi = virDomainApicEoiTypeFromString(tmp)) <= 0) { + if ((eoi = virDomainFeatureStateTypeFromString(tmp)) <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown value for attribute eoi: %s"), tmp); @@ -13828,7 +13828,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (i == VIR_DOMAIN_FEATURE_APIC && def->apic_eoi) { virBufferAsprintf(buf, " eoi='%s'", - virDomainApicEoiTypeToString(def->apic_eoi)); + virDomainFeatureStateTypeToString(def->apic_eoi)); } virBufferAddLit(buf, "/>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1ee4b30..ed53d44 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1389,12 +1389,12 @@ enum virDomainFeature { VIR_DOMAIN_FEATURE_LAST }; -enum virDomainApicEoi { - VIR_DOMAIN_APIC_EOI_DEFAULT = 0, - VIR_DOMAIN_APIC_EOI_ON, - VIR_DOMAIN_APIC_EOI_OFF, +enum virDomainFeatureState { + VIR_DOMAIN_FEATURE_STATE_DEFAULT = 0, + VIR_DOMAIN_FEATURE_STATE_ON, + VIR_DOMAIN_FEATURE_STATE_OFF, - VIR_DOMAIN_APIC_EOI_LAST + VIR_DOMAIN_FEATURE_STATE_LAST }; enum virDomainLifecycleAction { @@ -1708,7 +1708,7 @@ struct _virDomainDef { virDomainOSDef os; char *emulator; int features; - /* enum virDomainApicEoi */ + /* enum virDomainFeatureState */ int apic_eoi; virDomainClockDef clock; @@ -2173,7 +2173,7 @@ VIR_ENUM_DECL(virDomainVirt) VIR_ENUM_DECL(virDomainBoot) VIR_ENUM_DECL(virDomainBootMenu) VIR_ENUM_DECL(virDomainFeature) -VIR_ENUM_DECL(virDomainApicEoi) +VIR_ENUM_DECL(virDomainFeatureState) VIR_ENUM_DECL(virDomainLifecycle) VIR_ENUM_DECL(virDomainLifecycleCrash) VIR_ENUM_DECL(virDomainPMState) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6155738..0801c6c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -272,8 +272,6 @@ virBlkioDeviceWeightArrayClear; virDiskNameToBusDeviceIndex; virDiskNameToIndex; virDomainActualNetDefFree; -virDomainApicEoiTypeFromString; -virDomainApicEoiTypeToString; virDomainAssignDef; virDomainBlockedReasonTypeFromString; virDomainBlockedReasonTypeToString; @@ -363,6 +361,8 @@ virDomainFSTypeFromString; virDomainFSTypeToString; virDomainFSWrpolicyTypeFromString; virDomainFSWrpolicyTypeToString; +virDomainFeatureStateTypeFromString; +virDomainFeatureStateTypeToString; virDomainFindByID; virDomainFindByName; virDomainFindByUUID; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0c0c400..93aae55 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4227,7 +4227,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, if (def->apic_eoi) { char sign; - if (def->apic_eoi == VIR_DOMAIN_APIC_EOI_ON) + if (def->apic_eoi == VIR_DOMAIN_FEATURE_STATE_ON) sign = '+'; else sign = '-'; @@ -7761,9 +7761,9 @@ qemuParseCommandLineCPU(virDomainDefPtr dom, dom->clock.timers[i]->present = present; } else if (STREQ(feature, "kvm_pv_eoi")) { if (policy == VIR_CPU_FEATURE_REQUIRE) - dom->apic_eoi = VIR_DOMAIN_APIC_EOI_ON; + dom->apic_eoi = VIR_DOMAIN_FEATURE_STATE_ON; else - dom->apic_eoi = VIR_DOMAIN_APIC_EOI_OFF; + dom->apic_eoi = VIR_DOMAIN_FEATURE_STATE_OFF; } else { if (!cpu) { if (!(cpu = qemuInitGuestCPU(dom))) -- 1.7.12.3

On 10/17/2012 07:54 AM, Peter Krempa wrote:
The apic-eoi feature enum and implementation can be made more universal to allow re-use of the enum for other features. --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 14 +++++++------- src/libvirt_private.syms | 4 ++-- src/qemu/qemu_command.c | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-)
ACK. Looking at domain_conf.c, I also see virDomainIoEventFd, virDomainVirtioEventIdx, virDomainDiskCopyOnRead, virDomainMemDump, virDomainGraphicsSpicePlaybackCompression, and virDomainPciRombarMode that also might fit this pattern; would you like to do a followup patch for those as well, if it makes sense for any of them? -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 10/18/12 01:32, Eric Blake wrote:
On 10/17/2012 07:54 AM, Peter Krempa wrote:
The apic-eoi feature enum and implementation can be made more universal to allow re-use of the enum for other features. --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 14 +++++++------- src/libvirt_private.syms | 4 ++-- src/qemu/qemu_command.c | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-)
ACK. Looking at domain_conf.c, I also see virDomainIoEventFd, virDomainVirtioEventIdx, virDomainDiskCopyOnRead, virDomainMemDump, virDomainGraphicsSpicePlaybackCompression, and virDomainPciRombarMode that also might fit this pattern; would you like to do a followup patch for those as well, if it makes sense for any of them?
I will have a look what we can do with those.

Hypervisors are starting to support HyperV englightenment features that improve behavior of guests running Microsoft Windows operating systems. This patch adds support for the "relaxed" feature that improves timer behavior and also establishes a framework to add these features in future. --- docs/formatdomain.html.in | 21 ++++++++++++ docs/schemas/domaincommon.rng | 28 +++++++++++++++- src/conf/domain_conf.c | 74 +++++++++++++++++++++++++++++++++++++++++-- src/conf/domain_conf.h | 10 ++++++ src/libvirt_private.syms | 2 ++ 5 files changed, 132 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index ad8a41b..2417943 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1047,6 +1047,10 @@ <apic/> <hap/> <privnet/> + <hyperv> + <relaxed state='on'> + </hyperv> + </features> ...</pre> @@ -1087,6 +1091,23 @@ This feature is only relevant for container based virtualization drivers, such as LXC. </dd> + <dt><code>hyperv</code></dt> + <dd>Enable various features improving behavior of guests + running Microsoft Windows. + <table class="top_table"> + <tr> + <th>Feature</th> + <th>Description</th> + <th>Value</th> + </tr> + <tr> + <td>relaxed</td> + <td>Relax contstraints on timers</td> + <td> on, off</td> + </tr> + </table> + <span class="since">Since 1.0.0 (QEMU only)</span> + </dd> </dl> <h3><a name="elementsTime">Time keeping</a></h3> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 70bc0e2..17ad86b 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2946,7 +2946,8 @@ </element> </define> <!-- - A set of optional features: PAE, APIC, ACPI, and HAP support + A set of optional features: PAE, APIC, ACPI, + HyperV Enlightenment and HAP support --> <define name="features"> <optional> @@ -2980,6 +2981,9 @@ </element> </optional> <optional> + <ref name="hyperv"/> + </optional> + <optional> <element name="viridian"> <empty/> </element> @@ -3434,6 +3438,28 @@ </element> </define> + <!-- Optional HyperV Enlightenment features --> + <define name="hyperv"> + <element name="hyperv"> + <interleave> + <optional> + <element name="relaxed"> + <ref name="hypervtristate"/> + </element> + </optional> + </interleave> + </element> + </define> + + <define name="hypervtristate"> + <attribute name="state"> + <choice> + <value>on</value> + <value>off</value> + </choice> + </attribute> + </define> + <!-- Optional hypervisor extensions in their own namespace: QEmu diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b6bb080..7d38114 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -113,13 +113,17 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, "pae", "hap", "viridian", - "privnet") + "privnet", + "hyperv") VIR_ENUM_IMPL(virDomainFeatureState, VIR_DOMAIN_FEATURE_STATE_LAST, "default", "on", "off") +VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST, + "relaxed") + VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST, "destroy", "restart", @@ -9074,6 +9078,53 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, VIR_FREE(nodes); } + if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) { + int feature; + int value; + node = ctxt->node; + if ((n = virXPathNodeSet("./features/hyperv/*", ctxt, &nodes)) < 0) + goto error; + + for (i = 0; i < n; i++) { + feature = virDomainHypervTypeFromString((const char *)nodes[i]->name); + if (feature < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported HyperV Enlightenment feature: %s"), + nodes[i]->name); + goto error; + } + + ctxt->node = nodes[i]; + + switch ((enum virDomainHyperv) feature) { + case VIR_DOMAIN_HYPERV_RELAXED: + if (!(tmp = virXPathString("string(./@state)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, + _("missing 'state' attribute for " + "HyperV Enlightenment feature '%s'"), + nodes[i]->name); + goto error; + } + + if ((value = virDomainFeatureStateTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid value of state argument " + "for HyperV Enlightenment feature '%s'"), + nodes[i]->name); + goto error; + } + + def->hyperv_features[feature] = value; + break; + + case VIR_DOMAIN_HYPERV_LAST: + break; + } + } + VIR_FREE(nodes); + ctxt->node = node; + } + if (virDomainEventActionParseXML(ctxt, "on_reboot", "string(./on_reboot[1])", &def->onReboot, @@ -13817,7 +13868,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def->features) { virBufferAddLit(buf, " <features>\n"); for (i = 0 ; i < VIR_DOMAIN_FEATURE_LAST ; i++) { - if (def->features & (1 << i)) { + if (def->features & (1 << i) && i != VIR_DOMAIN_FEATURE_HYPERV) { const char *name = virDomainFeatureTypeToString(i); if (!name) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -13833,6 +13884,25 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAddLit(buf, "/>\n"); } } + + if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) { + virBufferAddLit(buf, " <hyperv>\n"); + for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { + switch ((enum virDomainHyperv) i) { + case VIR_DOMAIN_HYPERV_RELAXED: + if (def->hyperv_features[i]) + virBufferAsprintf(buf, " <%s state='%s'/>\n", + virDomainHypervTypeToString(i), + virDomainFeatureStateTypeToString(def->hyperv_features[i])); + break; + + case VIR_DOMAIN_HYPERV_LAST: + break; + } + } + virBufferAddLit(buf, " </hyperv>\n"); + } + virBufferAddLit(buf, " </features>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ed53d44..ac6311f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1385,6 +1385,7 @@ enum virDomainFeature { VIR_DOMAIN_FEATURE_HAP, VIR_DOMAIN_FEATURE_VIRIDIAN, VIR_DOMAIN_FEATURE_PRIVNET, + VIR_DOMAIN_FEATURE_HYPERV, VIR_DOMAIN_FEATURE_LAST }; @@ -1397,6 +1398,12 @@ enum virDomainFeatureState { VIR_DOMAIN_FEATURE_STATE_LAST }; +enum virDomainHyperv { + VIR_DOMAIN_HYPERV_RELAXED = 0, + + VIR_DOMAIN_HYPERV_LAST +}; + enum virDomainLifecycleAction { VIR_DOMAIN_LIFECYCLE_DESTROY, VIR_DOMAIN_LIFECYCLE_RESTART, @@ -1710,6 +1717,8 @@ struct _virDomainDef { int features; /* enum virDomainFeatureState */ int apic_eoi; + /* These options are of type virDomainFeatureState */ + int hyperv_features[VIR_DOMAIN_HYPERV_LAST]; virDomainClockDef clock; @@ -2239,6 +2248,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste) VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode) VIR_ENUM_DECL(virDomainNumatuneMemMode) VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode) +VIR_ENUM_DECL(virDomainHyperv) /* from libvirt.h */ VIR_ENUM_DECL(virDomainState) VIR_ENUM_DECL(virDomainNostateReason) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0801c6c..1a0c2f6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -406,6 +406,8 @@ virDomainHostdevRemove; virDomainHostdevSubsysTypeToString; virDomainHubTypeFromString; virDomainHubTypeToString; +virDomainHypervTypeFromString; +virDomainHypervTypeToString; virDomainInputDefFree; virDomainIoEventFdTypeFromString; virDomainIoEventFdTypeToString; -- 1.7.12.3

On 10/17/2012 07:54 AM, Peter Krempa wrote:
Hypervisors are starting to support HyperV englightenment features that improve behavior of guests running Microsoft Windows operating systems.
s/englightenment/enlightenment/
This patch adds support for the "relaxed" feature that improves timer behavior and also establishes a framework to add these features in future. --- docs/formatdomain.html.in | 21 ++++++++++++ docs/schemas/domaincommon.rng | 28 +++++++++++++++- src/conf/domain_conf.c | 74 +++++++++++++++++++++++++++++++++++++++++-- src/conf/domain_conf.h | 10 ++++++ src/libvirt_private.syms | 2 ++ 5 files changed, 132 insertions(+), 3 deletions(-)
+ for (i = 0; i < n; i++) { + feature = virDomainHypervTypeFromString((const char *)nodes[i]->name);
Is this cast really necessary? ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 10/18/12 01:38, Eric Blake wrote:
On 10/17/2012 07:54 AM, Peter Krempa wrote:
Hypervisors are starting to support HyperV englightenment features that improve behavior of guests running Microsoft Windows operating systems.
s/englightenment/enlightenment/
This patch adds support for the "relaxed" feature that improves timer behavior and also establishes a framework to add these features in future. --- docs/formatdomain.html.in | 21 ++++++++++++ docs/schemas/domaincommon.rng | 28 +++++++++++++++- src/conf/domain_conf.c | 74 +++++++++++++++++++++++++++++++++++++++++-- src/conf/domain_conf.h | 10 ++++++ src/libvirt_private.syms | 2 ++ 5 files changed, 132 insertions(+), 3 deletions(-)
+ for (i = 0; i < n; i++) { + feature = virDomainHypervTypeFromString((const char *)nodes[i]->name);
Is this cast really necessary?
Unfortunately, it is: conf/domain_conf.c: In function 'virDomainDefParseXML': conf/domain_conf.c:9089:13: error: pointer targets in passing argument 1 of 'virDomainHypervTypeFromString' differ in signedness [-Wpointer-sign]

This patch adds support for the "relaxed" feature implemented by previous patch. --- src/qemu/qemu_command.c | 38 +++++++++++++++++++++++++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.args | 4 +++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 28 ++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ tests/qemuxml2xmltest.c | 2 ++ 5 files changed, 74 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 93aae55..50e95c4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4238,6 +4238,26 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, have_cpu = true; } + if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) { + if (!have_cpu) { + virBufferAdd(&buf, default_model, -1); + have_cpu = true; + } + + for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { + switch ((enum virDomainHyperv) i) { + case VIR_DOMAIN_HYPERV_RELAXED: + if (def->hyperv_features[i] == VIR_DOMAIN_FEATURE_STATE_ON) + virBufferAsprintf(&buf, ",hv_%s", + virDomainHypervTypeToString(i)); + break; + + case VIR_DOMAIN_HYPERV_LAST: + break; + } + } + } + if (virBufferError(&buf)) goto no_memory; @@ -7764,6 +7784,24 @@ qemuParseCommandLineCPU(virDomainDefPtr dom, dom->apic_eoi = VIR_DOMAIN_FEATURE_STATE_ON; else dom->apic_eoi = VIR_DOMAIN_FEATURE_STATE_OFF; + } else if (STRPREFIX(feature, "hv_")) { + int f = virDomainHypervTypeFromString(feature + 3); + if (f < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported HyperV Enlightenment feature " + "'%s'"), feature); + goto error; + } + + switch ((enum virDomainHyperv) f) { + case VIR_DOMAIN_HYPERV_RELAXED: + if (policy == VIR_CPU_FEATURE_REQUIRE) + dom->hyperv_features[f] = VIR_DOMAIN_FEATURE_STATE_ON; + break; + + case VIR_DOMAIN_HYPERV_LAST: + break; + } } else { if (!cpu) { if (!(cpu = qemuInitGuestCPU(dom))) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args new file mode 100644 index 0000000..a414da0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.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,hv_relaxed -m 214 -smp 6 -nographic -monitor \ +unix:/tmp/test-monitor,server,nowait -boot n -net none -serial none \ +-parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml new file mode 100644 index 0000000..175c69f --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml @@ -0,0 +1,28 @@ +<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/> + <apic/> + <pae/> + <hyperv> + <relaxed state='on'/> + </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'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3ecd957..7403a8f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -412,6 +412,8 @@ mymain(void) DO_TEST("eoi-enabled", NONE); DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM); + DO_TEST("hyperv", NONE); + DO_TEST("hugepages", QEMU_CAPS_MEM_PATH); DO_TEST("disk-cdrom", NONE); DO_TEST("disk-cdrom-empty", QEMU_CAPS_DRIVE); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 21db5a4..1d366f1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -150,6 +150,8 @@ mymain(void) DO_TEST("eoi-disabled"); DO_TEST("eoi-enabled"); + DO_TEST("hyperv"); + DO_TEST("hugepages"); DO_TEST("disk-aio"); DO_TEST("disk-cdrom"); -- 1.7.12.3

On 10/17/2012 07:54 AM, Peter Krempa wrote:
This patch adds support for the "relaxed" feature implemented by previous patch. --- src/qemu/qemu_command.c | 38 +++++++++++++++++++++++++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.args | 4 +++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 28 ++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ tests/qemuxml2xmltest.c | 2 ++ 5 files changed, 74 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

This patch adds support for the "relaxed" feature implemented by previous patch. --- Diff to v1: - Fixed parsing of qemu commandline and added test. At the original place the code wasn't working as the hyperv features don't use the '+' sign to enable them src/qemu/qemu_command.c | 58 ++++++++++++++++++++++++- tests/qemuargv2xmltest.c | 2 + tests/qemuxml2argvdata/qemuxml2argv-hyperv.args | 4 ++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 26 +++++++++++ tests/qemuxml2argvtest.c | 2 + tests/qemuxml2xmltest.c | 2 + 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 93aae55..9c72c10 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4238,6 +4238,26 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, have_cpu = true; } + if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) { + if (!have_cpu) { + virBufferAdd(&buf, default_model, -1); + have_cpu = true; + } + + for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { + switch ((enum virDomainHyperv) i) { + case VIR_DOMAIN_HYPERV_RELAXED: + if (def->hyperv_features[i] == VIR_DOMAIN_FEATURE_STATE_ON) + virBufferAsprintf(&buf, ",hv_%s", + virDomainHypervTypeToString(i)); + break; + + case VIR_DOMAIN_HYPERV_LAST: + break; + } + } + } + if (virBufferError(&buf)) goto no_memory; @@ -7708,8 +7728,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom, cpu->model = model; model = NULL; } - } - else if (*p == '+' || *p == '-') { + } else if (*p == '+' || *p == '-') { char *feature; int policy; int ret = 0; @@ -7779,6 +7798,41 @@ qemuParseCommandLineCPU(virDomainDefPtr dom, VIR_FREE(feature); if (ret < 0) goto error; + } else if (STRPREFIX(p, "hv_")) { + char *feature; + int f; + p += 3; /* "hv_" */ + + if (*p == '\0' || *p == ',') + goto syntax; + + if (next) + feature = strndup(p, next - p - 1); + else + feature = strdup(p); + + if (!feature) + goto no_memory; + + dom->features |= (1 << VIR_DOMAIN_FEATURE_HYPERV); + + if ((f = virDomainHypervTypeFromString(feature)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported HyperV Enlightenment feature " + "'%s'"), feature); + goto error; + } + + switch ((enum virDomainHyperv) f) { + case VIR_DOMAIN_HYPERV_RELAXED: + dom->hyperv_features[f] = VIR_DOMAIN_FEATURE_STATE_ON; + break; + + case VIR_DOMAIN_HYPERV_LAST: + break; + } + + VIR_FREE(feature); } } while ((p = next)); diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 5e51d32..70de8c3 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -241,6 +241,8 @@ mymain(void) DO_TEST("smp"); + DO_TEST("hyperv"); + DO_TEST_FULL("restore-v1", 0, "stdio"); DO_TEST_FULL("restore-v2", 0, "stdio"); DO_TEST_FULL("restore-v2", 0, "exec:cat"); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args new file mode 100644 index 0000000..a414da0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.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,hv_relaxed -m 214 -smp 6 -nographic -monitor \ +unix:/tmp/test-monitor,server,nowait -boot n -net none -serial none \ +-parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml new file mode 100644 index 0000000..9b7d8f2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml @@ -0,0 +1,26 @@ +<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='on'/> + </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'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3ecd957..7403a8f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -412,6 +412,8 @@ mymain(void) DO_TEST("eoi-enabled", NONE); DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM); + DO_TEST("hyperv", NONE); + DO_TEST("hugepages", QEMU_CAPS_MEM_PATH); DO_TEST("disk-cdrom", NONE); DO_TEST("disk-cdrom-empty", QEMU_CAPS_DRIVE); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 21db5a4..1d366f1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -150,6 +150,8 @@ mymain(void) DO_TEST("eoi-disabled"); DO_TEST("eoi-enabled"); + DO_TEST("hyperv"); + DO_TEST("hugepages"); DO_TEST("disk-aio"); DO_TEST("disk-cdrom"); -- 1.7.12.3

On 10/18/2012 11:39 AM, Peter Krempa wrote:
This patch adds support for the "relaxed" feature implemented by
I'd write 'QEMU support' to make it clear, but that's just a hint :)
previous patch. --- Diff to v1: - Fixed parsing of qemu commandline and added test. At the original place the code wasn't working as the hyperv features don't use the '+' sign to enable them
src/qemu/qemu_command.c | 58 ++++++++++++++++++++++++- tests/qemuargv2xmltest.c | 2 + tests/qemuxml2argvdata/qemuxml2argv-hyperv.args | 4 ++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 26 +++++++++++ tests/qemuxml2argvtest.c | 2 + tests/qemuxml2xmltest.c | 2 + 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
ACK, Martin

On 10/18/12 12:07, Martin Kletzander wrote:
On 10/18/2012 11:39 AM, Peter Krempa wrote:
This patch adds support for the "relaxed" feature implemented by
I'd write 'QEMU support' to make it clear, but that's just a hint :)
That looks better.
previous patch. --- Diff to v1: - Fixed parsing of qemu commandline and added test. At the original place the code wasn't working as the hyperv features don't use the '+' sign to enable them
src/qemu/qemu_command.c | 58 ++++++++++++++++++++++++- tests/qemuargv2xmltest.c | 2 + tests/qemuxml2argvdata/qemuxml2argv-hyperv.args | 4 ++ tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 26 +++++++++++ tests/qemuxml2argvtest.c | 2 + tests/qemuxml2xmltest.c | 2 + 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
ACK,
Thanks. Peter

On 10/17/12 15:54, Peter Krempa wrote:
This series adds framework to deal with various HyperV Enlightenment features that improve behavior of Microsoft Windows guests.
First of the features implemented is "relaxed" that changes the behavior of timers.
The series is designed to ease addition of other hyperv features in the future.
Peter Krempa (3): conf: Make tri-state feature options more universal conf: Add support for HyperV Enlightenment features qemu: Add support for HyperV Enlightenment feature "relaxed"
Thanks for the reviews. I fixed the nits and pushed the series. Peter
participants (3)
-
Eric Blake
-
Martin Kletzander
-
Peter Krempa