mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +00:00
fix(storages): a volume another compute's VM uses on shared storage is not deleted
A pool on shared storage (an NFS share, or a directory mounted from one) holds the same file at the same path on every host that mounts it. A VM's delete checks the panel's other computes before it deletes its disk files, but the pool page, its API and a VM's disk delete checked only their own host: a disk of a VM on another compute could be deleted. They now ask the other computes too, and refuse while one uses the file or cannot be reached. The other computes are asked before this host's lock is taken, and before a VM's disk is detached.
This commit is contained in:
parent
fb3b2f479e
commit
143a74b145
11 changed files with 277 additions and 196 deletions
|
|
@ -191,6 +191,15 @@ class DeleteVolumeTestCase(unittest.TestCase):
|
|||
conn.del_volume("disk.qcow2")
|
||||
vols["disk.qcow2"].delete.assert_called_once_with(0)
|
||||
|
||||
def test_a_volume_another_compute_uses_is_refused(self):
|
||||
# shared storage: another host's VM has the same file at the same path
|
||||
conn, _vols = storage([], [volume("/pool/disk.qcow2")])
|
||||
asked = []
|
||||
conn.check_unused_elsewhere("disk.qcow2", lambda paths: asked.append(paths) or set())
|
||||
self.assertEqual(asked, [["/pool/disk.qcow2"]])
|
||||
with self.assertRaisesRegex(util.InUse, "disk.qcow2 is in use on another compute"):
|
||||
conn.check_unused_elsewhere("disk.qcow2", set)
|
||||
|
||||
|
||||
class RunningCopyTestCase(unittest.TestCase):
|
||||
"""A running guest's disk is not copied: the copy would mix instants."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue