1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat(instances): a guest that crashes or hangs is restarted or stopped

The VM Settings "When the guest crashes" choice (on_crash, restart for new
VMs) never acted: a guest reports a crash through a panic device, and the
panel gave VMs none. A guest whose kernel panicked stayed "running" until
someone noticed.

- new VMs get the panic device the host offers (get_panic_model: x86 ISA
  pvpanic, which Linux has built in and Windows gets with virtio-win; the
  PCI one elsewhere; ISA on x86 when libvirt does not tell), and an x86
  machine without a watchdog of its own (not q35, which has the iTCO; not
  microvm, which has no PCI bus) an i6300esb
- choosing Restart or Stop adds the panic device to a VM without one, an
  i6300esb when it has no watchdog (libvirt before 9.1 shows no iTCO on
  q35), and gives its watchdogs the matching action (reset, poweroff): a
  guest that arms its watchdog and hangs is met as one that crashed. A VM
  without these devices shows no choice made and says it cannot report a
  crash or a hang yet. From the next start, as before

Checked live on a Vagrant host with a guest whose init exits (kernel panic):
without the device it stayed "running (booted)"; after Stop it ended
"shut off (crashed)", after Restart it booted again.
This commit is contained in:
catborise 2026-11-22 21:45:50 +03:00
parent bdc5569cc8
commit ede9e0bca7
14 changed files with 179 additions and 25 deletions

View file

@ -1386,6 +1386,21 @@ class wvmConnect(object):
return util.get_xml_path(self.get_dom_cap_xml(arch, machine), func=tpm_model)
def get_panic_model(self, arch, machine):
"""The panic device a guest reports its crash through (pvpanic: Linux
has it built in, Windows with the virtio-win driver), for on_crash to
act on; None when the machine has none."""
def panic_model(ctx):
if not ctx.xpath("/domainCapabilities/devices/panic"):
# libvirt that does not tell (before 10.x): x86 has the ISA one
return "isa" if arch in ("x86_64", "i686") else None
models = ctx.xpath("/domainCapabilities/devices/panic[@supported='yes']/enum[@name='model']/value/text()")
# x86 ISA pvpanic, the PCI one elsewhere (aarch64), or the machine's own; hyperv needs Hyper-V enlightenments
return next((model for model in ("isa", "pvpanic", "pseries", "s390") if model in models), None)
return util.get_xml_path(self.get_dom_cap_xml(arch, machine), func=panic_model)
def is_supports_virtio(self, arch, machine):
if not self.is_qemu():
return False