54396 Commits
Author SHA1 Message Date
Dion Bosschieter 78b183d578 nwfilter: add used firewall backend to nwfilterbinding
Updates nwfilterbinding.rng to support the 'backend' XML element.
Defaults the def->backend field to the existing ebiptables firewall
backend inside nwfilter_gentech_driver.c.
This new element allows us to check the definition's firewall backend against the
current firewall backend and remove old existing rules via the previous firewall
backend. This switch between firewall backends happens inside
virNWFilterSwitchTechDriver.

Updated virnwfilterbindingxml2xmltest to test parsing and formatting of
the new nwfilterbinding backend element.

Signed-off-by: Dion Bosschieter <dionbosschieter@gmail.com>
2026-09-03 14:36:46 +01:00
Dion Bosschieter eb65962fb6 nwfilter: add unit tests and test data for nwfilter nftables driver
Add unit test files nwfilternftablestest.c and
nwfilterxml2nftfirewalltest.c, including data files in existing
nwfilterxml2firewalldata directory.

Tests follow same style and structure like the ebiptables driver
for nwfilter.

Signed-off-by: Dion Bosschieter <dionbosschieter@gmail.com>
2026-09-03 14:36:46 +01:00
Dion Bosschieter 1818afcfc2 nwfilter: allow use of nftables nwfilter driver via nwfilter.conf
Change the nwfilter driver loading mechanism to read from nwfilter.conf.
By default, it will use the nftables driver, which follows the
firewall_backend bridge driver config logic.

Added extra nwfilter config options "enable_trace" and "enable_counters"
to allow users to toggle nftable driver specific features.

Added nftables to *filter_tech_drivers as an available driver option
for users to choose from.

Signed-off-by: Dion Bosschieter <dionbosschieter@gmail.com>
2026-09-03 14:36:46 +01:00
Dion Bosschieter e416551ffb nwfilter: add nwfilter nftables driver
Resolves issue: https://gitlab.com/libvirt/libvirt/-/issues/603
Benchmarks showed that the amount of iifname jumps for each
interface is the cause for this.
Switched the nftables driver towards a vmap (verdict map) so we
can have 1 rule that jumps to the correct root input/output chain
per interface. Which improves throughput as when the number of
interface check and jump rules increases the throughput decreases.
The issue describes the interface matching works using the interface
name and the majority of the effort is the strncpy, this commit also
switches nftables to an interface_index compare instead.
However, just using the interface_index is not enough, the amount of
oif and iif jump rules causes quite the performance degradation,
the vmap instead solves this.

Split rules into separate tables: "libvirt_nwfilter_ethernet" and
"libvirt_nwfilter_inet" to preserve existing ebip firewall behavior.

Reworked chain logic for clarity with root -input/-output chains per
interface. input in the VM interface is filtered in the -input
chain(s), output out of the VM inteface is filtered in the -output
chain(s).
Ethernet table has support for subchains where the inet table puts
everything in one chain. This is for compatibility reasons with how
nwfilter ebiptables behaved, so that users may switch to nftables and
expect the same firewalling behavior.

Stuck with two tables for compatibility reasons with ebiptables.
Unifying into a single table would break user firewall definitions, which
depend on being able to accept traffic at the Ethernet layer
(currently defined via ebtables) and apply additional filtering
via IP rules (currently defined via ip(6)tables).
The nwfilter_nftables_driver splits the ethernet and
inet rules in seperate tables "libvirt_nwfilter_ethernet" and
"libvirt_nwfilter_inet", for above mentioned compatibility reasons.

Simplified conntrack handling: rules with accept+conntrack are
duplicated to the opposite chain for symmetric behavior, to support
the existing ebiptables logic.

Firewall updates continue to use tmp names for atomic replacement.

Unsupported nwfilter features (for now):
- IPSets (potential future support via nft sets)
- rejects (not allowed in bridge table and POST/PREROUTING hook)

Signed-off-by: Dion Bosschieter <dionbosschieter@gmail.com>
2026-09-03 14:03:09 +01:00
Ján Tomko 9ba0c64832 storage: logical: don't write past buffer bounds
If parsed number of extents is 0, the calculated buffer size
won't hold the first regex_unit.

