QEMU version 3.1 introduced PV_SEND_IPI CPUID feature bit under
commit 7f710c32bb8 (target-i386: adds PV_SEND_IPI CPUID feature bit).
This patch adds a new KVM feature 'pv-ipi' to disable this feature
(enabled by default). Newer CPU platform (Ex, AMD Zen2) supports
hardware accelation for IPI in guest, to use this feature to get
better performance in some scenarios. Detailed about the discussion:
https://lkml.org/lkml/2021/10/20/423
To disable kvm-pv-ipi and have libvirt add "-cpu host,kvm-pv-ipi=off"
to the QEMU command line, the following XML code needs to be added to the
guest's domain description:
<features>
<kvm>
<pv-ipi state='off'/>
</kvm>
</features>
Signed-off-by: zhenwei pi <pizhenwei@xxxxxxxxxxxxx>
---
docs/formatdomain.rst | 2 ++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 3 +++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 5 +++++
5 files changed, 16 insertions(+)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 58768f7e5e..8ff833bbd2 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1842,6 +1842,7 @@ Hypervisors may allow certain CPU / machine features to be toggled on/off.
<hidden state='on'/>
<hint-dedicated state='on'/>
<poll-control state='on'/>
+ <pv-ipi state='off'/>
</kvm>
<xen>
<e820_host state='on'/>
@@ -1930,6 +1931,7 @@ are:
hidden Hide the KVM hypervisor from standard MSR based discovery on, off :since:`1.2.8 (QEMU 2.1.0)`
hint-dedicated Allows a guest to enable optimizations when running on dedicated vCPUs on, off :since:`5.7.0 (QEMU 2.12.0)`
poll-control Decrease IO completion latency by introducing a grace period of busy waiting on, off :since:`6.10.0 (QEMU 4.2)`
+ pv-ipi Paravirtualized send IPIs on, off :since:`7.10.0 (QEMU 3.1)`
============== ============================================================================ ======= ============================
``xen``
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f71e375a33..67df13d90d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -7177,6 +7177,11 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <element name="pv-ipi">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 48c6ee9865..c8868de577 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -204,6 +204,7 @@ VIR_ENUM_IMPL(virDomainKVM,
"hidden",
"hint-dedicated",
"poll-control",
+ "pv-ipi",
);
VIR_ENUM_IMPL(virDomainXen,
@@ -21789,6 +21790,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src,
case VIR_DOMAIN_KVM_HIDDEN:
case VIR_DOMAIN_KVM_DEDICATED:
case VIR_DOMAIN_KVM_POLLCONTROL:
+ case VIR_DOMAIN_KVM_PVIPI:
if (src->kvm_features[i] != dst->kvm_features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of KVM feature '%s' differs: "
@@ -27821,6 +27823,7 @@ virDomainDefFormatFeatures(virBuffer *buf,
case VIR_DOMAIN_KVM_HIDDEN:
case VIR_DOMAIN_KVM_DEDICATED:
case VIR_DOMAIN_KVM_POLLCONTROL:
+ case VIR_DOMAIN_KVM_PVIPI:
if (def->kvm_features[j])
virBufferAsprintf(&childBuf, "<%s state='%s'/>\n",
virDomainKVMTypeToString(j),
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f4be5c84f0..cb6d8975b8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2073,6 +2073,7 @@ typedef enum {
VIR_DOMAIN_KVM_HIDDEN = 0,
VIR_DOMAIN_KVM_DEDICATED,
VIR_DOMAIN_KVM_POLLCONTROL,
+ VIR_DOMAIN_KVM_PVIPI,
VIR_DOMAIN_KVM_LAST
} virDomainKVM;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7374b2beca..f7c19246d8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6848,6 +6848,11 @@ qemuBuildCpuCommandLine(virCommand *cmd,
virBufferAddLit(&buf, ",kvm-poll-control=on");
break;
+ case VIR_DOMAIN_KVM_PVIPI:
+ if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_OFF)
+ virBufferAddLit(&buf, ",kvm-pv-ipi=off");
+ break;
+
case VIR_DOMAIN_KVM_LAST:
break;
}