1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 09:26:03 +00:00

fix(vmbackups): an incremental backup needs room for its changed blocks only

The target space check asked for every disk's virtual capacity even when
the backup copies only the blocks changed since its parent. The checkpoint
already reports those bytes per disk (VIR_DOMAIN_CHECKPOINT_XML_SIZE), so
checkpoint_usable becomes checkpoint_sizes and the check runs after the
parent is chosen, with the changed bytes for an incremental backup and the
capacity for a full one. The margin (free_percent, free_min_gib) is kept.
This commit is contained in:
catborise 2026-11-18 13:38:27 +03:00
parent 132676a772
commit 8cd7aee19a
5 changed files with 49 additions and 30 deletions

View file

@ -163,18 +163,19 @@ class wvmBackup(wvmInstance):
vol = None # in no pool: counted by its own size only
return total
def checkpoint_usable(self, name, devs):
"""Whether the checkpoint name can be an incremental backup's base:
on this host, with a bitmap of known size for each disk of devs
(libvirt leaves the size out for a lost or invalid bitmap)."""
def checkpoint_sizes(self, name, devs):
"""The bytes each disk of devs changed since the checkpoint name,
{dev: size}, or None when it cannot be an incremental backup's base:
not on this host, or a disk without a bitmap of known size (libvirt
leaves the size out for a lost or invalid bitmap)."""
try:
xml = self.instance.checkpointLookupByName(name).getXMLDesc(libvirt.VIR_DOMAIN_CHECKPOINT_XML_SIZE)
except libvirt.libvirtError as err:
if err.get_error_code() != libvirt.VIR_ERR_NO_DOMAIN_CHECKPOINT:
raise
return False
sized = set(etree.fromstring(xml).xpath("disks/disk[@checkpoint='bitmap' and @size]/@name"))
return set(devs) <= sized
return None
sizes = {d.get("name"): int(d.get("size")) for d in etree.fromstring(xml).xpath("disks/disk[@checkpoint='bitmap' and @size]")}
return {dev: sizes[dev] for dev in devs} if set(devs) <= set(sizes) else None
def prune_checkpoints(self, keep, known, devs):
"""Deletes the backups' checkpoints (wvc-) of a running VM but those