1
0
Fork 0
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:
catborise 2026-11-13 10:31:22 +03:00
parent fb3b2f479e
commit 143a74b145
11 changed files with 277 additions and 196 deletions

View file

@ -259,8 +259,17 @@ class wvmStorage(wvmConnect):
vol = self.get_volume(name)
return vol.XMLDesc(0)
def check_unused_elsewhere(self, name, elsewhere):
"""Refuses a volume a VM of another host sharing this storage uses:
elsewhere(paths) gives those the other hosts use
(instances.utils.paths_used_on_other_computes). Asked before this
host's lock, which a host that does not answer would hold meanwhile."""
path = self.pool.storageVolLookupByName(name).path()
if path in elsewhere([path]):
raise util.InUse(gettext_noop("Volume %(name)s is in use on another compute that shares this storage"), name=name)
def del_volume(self, name):
"""libvirt deletes any volume; one a VM still needs is refused."""
"""libvirt deletes any volume; one a VM of this host still needs is refused."""
vol = self.pool.storageVolLookupByName(name)
if vol.path() in self.paths_in_use():
raise util.InUse(gettext_noop("Volume %(name)s is in use: a VM's disk, a backing file or a snapshot's file"), name=name)