@samitouri / QOSamiQemu / commits / 2f6c2ede46

accel/mshv: install dummy handler for SIG_IPI

This is similar to HVF's implementation. We want to interrupt the blocking vcpu run. The self-kick was effectively a no-op for mshv. Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com> Reviewed-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com> Link: https://lore.kernel.org/r/20260710101534.664604-5-magnuskulke@linux.microsoft.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Magnus Kulke committed Jul 10, 2026 at 12:15 UTC 2f6c2ede4688f90a3583cfb2050de66a100fc5cb
1 file changed +6 -10
accel/mshv/mshv-all.c
+6 -10
@@ -621,17 +621,13 @@ static int mshv_cpu_exec(CPUState *cpu)
621 }
622
623 /*
624 - * The signal handler is triggered when QEMU's main thread receives a SIG_IPI
625 - * (SIGUSR1). This signal causes the current CPU thread to be kicked, forcing a
626 - * VM exit on the CPU. The VM exit generates an exit reason that breaks the loop
627 - * (see mshv_cpu_exec). If the exit is due to a Ctrl+A+x command, the system
628 - * will shut down. For other cases, the system will continue running.
624 + * We need a dummy handler to make SIG_IPI a deliverable signal. The kernel
625 + * handler will be woken up by the caught signal and instruct the hypervisor
626 + * to suspend execution (the concrete mechanism differs between schedulers)
627 + * and return to userspace.
628 */
630 -static void sa_ipi_handler(int sig)
629 +static void dummy_handler(int sig)
630 {
632 - /* TODO: call IOCTL to set_immediate_exit, once implemented. */
633 -
634 - qemu_cpu_kick_self();
631 }
632
633 static void init_signal(CPUState *cpu)
@@ -641,7 +637,7 @@ static void init_signal(CPUState *cpu)
637 sigset_t set;
638
639 memset(&sigact, 0, sizeof(sigact));
644 - sigact.sa_handler = sa_ipi_handler;
640 + sigact.sa_handler = dummy_handler;
641 sigaction(SIG_IPI, &sigact, NULL);
642
643 pthread_sigmask(SIG_BLOCK, NULL, &set);