Closes: https://gitlab.com/libvirt/libvirt/-/work_items/913
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-09-03 03:06:06 +02:00
Denis V. Lunev via Devel b3c0e3cd0b qemu: cap total size of auto-triggered dumps under auto_dump_path
Each on_crash or watchdog-triggered dump writes a full memory dump
into auto_dump_path. A guest that keeps crashing and restarting (or
crashing and getting destroyed, then respawned by the mgmt app) can
fill the disk one dump at a time, with nothing to stop it.

Add auto_dump_max_size (qemu.conf), parsed via virConfGetValueBytes()
so it takes a plain byte count or a size with a unit suffix (e.g.
"10GiB"). After a dump is written, the oldest dumps under
auto_dump_path are removed until the total fits the configured quota.
The dump that was just written is always kept by identity, not by
sort position: mtime is only second-granularity, so two dumps written
the same second would otherwise make the eviction order between them
arbitrary and could delete the one just written instead of an older
one. Defaults to 0, which keeps every dump forever, as before.

Only files named the way getAutoDumpPath() names them count toward the
quota, and nothing is pruned when the dump itself failed.

libvirtd_qemu.aug gains a matching entry; its quoted branch requires a
unit suffix, as one matching a bare number would overlap the integer
branch.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
2026-09-02 18:29:16 +01:00
Denis V. Lunev 268739d7a1 logging: accept a unit suffix in virtlogd's max_size
Switch max_size from virConfGetValueSizeT() to virConfGetValueBytes(),
so it accepts "2MiB" the same way domain XML memory sizes do, instead
of only a raw byte count.

virtlogd.aug accepts the quoted form too; its quoted branch requires a
unit suffix, as one matching a bare number would overlap the integer
branch.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2026-09-02 18:29:16 +01:00
Denis V. Lunev 29148e83ac util: add virStrToBytes() and virConfGetValueBytes() for scaled sizes
virScaleInteger() already turns a number plus a unit suffix into
bytes, but every caller has to split a whole string like "10GiB" by
hand via virStrToLong_ullp() first, the way virFileReadValueScaledInt()
does for sysfs files. Add virStrToBytes(), which does that split once,
and virConfGetValueBytes() on top of it, so a qemu.conf-style setting
can accept a scaled size in one call. Named "Bytes" rather than "Size"
to avoid reading as a variant of virConfGetValueSizeT()/SSizeT(),
whose "T" is the C type they fill, not a unit.

Add unit tests for virStrToBytes() in virstringtest.c.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2026-09-02 18:29:16 +01:00
Denis V. Lunev 193398620e qemu: auto-select win-dmp for crash- and watchdog-triggered dumps
Where QEMU_CAPS_WIN_DMP_GUEST_AWARE is present, QEMU reports win-dmp
as available only for a guest that has published a vmcoreinfo dump
header. In that case prefer it over the elf default: converting an
elf dump into a Windows-debuggable format afterwards is possible but
complicated and unreliable.

Add qemuDomainGetAutoDumpFormat(), which probes win-dmp support
right before an auto-triggered dump and falls back to elf
otherwise. Use it from both doCoreDumpToAutoDumpPath() (on_crash)
and processWatchdogEvent() (watchdog dump). virDomainCoreDump() and
virDomainCoreDumpWithFormat() are left untouched, since RAW there
is a documented part of their API contract, standing in for an
explicit caller request rather than an internal default.

The probe is best-effort: reset any error left by a failed monitor
call or QMP command, so it cannot leak past a dump that otherwise
succeeds.

Without the capability the probe is skipped: older QEMU offers win-dmp
on any x86 machine, where the resulting dump is useless.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2026-09-02 18:29:16 +01:00
Denis V. Lunev 8972619929 qemu: add capability for guest-aware win-dmp availability
query-dump-guest-memory-capability reported win-dmp on any x86 machine,
whether or not the guest had published a Windows dump header. QEMU
commit 1c0e259c5a35 tied it to the guest's vmcoreinfo note, but left
the change invisible to introspection.

