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

fix(migrate): a disk of an LVM or disk pool does not count as shared with the destination

Each host's logical volumes are its own: a VM whose disk is /dev/vg/x
migrated, uncopied, onto the destination's volume of the same name and
kept running on other data. Such a volume now counts as missing there.

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 22:39:26 +03:00
parent eb0343ee2f
commit c2c255a866
3 changed files with 24 additions and 4 deletions

View file

@ -88,8 +88,12 @@ def no_volume():
class FakeVolume:
def __init__(self, backing):
def __init__(self, backing, pool_type="dir"):
self.backing = backing
self.pool_type = pool_type
def storagePoolLookupByVolume(self):
return MagicMock(XMLDesc=lambda flags: f"<pool type='{self.pool_type}'/>")
def XMLDesc(self, flags=0):
if self.backing is None:
@ -121,7 +125,7 @@ class FakeHost:
"""The destination's libvirt connection. volumes: the paths its pools
list; unlisted: files its pools show after a refresh."""
def __init__(self, existing=(), volumes=(), unlisted=(), backing=None, inactive_pools=()):
def __init__(self, existing=(), volumes=(), unlisted=(), backing=None, inactive_pools=(), pool_types=None):
self.existing = set(existing)
self.defined = []
self.new = []
@ -129,12 +133,13 @@ class FakeHost:
self.unlisted = set(unlisted)
self.backing = backing or {} # path: the path of its backing file
self.inactive_pools = set(inactive_pools)
self.pool_types = pool_types or {} # path: the type of its volume's pool, dir if not named
self.refreshes = 0
def storageVolLookupByPath(self, path):
if path not in self.volumes:
raise no_volume()
return FakeVolume(self.backing.get(path))
return FakeVolume(self.backing.get(path), self.pool_types.get(path, "dir"))
def storagePoolLookupByName(self, name):
return FakePool(self, active=name not in self.inactive_pools)