1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 11:46:49 +00:00

fix(instances): recovery removes the UEFI variables copy of a clone that was not defined

A shut-off clone copies the VM's NVRAM file just before it defines the
clone; a worker that stopped between the two left the copy, unnamed by
the job, which recovery then reported as leaving nothing. The job
records the copy's path once libvirt made it, and recovery deletes that
file when the clone was not defined, in whichever pool it is.

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:46:49 +03:00
parent b4e5567e4a
commit ce98bc85d0
4 changed files with 71 additions and 19 deletions

View file

@ -321,7 +321,7 @@ class DefineCloneTestCase(unittest.TestCase):
p.define_clone = MagicMock(return_value=UUID)
self.assertEqual(p.clone_instance(FORM, UUID), UUID)
p.pool.createXMLFrom.assert_called_once()
p.define_clone.assert_called_once_with(FORM, UUID, {"vda": "/pool/copy-vda.qcow2"})
p.define_clone.assert_called_once_with(FORM, UUID, {"vda": "/pool/copy-vda.qcow2"}, None)
def test_clone_instance_checks_the_macs_before_copying(self):
p = proxy()
@ -414,12 +414,15 @@ class LiveCloneTestCase(SimpleTestCase):
vm = wvmInstance(*self.args, None, uuid=dom.UUIDString())
source = vm.get_nvram()
made = []
uuid = vm.clone_instance(
{"name": P + "clone-uefi-copy", "disk-vda": P + "clone-uefi-copy-a.qcow2", "disk_owner_uid": 0, "disk_owner_gid": 0}, "abababab-0000-1111-2222-333333333333"
{"name": P + "clone-uefi-copy", "disk-vda": P + "clone-uefi-copy-a.qcow2", "disk_owner_uid": 0, "disk_owner_gid": 0}, "abababab-0000-1111-2222-333333333333",
on_nvram=made.append,
)
clone = self.conn.lookupByUUIDString(uuid)
path = ElementTree.fromstring(clone.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)).findtext("os/nvram")
self.assertEqual(made, [path]) # the job records it: recovery removes it if the clone is not defined
self.assertEqual(path, os.path.join(os.path.dirname(source), P + "clone-uefi-copy_VARS.fd"))
with vm._nvram_pool() as pool:
copy = pool.storageVolLookupByName(os.path.basename(path))