mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(instances): a VM's RNG device and crash action in its options
Two settings the owner chose to add to Settings > Options after the page's review with Codex. Both change the persistent definition, so they are saved while the VM runs and used from its next start. - Random number generator: a switch for a virtio RNG device fed from the host's /dev/urandom, so a new VM does not wait for entropy at boot. Another RNG device, or the panel's with a rate or driver, is shown as the VM's own and left to the XML editor. - When the guest crashes: Restart or Stop (on_crash restart or destroy); libvirt's default, Stop, when the definition has none. Stop keeps a VM that crashes again and again down for a look. Any other action is shown and left to the XML editor.
This commit is contained in:
parent
a993c12db0
commit
1150b941be
8 changed files with 177 additions and 0 deletions
|
|
@ -1749,6 +1749,34 @@ def set_guest_agent(request, pk):
|
|||
return _back(request, pk, "options")
|
||||
|
||||
|
||||
@require_POST
|
||||
@superuser_only
|
||||
@serialize_instance_mutation
|
||||
def set_rng(request, pk):
|
||||
instance = get_instance(request.user, pk)
|
||||
enabled = bool(request.POST.get("rng"))
|
||||
try:
|
||||
with audit_vm(request, instance, "add RNG device" if enabled else "remove RNG device"):
|
||||
instance.proxy.set_rng(enabled)
|
||||
except util.OperationError as err:
|
||||
messages.error(request, err)
|
||||
return _back(request, pk, "options")
|
||||
|
||||
|
||||
@require_POST
|
||||
@superuser_only
|
||||
@serialize_instance_mutation
|
||||
def set_on_crash(request, pk):
|
||||
instance = get_instance(request.user, pk)
|
||||
action = request.POST.get("on_crash", "")
|
||||
try:
|
||||
with audit_vm(request, instance, f"set crash action {action}"):
|
||||
instance.proxy.set_on_crash(action)
|
||||
except util.OperationError as err:
|
||||
messages.error(request, err)
|
||||
return _back(request, pk, "options")
|
||||
|
||||
|
||||
@require_POST
|
||||
@superuser_only
|
||||
@serialize_instance_mutation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue