]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Add support for direct and extended tlbflush features
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 20 Dec 2024 11:28:24 +0000 (12:28 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 26 Dec 2024 09:46:59 +0000 (10:46 +0100)
They require special handling since they are dependent on the basic
tlbflush feature itself and therefore are not handled automatically as
part of virDomainHyperv enum, just like the stimer-direct feature.

Resolves: https://issues.redhat.com/browse/RHEL-7122
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_process.c
tests/qemuxmlconfdata/hyperv.x86_64-latest.args
tests/qemuxmlconfdata/hyperv.xml

index dcb9c4934ec68450bc1541349c3bff6112af3038..1f28de61943290b8ddc9ced2632520191d97d6f4 100644 (file)
@@ -6350,6 +6350,12 @@ qemuBuildCpuCommandLine(virCommand *cmd,
                 if ((i == VIR_DOMAIN_HYPERV_STIMER) &&
                     (def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON))
                     virBufferAsprintf(&buf, ",%s=on", VIR_CPU_x86_HV_STIMER_DIRECT);
+                if (i == VIR_DOMAIN_HYPERV_TLBFLUSH) {
+                    if (def->hyperv_tlbflush_direct == VIR_TRISTATE_SWITCH_ON)
+                        virBufferAsprintf(&buf, ",%s=on", VIR_CPU_x86_HV_TLBFLUSH_DIRECT);
+                    if (def->hyperv_tlbflush_extended == VIR_TRISTATE_SWITCH_ON)
+                        virBufferAsprintf(&buf, ",%s=on", VIR_CPU_x86_HV_TLBFLUSH_EXT);
+                }
                 break;
 
             case VIR_DOMAIN_HYPERV_SPINLOCKS:
index c72886503b17fcc0a6e11b0a0567fe93dda76843..6db48b0e7b00de6a9991b015a1e23f70c62fe869 100644 (file)
@@ -4281,6 +4281,30 @@ qemuProcessVerifyHypervFeatures(virDomainDef *def,
                                "direct");
                 return -1;
             }
+            if (i == VIR_DOMAIN_HYPERV_TLBFLUSH) {
+                if (def->hyperv_tlbflush_direct == VIR_TRISTATE_SWITCH_ON) {
+                    rc = virCPUDataCheckFeature(cpu, VIR_CPU_x86_HV_TLBFLUSH_DIRECT);
+                    if (rc < 0)
+                        return -1;
+                    if (rc == 0) {
+                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                       _("host doesn't support hyperv tlbflush '%1$s' feature"),
+                                       "direct");
+                        return -1;
+                    }
+                }
+                if (def->hyperv_tlbflush_extended == VIR_TRISTATE_SWITCH_ON) {
+                    rc = virCPUDataCheckFeature(cpu, VIR_CPU_x86_HV_TLBFLUSH_EXT);
+                    if (rc < 0)
+                        return -1;
+                    if (rc == 0) {
+                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                       _("host doesn't support hyperv tlbflush '%1$s' feature"),
+                                       "extended");
+                        return -1;
+                    }
+                }
+            }
             continue;
         }
 
index 2aafafb340a6db3363d6634fd7b6c468662e7811..5a32b80e717f01859d7c8150c12b23b54fc87ffc 100644 (file)
@@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
 -machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=on \
 -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,hv-avic=on,hv-emsr-bitmap=on,hv-xmm-input=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-tlbflush-direct=on,hv-tlbflush-ext=on,hv-ipi=on,hv-evmcs=on,hv-avic=on,hv-emsr-bitmap=on,hv-xmm-input=on' \
 -m size=219136k \
 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
 -overcommit mem-lock=off \
index a1e3cbbdf8421a84cdba586fe6626626b20be49f..8c323f65785138c9fcfe7154373637fbec4495a4 100644 (file)
       <vendor_id state='on' value='KVM Hv'/>
       <frequencies state='on'/>
       <reenlightenment state='on'/>
-      <tlbflush state='on'/>
+      <tlbflush state='on'>
+        <direct state='on'/>
+        <extended state='on'/>
+      </tlbflush>
       <ipi state='on'/>
       <evmcs state='on'/>
       <avic state='on'/>