mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(instances): a VM's TPM 2.0 is switched on and off on its Options tab
A VM made without a TPM, a Windows 10 to be upgraded to Windows 11, had no way to get one but the XML editor. The Options tab has a TPM 2.0 switch, as the RNG one: it adds an emulated TPM of the host's model to the definition for the next start, or removes it. Its state stays on the host until the VM is undefined, so a TPM added again has it back. A TPM the switch did not make (passthrough, 1.2, encrypted, with its own state path) is left to the XML editor, and a host without swtpm says so.
This commit is contained in:
parent
2a05576e18
commit
e35342bff1
10 changed files with 288 additions and 130 deletions
|
|
@ -308,6 +308,7 @@ def _instance_page(request, pk, instance, compute):
|
|||
memory_host = instance.proxy.get_max_memory()
|
||||
bus_host = instance.proxy.get_disk_bus_types(instance.arch, instance.machine)
|
||||
cdrom_buses = cdrom_bus_choices(instance)
|
||||
tpm_support = bool(instance.proxy.get_tpm_model(instance.arch, instance.machine))
|
||||
networks_host = sorted(instance.proxy.get_networks())
|
||||
interfaces_host = sorted(instance.proxy.get_ifaces())
|
||||
nwfilters_host = instance.proxy.get_nwfilters()
|
||||
|
|
@ -1883,6 +1884,20 @@ def set_rng(request, pk):
|
|||
return _back(request, pk, "options")
|
||||
|
||||
|
||||
@require_POST
|
||||
@superuser_only
|
||||
@serialize_instance_mutation
|
||||
def set_tpm(request, pk):
|
||||
instance = get_instance(request.user, pk)
|
||||
enabled = bool(request.POST.get("tpm"))
|
||||
try:
|
||||
with audit_vm(request, instance, "add TPM" if enabled else "remove TPM"):
|
||||
instance.proxy.set_tpm(enabled)
|
||||
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