本文将mark下pvpanic相关notes。

Overview

pvpanic, which is a paravirtualized device emulated by QEMU and used by the guest OS to report to the VMM when it experiences a panic/crash. This mechanism allows a guest OS kernel to signal the hypervisor when it panics, before any crash dump is collected.

pvpanic device

pvpanic device is a simulated device, through which a guest panic event is sent to qemu, and a QMP event is generated. This allows management apps (e.g. libvirt) to be notified and respond to the event.

The management app has the option of waiting for GUEST_PANICKED events, and/or polling for guest-panicked RunState, to learn when the pvpanic device has fired a panic event.

The pvpanic device can be implemented as an ISA device (using IOPORT) or as a PCI device.

crash_kexec_post_notifiers

During initialization, the pvpanic module registers a callback with the panic_notifier_list notifier chain. When the kernel panics, the value of crash_kexec_post_notifiers determines whether or not the callbacks registered in the panic_notifier_list are invoked before kexec’ing into the capture kernel which will collect the crash dump. The panic() code in kernel/panic.c is extensively commented and worth a look if you are interested in the details.


参考资料:

  1. docs/specs/pvpanic.txt
  2. An introduction to pvpanic
  3. PVPanic的实现原理以及应用