1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(vrtManager): a disk in an inactive pool keeps the files it may be made from

Only a running disk's definition has its backing chain; for the others the
in-use check reads it from the volumes of active pools. With such a disk's
overlay in an inactive pool (a stopped VM's, the next start's, a saved
state's or a snapshot's), its backing file counted as unused, so deleting
another VM with its disks, or the volume itself, could delete it. The check
now refuses (InUse) while a disk that is not running and not raw has its
file in an inactive pool, and says to start the pool. A snapshot delete
that is done reports no left-behind files then, rather than failing.

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-11 14:32:46 +03:00
parent effe2a33f0
commit b91daf0525
8 changed files with 413 additions and 338 deletions

View file

@ -612,6 +612,13 @@ class LeftBehindTestCase(unittest.TestCase):
# their own backing files do not keep each other
in_use.assert_called_once_with(own=["/pool/a.one", "/pool/vm.one.mem"])
def test_nothing_is_reported_when_another_vm_s_files_cannot_be_read(self):
# a disk in an inactive pool: any file may be one it grows from; the delete itself is done
refused = util.InUse("Pool %(pool)s is not active", pool="overlays")
with patch.object(wvmInstance, "paths_in_use", side_effect=refused):
left = self.run_delete({"/pool/a.one", "/pool/vm.one.mem", "/pool/a.two", "/pool/a.qcow2"})
self.assertEqual(left, [])
def test_a_file_below_one_another_vm_uses_is_not_reported(self):
# the other VM is shut off: its definition does not list the backing
# file, and the in-use top's own backing reference does not count