QEMU 11.1 marks the win-dmp member of DumpGuestMemoryFormat with an
'allowed-by-guest' feature. Detect it, so a caller picking a dump format
can tell whether a reported win-dmp says anything about the guest.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2026-09-02 18:29:16 +01:00
Roman Bogorodskiy 27d2f39d9a bhyve: domain: fix filling of firmware data
Fixing the transient definition bug in a0d2ec63b99c4e0f500d6b61a208be48b3e3b396
exposed another issue: the startup filled firmware data is only
available in the live definition. Thus, after shutdown, there is
no information about the VARS file, so `virsh undefine --nvram` cannot
remove it.

Fix that by filling firmware data in the domain XML post-parse stage.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-09-02 18:52:03 +02:00
Roman Bogorodskiy e351099fb5 bhyve: honor VIR_DOMAIN_XML_INACTIVE in virDomainGetXMLDesc()
For an active persistent domain, vm->def contains the live definition
and vm->newDef contains the persistent definition. Use vm->newDef when
VIR_DOMAIN_XML_INACTIVE is requested so that the persistent XML is
returned.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-09-02 18:52:00 +02:00
Roman Bogorodskiy 69bb5d29ff bhyve: process: discard stale live definition on reconnect failure
When reconnect to a domain fails, its status is set to SHUTOFF.
Also call virDomainObjRemoveTransientDef() to make sure
we do not mix vm->def and vm->newDef later.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-09-02 18:51:56 +02:00
Roman Bogorodskiy 6438ddb84c bhyve: process: do not leak live changes to persistent XML
Update virBhyveProcessStart() to call virDomainObjSetDefTransient()
so we save the persistent configuration in vm->newDef, and use
vm->def as a live definition.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-09-02 18:51:46 +02:00
Peter Krempa 0ae3330a14 ci: Add job to check if all mentioned CVEs have corresponding git tags
Introduce a job which will run with the scheduled libvirt pipeline runs
which will check if all CVEs mentioned in the git commit messages, NEWS
entries and for all libvirt security notices published at
https://security.libvirt.org have corresponding git tags.

Since git commit messages do sometimes mention CVE not related to
libvirt, the '.cve_exceptions' file lists allows to add overrides.

Since the upstream repository has signed tags, the tagging is done by
Jirka, so it doesn't make sense to run this check inside the checkout or
as a regular CI pipeline run, so it's implemented directly in the CI job
rather than as a standalone tool.

The job also creates an artifact containing all tagged CVEs in the
repository. This can later be used e.g. to see which CVEs are missing a
libvirt security notice.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2026-09-01 11:43:29 +02:00
Peter Krempa cae70a18d1 qemuDomainRestoreInternal: Preserve error on cleanup path
Preserve the error on cleanup path as cleanup of the 'libvirt_iohelper'
process may overwrite it with an unactionable error, such as when
attempting to restore a save image while the VM is already running:

  $ virsh list
   Id   Name       State
  --------------------------
   9    cd         running

  $ virsh restore /tmp/cd.save
  error: Failed to restore domain from /tmp/cd.save
  error: internal error: Child process (LIBVIRT_LOG_OUTPUTS=1:stderr /home/pipo/build/libvirt/gcc/src/libvirt_iohelper /tmp/cd.save 0) unexpected fatal signal 13

After this patch the original error is reported:

  $ virsh restore /tmp/cd.save
  error: Failed to restore domain from /tmp/cd.save
  error: Requested operation is not valid: domain 'cd' is already active

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2026-09-01 11:42:36 +02:00
Jiri Denemark 320636d0fb Post-release version bump to 12.8.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2026-09-01 10:32:30 +02:00
Jiri Denemark f639bc728b Release of libvirt-12.7.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
v12.7.0
2026-09-01 10:29:22 +02:00
Peter Krempa 2110116385 NEWS: Document CVEs and a virsh crash fixed in this release
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2026-08-31 17:36:58 +02:00
Michal Privoznik 1c6c367f3e NEWS: Document features/improvements/bug fixes I've participated in
There are some features/improvements/bug fixes I've either
contributed or reviewed/merged. Document them for upcoming
release.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2026-08-27 14:51:18 +02:00
Ross Golder 6a1dc8c694 rpc: refuse to queue a message that is already queued
virNetMessageQueuePush() appends by walking to the tail of the queue. If
it is handed a message which is already in that queue, and that message
happens to be the tail, it links the message to itself. The cycle then
makes virNetMessageQueueServe() return the same pointer on consecutive
calls, and callers which free what they are served - such as
virNetServerClientDispatchWrite() - free it twice, aborting the process
with "free(): invalid pointer".

