[libvirt] [PATCH v4 0/4] Add support for Direct Mode for Hyper-V Synthetic timers

Changes since v3 [Ján Tomko]: - Drop already merged patches. - add "tests: qemuxml2argv: switch to DO_TEST_CAPS_LATEST for Hyper-V tests" patch (hope I got the idea correctly). - add hyperv-stimer-direct test to qemuxml2xml/qemuxml2argv tests. - use VIR_CPU_x86_HV_STIMER_DIRECT instead of 'hv-stimer-direct'. Original description: QEMU-4.1 will bring us Direct Mode for Hyper-V Synthetic timers support, we need to support it in libvirt too. As this is not a new enlightenment but rather an enhancement of an existing one ('stimer'), support it in <stimer state='on'> <direct state='on'/> </stimer> form. Backwards compatibility is (hopefully) preserved. Vitaly Kuznetsov (4): tests: qemuxml2argv: switch to DO_TEST_CAPS_LATEST for Hyper-V tests conf: add support for Direct Mode for Hyper-V Synthetic timers qemu: add support for Direct Mode for Hyper-V Synthetic timers news: mention Direct Mode for Hyper-V Synthetic timers support docs/formatdomain.html.in | 10 +-- docs/news.xml | 9 +++ docs/schemas/domaincommon.rng | 16 ++++- src/conf/domain_conf.c | 62 ++++++++++++++++++- src/conf/domain_conf.h | 1 + src/cpu/cpu_x86.c | 3 + src/cpu/cpu_x86_data.h | 2 + src/qemu/qemu_command.c | 3 + src/qemu/qemu_process.c | 20 +++++- tests/qemuxml2argvdata/hyperv-off.args | 27 -------- .../hyperv-off.x86_64-latest.args | 32 ++++++++++ tests/qemuxml2argvdata/hyperv-panic.args | 27 -------- .../hyperv-panic.x86_64-latest.args | 32 ++++++++++ .../hyperv-stimer-direct.x86_64-latest.args | 32 ++++++++++ .../qemuxml2argvdata/hyperv-stimer-direct.xml | 33 ++++++++++ tests/qemuxml2argvdata/hyperv.args | 29 --------- .../hyperv.x86_64-latest.args | 34 ++++++++++ tests/qemuxml2argvtest.c | 7 ++- .../hyperv-stimer-direct.xml | 35 +++++++++++ tests/qemuxml2xmltest.c | 1 + 20 files changed, 321 insertions(+), 94 deletions(-) delete mode 100644 tests/qemuxml2argvdata/hyperv-off.args create mode 100644 tests/qemuxml2argvdata/hyperv-off.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hyperv-panic.args create mode 100644 tests/qemuxml2argvdata/hyperv-panic.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.xml delete mode 100644 tests/qemuxml2argvdata/hyperv.args create mode 100644 tests/qemuxml2argvdata/hyperv.x86_64-latest.args create mode 100644 tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml -- 2.20.1

