1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 11:16:47 +00:00

fix(instances): a clone's TPM is a new one, never the VM's state

A shut-off clone kept the VM's TPM element as it was: an emulated TPM
with a state path of its own, a host's TPM or an external one would be
shared with the VM, not the new, empty TPM the clone form promises. An
emulated TPM loses its state path, and the others are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-07 23:45:22 +03:00
parent d49db11e78
commit 3fd9148b67
6 changed files with 93 additions and 64 deletions

View file

@ -2399,6 +2399,14 @@ class wvmInstance(wvmConnect):
raise ValueError("Cannot clone a disk without a supported source and destination")
disks.append((source, dev))
# the clone gets a new, empty TPM (the clone form says so): an emulated
# one without the VM's state path; a host's or another process's would be shared
for backend in tree.xpath("devices/tpm/backend"):
if backend.get("type") != "emulator":
raise util.OperationError(gettext_noop("A VM with a host's or an external TPM is not cloned; remove it first"))
for source in backend.findall("source"):
backend.remove(source)
# a host device is one VM's: the clone gets none (the clone form says so)
for hostdev in tree.findall("devices/hostdev"):
hostdev.getparent().remove(hostdev)