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

135 commits

Author SHA1 Message Date
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
be4616ee85 fix(computes): a VM that cannot be read leaves a host's capacity unknown
A host's capacity sums its VMs' vCPUs and memory; a VM busy with a job
is read from its XML. A VM whose XML could not be read for any reason
was skipped as if gone, so a refused read or a dropped connection made
the host look as if it had given less than it had, even nothing. Only a
VM gone meanwhile is skipped now; another error leaves the capacity
unknown, which the pages show as not read.
2026-11-13 16:38:42 +03:00
catborise
81d183f802 fix(computes): a host's CPU chart counts I/O wait as idle, and its memory in GiB
The CPU in use was the share of time not idle, with I/O wait counted as
busy: a host that only waited for its disks showed 100% CPU in use. Time
waiting for I/O is idle now: no CPU runs then.

The memory chart divided by 1024³ and labelled the values GB; it says
GiB now.
2026-11-13 16:38:42 +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
2f7516b7f9 fix(nwfilters): a filter is checked against libvirt's schema before it is defined
libvirt drops the attributes and elements of a filter it does not know,
without an error. A rule accepting <tcp dstport='443'/> (dstportstart is
the attribute) became a rule accepting all TCP; a rule dropping
<tpc dstportstart='22'/> became one dropping all incoming traffic; a
priority of 5000 became 500 (all seen live). Creating, cloning and
editing a filter and adding or removing its rules and references now
define it with VIR_NWFILTER_DEFINE_VALIDATE, and libvirt's refusal names
what it did not accept.
2026-11-13 11:20:47 +03:00
catborise
143a74b145 fix(storages): a volume another compute's VM uses on shared storage is not deleted
A pool on shared storage (an NFS share, or a directory mounted from one)
holds the same file at the same path on every host that mounts it. A
VM's delete checks the panel's other computes before it deletes its disk
files, but the pool page, its API and a VM's disk delete checked only
their own host: a disk of a VM on another compute could be deleted. They
now ask the other computes too, and refuse while one uses the file or
cannot be reached. The other computes are asked before this host's lock
is taken, and before a VM's disk is detached.
2026-11-13 10:41:18 +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
6b92e24359 fix(interfaces): the interface the panel reaches its host by is kept
An interface carrying the address the panel reaches the host by, or a
device in it, could be stopped, and a bridge could be built over such a
device without that address; either cut the panel off the host, with
only a confirmation dialog in the way. Both are refused now: a bridge
over such a device must take the address, or DHCP of its family. The
addresses are the ones libvirt reports for the running interface; one
whose addresses netcf cannot report (a virtio card) and that leases
them is kept too.