In particular, switch to using canonical 'hv-feature' syntax instead of 'hv_feature' aliases. Suggested-by: Ján Tomko <jtomko@redhat.com>~ Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- tests/qemuxml2argvdata/hyperv-off.args | 27 --------------- .../hyperv-off.x86_64-latest.args | 32 +++++++++++++++++ tests/qemuxml2argvdata/hyperv-panic.args | 27 --------------- .../hyperv-panic.x86_64-latest.args | 32 +++++++++++++++++ tests/qemuxml2argvdata/hyperv.args | 29 ---------------- .../hyperv.x86_64-latest.args | 34 +++++++++++++++++++ tests/qemuxml2argvtest.c | 6 ++-- 7 files changed, 101 insertions(+), 86 deletions(-) delete mode 100644 tests/qemuxml2argvdata/hyperv-off.args create mode 100644 tests/qemuxml2argvdata/hyperv-off.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hyperv-panic.args create mode 100644 tests/qemuxml2argvdata/hyperv-panic.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hyperv.args create mode 100644 tests/qemuxml2argvdata/hyperv.x86_64-latest.args diff --git a/tests/qemuxml2argvdata/hyperv-off.args b/tests/qemuxml2argvdata/hyperv-off.args deleted file mode 100644 index 59a79376d1..0000000000 --- a/tests/qemuxml2argvdata/hyperv-off.args +++ /dev/null @@ -1,27 +0,0 @@ -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 QEMUGuest1 \ --S \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --m 214 \ --realtime mlock=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,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ -server,nowait \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --usb \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/hyperv-off.x86_64-latest.args b/tests/qemuxml2argvdata/hyperv-off.x86_64-latest.args new file mode 100644 index 0000000000..52f7473e14 --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv-off.x86_64-latest.args @@ -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 \ +-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 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/hyperv-panic.args b/tests/qemuxml2argvdata/hyperv-panic.args deleted file mode 100644 index 1ef5068aca..0000000000 --- a/tests/qemuxml2argvdata/hyperv-panic.args +++ /dev/null @@ -1,27 +0,0 @@ -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 QEMUGuest1 \ --S \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --cpu qemu32,hv-crash \ --m 214 \ --realtime mlock=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,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ -server,nowait \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --usb diff --git a/tests/qemuxml2argvdata/hyperv-panic.x86_64-latest.args b/tests/qemuxml2argvdata/hyperv-panic.x86_64-latest.args new file mode 100644 index 0000000000..c92df8b79f --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv-panic.x86_64-latest.args @@ -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-crash \ +-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 diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args deleted file mode 100644 index 086adaa349..0000000000 --- a/tests/qemuxml2argvdata/hyperv.args +++ /dev/null @@ -1,29 +0,0 @@ -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 QEMUGuest1 \ --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' \ --m 214 \ --realtime mlock=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,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ -server,nowait \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --usb diff --git a/tests/qemuxml2argvdata/hyperv.x86_64-latest.args b/tests/qemuxml2argvdata/hyperv.x86_64-latest.args new file mode 100644 index 0000000000..33c70bb7e7 --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv.x86_64-latest.args @@ -0,0 +1,34 @@ +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-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' \ +-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 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c166fd18d6..4c3aeffe76 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -911,9 +911,9 @@ mymain(void) DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "4.0.0"); DO_TEST_CAPS_LATEST("kvmclock+eoi-disabled"); - DO_TEST("hyperv", NONE); - DO_TEST("hyperv-off", NONE); - DO_TEST("hyperv-panic", NONE); + DO_TEST_CAPS_LATEST("hyperv"); + DO_TEST_CAPS_LATEST("hyperv-off"); + DO_TEST_CAPS_LATEST("hyperv-panic"); DO_TEST("kvm-features", NONE); DO_TEST("kvm-features-off", NONE); -- 2.20.1

