1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +00:00
Commit graph

10 commits

Author SHA1 Message Date
catborise
5b05e76ebc feat(vmbackups): a backup's file names begin with its VM's name
Someone looking at the target's directory could not tell whose backup a
file was without opening its manifest. A new backup's files are named
<vm>-<backup uuid>-<file> (the VM's name made safe for a file name, at most
64 characters). The prefix is kept on the row: backups made before keep
their wvc-<uuid> names (migration 0007), and an import takes it from the
manifest's file name. Manifests of either naming are found by their
UUID suffix.
2026-11-18 14:57:14 +03:00
catborise
8cd7aee19a 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.
2026-11-18 13:38:27 +03:00
catborise
132676a772 fix(vmbackups): fifth audit: offline copies, domain file mode, target check
- An offline backup is not published when the VM was started while its
  disks were copied (its NVRAM and TPM state would be newer than the
  disks); recovery does not publish it either.
- A cancel asked during the last disk of an offline copy is honoured:
  the copies are removed instead of the backup being published.
- The backup's domain definition is written 0600, as the TPM state is:
  it holds the graphics passwords.
- The daily target check does not mark missing a backup finished in the
  last 10 minutes: written through another compute, its files may not
  be listed yet by this one's NFS client.
2026-11-18 12:19:13 +03:00
catborise
df11685037 fix(vmbackups): second audit: a frozen guest, refused copies, stuck deletes, lists
Codex's audit of the module, each fix tested:
- a backup cancelled while its guest stayed frozen ends through recovery,
  which thaws the guest first, not as a cancel that never thaws it;
- a restore copy libvirt refuses fails and removes the copies, instead of
  waiting on an administrator as an unknown outcome;
- a deletion that did not end can be asked again from the page;
- recovery starts a restored VM the restore was asked to start;
- a manifest with a bad UUID no longer stops reading the target's others;
- an owner is not linked to a job only its submitter or a superuser opens.

From the browser audit: with a long VM name the backup list pushed the
state and the actions out of view, and on a phone only the time and VM
showed. The list folds the target under the time and the schedule under
the VM, cuts long names (whole on hover), shows the restore menu as an
icon on a phone, and fits from 390 px up. An owner without a backup quota
is told so, and quota sizes never read 0.0 GiB.
2026-11-18 07:29:36 +03:00
catborise
43d25a2759 feat(vmbackups): the Backups tab and restore pages for VM owners
A VM owner with the backup permission who may change the VM gets its
Backups tab: the targets open to VM owners, the VM's backups on them,
Restore as a new VM or over the VM, and Delete for the backups they took;
no schedule is shown. Their restore as a new VM names the VM's host and
pool instead of asking, and the restore-over page says that the disks the
VM runs from are deleted. A superuser opens or closes a target to VM
owners on its page.
2026-11-17 19:40:33 +03:00
catborise
72e270a87e feat(vmbackups): incremental scheduled backups of running VMs
A schedule with 'a full backup every N backups' above one makes a
checkpoint with each running VM's backup. The next builds on the
schedule's newest ready backup: the changed blocks are pushed into qcow2
volumes made with the base's file as backing file, by its name, as the
target pool's directory differs per host. The base is used only when its
chain is shorter than N, its disks are the VM's, every file of the chain
is in the target, and its checkpoint has a sized bitmap for every disk;
otherwise the backup is full and starts a chain.

Before each scheduled backup of a running VM, the VM's backup
checkpoints are pruned to each schedule's newest base. A checkpoint
libvirt no longer lists, as after a migration, is redefined first so
that its bitmap goes too.

A shut-off VM's backup checkpoints are forgotten before its external
snapshot: libvirt 11.10 makes no offline external snapshot while a
checkpoint exists. The next scheduled backup is then full.
2026-11-17 17:12:05 +03:00
catborise
52b6096efe feat(vmbackups): back up a shut-off VM's TPM state
A VM with the panel's emulated TPM 2.0 is backed up when it is shut off:
each state file of libvirt's swtpm directory for the VM, read through a
transient pool on it, becomes a small file of the backup (role tpm),
written and read back like the NVRAM file. A running or paused VM with a
TPM is refused, and so is a TPM with its own settings (encryption, a
state path, another backend). The manifest says whether the TPM state was
copied or never written.
2026-11-17 13:54:12 +03:00
catborise
1219a37cc4 feat(vmbackups): backup schedules' records; the worker runs the apps' periodic tasks
A backup schedule (BackupPolicy) names its VMs, chosen or every VM of a
compute at the time it runs (templates left out), a target, a daily time
in the panel's time zone, how many backups of each VM to keep (one at
least), whether frozen file systems are required, and the superuser its
jobs run as. A run (BackupRun) records one VM's backup of one day, keyed
by the VM's row, not its UUID, which two VM rows may share. A backup
keeps the schedule that made it; deleting the schedule keeps its
backups. A backup whose files are gone can be marked missing, and a
target keeps when it was last checked.

The worker runs the tasks apps register with register_periodic about
once a minute, on a thread of their own, one pass at a time, each
guarded: a pass stuck on a host takes no thread recovery or a cancel
needs, and one failing task stops none of the others. Nothing registers
one yet.

backup.create takes the schedule that asked for it; one deleted while
the job was queued leaves the backup without a schedule.
2026-11-17 10:18:04 +03:00
catborise
7227867d78 feat(vmbackups): delete a backup; the Backups page
Backups in the menu now opens a page of every backup, newest first,
filtered by VM name, target and state; a removed VM's backups are
marked. Each backup, there and on the VM's Backups tab, has a Delete
button (also DELETE /api/v1/backups/<uuid>/, 202 with the job).

The backup.delete job holds the backup and its target. Through the
first of the target's computes that reaches its pool, it marks the
backup deleting, removes the manifest first, so the target no longer
holds a complete backup, then every other file named from the backup's
UUID (also those a failed backup left), then the row. Recovery runs the
same steps again. A backup being made is refused: its job is cancelled
instead.

States and consistency are shown in the reader's language.
2026-11-17 09:14:07 +03:00
catborise
f4559acbc7 feat(vmbackups): back up a running or shut-off VM into a target
A superuser backs a VM up from its new Backups tab, or with POST
/api/v1/backups/ (202 with the job); GET lists and reads backups. The
backup.create job holds the VM, its compute (shared) and the target, so
migrations, snapshots and power changes of the VM wait meanwhile.

- A shut-off VM's disks are copied one at a time into the target pool,
  flat, in their format (createXMLFrom); a cancel stops before the next.
- A running or paused VM's disks go by libvirt's push backup into
  volumes made first, as the live clone: the file systems frozen for its
  start when the guest agent answers (frozen), crash-consistent
  otherwise, or refused when frozen file systems are required. A guest
  that shuts down meanwhile does not end the backup.
- A running VM's NVRAM file is kept only when it reads the same after
  the copy as before it (three reads), so it is the capture point's.
- Then the NVRAM file, the definition and the manifest (written last)
  are uploaded and read back, and the row becomes ready with its files.
- Recovery thaws a frozen guest first, watches a push backup still
  running, finishes a copied backup, removes the files of a failed or
  cancelled one, and leaves a copy whose end libvirt cannot tell
  uncertain with its files named. The target pool is checked by UUID and
  its free space before anything is made.
2026-11-17 09:13:59 +03:00