Refuse such a push and warn instead, so that a caller bug shows up as a
diagnosable log message rather than as heap corruption some time later.

The check has to walk the queue rather than just test msg->next, because
virNetMessageClear() memsets the whole message: a queued message which
has been cleared appears unlinked while still being referenced.

Also break the cycle in virNetMessageQueueServe() if one is somehow
already present, rather than handing out the same message indefinitely,
and clear msg->next in virNetMessageFree() so a stale reference held by a
queue is detectable instead of dangling.

The accompanying test reproduces the self-cycle deterministically: with
the check removed it fails with "Message linked to itself".

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ross Golder <ross@golder.org>
v12.7.0-rc2
2026-08-27 12:38:53 +01:00
Ross Golder 4d0b5d7022 remote: don't queue the stream error reply twice
When a stream write fails, daemonStreamHandleWriteData() reports the
error to the client via virNetServerProgramSendReplyError(), which takes
ownership of 'msg' and queues it on client->tx. It then returns that
function's return value, which is 0 on success.

Its caller daemonStreamHandleWrite() treats 0 as "the handler did not
send anything", so for VIR_NET_CONTINUE it clears the message and queues
it a second time to release the client's request slot. As the message is
by then the sole element of client->tx, virNetMessageQueuePush() walks to
the tail - which is the message itself - and links it to itself. The
resulting cycle makes virNetMessageQueueServe() hand out the same pointer
twice, and virNetServerClientDispatchWrite() frees it twice:

  libvirtd[109078]: free(): invalid pointer
  systemd[1]: libvirtd.service: Main process exited, code=dumped,
              status=6/ABRT

The daemon then crash-loops until systemd's start limit is reached.

Note that virNetMessageClear() memsets the whole message, including
->next, so the doubly-queued message looks unlinked and the condition is
not detectable by inspecting msg->next alone.

Give the handlers a distinct return value 2, meaning "fully processed and
already queued, the caller must not touch msg again", and honour it in
daemonStreamHandleWrite(). The requeue test changes from "ret > 0" to
"ret == 1" - otherwise the new value would requeue a message which is
already on client->tx.

daemonStreamHandleHole() had the identical defect and is fixed the same
way. daemonStreamHandleFinish() and daemonStreamHandleAbort() also
consume the message, but are only reached for VIR_NET_OK and
VIR_NET_ERROR respectively, so the VIR_NET_CONTINUE re-send never applies
to them.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/902

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ross Golder <ross@golder.org>
2026-08-27 12:34:00 +01:00
Boris Fiuczynski fdf69c9427 NEWS: document added qemu poll-weigth support
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-08-27 13:03:50 +02:00
Roman Bogorodskiy 13295d45c0 NEWS: document bhyve changes for 12.7.0
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2026-08-25 18:56:46 +02:00
Benjamin 04942b2810 Correct QEMU case typo
Verified exhaustiveness thanks to:

```bash
grep -ri 'QEMU' | sed -E 's/qemu|QEMU|Qemu//g' | grep -i qemu
```

Signed-off-by: Benjamin Loison <benjamin.loison@orange.fr>
2026-08-24 17:41:56 +02:00
Ján Tomko 9d3adf8db6 qemu: agent: clear stale pointer in qemuAgentGetDisks
CVE-2026-77158

In case of hitting the cleanup label, the disks array
was freed but the pointer was not cleared, leading
to a possible double free.