On Fri, Aug 09, 2019 at 04:31:38PM +0200, Vitaly Kuznetsov wrote:
In particular, switch to using canonical 'hv-feature' syntax instead of 'hv_feature' aliases.
We should keep the coverage for the old syntax too.
Suggested-by: Ján Tomko <jtomko@redhat.com>~ Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- tests/qemuxml2argvdata/hyperv-off.args | 27 --------------- .../hyperv-off.x86_64-latest.args | 32 +++++++++++++++++ tests/qemuxml2argvdata/hyperv-panic.args | 27 --------------- .../hyperv-panic.x86_64-latest.args | 32 +++++++++++++++++ tests/qemuxml2argvdata/hyperv.args | 29 ---------------- .../hyperv.x86_64-latest.args | 34 +++++++++++++++++++ tests/qemuxml2argvtest.c | 6 ++-- 7 files changed, 101 insertions(+), 86 deletions(-) delete mode 100644 tests/qemuxml2argvdata/hyperv-off.args create mode 100644 tests/qemuxml2argvdata/hyperv-off.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hyperv-panic.args create mode 100644 tests/qemuxml2argvdata/hyperv-panic.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hyperv.args create mode 100644 tests/qemuxml2argvdata/hyperv.x86_64-latest.args
Reviewed-by: Ján Tomko <jtomko@redhat.com> with the following squashed in: diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 62afd31575..784316e816 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -911,8 +911,11 @@ mymain(void) DO_TEST_CAPS_VER("kvmclock+eoi-disabled", "4.0.0"); DO_TEST_CAPS_LATEST("kvmclock+eoi-disabled"); + DO_TEST_CAPS_VER("hyperv", "4.0.0"); DO_TEST_CAPS_LATEST("hyperv"); + DO_TEST_CAPS_VER("hyperv-off", "4.0.0"); DO_TEST_CAPS_LATEST("hyperv-off"); + DO_TEST_CAPS_VER("hyperv-panic", "4.0.0"); DO_TEST_CAPS_LATEST("hyperv-panic"); DO_TEST("kvm-features", NONE); diff --git a/tests/qemuxml2argvdata/hyperv-off.x86_64-4.0.0.args b/tests/qemuxml2argvdata/hyperv-off.x86_64-4.0.0.args new file mode 100644 index 0000000000..d99bfb4d4e --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv-off.x86_64-4.0.0.args @@ -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-i440fx-4.0,accel=tcg,usb=off,dump-guest-core=off \ +-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 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/hyperv-panic.x86_64-4.0.0.args b/tests/qemuxml2argvdata/hyperv-panic.x86_64-4.0.0.args new file mode 100644 index 0000000000..5a16ac97ee --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv-panic.x86_64-4.0.0.args @@ -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-i440fx-4.0,accel=tcg,usb=off,dump-guest-core=off \ +-cpu qemu32,hv-crash \ +-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 diff --git a/tests/qemuxml2argvdata/hyperv.x86_64-4.0.0.args b/tests/qemuxml2argvdata/hyperv.x86_64-4.0.0.args new file mode 100644 index 0000000000..7966cebdc1 --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv.x86_64-4.0.0.args @@ -0,0 +1,34 @@ +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-i440fx-4.0,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' \ +-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