A bridge dropped its device's MTU, so jumbo frames stopped; the bridge
now takes it (netcf gives the bridge's MTU to its members), and a
deleted bridge gives it back to its members.
2026-11-12 16:17:33 +03:00
catborise
de249ebad7 fix(interfaces): an interface a VM or a network uses is not deleted
A stopped bridge was deleted while a shut-off VM's network card or a
libvirt network named it; that VM or network then did not start.
Deleting an interface is now refused while any definition of a VM,
running or not, or a network names it, with their names.

A new bridge was offered a device a VM's macvtap card or a network
forwarding to it used; bridging it cut that VM off. Such devices are no
longer offered. A NAT or routed network's outgoing device counts as
used too.
2026-11-12 16:17:33 +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
b7724928fd fix(virtsecrets): a secret in use is not deleted by its UUID in capitals
libvirt finds a secret by its UUID in capitals too, but its users were
looked up by the UUID as posted: a secret a VM's disk or a pool named
was deleted, and that VM or pool no longer started. They are now looked
up by the secret's own UUID.

A usage with a control character made the page fail (lxml refuses it in
XML text) and libvirt dropped a line break silently; the form refuses
both. An empty value set later showed libvirt's "value in
virSecretSetValue must not be NULL"; it is refused in words.
2026-11-12 16:17:21 +03:00
catborise
d00f7d8841 fix(networks): the XML editor does not overwrite a change made meanwhile
The network and filter XML editors defined what they sent as a whole, so
a page opened before another admin's change (a QoS limit, a filter rule)
saved over it and the change was gone without a word. The editor now
sends a digest of the definition it showed, and a definition changed
since is refused with a reload hint.
2026-11-12 13:30:09 +03:00
catborise
534782fdda fix(networks): a network or interface in use is not stopped, and a new one is whole
An interface was stopped from the Interfaces page while running VMs had
cards on it, directly or through a network using it, and they were cut
off; a network in the same case was already refused. Stopping it is now
refused the same way, naming the VMs.

A new network whose autostart could not be set stayed defined and
running while the page said it failed; it is now stopped and undefined
like one that does not start, and a rollback that fails is said with the
first error. A network named "." or ".." is refused: its page address
was another page.

A VM create checks when it is asked and again when its job starts that
the host has the networks and the filter it names, and that no card is
left without a network: one deleted meanwhile, or an empty name in the
list, left a VM that does not start once its disks were made.
2026-11-12 13:30:09 +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
a78d92e7aa fix(networks): a fixed address has a host name, a host address and is changed as shown
dnsmasq skips a fixed address whose name is not a host name ("bad DHCP
host name"): the VM got no fixed address while the page said it was set.
A name now has only letters, digits, '.', '_' and '-', as the dialog
already asks.

An IPv4 fixed address or DHCP range end may no longer be the subnet's
network or broadcast address.

The edit dialog sends the entry's MAC or DUID and name as the page showed
them; an entry another admin changed meanwhile is refused instead of being
changed back.
2026-11-12 13:25:30 +03:00
catborise
d682c4bc82 fix(computes): a changed compute does not use or list its old host
A compute saved with another address, login or password, or deleted, left
its connection open in the panel: saved back to the old credentials, the
panel used it again although the host no longer took them. A VM list that
read the host before such a change could then save that listing over the
VMs of the new one.

The old connection is retired when a compute's connection changes or the
compute is deleted, and a listing is saved only when the compute's
connection is still the one it was read with.
2026-11-12 09:19:03 +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
4045819b8d fix(instances): the Host devices tab says when the host cannot give a VM's USB device
libvirt does not start a VM whose USB device the host does not have as the
definition names it: a device replugged gets another address, and a second
device of a model makes a model-only name ambiguous. The tab said nothing
and the start failed with libvirt's words. The tab's form now says which
device the next start cannot have and what to do (usb_unmatched), and a
snapshot revert checks the same before it starts (check_hostdevs). The
add form posts the device's IDs with its address: a device replugged since
the page was loaded is not given in its place.
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
897c95a5bf fix(instances): a VM's saved state keeps the disks it starts with
A VM with a saved state (managed save, as libvirt-guests leaves VMs when
its host shuts down) shows as shut off, and its start restores the
definition it was saved with. The panel let the VM's Delete remove a disk
of it, and the storage pool delete a volume detached since: the VM then
did not start ("Cannot access storage file"), and the panel has no way to
drop the saved state.

A VM's Delete now refuses a disk while the VM has a saved state, and a
volume in a domain's saved state is in use for every delete check.
2026-11-11 12:55:34 +03:00
catborise
dabb7f4678 fix: worker warnings and CPU windows do not depend on a wall clock
The job panel warned "Worker unavailable" when the worker's last
heartbeat was more than 60 s older than the browser's clock: a browser
set two minutes ahead warned about a worker that had just beaten, and
one behind hid a worker that had stopped. The server now says whether
the worker is gone (worker_gone in the job panel's answer), by the same
rule as the Jobs page.

A host's CPU graph measured its averaging window with time.time(): a
clock set back between two polls gave a negative window. It now uses
time.monotonic(), as a VM's usage already does; a sample from before
the server restarted is measured over a second again.
2026-11-10 12:21:36 +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
3334344634 fix(vrtManager): reconnect after a host's storage or network daemon restarts
On a host with libvirt's modular daemons, a restart of virtstoraged or
virtnetworkd (a package update, for one) left the panel's connection to
virtproxyd open and alive, but every later storage or network call on it
failed with "internal error: client socket is closed". Nothing replaced
it: the storage and network pages showed the error and the VM page gave
500 until the panel was restarted, and a clone running then waited in
recovery for up to an hour, holding its VM.

libvirt reports that error as an RPC internal error and does not say on
which connection, so the error handler now has the process retire its
open connections at the next get_connection: each opens again when next
asked. A retired connection stays with the threads that use them, its
close callback unregistered so that it closes once they are done; a
connection that failed or is opening keeps its retry delay. On compute1 the
pages answered again from the second request on, and the clone's job
failed at its first recovery check, 30 s later, freeing its VM.
2026-11-10 11:12:08 +03:00
catborise
b867903894 test(connection): host-request tests give the fake open 1 s, not 0.2 s
CONNECT_TIMEOUT bounds both the wait for a host's request slot, which
these tests time out on purpose, and the wait for the open's thread,
which they expect to finish. 0.2 s was missed once on a CI runner
("h did not answer within 0.2 s" in test_an_ended_request_lets_the_next_one_in).
The four refusal tests now wait 1 s each.
2026-11-09 10:22:41 +03:00
catborise
04f39d469c test(connection): the thread tests wait for the opens they started
ConnectionThreadsTestCase, like BoundedOpenTestCase, released its blocked
opens when a test ended without waiting for them, so an open could still
end during the next test. Its cleanup joins the threads the test started.
2026-11-08 22:38:07 +03:00
catborise
e4fc2547c2 test(connection): a test waits for the opens it started
BoundedOpenTestCase released its blocked opens when a test ended but did
not wait for them: an open that ended during the next test logged
"h: connected" into that test's assertLogs, and the log test failed in
two of three runs of the vrtManager tests in reverse order. The cleanup
now joins the threads the test started.
2026-11-08 22:12:55 +03:00
catborise
e1041a8d7a test(connection): a close during the lookup returns the connection it checked
The test fired the close callback at the 1st, 2nd or 3rd isAlive call of
a lookup, but a lookup calls isAlive once: two of its three cases closed
nothing. It also took a libvirtError for a result, as it only asserted
that the result was not None. It now runs the one interleaving there is
and asserts that the lookup returns the connection it checked.
2026-11-08 20:51:02 +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
c26ff69b3f refactor(vrtManager): the connection manager locks its dict with threading.RLock
The 223-line read-write lock guarded only the dict of connections, a
lookup of a few entries: readers never waited on a long writer, as the
connection is opened outside the lock. One reentrant lock does the same.
2026-11-08 14:43:33 +03:00
catborise
8e24e2ad44 fix(vrtManager): a new VM's disk path, network and filter names are XML text
create_instance put an existing volume's path and the network and
filter names into the domain XML unescaped, so a quote or ampersand,
which libvirt allows in them, broke the VM's XML. They are escaped as
attach_disk does.
2026-11-08 14:42:47 +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
013b41feff fix(vrtManager): a template's copy takes qcow2's options only as qcow2
The copy of a template for a new VM always got qcow2's compat and
lazy_refcounts, which libvirt refuses for a qcow template, and only a
dir pool named it as a file. Every pool of files now does, and only a
qcow2 copy gets those options. The pool types of files are one list,
which the cloud-init seed check also reads.
2026-11-08 14:35:19 +03:00
catborise
3f13a34665 fix(vrtManager): a VM's new disk in an NFS or filesystem pool keeps its format
A new VM's disk and a disk added to a VM were built by a copy of the
volume XML of the Storage page that kept the format in dir pools only:
in an fs or netfs pool a qcow2 disk became a raw one allocated whole,
and a qcow disk got qcow2's compat and lazy_refcounts, which libvirt
refuses. Both now use the Storage page's builder, where every pool of
files keeps the format and the other pools make a raw volume without
metadata preallocation.
2026-11-08 14:34:51 +03:00
catborise
a1ed639999 refactor(vrtManager): new VM UUIDs come from uuid.uuid4()
randomUUID() built a version 4 UUID from 16 random bytes by hand; the clone and create jobs now take str(uuid4()) from the standard library, and the function and its format test go.
2026-11-08 12:24:47 +03:00
catborise
b3eb13a980 perf(vrtManager): the domain capabilities and each pool's XML are parsed once
get_dom_capabilities() parsed the same domain capabilities XML for each of its 14 reads, and the pool list parsed each pool's XML for its type, its path and its source name. Each is now parsed once and read with get_xpath().
2026-11-08 12:06:37 +03:00
catborise
488a8e7519 perf(vrtManager): a pool's size is read with one info call
get_size() called pool.info() twice for its capacity and free space, two libvirt calls on every pool page and API read.
2026-11-08 12:03:39 +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