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

fix(quota): a disk whose size is unknown is not counted as 0 GiB

A disk of the user's VMs whose size could not be read (its volume not in a
pool, the pool stopped) counted as 0 GiB, so a disk-limited user's increase
could pass over the limit. A disk no pool holds now has the size libvirt
reads from the file or device (blockInfo, also for a shut-off VM); one whose
size is still unknown makes the usage unverified and the increase is
refused, as when a host cannot be reached. Users without a disk limit are
not affected.
This commit is contained in:
catborise 2026-11-07 16:00:35 +03:00
parent d8a184eff7
commit 0b4a601ecb
9 changed files with 215 additions and 184 deletions

View file

@ -926,6 +926,11 @@ class wvmInstance(wvmConnect):
volume, disk_size, used_size, storage = details
else:
volume = src_file
# a disk no pool holds: libvirt reads its size from the file or device,
# named by its path: a target names the running VM's disk, which may
# be another file than the one saved for its next start (that one: unknown)
with contextlib.suppress(libvirtError):
disk_size, used_size = self.instance.blockInfo(src_file)[:2]
except Exception as e:
logger.warning("Disk %s of %s not fully read: %s", dev, self.instance.name(), e)
finally: