qemu: support kvm-pv-ipi off

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@bytedance.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
zhenwei pi 2021-10-27 15:04:30 +08:00 committed by Michal Privoznik
parent d7547dbcf3
commit b2757b697e
5 changed files with 16 additions and 0 deletions

View File

@ -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``

View File

@ -7177,6 +7177,11 @@
<ref name="featurestate"/>
</element>
</optional>
<optional>
<element name="pv-ipi">
<ref name="featurestate"/>
</element>
</optional>
</interleave>
</element>
</define>

View File

@ -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),

View File

@ -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;

View File

@ -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;
}