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

@ -172,3 +172,17 @@ def is_loopback(address):
return ipaddress.ip_address(address).is_loopback
except ValueError:
return address == "localhost"
# the watchdog's action for each crash action (on_crash): a guest that hangs is met as one that crashed
WATCHDOG_ACTIONS = {"restart": "reset", "destroy": "poweroff"}
def takes_watchdog(arch, machine):
"""An x86 machine with a PCI bus takes an i6300esb (microvm has none)."""
return arch in ("x86_64", "i686") and not machine.startswith("microvm")
def needs_watchdog(arch, machine):
"""A new VM's machine has no watchdog of its own (q35 has the iTCO): it gets an i6300esb."""
return takes_watchdog(arch, machine) and "q35" not in machine