Changes since v3: - Make 'hv-default' override 'hv-*' options which were already set (e.g. 'hv-feature=on,hv-default' case) [Igor]. Make 'hv-passthrough' behave the same way. - Add "i386: be more picky about implicit 'hv-evmcs' enablement" patch to avoid enabling 'hv-evmcs' with hv-default/hv-passthrough when guest CPU lacks VMX. - Add "i386: support 'hv-passthrough,hv-feature=off' on the command line" patch to make 'hv-passthrough' semantics match the newly introduced 'hv-default'. - Add "i386: track explicit 'hv-*' features enablement/disablement" patch to support the above mentioned changes. - Expand qtest to check the above mentioned improvements.
Original description: Upper layer tools like libvirt want to figure out which Hyper-V features are supported by the underlying stack (QEMU/KVM) but currently they are unable to do so. We have a nice 'hv_passthrough' CPU flag supported by QEMU but it has no effect on e.g. QMP's query-cpu-model-expansion type=full model={"name":"host","props":{"hv-passthrough":true}} command as we parse Hyper-V features after creating KVM vCPUs and not at feature expansion time. To support the use-case we first need to make KVM_GET_SUPPORTED_HV_CPUID ioctl a system-wide ioctl as the existing vCPU version can't be used that early. This is what KVM part does. With that done, we can make early Hyper-V feature expansion (this series). In addition, provide a simple 'hv-default' option which enables (and requires from KVM) all currently supported Hyper-V enlightenments. Unlike 'hv-passthrough' mode, this is going to be migratable. Vitaly Kuznetsov (21): i386: keep hyperv_vendor string up-to-date i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough i386: always fill Hyper-V CPUID feature leaves from X86CPU data i386: stop using env->features[] for filling Hyper-V CPUIDs i386: introduce hyperv_feature_supported() i386: introduce hv_cpuid_get_host() i386: drop FEAT_HYPERV feature leaves i386: introduce hv_cpuid_cache i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids() i386: move eVMCS enablement to hyperv_init_vcpu() i386: switch hyperv_expand_features() to using error_setg() i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one i386: use global kvm_state in hyperv_enabled() check i386: expand Hyper-V features during CPU feature expansion time i386: track explicit 'hv-*' features enablement/disablement i386: support 'hv-passthrough,hv-feature=off' on the command line i386: be more picky about implicit 'hv-evmcs' enablement i386: introduce kvm_hv_evmcs_available() i386: provide simple 'hv-default=on' option qtest/hyperv: Introduce a simple hyper-v test MAINTAINERS | 1 + docs/hyperv.txt | 16 +- target/i386/cpu.c | 430 ++++++++++++++++++++--------- target/i386/cpu.h | 11 +- target/i386/kvm/kvm-stub.c | 10 + target/i386/kvm/kvm.c | 535 +++++++++++++++++++++---------------- target/i386/kvm/kvm_i386.h | 2 + tests/qtest/hyperv-test.c | 312 +++++++++++++++++++++ tests/qtest/meson.build | 3 +- 9 files changed, 950 insertions(+), 370 deletions(-) create mode 100644 tests/qtest/hyperv-test.c -- 2.29.2