Fixes: 0cb2d9f05d (v6.10.0-9-g0cb2d9f05d)
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/910
Reported-by: David Korczynski (Ada Logics)
Found-by: Claude
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
CVE-2026-77158
2026-08-24 16:03:31 +02:00
Jiri Denemark b8eb060035 po: Refresh potfile for v12.7.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
v12.7.0-rc1
2026-08-24 11:39:23 +02:00
Roman Bogorodskiy f2c32f9d0d bhyve: allow setting eui64 for NVMe disks
Bhyve allows to set eui64 for the NVMe disks:

     eui64       IEEE Extended Unique Identifier (8 byte value).

And in a real command line:

 -s 5:0,nvme,/data/img/10gb.img,ser=BHYVE-NVME01-F000,eui64=0x01000000efbeadde

Model that using the <wwn> element:

  <disk type='file'>
    <driver name='file' type='raw'/>
    <source file='/path/to/some.img'/>
    <target dev='nvme0n1' bus='nvme'/>
    <wwn>01000000efbeadde</wwn>
  </disk>

As this element does not allow commas, it's not necessary to add
additional validation for that.

Closes: https://gitlab.com/libvirt/libvirt/-/work_items/901
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-08-24 11:35:58 +02:00
Roman Bogorodskiy 986c97e04c bhyve: support setting serial number for NVMe controllers
bhyve supports setting NVMe controller serial number using
the "ser=<SN>" option. Update bhyveBuildNVMeControllerArgStr()
to set that if "serial" is specified for the controller.

We do it in the controller's disks loop, but as we prohibit more than 1
disk per controller in bhyveDomainDefValidate(), there is no
repetition here.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-21 13:43:35 +02:00
Roman Bogorodskiy 083db37e22 bhyve: support setting serial number for SATA disks
bhyve supports passing disk serial number using the "ser=<SN>"
option, so update bhyveBuildAHCIControllerArgStr() to set it
from the "serial" element.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-21 13:43:35 +02:00
Roman Bogorodskiy 5a59a74769 bhyve: forbid "," in disk serial numbers
As bhyve options are passed as a comma separated list, e.g.:

 -s N:0,ahci,hd:/tmp/my.img,nmrr=7200,ser=BHYVE-SER01-0001

