Re: [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit
On 11/1/23 18:13, Denis V. Lunev wrote: > On 11/1/23 16:23, Andrey Drobyshev wrote: >> 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 >> Acked-by: Denis V. Lunev >> --- >> 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); > This allows to gracefully handle this problem in production > and reset the guest using on_crash action in libvirt. Ping
Re: [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit
On 11/1/23 16:23, Andrey Drobyshev wrote: 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 Acked-by: Denis V. Lunev --- 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); This allows to gracefully handle this problem in production and reset the guest using on_crash action in libvirt.
Re: [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit
On 11/1/23 18:13, Denis V. Lunev wrote: > On 11/1/23 16:23, Andrey Drobyshev wrote: >> 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 >> Acked-by: Denis V. Lunev >> --- >> 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); > This allows to gracefully handle this problem in production > and reset the guest using on_crash action in libvirt. Ping
Re: [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit
On 1/11/24 15:15, Andrey Drobyshev wrote: > On 11/1/23 18:13, Denis V. Lunev wrote: >> On 11/1/23 16:23, Andrey Drobyshev wrote: >>> 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 >>> Acked-by: Denis V. Lunev >>> --- >>> 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); >> This allows to gracefully handle this problem in production >> and reset the guest using on_crash action in libvirt. > > Ping Ping
Re: [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit
On 1/25/24 18:36, Andrey Drobyshev wrote: > On 1/11/24 15:15, Andrey Drobyshev wrote: >> On 11/1/23 18:13, Denis V. Lunev wrote: >>> On 11/1/23 16:23, Andrey Drobyshev wrote: 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 Acked-by: Denis V. Lunev --- 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); >>> This allows to gracefully handle this problem in production >>> and reset the guest using on_crash action in libvirt. >> >> Ping > > Ping Yet another ping
Re: [PATCH] kvm: emit GUEST_PANICKED event in case of abnormal KVM exit
Andrey Drobyshev 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 > Acked-by: Denis V. Lunev > --- > 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