QEMU-4.1 supports 'Direct Mode' for Hyper-V synthetic timers
(hv-stimer-direct CPU flag): Windows guests can request that timer
expiration notifications are delivered as normal interrupts (and not
VMBus messages). This is used by Hyper-V on KVM.
Signed-off-by: Vitaly Kuznetsov <vkuznets(a)redhat.com>
---
src/qemu/qemu_command.c | 12 ++++++++----
src/qemu/qemu_process.c | 20 ++++++++++++++++++--
tests/qemuxml2argvdata/hyperv.args | 4 ++--
tests/qemuxml2argvdata/hyperv.xml | 4 +++-
tests/qemuxml2xmloutdata/hyperv.xml | 4 +++-
5 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c8494de785..af913dba34 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7152,10 +7152,10 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
}
if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) {
- const char *hvPrefix = "hv-";
+ const char *hvDelimiter = "-";
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES))
- hvPrefix = "hv_";
+ hvDelimiter = "_";
for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
switch ((virDomainHyperv) i) {
@@ -7172,9 +7172,13 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_HYPERV_IPI:
case VIR_DOMAIN_HYPERV_EVMCS:
if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
- virBufferAsprintf(&buf, ",%s%s",
- hvPrefix,
+ virBufferAsprintf(&buf, ",hv%s%s",
+ hvDelimiter,
virDomainHypervTypeToString(i));
+ if ((i == VIR_DOMAIN_HYPERV_STIMER) &&
+ (def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON))
+ virBufferAsprintf(&buf, ",hv%sstimer%sdirect",
hvDelimiter,
+ hvDelimiter);
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1ed56457b1..792fa33327 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4112,10 +4112,26 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
rc = virCPUDataCheckFeature(cpu, cpuFeature);
VIR_FREE(cpuFeature);
- if (rc < 0)
+ if (rc < 0) {
return -1;
- else if (rc == 1)
+ } else if (rc == 1) {
+ if (i == VIR_DOMAIN_HYPERV_STIMER) {
+ if (def->hyperv_stimer_direct != VIR_TRISTATE_SWITCH_ON)
+ continue;
+
+ rc = virCPUDataCheckFeature(cpu, "hv-stimer-direct");
+ if (rc < 0)
+ return -1;
+ else if (rc == 1)
+ continue;
+
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("host doesn't support hyperv stimer
'%s' feature"),
+ "direct");
+ return -1;
+ }
continue;
+ }
switch ((virDomainHyperv) i) {
case VIR_DOMAIN_HYPERV_RELAXED:
diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args
index 086adaa349..8040da9caa 100644
--- a/tests/qemuxml2argvdata/hyperv.args
+++ b/tests/qemuxml2argvdata/hyperv.args
@@ -12,8 +12,8 @@ QEMU_AUDIO_DRV=none \
-S \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu 'qemu32,hv_relaxed,hv_vapic,hv-spinlocks=0x2fff,hv_vpindex,hv_runtime,\
-hv_synic,hv_stimer,hv_reset,hv-vendor-id=KVM Hv,hv_frequencies,\
-hv_reenlightenment,hv_tlbflush,hv_ipi,hv_evmcs' \
+hv_synic,hv_stimer,hv_stimer_direct,hv_reset,hv-vendor-id=KVM Hv,\
+hv_frequencies,hv_reenlightenment,hv_tlbflush,hv_ipi,hv_evmcs' \
-m 214 \
-realtime mlock=off \
-smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/hyperv.xml b/tests/qemuxml2argvdata/hyperv.xml
index c6feaed528..ae0f934f76 100644
--- a/tests/qemuxml2argvdata/hyperv.xml
+++ b/tests/qemuxml2argvdata/hyperv.xml
@@ -17,7 +17,9 @@
<vpindex state='on'/>
<runtime state='on'/>
<synic state='on'/>
- <stimer state='on'/>
+ <stimer state='on'>
+ <direct state='on'/>
+ </stimer>
<reset state='on'/>
<vendor_id state='on' value='KVM Hv'/>
<frequencies state='on'/>
diff --git a/tests/qemuxml2xmloutdata/hyperv.xml b/tests/qemuxml2xmloutdata/hyperv.xml
index 5510d3dfad..2e4b43d4c6 100644
--- a/tests/qemuxml2xmloutdata/hyperv.xml
+++ b/tests/qemuxml2xmloutdata/hyperv.xml
@@ -17,7 +17,9 @@
<vpindex state='on'/>
<runtime state='on'/>
<synic state='on'/>
- <stimer state='on'/>
+ <stimer state='on'>
+ <direct state='on'/>
+ </stimer>
<reset state='on'/>
<vendor_id state='on' value='KVM Hv'/>
<frequencies state='on'/>
--
2.20.1