1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 19:56:48 +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

@ -290,6 +290,17 @@ class DefineCloneTestCase(unittest.TestCase):
self.assertEqual(tree.find("devices/interface/mac").get("address"), "52:54:00:00:00:02")
p.vol.storagePoolLookupByVolume.return_value.createXMLFrom.assert_not_called()
def test_the_clone_s_tpm_is_new(self):
state = "<tpm model='tpm-crb'><backend type='emulator' version='2.0'><source type='dir' path='/srv/tpm/src'/></backend></tpm>"
p = proxy(domain(extra=state))
tree, _disks = p._clone_definition(FORM, UUID)
self.assertEqual(tree.xpath("devices/tpm/backend/source"), [])
for backend in ("<backend type='passthrough'><device path='/dev/tpm0'/></backend>",
"<backend type='external'><source type='unix' path='/run/tpm.sock'/></backend>"):
with self.subTest(backend=backend):
with self.assertRaisesRegex(util.OperationError, "external TPM is not cloned"):
proxy(domain(extra=f"<tpm model='tpm-crb'>{backend}</tpm>"))._clone_definition(FORM, UUID)
def test_a_missing_mac_is_refused(self):
p = proxy()
p._defineXML = MagicMock()