Do not allow using "," in the serial name. This applies to both NVMe and
SATA disks.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-21 13:43:35 +02:00
Benjamin Loison 70ede8a7a9 Translated using Weblate (Czech)
Currently translated at 100.0% (10958 of 10958 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/cs/

Signed-off-by: Benjamin Loison <benjamin.loison@orange.fr>
2026-08-20 16:07:49 +00:00
Hector Cao 96795f2e93 apparmor: Allow vfio-ccw hostdev sysfs access
Attaching a vfio-ccw mediated device as a <hostdev> fails under the
libvirt-qemu AppArmor profile because QEMU's channel subsystem code
(hw/s390x/css.c) reads several sysfs attributes of the passed-through
subchannel when building the guest SCHIB, and the profile does not grant
read access to them:

  css_sch_get_chpids()     -> /sys/bus/css/devices/<id>/chpids
  css_sch_get_path_masks() -> /sys/bus/css/devices/<id>/pimpampom
  css_sch_get_chpid_type() -> /sys/devices/css<n>/chp0.<chpid>/type

The first two are opened via /sys/bus/css/devices/<id> symlinks, which
AppArmor resolves to the real device path /sys/devices/css<n>/<id>/
before mediating the access; the CHPID type file is read directly under
/sys/devices/. Without these rules the attach (or hotplug) fails with an
AppArmor DENIED message and QEMU aborts with:

  s390_ccw_realize: Failed to build initial schib: Invalid argument

Add narrowly-scoped read rules for these three files so vfio-ccw
passthrough works without granting broad access to /sys/devices/css*.

Signed-off-by: Hector Cao <hector.cao@canonical.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:21:00 +02:00
Jaehoon Kim a6ce54cdc4 virsh: add iothreadset --poll-weight support
Extend iothreadset to allow configuring the iothread poll-weight value
from the command line.

Add a --poll-weight option to opts_iothreadset and wire it up in
cmdIOThreadSet. If the option is omitted the parameter
is not added to the list and the backend leaves the value unchanged.

Document --poll-weight in the iothreadset section of the virsh manpage
and update the syntax synopsis to include the new option. Extend the
virsh test suite with an iothreadset --poll-weight 3 call followed by
a domstats check that confirms the updated value is reflected.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:11:49 +02:00
Jaehoon Kim 3412e9c739 test: add poll-weight support to the test driver
Add poll-weight support to the test driver so that the virsh test
suite can exercise the iothreadset --poll-weight path end-to-end.

Add a poll_weight field to the testIOThreadInfo struct and initialise
it to 0 in both testDomainGenerateIOThreadInfos and
testDomainAddIOThread. Extend testDomainIOThreadParseParams to accept
and store VIR_DOMAIN_IOTHREAD_POLL_WEIGHT, and extend
testDomainGetStatsIOThread to emit the value via domstats.

Update the expected iothreads.out output to include the poll-weight=0
field in the existing domstats blocks now that the test driver reports
it unconditionally.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:11:49 +02:00
Jaehoon Kim af0d03b215 qemu: support iothread poll-weight
Wire the poll-weight setting into the QEMU command line, monitor, and
driver-side parameter handling.

Add poll-weight to the iothread object properties when building the
QEMU command line. Add the live setter in the monitor JSON layer using
a new VIR_IOTHREAD_SET_PROP_UINT macro consistent with the existing UL
variant. Wire up typed parameter parsing with an explicit range check
for [0, 63] and propagate the value into the persistent domain
definition on hotplug. Guard the live path with a capability check.

Add a CAPS check in the domain validator and remove the now-unnecessary
break from the thread pool validation loop since the loop must continue
to check poll-weight on every iothread.

Also add VIR_DOMAIN_IOTHREAD_POLL_WEIGHT typed parameter constant and
a qemuxmlconf test case for the new functionality.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:11:49 +02:00
Jaehoon Kim 17e8a76205 qemu: add poll-weight getter and stats support
Add support for reading the iothread poll-weight value from QEMU and
exposing it via domain stats.

Add poll_weight and set_poll_weight fields to qemuMonitorIOThreadInfo
and parse the poll-weight property from the QMP query-iothreads
response. The property is optional and only present on newer QEMU
binaries.

Expose the fetched value through the domain stats interface by adding
VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_WEIGHT and reporting it in
qemuDomainGetStatsIOThread when the value is available.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:11:49 +02:00
Jaehoon Kim 7287057e67 qemu: capabilities: add capability for iothread poll-weight
Add a capability flag for the iothread poll-weight property.

Detect support for the property from the QMP schema so that libvirt
can conditionally expose and use poll-weight only with QEMU binaries
that support it.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:11:49 +02:00
Jaehoon Kim 5b760c9df4 docs: formatdomain: document iothread poll-weight
Document the iothread poll-weight XML attribute in formatdomain.

Extend the description of iothread polling controls to cover the new
poll-weight attribute and how it relates to the existing poll-max,
poll-grow, and poll-shrink settings. Also document the accepted
range and the meaning of zero as a request for the hypervisor
default.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:11:49 +02:00
Jaehoon Kim f002b40e54 conf: add iothread poll-weight XML support
Add support for the iothread poll-weight XML attribute.

Store the value in the internal iothread definition, parse it from
the <poll/> element, and format it back into domain XML. Also extend
the schema to accept the new attribute and enforce the accepted
range of [0, 63] in the domain validator.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 17:11:49 +02:00
John Levon e5c111be7f Allow slices for block backed NVRAM
For NVRAM storage specifically, the guest-visible size is critical to
correct handling of the OVMF address space. Allow specifying storage
slices for NVRAM storage when the underlying block may be larger
due to alignment/allocation restrictions.

As qemuPrepareNVRAMBlock() does not support it, disallow slices with
non-raw formats, and slice offsets.

Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 16:27:49 +02:00
Sergey Zhidkih 3bca1ab993 storage: check bounds before accessing encryption payload offset
'virStorageFileGetEncryptionPayloadOffset' expects payloadOffset + 4 to
be in buffer bounds which isn't checked anywhere.

For example malicious actor may provide LUKS header with just magic and
version like: '4c554b53 babe 0001'. This example successefully passes
'virStorageFileHasEncryptionFormat' and leads to OOB read of 4 bytes.

So the fix is to add bounds checks.

Fixes: b7d44f450c
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/906

Signed-off-by: Sergey Zhidkih <rx1513@altlinux.org>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-20 15:18:30 +02:00
Jim Fehlig 68e03ee02f qemu: tpm: Avoid following symlinks when chown'ing log file
libvirt chown()s the swtpm log file to the swtpm user:group when starting
a VM. The swtpm log directory is writable by swtmp user, who could replace
the logfile with a symlink to a root-owned path. At next VM start, libvirt
will chown() that path to the swtpm user:group, which breaks the intended
separation between the confined swtpm account and root-owned files.

Use fchown() on an fd opened with O_NOFOLLOW to avoid the potential
symlink attack.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
CVE-2026-77159
2026-08-19 11:59:22 -06:00
Nathan Chen 4f99712849 tests: qemuxmlconfdata: provide cmdqv sample XML and CLI args
Provide sample XML and CLI args for the cmdqv XML schema.

Signed-off-by: Nathan Chen <nathanc@nvidia.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2026-08-19 15:35:50 +02:00
Nathan Chen 8646802058 qemu: add IOMMU attribute "cmdqv" for smmuv3
Introduce support for "cmdqv" IOMMU attribute, which enables NVIDIA
Tegra241 CMDQV, an extension for ARM SMMUv3. It supports passthroughs
of physical SMMU-CMDQ linked command queue from host space to a VM.

Reject domain configs that set cmdqv when the QEMU binary lacks the
property.

Signed-off-by: Nathan Chen <nathanc@nvidia.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2026-08-19 15:35:46 +02:00
Nathan Chen 519954a874 qemu: introduce QEMU_CAPS_ARM_SMMUV3_CMDQV
Probe the arm-smmuv3 cmdqv device property via device-list-properties,
gated on QEMU_CAPS_DEVICE_ARM_SMMUV3.

Signed-off-by: Nathan Chen <nathanc@nvidia.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2026-08-19 15:34:07 +02:00
Michal Privoznik ab46208bda esx: Don't crash when parsing unmounted datastore
When parsing disk source in ESX driver (esxParseVMXFileName())
the datastore is traversed through trying to find matching
prefix. But not every datastore has to be mounted. In that case,
esxVI_LookupDatastoreHostMount() returns success and the returned
struct has mountInfo->path set to NULL. This can be deducted from
the following backtrace (which shows that strlen() hidden in
STRSKIP() macro was given NULL pointer).

Thread 1 "virsh" received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
76		VPCMPEQ	(%rdi), %ymm0, %ymm1
(gdb) bt full
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
No locals.
#1  0x00007ffff7c292d7 in esxParseVMXFileName (fileName=0x5555557341d0 "/vmfs/volumes/5f64209f-c0af0aa8-70c4-e4434ba73190/msafra-RHEL9-shared-1/msafra-RHEL9-shared-1_1.vmdk", opaque=0x7fffffffcf80,
    out=0x7fffffffc738, allow_missing=false) at ../src/esx/esx_driver.c:172
        data = 0x7fffffffcf80
        propertyNameList = 0x555555738b50
        datastoreList = 0x55555573cf40
        datastore = <optimized out>
        hostMount = 0x555555733640
        datastoreName = 0x55555573e590 "mnecas-nfs-test"
        tmp = <optimized out>
        saveptr = 0x5555556a5b50 ""
        strippedFileName = 0x0
        copyOfFileName = 0x0
        directoryAndFileName = <optimized out>
        ret = -1
        __FUNCTION__ = "esxParseVMXFileName"
