qemu-6.2 introduced support for the hv-avic enlightenment which allows to use Hyper-V SynIC with hardware APICv/AVIC enabled. Implement the libvirt support for it. Closes: https://gitlab.com/libvirt/libvirt/-/issues/402 Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- docs/formatdomain.rst | 1 + src/conf/domain_conf.c | 4 ++++ src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 5 +++++ src/qemu/qemu_command.c | 1 + src/qemu/qemu_process.c | 1 + tests/qemuxml2argvdata/hyperv.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/hyperv.xml | 1 + tests/qemuxml2xmloutdata/hyperv.xml | 1 + 9 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index acb318520c..488b6be862 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2016,6 +2016,7 @@ are: tlbflush Enable PV TLB flush support on, off :since:`4.7.0 (QEMU 3.0)` ipi Enable PV IPI support on, off :since:`4.10.0 (QEMU 3.1)` evmcs Enable Enlightened VMCS on, off :since:`4.10.0 (QEMU 3.1)` + avic Enable use Hyper-V SynIC with hardware APICv/AVIC on, off :since:`8.10.0 (QEMU 6.2)` =============== ====================================================================== ============================================ ======================================================= :since:`Since 8.0.0` , the hypervisor can be configured further by setting diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dc2281b2bd..2643f62e03 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -206,6 +206,7 @@ VIR_ENUM_IMPL(virDomainHyperv, "tlbflush", "ipi", "evmcs", + "avic", ); VIR_ENUM_IMPL(virDomainKVM, @@ -15814,6 +15815,7 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, case VIR_DOMAIN_HYPERV_TLBFLUSH: case VIR_DOMAIN_HYPERV_IPI: case VIR_DOMAIN_HYPERV_EVMCS: + case VIR_DOMAIN_HYPERV_AVIC: break; case VIR_DOMAIN_HYPERV_STIMER: @@ -20134,6 +20136,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src, case VIR_DOMAIN_HYPERV_TLBFLUSH: case VIR_DOMAIN_HYPERV_IPI: case VIR_DOMAIN_HYPERV_EVMCS: + case VIR_DOMAIN_HYPERV_AVIC: if (src->hyperv_features[i] != dst->hyperv_features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of HyperV enlightenment " @@ -26454,6 +26457,7 @@ virDomainDefFormatFeatures(virBuffer *buf, case VIR_DOMAIN_HYPERV_TLBFLUSH: case VIR_DOMAIN_HYPERV_IPI: case VIR_DOMAIN_HYPERV_EVMCS: + case VIR_DOMAIN_HYPERV_AVIC: virBufferAddLit(&childBuf, "/>\n"); break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 54dc9098df..a05d4d4b1c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2149,6 +2149,7 @@ typedef enum { VIR_DOMAIN_HYPERV_TLBFLUSH, VIR_DOMAIN_HYPERV_IPI, VIR_DOMAIN_HYPERV_EVMCS, + VIR_DOMAIN_HYPERV_AVIC, VIR_DOMAIN_HYPERV_LAST } virDomainHyperv; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index cefe818044..03703148df 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7461,6 +7461,11 @@ <ref name="featurestate"/> </element> </optional> + <optional> + <element name="avic"> + <ref name="featurestate"/> + </element> + </optional> </interleave> </group> </choice> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 256ef4912c..513ff7624f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6237,6 +6237,7 @@ qemuBuildCpuCommandLine(virCommand *cmd, case VIR_DOMAIN_HYPERV_TLBFLUSH: case VIR_DOMAIN_HYPERV_IPI: case VIR_DOMAIN_HYPERV_EVMCS: + case VIR_DOMAIN_HYPERV_AVIC: if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) virBufferAsprintf(&buf, ",hv-%s=on", virDomainHypervTypeToString(i)); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e7f92228f5..0ced2d88ab 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4245,6 +4245,7 @@ qemuProcessVerifyHypervFeatures(virDomainDef *def, case VIR_DOMAIN_HYPERV_TLBFLUSH: case VIR_DOMAIN_HYPERV_IPI: case VIR_DOMAIN_HYPERV_EVMCS: + case VIR_DOMAIN_HYPERV_AVIC: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("host doesn't support hyperv '%s' feature"), virDomainHypervTypeToString(i)); diff --git a/tests/qemuxml2argvdata/hyperv.x86_64-latest.args b/tests/qemuxml2argvdata/hyperv.x86_64-latest.args index 50329f6e30..0b00102e18 100644 --- a/tests/qemuxml2argvdata/hyperv.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hyperv.x86_64-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ -machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \ -accel tcg \ --cpu 'qemu64,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x2fff,hv-vpindex=on,hv-runtime=on,hv-synic=on,hv-stimer=on,hv-reset=on,hv-vendor-id=KVM Hv,hv-frequencies=on,hv-reenlightenment=on,hv-tlbflush=on,hv-ipi=on,hv-evmcs=on' \ +-cpu 'qemu64,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x2fff,hv-vpindex=on,hv-runtime=on,hv-synic=on,hv-stimer=on,hv-reset=on,hv-vendor-id=KVM Hv,hv-frequencies=on,hv-reenlightenment=on,hv-tlbflush=on,hv-ipi=on,hv-evmcs=on,hv-avic=on' \ -m 214 \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ -overcommit mem-lock=off \ diff --git a/tests/qemuxml2argvdata/hyperv.xml b/tests/qemuxml2argvdata/hyperv.xml index e3184b3657..dde091aa9a 100644 --- a/tests/qemuxml2argvdata/hyperv.xml +++ b/tests/qemuxml2argvdata/hyperv.xml @@ -25,6 +25,7 @@ <tlbflush state='on'/> <ipi state='on'/> <evmcs state='on'/> + <avic state='on'/> </hyperv> </features> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/hyperv.xml b/tests/qemuxml2xmloutdata/hyperv.xml index e21c330767..4445c85118 100644 --- a/tests/qemuxml2xmloutdata/hyperv.xml +++ b/tests/qemuxml2xmloutdata/hyperv.xml @@ -25,6 +25,7 @@ <tlbflush state='on'/> <ipi state='on'/> <evmcs state='on'/> + <avic state='on'/> </hyperv> </features> <clock offset='utc'/> -- 2.37.3