* Re: [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit
[not found] <20231101152311.181817-1-andrey.drobyshev@virtuozzo.com>
@ 2024-02-09 17:46 ` Alex Bennée
0 siblings, 0 replies; only message in thread
From: Alex Bennée @ 2024-02-09 17:46 UTC (permalink / raw)
To: Andrey Drobyshev; +Cc: qemu-devel, pbonzini, den, kvm
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> writes:
(Add kvm@vger to CC for wider review)
> Currently we emit GUEST_PANICKED event in case kvm_vcpu_ioctl() returns
> KVM_EXIT_SYSTEM_EVENT with the event type KVM_SYSTEM_EVENT_CRASH. Let's
> extend this scenario and emit GUEST_PANICKED in case of an abnormal KVM
> exit. That's a natural thing to do since in this case guest is no
> longer operational anyway.
>
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> Acked-by: Denis V. Lunev <den@virtuozzo.com>
> ---
> accel/kvm/kvm-all.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index e39a810a4e..d74b3f0b0e 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -2816,6 +2816,14 @@ static void kvm_eat_signals(CPUState *cpu)
> } while (sigismember(&chkset, SIG_IPI));
> }
>
> +static void kvm_emit_guest_crash(CPUState *cpu)
> +{
> + kvm_cpu_synchronize_state(cpu);
> + qemu_mutex_lock_iothread();
> + qemu_system_guest_panicked(cpu_get_crash_info(cpu));
> + qemu_mutex_unlock_iothread();
> +}
> +
> int kvm_cpu_exec(CPUState *cpu)
> {
> struct kvm_run *run = cpu->kvm_run;
> @@ -2969,21 +2977,24 @@ int kvm_cpu_exec(CPUState *cpu)
> ret = EXCP_INTERRUPT;
> break;
> case KVM_SYSTEM_EVENT_CRASH:
> - kvm_cpu_synchronize_state(cpu);
> - qemu_mutex_lock_iothread();
> - qemu_system_guest_panicked(cpu_get_crash_info(cpu));
> - qemu_mutex_unlock_iothread();
> + kvm_emit_guest_crash(cpu);
> ret = 0;
> break;
> default:
> DPRINTF("kvm_arch_handle_exit\n");
> ret = kvm_arch_handle_exit(cpu, run);
> + if (ret < 0) {
> + kvm_emit_guest_crash(cpu);
> + }
> break;
> }
> break;
> default:
> DPRINTF("kvm_arch_handle_exit\n");
> ret = kvm_arch_handle_exit(cpu, run);
> + if (ret < 0) {
> + kvm_emit_guest_crash(cpu);
> + }
> break;
> }
> } while (ret == 0);
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-09 17:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20231101152311.181817-1-andrey.drobyshev@virtuozzo.com>
2024-02-09 17:46 ` [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit Alex Bennée
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox