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

250 commits

Author SHA1 Message Date
catborise
5f7555f348 fix(instances): a VM with backup checkpoints is deleted and moved offline
libvirt refuses to undefine a domain that has checkpoints unless asked to
drop their metadata. The VM delete job and the shut-off migration's
removal of the source definition now pass CHECKPOINTS_METADATA; a backup
chain ends with them, and the next backup is full.
2026-11-17 16:55:26 +03:00
catborise
823d34cc18 feat(vmbackups): restore a backup as a new VM
A ready backup has a Restore button (Backups page and the VM's tab) and
POST /api/v1/backups/<uuid>/restore/. The form takes the new VM's name
(default <vm>-restored), a compute that has the target's pool, the pool
for its disks, Connect the network (off by default: the restored guest
keeps the VM's addresses and host name) and Start after restore. The job
page follows the restore.

The backup.restore job holds what a new VM's job holds, the backup
(shared) and the target. Before anything is made it checks again: the
host is not in maintenance; the name is free in the panel and on the
host (a VM made with virsh too); the backup's files are in the target,
the disks at their size and the small files with their SHA-256; the
host offers the definition's emulator, machine type and firmware, its
networks, bridges and network filters; the destination pool has room
and none of the copies' names. The new VM's UUID, MACs, volume names and
NVRAM path are recorded first. Then the disks are copied from the
target, the NVRAM file uploaded, maintenance checked once more, and the
VM defined last and given to the superuser who restored it.

The definition is the kept one rewritten as a clone's (rewrite_for_new_vm,
taken out of _clone_definition for both): new name, UUID and SMBIOS
UUID, MACs and filter parameters, a VNC password, no cloud-init seed of
the VM's; with a new generation ID, each disk's source the restored file
without the old chain, the NVRAM path, and links down unless connected.

Recovery records a VM defined by the recorded UUID; otherwise it removes
the copies and the NVRAM file by their recorded names.
2026-11-17 09:14:09 +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
catborise
89835f2b06 feat(vmbackups): what a VM's backup holds and the target files
wvmBackup.backup_plan reads a VM's persistent definition and says what a
backup copies: each file disk (qcow2 or raw) with its pool and virtual
size, the NVRAM file, and what is left out (CD-ROMs, floppies). It
refuses, naming the reason, what a backup could not restore as it is:
encrypted, block, network, volume, directory and shareable disks, other
disk formats, a disk in no storage pool, shared host directories, a
kernel file boot, host devices, a saved state, TPM state (a later
layer), an NVRAM file outside libvirt's directory, and a running VM
whose disks change at its next start.

The target side: the files' names from the backup's UUID only, the free
space check (virtual size plus the snapshots' margin), small files
written and read back with their SHA-256, read, removed and the
manifests listed. download_volume is taken out of copy_nvram for both.
Every user of the NVRAM pool runs in the worker, so its process lock
holds.

A push backup target of a raw disk (live backup or live clone) is made
without qcow2's compat and features, which libvirt refuses for raw.
2026-11-17 08:40:06 +03:00
catborise
ea20f12bc8 feat(computes): Bulk Migrate spreads a host's VMs over the others; host checks asked once
Bulk Migrate sent every chosen VM to one destination, without looking at
its memory. With several other hosts it now spreads them by default
(computes.balance.spread): the largest VMs first, each to the host that
has the least memory, then vCPUs, with it; a VM that holds its memory
(running or paused) only where it fits the memory the host's running and
paused VMs leave. The page shows where
each VM goes and makes the spread again when a VM is ticked or unticked;
a VM no host has room for says so. One destination stays a choice. The
host.bulk_migrate job takes a destination per VM ("moves").

The Balance and Bulk Migrate pages asked, for every VM and destination,
the host's identity and whether both hosts share each disk directory,
which writes a marker file on the shared storage: about 86 ms a pair,
sequential, so minutes with a few hundred VMs on ten hosts. A Reach
(computes/reach.py) asks each host pair and each directory once and
reads a VM's definitions once. vrtManager: wvmInstances.shares and
file_disks, also used by disk_plan.

read_fleet reads the hosts, their VMs and loads for both pages.
2026-11-16 10:29:07 +03:00
catborise
4941a8a048 feat(computes): Balance proposes migrations that even out the hosts
A Balance button on the Computes page opens computes/balance/: the memory
and vCPUs each host gives its running VMs, before and after, and the
proposed migrations. The proposal (computes/balance.py) takes, step by
step, the one move that most lowers the sum of the squared memory loads,
then of the squared vCPU loads, and stops when none does; each VM moves
once, and the VMs moved to a host fit in the memory its running and
paused VMs leave without counting those moved away, so the moves may
run in any order. Only running VMs count and
move; one that cannot move (no destination shares its disks) still
counts on its host and is listed with the reason. Unticking a VM keeps
it where it is and makes the proposal again.

Migrate runs the moves shown in one host.balance job. It shares the bulk
migration's loop (computes.jobs.Migrations): migrate jobs, the chosen
number at once, one bulk job at a time. Its migrations take only a
running VM (moveto running_only): one stopped since stays where it is.

A job another one started now shows only on its own page: a host's page
no longer lists a bulk migration's or a balance's migrations, and the
Computes page shows the bulk jobs.
2026-11-16 07:37:10 +03:00
catborise
690275adb7 refactor(vrtManager): a shut-off VM clone copies its disks with clone_volume
clone_instance built its own volume XML for file disks and for RBD
images, and called clone_volume only for block disks. Each disk now goes
through wvmStorage.clone_volume, in the pool of its source volume.

clone_volume makes the volume under the exact name it is given and
returns its path; clone_name, as before, gives a dir pool's name its
suffix, and the template copy and the storage clone job use it. Metadata
preallocation is asked only for qcow2, the one format libvirt
preallocates. A raw file copy no longer gets qcow2's compat options, and
an RBD copy no longer passes the preallocation flag, which the RBD
backend refuses.
2026-11-14 19:43:11 +03:00
catborise
dd258888d2 refactor(vrtManager): a new VM's copy of a template is made by clone_volume
clone_from_template wrote its own copy XML next to wvmStorage.clone_volume,
which the volume and VM clones use. clone_volume now takes the volume to
copy, of its pool or another, so the template's copy goes through it too;
it leaves metadata unallocated in a pool of no files, as the template copy
did. A qcow2 template's copy in a file pool is now named <vm>.qcow2, like
a new empty disk, not <vm>.img.
2026-11-14 15:23:26 +03:00
catborise
d6df6b1df4 fix(instances): console changes that cannot be made are refused, not reported as done
A switch to the serial console removed the graphics device but kept a
serial console of another type, a TCP one say, which the browser does
not open; the audit log said the console type was set. The switch is now
refused, with nothing changed, unless the serial console is a pty one.

A listen address change of a console that listens on a network, a socket
or nowhere did nothing without a word. It is refused with the reason.

The .vv file pointed virt-viewer at "::" for a console on all IPv6
addresses; such a console is reached through the host, as one on
0.0.0.0.
2026-11-13 22:49:28 +03:00
catborise
7fe79463fc fix(instances): saving a SPICE console's settings keeps it SPICE
The console type list offers VNC and Serial only, so the page of a SPICE
VM showed VNC and any save, of the keymap alone, switched the console:
libvirt refused the definition when the VM had a SPICE channel, and
without one the VM silently got a new VNC console. A console type the
panel does not create is now offered as it is, and kept on save.

A switch from SPICE that is chosen removes the SPICE channels, USB
redirection and smartcards libvirt refuses without SPICE graphics and
mutes SPICE audio. A new VNC console keeps the keymap and a password VNC
can take; a longer one is replaced by a generated password.

The console settings were read from the first graphics device that had
each attribute: with VNC and SPICE devices the page showed VNC's port
with SPICE's password. All are read from the first device, the one the
settings change.
2026-11-13 22:49:21 +03:00
catborise
cd3edf4dff fix(instances): a VNC password the browser console can send, kept as set
The console settings accepted any password of at most 8 bytes, so "éééé"
was saved, but noVNC derives its key from the characters while QEMU
compares the UTF-8 bytes: the browser console could not log in. A new
password now takes up to 8 printable ASCII characters, which also keeps
control characters out of the definition.

The .vv file wrote the password and the VM name as they are; virt-viewer
reads it as a GLib key file, so a backslash or a leading space changed
the password. Both are escaped as a key file expects.

A new or removed password also drops a passwdValidTo set elsewhere: an
expired one left the new password unusable.
2026-11-13 22:49:12 +03:00
catborise
7bbc951082 fix(instances): a clone's NIC filter keeps no address of its source's
A NIC filter such as clean-traffic can name the VM's own MAC and IP as
parameters. A clone kept the source's, so the filter dropped the clone's
traffic from its new MAC. A clone's MAC parameter is now its own MAC,
and its IP parameter is left out for the filter to learn the clone's
address, as clean-traffic does by default; with learning turned off
(CTRL_IP_LEARNING none) the filter needs it, and it stays, as an IPV6
parameter does (libvirt learns no IPv6 address).

A filter page showed the actions drop, reject, return and continue in
English in every language; they are translated now.
2026-11-13 11:46:12 +03:00
catborise
b1c6184931 fix(instances): a VM is not migrated to a host whose filters of its names differ
A migration checked only that the destination had network filters of
the names the VM's NICs use. A VM runs with its host's filter of a name,
whatever its rules: a destination whose filter of that name was empty,
or lacked a filter it references, left the VM unfiltered there. The
filters the VM names and those they reference are now compared rule by
rule (each host's UUID aside), and one missing or different on the
destination refuses the migration.

A filter created or edited with a reference to a filter the host does
not have, which libvirt accepts, is refused too: a VM using it would not
start.
2026-11-13 11:46:01 +03:00
catborise
b664e34161 fix(nwfilters): two changes at once do not undo each other
A rule or reference change reads a filter and defines it again whole:
two admins changing one filter at once each defined their copy, and the
second removed the first's rule. Changes to a host's filters (create,
clone, delete, rules, references, XML) now run one at a time; one that
finds another running is told to try again.

A VM's NIC form sends back its source, model, filter and MAC whole: a
form opened before another admin changed the NIC's filter put the old
filter back. The form now sends a fingerprint of the NIC as it showed
it, and a NIC changed meanwhile is refused.
2026-11-13 11:46:01 +03:00
catborise
272a40f4e1 fix(instances): power off does not wait a minute for a guest agent that hangs
libvirt shuts a VM down through its guest agent when one is connected,
and waits 60 s for an agent that hangs before it presses the ACPI power
button. The Power Off request hung for that minute, holding the VM's
lock. A running VM's connected agent is now pinged first; one that does
not answer in 10 s is passed over and the power button is pressed.
2026-11-13 08:44:03 +03:00
catborise
3412c63417 fix(instances): a Windows VM's root password and SSH key are refused in words
On a running Windows VM with its guest agent connected, the Access tab's
root password and SSH key were sent to the agent, which has no root
account, takes no crypt(3) hash and has no SSH key command: the owner got
the agent's raw error. The guest's OS is now asked first, and a Windows
guest is refused with a message.
2026-11-13 08:43:50 +03:00
catborise
edc165cfc4 fix(instances): a VM is not migrated to a host without its secrets
A shut-off VM whose disk, host device or vTPM names a secret was moved
to a host that does not have that secret: libvirt defines the VM there,
the source definition was removed, and the VM then did not start. A
migration now names the secrets the destination lacks, by UUID or by
usage, and is refused before anything changes, as it is for networks.
2026-11-12 16:17:21 +03:00
catborise
3308a75557 fix(instances): a VM's network cards name networks and filters its host has
libvirt saves a network card whose network or filter the host does not
have, and the VM then does not start: a card added or changed with an
unknown network (net:missing) or filter was saved and the page said the
card was changed. Adding or changing a card now refuses a network or
filter the host does not have; a stopped network is still the host's.

A migration defines the VM on the destination the same way: a shut-off
VM moved to a host without one of its networks or filters stayed there
unable to start. The migration now refuses such a destination before
anything changes.
2026-11-12 13:25:30 +03:00
catborise
2db25314ea fix(instances): USB device changes as PCI ones; device refusals name no VM to owners
- A USB device added to or removed from a VM with a saved state applied
  only at the next cold boot: refused now, as for PCI devices, and the
  form says so.
- A USB hot plug or removal that failed half way said only libvirt's
  error: it now says where the device is, as for PCI devices
  (_hostdev_outcome, shared).
- A host device refusal (check_hostdevs) names the other VMs that have
  the device; users who do not see the hosts, such as an owner whose
  snapshot revert is refused, now read that a device is not free and that
  an administrator can see why.
- The host's USB devices named among a PCI device's host resources were
  English in every language.
2026-11-11 22:58:40 +03:00
catborise
a36ffcd3ba fix(instances): a VM starts only with host devices the host can give now
A device is checked when it is given to a VM, but a start later did not
check it again: a PCI device bound back to a host driver for the host's
own network or disks, or a USB device the host no longer has as named,
was taken from the host or failed in libvirt. Power On and Power Cycle now
check the definition the VM starts from (its saved state's when restored)
as a snapshot revert does, and refuse with the reasons; Power Cycle checks
before it stops the VM.
2026-11-11 22:58:34 +03:00
catborise
f0a9d2cf82 fix(vrtManager): a disk in an inactive pool keeps the files it may be made from
Only a running disk's definition has its backing chain; for the others the
in-use check reads it from the volumes of active pools. With such a disk's
overlay in an inactive pool (a stopped VM's, the next start's, a saved
state's or a snapshot's), its backing file counted as unused, so deleting
another VM with its disks, or the volume itself, could delete it. The check
now refuses (InUse) while a disk that is not running and not raw has its
file in an inactive pool, and says to start the pool. A snapshot delete
that is done reports no left-behind files then, rather than failing.
2026-11-11 15:21:49 +03:00
catborise
1957a5a85a fix(instances): memory, boot order and QoS edits check what they change first
Three edits went wrong on input or a state made outside the panel:

- A running VM's memory was set live, then for its next start. When the
  next start had a lower maximum (virsh --config), the live change was
  made and the second one failed. The maximum of the next start is now
  checked first.
- A boot order entry without its device type ("disk") raised an error
  page. It is now refused with a message.
- A QoS form of a NIC whose MAC changed since redefined the VM unchanged
  and said the QoS was set or deleted. It now says the NIC is not in the
  definition.

Turkish and Chinese texts included.
2026-11-11 12:55:34 +03:00
catborise
fce63996ba fix(instances): a refused vCPU resize keeps the VM's vCPU hotplug
With vCPU hotplug on, a resize defined the VM three times: without its
hotplug settings, with the new counts, with hotplug settings again. When
libvirt refused the new counts (a maximum over the machine type's limit),
the VM was left with hotplug switched off and an error.

The counts and the hotplug settings for them now go in one definition.
2026-11-11 12:55:34 +03:00
catborise
84866cdf0d fix: backups and snapshots keep their order when the clock goes back
Backup retention kept the last --keep backups by name, and a name is the
panel's local time. Where the clock goes back an hour in autumn
(TIME_ZONE=Europe/Berlin), a backup at 02:10 CET forty minutes after one
at 02:50 CEST sorted first, and --keep 1 deleted the new one. Retention
now keeps the newest by when they were made (the directory's mtime);
the names stay as they were.

Snapshot times from libvirt (epoch seconds) became naive local times,
which the snapshot list sorts newest first: in the same hour the older
snapshot came first. They are now aware UTC times; the page still shows
them in the panel's time zone.
2026-11-10 12:21:36 +03:00
catborise
24ed1c8065 test(snapshots): check the call that creates a snapshot, not a wrapper of it
_snapshotCreateXML only forwarded to the domain's snapshotCreateXML, and
every snapshot test replaced it with a mock: a wrapper that called nothing
passed all of them. The wrapper is gone and the tests assert on the
domain's call, which the code makes directly.
2026-11-08 20:50:05 +03:00
catborise
d19151b88e refactor(vrtManager): instance.py imports libvirt's names without a fallback
When the import of libvirt's names failed, the except branch imported
four of them and left the module to fail later on any other one with a
NameError. libvirt-python always has them; the import is a plain one.
2026-11-08 14:44:09 +03:00
catborise
021d75102e fix(vrtManager): an RBD disk takes its pool's auth and monitors as they are
A disk of an RBD pool, at VM creation or added later, had the pool's
user, secret uuid and monitors put into its XML as strings: a user with
a quote or ampersand broke the XML, and a secret named by usage gave
IndexError on attach and uuid='None' at creation. One function now
copies the pool's auth (uuid or usage) and host elements into the
disk's source with lxml, replacing the two string builders.
2026-11-08 14:42:20 +03:00
catborise
38b5306fee fix(vrtManager): an ISO put in a host CD-ROM drive is read
A CD-ROM of type block (a host drive) kept its type when an ISO was
inserted, and libvirt reads only source/@dev for that type, so the drive
stayed empty. Inserting an ISO now makes it a file drive.
2026-11-08 14:40:26 +03:00
catborise
d567bbf687 fix(vrtManager): a vCPU maximum the CPU topology does not make is refused first
A VM with a CPU topology takes only the maximum it makes; libvirt
refused another one after the vCPU hotplug list had been removed, so a
failed resize left hotplug off. The maximum is now checked against the
topology before anything changes, with tr and zh translations.
2026-11-08 14:40:06 +03:00
catborise
b90b632a09 fix(vrtManager): a NIC's edit keeps the parameters of its filter
Saving a NIC's settings replaced its filterref even when the filter
stayed the same, so its parameters were lost: clean-traffic with a
fixed IP went back to learning the address at the next start. The same
filter now keeps its element; another filter replaces it.
2026-11-08 14:38:53 +03:00
catborise
32e8ff3c11 fix(instances): recovery removes the UEFI variables copy of a clone that was not defined
A shut-off clone copies the VM's NVRAM file just before it defines the
clone; a worker that stopped between the two left the copy, unnamed by
the job, which recovery then reported as leaving nothing. The job
records the copy's path once libvirt made it, and recovery deletes that
file when the clone was not defined, in whichever pool it is.
2026-11-07 23:58:50 +03:00
catborise
e2b038f3fa fix(instances): a VM with an SMBIOS UUID can be cloned
The clone took a new UUID but kept the VM's in its SMBIOS system
information, and libvirt refused the definition (UUID mismatch between
<uuid> and <sysinfo>). The SMBIOS entry takes the clone's UUID.
2026-11-07 23:56:04 +03:00
catborise
ae5fe5216c fix(instances): a clone's TPM is a new one, never the VM's state
A shut-off clone kept the VM's TPM element as it was: an emulated TPM
with a state path of its own, a host's TPM or an external one would be
shared with the VM, not the new, empty TPM the clone form promises. An
emulated TPM loses its state path, and the others are refused.
2026-11-07 23:56:04 +03:00
catborise
b1c6281af9 fix(instances): a shut-off clone into a volume name its pool has is refused before it begins
libvirt refused the copy only after the job had begun; recovery then
found a volume of the planned name and ended the job uncertain, holding
the VM. The names are checked when the job is queued and before it runs,
as a live clone did; that check now refreshes the pool first, so a live
clone's free space is read current too.
2026-11-07 23:56:04 +03:00
catborise
3c5aac2911 fix(migrate): a shut-off VM whose NVRAM file is outside libvirt's directory is refused
Only a file in libvirt's NVRAM directory was copied; one elsewhere was
skipped without a word, and the VM started on the destination from the
firmware's template, its saved boot entries lost. Such a VM is now
refused before anything changes.
2026-11-07 23:10:19 +03:00
catborise
7566ecf81a fix(migrate): recovery removes the disk copies of a migration whose worker stopped
A worker that stopped during the copy left the partial files on the
destination: libvirt ends the migration and the VM stays, but the files
took the space and refused the next try, as a copy never replaces a
file. The job records the copies before libvirt makes them, and
recovery deletes them while the destination has no VM of it.
2026-11-07 23:10:19 +03:00
catborise
cf0c586572 fix(migrate): the next start's definition names a copied disk under its new path
A copied disk was found by its target as well as its path: after a bus
change waiting for the next start (vda to sda), the next start's
definition kept the source path, which the destination does not have,
and the VM would not start again there. The path alone finds it, so two
disks of one file can no longer be copied to two places.
2026-11-07 23:10:19 +03:00
catborise
0eb8e8282e fix(migrate): a copied disk's source file is deleted only when no compute may use it
The source host alone was asked: a file on storage the computes share,
used by a VM or volume of another compute, was deleted under it. The
check the disk move makes, every compute and a host that cannot tell
counting as using it, moves to instances.utils and serves both. The
destination is not asked when its copy has the source's path: its VM
uses that copy, another file.
2026-11-07 22:51:25 +03:00
catborise
d90a967ba6 fix(migrate): a disk of an LVM or disk pool does not count as shared with the destination
Each host's logical volumes are its own: a VM whose disk is /dev/vg/x
migrated, uncopied, onto the destination's volume of the same name and
kept running on other data. Such a volume now counts as missing there.
2026-11-07 22:39:26 +03:00
catborise
897bcba66f 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.
2026-11-07 16:19:12 +03:00
catborise
1c81d3e1cb perf(instances): a VM page does not wait for the guest agent's addresses
A running VM's page read its addresses while it rendered: the guest agent,
when its channel is connected but it does not answer, holds the page (and
a gunicorn worker) for its whole 10 s timeout, on every load. The page now
shows them once it has loaded: vm_addresses.js asks the new
instances/<pk>/addresses/ for each NIC's addresses and fills the header's
IPv4 and each network card's IPv4 and IPv6.
2026-11-07 15:42:49 +03:00
catborise
e9e514a7e9 fix(logs): a row says what happened: a recovered migration, a failed clone step, a device not there
- A migration whose libvirt call failed but which recovery finds moved (or
  cannot tell) gets a row of that end; only a failure already logged by
  migrate_instance is not logged twice.
- A clone made with its resize or start failed, and a recovered migration
  whose autostart or NVRAM step failed, write a failed row of that step, as
  migrate_instance does for its later steps.
- Setting the link state of an interface or the video model of a VM that
  has none is refused: it changed nothing and was logged as done.
- The rows of a removed VM record (deleted or expired) name its host, VM
  and UUID, so the VM's history has them.
2026-11-07 14:36:34 +03:00
catborise
fd40c00ce8 fix(instances): a new VM and each clone get a VNC password of their own
Since the VM create became a job (6f0c7300) every new VM was defined with
no VNC password, and a clone copied its source's password (or its lack
of one) exactly: every clone of a template shared it. Computes listen
for VNC on all their addresses (dev/libvirt-bootstrap.sh), so anyone who
could reach a compute's VNC ports opened any of these consoles directly,
without the panel; the README's firewall rule was the only guard.

The create job asks for create.py's random 8-character password again,
and a clone's VNC graphics get a new random one. The console page sends
the password to a user with passwordless_console, which the user create
form now ticks by default next to change_password; a user without it is
asked for the password, as the permission intends. Existing VMs keep
their settings.

Live create, clone and VM page tests pass on a TCP compute.
2026-11-06 20:00:43 +03:00
catborise
0582e4173a feat(jobs): deleting a VM is a job that recovery finishes
The delete ran in the request: undefine, then the VM's record, then its
disk files. A request that died in between (a gunicorn worker past its
timeout, OOM, a restart), or a database write that failed after the
undefine, left a record that later showed as removed outside the panel,
and the disk files the user asked to delete were never deleted.

Deleting a VM is now an instance.delete job. It holds the compute
exclusively, as the request did, so no other VM attaches a file it is
about to delete. The job chooses the files before it stops the VM (a host
that cannot be checked still stops nothing) and records them first. It
then stops and undefines the VM, removes its record, and deletes the
files, each with its own Logs row. Recovery decides from libvirt: a VM
still on its host means the delete failed; a VM gone means libvirt did
it, so recovery removes the record and deletes the recorded files that
are still there.

The page queues the job and returns to the VM page, where the job panel
follows it and opens the VM list when it ends; disks that were kept are
the result's warning. The API's delete answers 202 with the job and
needs a submission_key. backing_path moves to wvmConnect, as recovery
has no domain to ask.
2026-11-06 09:49:31 +03:00
catborise
386832fa9c perf(instances): the Stats tab reads a VM's counters in one libvirt call
Each poll called info(), then blockStats() for every disk and
interfaceStats() for every NIC: nine calls for a VM with four disks and
two NICs, every 5 s for each open Stats tab. domainListGetStats now gives
the CPU time and every disk's and NIC's counters at once; a counter the
host does not report is -1, as before.
2026-11-05 18:58:13 +03:00
catborise
4a3db744c7 fix(instances): reverting a running VM to an internal snapshot fails before any effect
The internal revert's shut-off check ran in the job's run, after its
intent was recorded, so the refusal went to recovery: the job ended
uncertain and kept the VM's claim until a superuser resolved it. The check
(check_internal_revert) now runs in precheck too, so a page older than the
VM's start, or a direct POST, fails the job with the reason.
2026-11-05 16:16:47 +03:00
catborise
1924ac4679 fix(vrtManager): a failed NVRAM copy aborts its libvirt streams
libvirt requires a stream that did not finish to be aborted before it is
freed. The NVRAM download of a shut-off move and upload_volume (NVRAM
upload, cloud-init seed) freed theirs after a failed send, receive or
finish without aborting, on the shared host connection. They abort now;
upload_volume opens its stream before it makes the volume, so the
cleanup has both.
2026-11-04 19:56:10 +03:00
catborise
0ad6524bbf fix(instances): a resize keeps a VM's maximum vCPUs above the host's CPUs
The Resize tab offered vCPU counts only up to the host's logical CPUs.
A VM whose maximum was higher (4 on a 2-CPU host, say) found no option
for it, so the Maximum list showed 1, and a resize of the shut-off VM
lowered its maximum to that without a word.

get_max_cpus() now takes the VM's own maximum as a floor, and the
Instance's vcpu_range passes it. The host's CPU count shown on the page
and used by the clone form is read from the host alone, not from that
range.
2026-11-03 23:07:59 +03:00
catborise
e8e7ad4d80 refactor(vrtManager): a VM's addresses are read once a page, not once an object
wvmInstance kept the guest agent's and the ARP table's addresses from
the first NIC it was asked about, and never read them again on that
object; it carried a lease lookup that was never filled.

The addresses are now one {MAC: (IPv4, IPv6)} read, kept like the
domain XML only inside a cached_reads block: the VM page, which reads
its NICs twice, asks the agent once (it may take its whole timeout),
and a read outside a page's block is a new one. The agent's addresses
still come before the ARP table's.
2026-11-03 07:11:11 +03:00
catborise
82b97f8ec5 feat(vrtManager): the libvirt layer's messages show in the reader's language
vrtManager's errors (some 140: a disk that does not move, a network
address outside its subnet, a host device given to another VM, the
disks a migration cannot copy) were English f-strings, so no catalog
could translate them, on pages or in jobs.

They are marked texts with their values now; a variant that differs by
a word (internal or external, running or persistent, with a subnet or
without) is a whole message of its own, and a list of problems is a
list of messages. OperationError reads in the active language, so the
pages that show one translate it as they are; its args stay English, and
so do the logs and the audit log. Host device problems and the Migrate
tab's reasons a disk is not copied are messages too.
2026-11-03 00:05:34 +03:00