@samitouri / QOSamiQemu / commits / 02dff8f72d

whpx: refactor whpx_destroy_vcpu to arch-specific function

Avoid a TARGET_X86_64 define by moving platform-specific code away from generic WHPX support. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Link: https://lore.kernel.org/r/20260223233950.96076-9-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Feb 24, 2026 at 00:39 UTC 02dff8f72d3319b40e747e957906842344622fda
4 files changed +13 -4
accel/whpx/whpx-common.c
+1 -4
@@ -236,10 +236,7 @@ void whpx_destroy_vcpu(CPUState *cpu)
236 struct whpx_state *whpx = &whpx_global;
237
238 whp_dispatch.WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index);
239 -#ifdef HOST_X86_64
240 - AccelCPUState *vcpu = cpu->accel;
241 - whp_dispatch.WHvEmulatorDestroyEmulator(vcpu->emulator);
242 -#endif
239 + whpx_arch_destroy_vcpu(cpu);
240 g_free(cpu->accel);
241 }
242
include/system/whpx-all.h
+1
@@ -17,6 +17,7 @@ void whpx_translate_cpu_breakpoints(
17 struct whpx_breakpoints *breakpoints,
18 CPUState *cpu,
19 int cpu_breakpoint_count);
20 +void whpx_arch_destroy_vcpu(CPUState *cpu);
21
22 /* called by whpx-accel-ops */
23 bool whpx_arch_supports_guest_debug(void);
target/arm/whpx/whpx-all.c
+5
@@ -308,6 +308,11 @@ bool whpx_arch_supports_guest_debug(void)
308 return false;
309 }
310
311 +void whpx_arch_destroy_vcpu(CPUState *cpu)
312 +{
313 + /* currently empty on Arm */
314 +}
315 +
316 static void whpx_get_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTER_VALUE* val)
317 {
318 struct whpx_state *whpx = &whpx_global;
target/i386/whpx/whpx-all.c
+6
@@ -1277,6 +1277,12 @@ bool whpx_arch_supports_guest_debug(void)
1277 return true;
1278 }
1279
1280 +void whpx_arch_destroy_vcpu(CPUState *cpu)
1281 +{
1282 + AccelCPUState *vcpu = cpu->accel;
1283 + whp_dispatch.WHvEmulatorDestroyEmulator(vcpu->emulator);
1284 +}
1285 +
1286 /* Returns the address of the next instruction that is about to be executed. */
1287 static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid)
1288 {