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

feat(instances): free a running VM's unused disk space with the guest agent

The Disks tab of a running VM gets "Free unused space": a job
(instance.fstrim) has the guest agent trim each mounted file system
(guest-fstrim, 30 minutes at most) and lists what each one trimmed. A
disk passes the trim to its image file only with the discard mode unmap:
the tab and the job say when no disk of the running VM has it, and where
to set it (the disk's device details, from the next start).
This commit is contained in:
catborise 2026-11-25 10:51:41 +03:00
parent d6cee18434
commit 8625d6250a
17 changed files with 367 additions and 5 deletions

View file

@ -79,6 +79,11 @@ class Instance(models.Model):
def disks(self) -> list[dict]:
return self.proxy.get_disk_devices()
@property
def discard_unmap(self) -> bool:
"""Whether a disk of the running definition passes the guest's trim to its image (discard unmap)."""
return any(disk.get("discard") == "unmap" for disk in self.disks)
@cached_property
def info(self) -> list | None:
"""virDomainGetInfo, read once: state, max memory KiB, memory KiB, vCPUs, CPU time.