#2  0x00007ffff7bd47f4 in virVMXParseDisk (ctx=ctx@entry=0x7fffffffcfb0, xmlopt=xmlopt@entry=0x555555738d80, conf=conf@entry=0x5555556a5b50, device=device@entry=0, busType=<optimized out>, busType@entry=3,
    controllerOrBus=controllerOrBus@entry=1, unit=<optimized out>, def=0x7fffffffc960, vmdef=0x5555557375a0) at ../src/vmx/vmx.c:2553
        tmp = 0x0
        result = -1
        prefix = 0x5555557384d0 "scsi1:0"
        present_name = "scsi1:0.present", '\000' <repeats 16 times>
        present = true
        startConnected_name = "scsi1:0.startConnected\000\000\000\000\000\000\000\000\000"
        startConnected = true
        deviceType_name = "scsi1:0.deviceType", '\000' <repeats 13 times>
        deviceType = 0x555555737f60 "scsi-hardDisk"
        clientDevice_name = "scsi1:0.clientDevice", '\000' <repeats 11 times>
        clientDevice = false
        fileType_name = "scsi1:0.fileType", '\000' <repeats 15 times>
        fileType = 0x0
        fileName_name = "scsi1:0.fileName", '\000' <repeats 15 times>
        fileName = 0x5555557341d0 "/vmfs/volumes/5f64209f-c0af0aa8-70c4-e4434ba73190/msafra-RHEL9-shared-1/msafra-RHEL9-shared-1_1.vmdk"
        writeThrough_name = "scsi1:0.writeThrough", '\000' <repeats 11 times>
        writeThrough = false
        mode_name = "scsi1:0.mode", '\000' <repeats 19 times>
        mode = 0x0
        cleanup = <optimized out>
        __FUNCTION__ = "virVMXParseDisk"
