qemu: add support for Direct Mode for Hyper-V Synthetic timers

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Vitaly Kuznetsov 2019-08-09 16:31:40 +02:00 committed by Ján Tomko
parent 65c02db98d
commit 9f3b5f89d4
7 changed files with 123 additions and 2 deletions

View File

@ -7175,6 +7175,9 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
virBufferAsprintf(&buf, ",%s%s",
hvPrefix,
virDomainHypervTypeToString(i));
if ((i == VIR_DOMAIN_HYPERV_STIMER) &&
(def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON))
virBufferAsprintf(&buf, ",%s", VIR_CPU_x86_HV_STIMER_DIRECT);
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:

View File

@ -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, VIR_CPU_x86_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:

View File

@ -0,0 +1,32 @@
LC_ALL=C \
PATH=/bin \
HOME=/tmp/lib/domain--1-QEMUGuest1 \
USER=test \
LOGNAME=test \
XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
QEMU_AUDIO_DRV=none \
/usr/bin/qemu-system-i686 \
-name guest=QEMUGuest1,debug-threads=on \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu qemu32,hv-vpindex,hv-synic,hv-stimer,hv-stimer-direct \
-m 214 \
-overcommit mem-lock=off \
-smp 6,sockets=6,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-display none \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=1729,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
-msg timestamp=on

View File

@ -0,0 +1,33 @@
<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>
<vpindex state='on'/>
<synic state='on'/>
<stimer state='on'>
<direct state='on'/>
</stimer>
</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-system-i686</emulator>
<controller type='usb' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<memballoon model='none'/>
</devices>
</domain>

View File

@ -917,6 +917,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("hyperv-off");
DO_TEST_CAPS_VER("hyperv-panic", "4.0.0");
DO_TEST_CAPS_LATEST("hyperv-panic");
DO_TEST_CAPS_LATEST("hyperv-stimer-direct");
DO_TEST("kvm-features", NONE);
DO_TEST("kvm-features-off", NONE);

View File

@ -0,0 +1,35 @@
<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>
<vpindex state='on'/>
<synic state='on'/>
<stimer state='on'>
<direct state='on'/>
</stimer>
</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-system-i686</emulator>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<memballoon model='none'/>
</devices>
</domain>

View File

@ -300,6 +300,7 @@ mymain(void)
DO_TEST("hyperv", NONE);
DO_TEST("hyperv-off", NONE);
DO_TEST("hyperv-panic", NONE);
DO_TEST("hyperv-stimer-direct", NONE);
DO_TEST("kvm-features", NONE);
DO_TEST("kvm-features-off", NONE);