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

fix(instances): a VM starts only with host devices the host can give now

A device is checked when it is given to a VM, but a start later did not
check it again: a PCI device bound back to a host driver for the host's
own network or disks, or a USB device the host no longer has as named,
was taken from the host or failed in libvirt. Power On and Power Cycle now
check the definition the VM starts from (its saved state's when restored)
as a snapshot revert does, and refuse with the reasons; Power Cycle checks
before it stops the VM.
This commit is contained in:
catborise 2026-11-11 16:16:55 +03:00
parent 4045819b8d
commit a36ffcd3ba
4 changed files with 59 additions and 1 deletions

View file

@ -811,9 +811,11 @@ def poweron(request, pk):
messages.warning(request, _("Templates cannot be started."))
elif options.validated_data["fresh"]: # the saved state is discarded: the VM boots anew
with audit_vm(request, instance, "power on without the saved state"):
instance.proxy.check_start_hostdevs(restore=False)
instance.proxy.start(VIR_DOMAIN_START_FORCE_BOOT)
else:
with audit_vm(request, instance, "power on"):
instance.proxy.check_start_hostdevs()
instance.proxy.start()
return get_safe_redirect(
@ -829,6 +831,7 @@ def powercycle(request, pk):
messages.warning(request, _("Templates cannot be started."))
else:
with audit_vm(request, instance, "power cycle") as entry:
instance.proxy.check_start_hostdevs(restore=False) # before it stops
instance.proxy.force_shutdown()
try:
instance.proxy.start()