#3  0x00007ffff7bd5f01 in virVMXParseConfig (ctx=0x7fffffffcfb0, xmlopt=0x555555738d80, caps=<optimized out>, vmx=<optimized out>) at ../src/vmx/vmx.c:1749
#4  0x00007ffff7c35319 in esxDomainGetXMLDesc (domain=<optimized out>, flags=0) at ../src/esx/esx_driver.c:2595
#5  0x00007ffff7cc4fd3 in virDomainGetXMLDesc (domain=domain@entry=0x5555557367f0, flags=flags@entry=0) at ../src/libvirt-domain.c:2898
#6  0x0000555555586cca in cmdDumpXML (ctl=0x7fffffffd1d0, cmd=0x5555556a5450) at ../tools/virsh-domain.c:10787
#7  0x00005555555bc7cb in vshCommandRun (ctl=0x7fffffffd1d0, cmd=0x5555556a5450) at ../tools/vsh.c:1383
#8  0x0000555555562fbc in main (argc=<optimized out>, argv=0x7fffffffd5c8) at ../tools/virsh.c:900

The backtrace was trimmed.

To fix this, just check whether mount path is not NULL before
passing it to STRSKIP().

Resolves: https://redhat.atlassian.net/browse/RHEL-213506
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2026-08-19 09:19:57 +02:00
Peter Krempa 82b39d0580 qemu: Fix proper ordering of 'virtlockd' shutdown
In commit aa1bf13b9c I attempted to fix
the ordering of virtlockd and virtlogd during shutdown but I made a typo
in the name of 'virtlockd.service' (missing 'd').

Fixes: aa1bf13b9c
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2026-08-18 10:22:04 +02:00
Michal Privoznik a634a99a07 virsh: Add support for VIR_DOMAIN_GUEST_INFO_DEVICES
The virDomainGetGuestInfo() API is exposed as 'guestinfo'
command. Introduce new --devices option for it to reflect
introduction of VIR_DOMAIN_GUEST_INFO_DEVICES type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-17 14:20:41 +02:00
Michal Privoznik af5db68758 bhyve: Implement device info for virDomainGetGuestInfo() API
Use freshly introduced qemuAgentGetGuestDeviceInfo() to implement
support of VIR_DOMAIN_GUEST_INFO_DEVICES type of
virDomainGetGuestInfo() API in the bhyve driver.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-08-17 14:20:41 +02:00