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

fix(storages): a volume a running VM uses is not cloned

The copy was read while the guest wrote: a raw disk was copied with
data of different instants, and a qcow2 one failed on qemu-img's image
lock with a message that did not say why. Such a clone is refused, with
the running VMs named, when it is queued and again before it runs.

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 23:40:28 +03:00
parent 50ed08f3ca
commit 018ca69a3b
8 changed files with 266 additions and 213 deletions

View file

@ -351,6 +351,16 @@ class wvmStorage(wvmConnect):
return f"{target_file}.{vol_fmt}"
return f"{target_file}.{file_suffix}" if file_suffix else target_file
def refuse_running_copy(self, name):
"""A volume a running guest writes is not copied: the copy would mix
instants."""
path, pool = self.get_volume(name).path(), self.pool.name()
# a disk names it by its path (an RBD image by pool/image) or by its pool and name
uses = "devices/disk/source[@file=$p or @dev=$p or @name=$p or (@pool=$pool and @volume=$v)]"
if vms := self.domains_using(lambda domain: domain.xpath(uses, p=path, pool=pool, v=name), running_only=True):
raise util.OperationError(gettext_noop("The running VMs %(vms)s use volume %(name)s; shut them down to copy it"),
vms=", ".join(vms), name=name)
def clone_volume(
self,
name,