Support 'Direct Mode' for Hyper-V Synthetic Timers in domain config. Make it 'stimer' enlightenment option as it is not a separate thing. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- docs/formatdomain.html.in | 10 +++--- docs/schemas/domaincommon.rng | 16 ++++++++- src/conf/domain_conf.c | 62 ++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 1 + src/cpu/cpu_x86.c | 3 ++ src/cpu/cpu_x86_data.h | 2 ++ 6 files changed, 88 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f5c882141a..de577e5755 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2033,7 +2033,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'/> @@ -2148,9 +2150,9 @@ </tr> <tr> <td>stimer</td> - <td>Enable SynIC timers</td> - <td>on, off</td> - <td><span class="since">1.3.3 (QEMU 2.6)</span></td> + <td>Enable SynIC timers, optionally with Direct Mode support</td> + <td>on, off; direct - on,off</td> + <td><span class="since">1.3.3 (QEMU 2.6), direct mode 5.7.0 (QEMU 4.1)</span></td> </tr> <tr> <td>reset</td> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a0771da45b..6707dcc634 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5907,7 +5907,7 @@ </optional> <optional> <element name="stimer"> - <ref name="featurestate"/> + <ref name="stimer"/> </element> </optional> <optional> @@ -5956,6 +5956,20 @@ </element> </define> + <!-- Hyper-V stimer features --> + <define name="stimer"> + <interleave> + <optional> + <ref name="featurestate"/> + </optional> + <optional> + <element name="direct"> + <ref name="featurestate"/> + </element> + </optional> + </interleave> + </define> + <!-- Optional KVM features --> <define name="kvm"> <element name="kvm"> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0456369d55..f56e850ade 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20388,6 +20388,39 @@ virDomainDefParseXML(xmlDocPtr xml, ctxt->node = node; } + if (def->features[VIR_DOMAIN_HYPERV_STIMER] == VIR_TRISTATE_SWITCH_ON) { + int value; + if ((n = virXPathNodeSet("./features/hyperv/stimer/*", ctxt, &nodes)) < 0) + goto error; + + for (i = 0; i < n; i++) { + if (STRNEQ((const char *)nodes[i]->name, "direct")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported Hyper-V stimer feature: %s"), + nodes[i]->name); + goto error; + } + + if (!(tmp = virXMLPropString(nodes[i], "state"))) { + virReportError(VIR_ERR_XML_ERROR, + _("missing 'state' attribute for " + "Hyper-V stimer '%s' feature"), "direct"); + goto error; + } + + if ((value = virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid value of state argument " + "for Hyper-V stimer '%s' feature"), "direct"); + goto error; + } + + VIR_FREE(tmp); + def->hyperv_stimer_direct = value; + } + VIR_FREE(nodes); + } + if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) { int feature; int value; @@ -22612,6 +22645,17 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, } } + if (src->hyperv_features[VIR_DOMAIN_HYPERV_STIMER] == VIR_TRISTATE_SWITCH_ON) { + if (src->hyperv_stimer_direct != dst->hyperv_stimer_direct) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("State of HyperV stimer direct feature differs: " + "source: '%s', destination: '%s'"), + virTristateSwitchTypeToString(src->hyperv_stimer_direct), + virTristateSwitchTypeToString(dst->hyperv_stimer_direct)); + return false; + } + } + /* kvm */ if (src->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) { for (i = 0; i < VIR_DOMAIN_KVM_LAST; i++) { @@ -28071,7 +28115,6 @@ virDomainDefFormatFeatures(virBufferPtr buf, case VIR_DOMAIN_HYPERV_VPINDEX: case VIR_DOMAIN_HYPERV_RUNTIME: case VIR_DOMAIN_HYPERV_SYNIC: - case VIR_DOMAIN_HYPERV_STIMER: case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: @@ -28090,6 +28133,23 @@ virDomainDefFormatFeatures(virBufferPtr buf, def->hyperv_spinlocks); break; + case VIR_DOMAIN_HYPERV_STIMER: + if (def->hyperv_features[j] != VIR_TRISTATE_SWITCH_ON) { + virBufferAddLit(&childBuf, "/>\n"); + break; + } + if (def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON) { + virBufferAddLit(&childBuf, ">\n"); + virBufferAdjustIndent(&childBuf, 2); + virBufferAddLit(&childBuf, "<direct state='on'/>\n"); + virBufferAdjustIndent(&childBuf, -2); + virBufferAddLit(&childBuf, "</stimer>\n"); + } else { + virBufferAddLit(&childBuf, "/>\n"); + } + + break; + case VIR_DOMAIN_HYPERV_VENDOR_ID: if (def->hyperv_features[j] != VIR_TRISTATE_SWITCH_ON) { virBufferAddLit(&childBuf, "/>\n"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 57ca2a8ad1..8434f1fd0b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2400,6 +2400,7 @@ struct _virDomainDef { int kvm_features[VIR_DOMAIN_KVM_LAST]; int msrs_features[VIR_DOMAIN_MSRS_LAST]; unsigned int hyperv_spinlocks; + int hyperv_stimer_direct; virGICVersion gic_version; virDomainHPTResizing hpt_resizing; unsigned long long hpt_maxpagesize; /* Stored in KiB */ diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index d2d9537c32..32b9836dd5 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -100,6 +100,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_HV_IPI, 0x40000004, 0x00000400, 0x0); KVM_FEATURE_DEF(VIR_CPU_x86_HV_EVMCS, 0x40000004, 0x00004000, 0x0); +KVM_FEATURE_DEF(VIR_CPU_x86_HV_STIMER_DIRECT, + 0x40000003, 0x0, 0x00080000); static virCPUx86Feature x86_kvm_features[] = { @@ -116,6 +118,7 @@ static virCPUx86Feature x86_kvm_features[] = KVM_FEATURE(VIR_CPU_x86_HV_TLBFLUSH), KVM_FEATURE(VIR_CPU_x86_HV_IPI), KVM_FEATURE(VIR_CPU_x86_HV_EVMCS), + KVM_FEATURE(VIR_CPU_x86_HV_STIMER_DIRECT), }; typedef struct _virCPUx86Model virCPUx86Model; diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index cc0c93dff0..cebf3b6669 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -64,6 +64,8 @@ struct _virCPUx86MSR { #define VIR_CPU_x86_HV_IPI "hv-ipi" #define VIR_CPU_x86_HV_EVMCS "hv-evmcs" +/* Hyper-V Synthetic Timer option */ +#define VIR_CPU_x86_HV_STIMER_DIRECT "hv-stimer-direct" #define VIR_CPU_X86_DATA_INIT { 0 } -- 2.20.1

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> --- src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_process.c | 20 +++++++++-- .../hyperv-stimer-direct.x86_64-latest.args | 32 +++++++++++++++++ .../qemuxml2argvdata/hyperv-stimer-direct.xml | 33 +++++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../hyperv-stimer-direct.xml | 35 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 7 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.xml create mode 100644 tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 71a36ff63a..9add21b929 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1ed56457b1..7c6428ea75 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, 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: diff --git a/tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args b/tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args new file mode 100644 index 0000000000..34e27c75f0 --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args @@ -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 diff --git a/tests/qemuxml2argvdata/hyperv-stimer-direct.xml b/tests/qemuxml2argvdata/hyperv-stimer-direct.xml new file mode 100644 index 0000000000..9c865f5746 --- /dev/null +++ b/tests/qemuxml2argvdata/hyperv-stimer-direct.xml @@ -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> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4c3aeffe76..235efe0b06 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -914,6 +914,7 @@ mymain(void) DO_TEST_CAPS_LATEST("hyperv"); DO_TEST_CAPS_LATEST("hyperv-off"); DO_TEST_CAPS_LATEST("hyperv-panic"); + DO_TEST_CAPS_LATEST("hyperv-stimer-direct"); DO_TEST("kvm-features", NONE); DO_TEST("kvm-features-off", NONE); diff --git a/tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml b/tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml new file mode 100644 index 0000000000..806164beea --- /dev/null +++ b/tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml @@ -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> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 525eb9a740..7e14125f97 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -289,6 +289,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); -- 2.20.1

