This patch adds support for "vpindex", "runtime", "synic"
and
"stimer" features available in qemu 2.5+.
- When Hyper-V "vpindex" is on, guest can use MSR HV_X64_MSR_VP_INDEX
to get virtual processor ID.
- Hyper-V "runtime" enlightement feature allows to use MSR
HV_X64_MSR_VP_RUNTIME to get the time the virtual processor consumes
running guest code, as well as the time the hypervisor spends running
code on behalf of that guest.
- Hyper-V "synic" stands for Synthetic Interrupt Controller, which is
lapic extension controlled via MSRs.
- Hyper-V "stimer" switches on Hyper-V SynIC timers MSR's support.
Guest can setup and use fired by host events (SynIC interrupt and
appropriate timer expiration message) as guest clock events
Signed-off-by: Maxim Nestratov <mnestratov(a)virtuozzo.com>
---
docs/formatdomain.html.in | 28 ++++++++++++++++++++++
docs/schemas/domaincommon.rng | 20 ++++++++++++++++
src/conf/domain_conf.c | 18 +++++++++++++-
src/conf/domain_conf.h | 4 ++++
src/qemu/qemu_command.c | 8 +++++++
tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml | 4 ++++
tests/qemuxml2argvdata/qemuxml2argv-hyperv.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 4 ++++
8 files changed, 86 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index b3187bb..3edd0a2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1460,6 +1460,10 @@
<relaxed state='on'/>
<vapic state='on'/>
<spinlocks state='on' retries='4096'/>
+ <vpindex state='on'/>
+ <runtime state='on'/>
+ <synic state='on'/>
+ <stimer state='on'/>
</hyperv>
<kvm>
<hidden state='on'/>
@@ -1535,6 +1539,30 @@
<td>on, off; retries - at least 4095</td>
<td><span class="since">1.1.0 (QEMU
only)</span></td>
</tr>
+ <tr>
+ <td>vpindex</td>
+ <td>Virtual processor index</td>
+ <td> on, off</td>
+ <td><span class="since">2.5.0 (QEMU
only)</span></td>
+ </tr>
+ <tr>
+ <td>runtime</td>
+ <td>Processor time spent on running guest code and on behalf of guest
code</td>
+ <td> on, off</td>
+ <td><span class="since">2.5.0 (QEMU
only)</span></td>
+ </tr>
+ <tr>
+ <td>synic</td>
+ <td>Enable Synthetic Interrupt Controller (SyNIC)</td>
+ <td> on, off</td>
+ <td><span class="since">2.5.0 (QEMU
only)</span></td>
+ </tr>
+ <tr>
+ <td>stimer</td>
+ <td>Enable SyNIC timers</td>
+ <td> on, off</td>
+ <td><span class="since">2.5.0 (QEMU
only)</span></td>
+ </tr>
</table>
</dd>
<dt><code>pvspinlock</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5deb17b..e079e86 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4858,6 +4858,26 @@
</optional>
</element>
</optional>
+ <optional>
+ <element name="vpindex">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="runtime">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="synic">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="stimer">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1ea74a6..bbc14fd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -145,7 +145,11 @@ VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
"relaxed",
"vapic",
- "spinlocks")
+ "spinlocks",
+ "vpindex",
+ "runtime",
+ "synic",
+ "stimer")
VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
"hidden")
@@ -15460,6 +15464,10 @@ virDomainDefParseXML(xmlDocPtr xml,
switch ((virDomainHyperv) feature) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
+ case VIR_DOMAIN_HYPERV_VPINDEX:
+ case VIR_DOMAIN_HYPERV_RUNTIME:
+ case VIR_DOMAIN_HYPERV_SYNIC:
+ case VIR_DOMAIN_HYPERV_STIMER:
if (!(tmp = virXPathString("string(./@state)", ctxt))) {
virReportError(VIR_ERR_XML_ERROR,
_("missing 'state' attribute for
"
@@ -17508,6 +17516,10 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
switch ((virDomainHyperv) i) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
+ case VIR_DOMAIN_HYPERV_VPINDEX:
+ case VIR_DOMAIN_HYPERV_RUNTIME:
+ case VIR_DOMAIN_HYPERV_SYNIC:
+ case VIR_DOMAIN_HYPERV_STIMER:
if (src->hyperv_features[i] != dst->hyperv_features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -22099,6 +22111,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
switch ((virDomainHyperv) j) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
+ case VIR_DOMAIN_HYPERV_VPINDEX:
+ case VIR_DOMAIN_HYPERV_RUNTIME:
+ case VIR_DOMAIN_HYPERV_SYNIC:
+ case VIR_DOMAIN_HYPERV_STIMER:
if (def->hyperv_features[j])
virBufferAsprintf(buf, "<%s
state='%s'/>\n",
virDomainHypervTypeToString(j),
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0141009..c96e0c4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1700,6 +1700,10 @@ typedef enum {
VIR_DOMAIN_HYPERV_RELAXED = 0,
VIR_DOMAIN_HYPERV_VAPIC,
VIR_DOMAIN_HYPERV_SPINLOCKS,
+ VIR_DOMAIN_HYPERV_VPINDEX,
+ VIR_DOMAIN_HYPERV_RUNTIME,
+ VIR_DOMAIN_HYPERV_SYNIC,
+ VIR_DOMAIN_HYPERV_STIMER,
VIR_DOMAIN_HYPERV_LAST
} virDomainHyperv;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5d3ab3a..fc55a82 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7739,6 +7739,10 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
switch ((virDomainHyperv) i) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
+ case VIR_DOMAIN_HYPERV_VPINDEX:
+ case VIR_DOMAIN_HYPERV_RUNTIME:
+ case VIR_DOMAIN_HYPERV_SYNIC:
+ case VIR_DOMAIN_HYPERV_STIMER:
if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
virBufferAsprintf(&buf, ",hv_%s",
virDomainHypervTypeToString(i));
@@ -12790,6 +12794,10 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
switch ((virDomainHyperv) f) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
+ case VIR_DOMAIN_HYPERV_VPINDEX:
+ case VIR_DOMAIN_HYPERV_RUNTIME:
+ case VIR_DOMAIN_HYPERV_SYNIC:
+ case VIR_DOMAIN_HYPERV_STIMER:
if (value) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("HyperV feature '%s' should not "
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml
b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml
index 1067f64..438f4a5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv-off.xml
@@ -14,6 +14,10 @@
<relaxed state='off'/>
<vapic state='off'/>
<spinlocks state='off'/>
+ <vpindex state='off'/>
+ <runtime state='off'/>
+ <synic state='off'/>
+ <stimer state='off'/>
</hyperv>
</features>
<clock offset='utc'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
index a6f37e3..e4b2af5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
-name QEMUGuest1 \
-S \
-M pc \
--cpu qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff \
+-cpu
qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,hv_synic,hv_stimer \
-m 214 \
-smp 6 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
index 2b8f332..2844b24 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
@@ -14,6 +14,10 @@
<relaxed state='on'/>
<vapic state='on'/>
<spinlocks state='on' retries='12287'/>
+ <vpindex state='on'/>
+ <runtime state='on'/>
+ <synic state='on'/>
+ <stimer state='on'/>
</hyperv>
</features>
<clock offset='utc'/>
--
1.8.3.1