1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 04:36:48 +00:00

fix: a network, pool or secret a VM needs is not stopped or deleted

Stopping a network cut the running VMs on it off, deleting one or a
secret kept the VMs that name it from starting, and stopping a pool
took the disks of running VMs away, all without a word. Each is now
refused with the VMs (and, for a secret, the pools) that need it:
stopping while a running VM uses it, deleting while a VM's definition
names it. A disk given by its file path does not need its pool's
definition. The API's pool stop is refused the same way.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
catborise 2026-10-22 07:53:24 +03:00
parent ef1faf57c8
commit 887b807451
9 changed files with 268 additions and 3 deletions

View file

@ -955,6 +955,17 @@ class wvmConnect(object):
instances.append(name)
return instances
def domains_using(self, match, running_only=False):
"""Names of the domains with a definition, parsed, that match(tree)
holds for: the live and the persistent one of each domain, or with
running_only the live one of each running domain."""
listing = libvirt.VIR_CONNECT_LIST_DOMAINS_ACTIVE if running_only else 0
flags = (0,) if running_only else (0, libvirt.VIR_DOMAIN_XML_INACTIVE)
return sorted(
dom.name() for dom in self.wvm.listAllDomains(listing)
if any(match(etree.fromstring(dom.XMLDesc(f))) for f in flags)
)
def paths_in_use(self, skip_uuid=None, own=()):
"""Paths (names for network disks) a domain uses as a disk or a
backing file of one, or as a file of its snapshots (overlays, memory,