]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: support kvm-pv-ipi off
authorzhenwei pi <pizhenwei@bytedance.com>
Wed, 27 Oct 2021 07:04:30 +0000 (15:04 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 1 Nov 2021 14:44:26 +0000 (15:44 +0100)
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>
docs/formatdomain.rst
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c

index b500d35f5bed85bfb92e85d53c434d279a18674e..0651975c88c2429173d0741795a1ef14406f5367 100644 (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``
index f71e375a33c2ffc47c6ef538c647c9efb28d38fb..67df13d90d4454a129284c8a9294c374f3b7a53d 100644 (file)
             <ref name="featurestate"/>
           </element>
         </optional>
+        <optional>
+          <element name="pv-ipi">
+            <ref name="featurestate"/>
+          </element>
+        </optional>
       </interleave>
     </element>
   </define>
index 8a7d241df18b931aa922dfe0b124cc546ae235d6..4644d18120784a6705af1591146650e662e6b6af 100644 (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),
index f4be5c84f05963d618a6adaff2d3806b0f9a00c1..cb6d8975b8d261e302768fae491e5863726f6ed2 100644 (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;
index 77977c396e5790e517b6693372a48a4da721ecb2..45278c710844462d69a9dd3f6ecf1ee7bd8466e4 100644 (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;
             }