On Fri, Aug 09, 2019 at 04:31:40PM +0200, Vitaly Kuznetsov wrote:
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> --- src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_process.c | 20 +++++++++-- .../hyperv-stimer-direct.x86_64-latest.args | 32 +++++++++++++++++ .../qemuxml2argvdata/hyperv-stimer-direct.xml | 33 +++++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../hyperv-stimer-direct.xml | 35 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 7 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.xml create mode 100644 tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The QEMU driver now supports Direct Mode for Hyper-V Synthetic timers for Hyper-V guests. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- docs/news.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index a4d727b9c5..d63fca3b48 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -41,6 +41,15 @@ <libvirt> <release version="v5.7.0" date="unreleased"> <section title="New features"> + <change> + <summary> + qemu: Support Direct Mode for Hyper-V Synthetic timers + </summary> + <description> + The QEMU driver now supports Direct Mode for Hyper-V Synthetic timers + for Hyper-V guests. + </description> + </change> </section> <section title="Improvements"> </section> -- 2.20.1

Vitaly Kuznetsov <vkuznets@redhat.com> writes:
Changes since v3 [Ján Tomko]: - Drop already merged patches. - add "tests: qemuxml2argv: switch to DO_TEST_CAPS_LATEST for Hyper-V tests" patch (hope I got the idea correctly). - add hyperv-stimer-direct test to qemuxml2xml/qemuxml2argv tests. - use VIR_CPU_x86_HV_STIMER_DIRECT instead of 'hv-stimer-direct'.
Original description:
QEMU-4.1 will bring us Direct Mode for Hyper-V Synthetic timers support, we need to support it in libvirt too. As this is not a new enlightenment but rather an enhancement of an existing one ('stimer'), support it in
<stimer state='on'> <direct state='on'/> </stimer>
form. Backwards compatibility is (hopefully) preserved.
Vitaly Kuznetsov (4): tests: qemuxml2argv: switch to DO_TEST_CAPS_LATEST for Hyper-V tests conf: add support for Direct Mode for Hyper-V Synthetic timers qemu: add support for Direct Mode for Hyper-V Synthetic timers news: mention Direct Mode for Hyper-V Synthetic timers support
ping? -- Vitaly
participants (2)
-
Ján Tomko
-
Vitaly Kuznetsov