1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-12-02 12:24:29 +03:00
Commit Graph

52913 Commits

Author SHA1 Message Date
Andrea Bolognani
05b67b8cde tests: Minimize SEV tests
Removing all unnecessary devices and elements makes it easier
to focus on the actual purpose of these tests (configuring
the SEV-specific bits).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2025-09-24 13:59:53 +02:00
Andrea Bolognani
f2dbd14342 tests: Tweak descriptor for combined firmware
This kind of firmware build is not shipped in Fedora, where
most descriptors in our test suite come from, so we had to
make it up. It was based off the Secure Boot-enabled edk2
build, and the filename it points to is the same.

That has been fine so far since it's not actually being picked
up by any of the test cases, but that's going to change soon
and when it does we want to be able to avoid any confusion.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2025-09-24 13:59:53 +02:00
Peter Krempa
2d6e21885f qemuMigrationSrcIsSafeDisk: Allow non-shared qcow2's with raw data file
A qcow2 image which uses a data file and the 'data_file_raw' flag is
effectively a raw image with the qcow2 wrapper used only to store
metadata (block dirty bitmaps).

Since the dirty bitmaps are always migrated using the migration stream
it's technically not required that the qcow2 overlay itself is shared
between the destinations.

Management tools like Kubevirt want to migrate VMs which have a qcow2
overlay with the above config stored in a location that is not shared,
but the data file itself is.

This patch adds code that skips the validation of the overlay since it's
not needed to ensure data consistency in that very specific case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 18:57:00 +02:00
Peter Krempa
6e5a3334b2 qemuBlockGetNamedNodeData: Extract 'data_file_raw' flag
The 'data_file_raw' flag of qcow2 notifies that all data inside the
'data_file' is a raw image so can be used standalone without the
metadata without any problem (except for not updating the dirty
bitmaps).

Our migration safety checks will allow skipping the migration safety
check for these files as during migration we know it's safe to re-create
this on the destination in a location that isn't shared.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 18:57:00 +02:00
Peter Krempa
f8201b0032 qemuMigrationSrcIsSafeDisk: Check also data file properties for migrability
If the qcow2 data file feature (which separates the data into a separate
file from the metadata) is in use the migration safety check ought to
consider both the metadata and the data file for safe migration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 18:57:00 +02:00
Peter Krempa
0ca45005d7 qemuMigrationSrcIsSafeDisk: Extract safe migration checks for one storage source
Further split up the code originally in 'qemuMigrationSrcIsSafe' to
separate checks concerning a single storage source.

The code will then be reused to check the safe migration state also for
the data file (qcow2 feature that allows store of data separated from
the qcow2 metadata).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 18:57:00 +02:00
Peter Krempa
60899fc8fc qemuMigrationSrcIsSafe: Extract code for checking safe migrability of one disk
Extract the code which checks a source of a single disk for safe
migratability into 'qemuMigrationSrcIsSafeDisk'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 18:57:00 +02:00
Peter Krempa
9bf19c09a4 qemuMigrationSrcIsSafe: Drop 'DEBUG' message about qemu supporting cache dropping
The feature exists for a long time, no need to add extra notice about
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 18:57:00 +02:00
Michal Privoznik
07a40de613 ci: regenerate with 'lcitool manifest'
This pulls in the fix for generating ENV vars in Dockerfile
according to latest standard.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 15:57:05 +02:00
Sebastian Jensen
970fead068 docs/apps: Remove "Cuckoo Sandbox"
Link pointed to a squatted domain, and the upstream repository on
GitHub has been archived since Apr 27, 2021:

https://github.com/cuckoosandbox/cuckoo
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2025-09-23 12:45:56 +02:00
Américo Monteiro
04c1f45831 Translated using Weblate (Portuguese)
Currently translated at 87.0% (9534 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 86.7% (9493 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 86.4% (9466 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>
2025-09-21 11:59:49 +02:00
Américo Monteiro
8e8f496d87 Translated using Weblate (Portuguese)
Currently translated at 86.0% (9423 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>
2025-09-18 02:51:58 +02:00
jianqing yan
c1f742fe69 Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 97.8% (10711 of 10948 strings)

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

Signed-off-by: jianqing yan <yanjianqing@kylinos.cn>
2025-09-16 11:31:30 +02:00
Américo Monteiro
229f9e8ee8 Translated using Weblate (Portuguese)
Currently translated at 86.0% (9419 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 85.5% (9371 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 85.2% (9336 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 85.0% (9311 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>
2025-09-16 11:31:29 +02:00
Fco. Javier F. Serrador
4eb9cc83c8 Translated using Weblate (Spanish)
Currently translated at 75.7% (8294 of 10948 strings)

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

Signed-off-by: "Fco. Javier F. Serrador" <fserrador@gmail.com>
2025-09-16 11:31:29 +02:00
Ján Tomko
1d1e316152 util: remove glibcompat.c
There are no functions reimplemented here anymore.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-09-15 12:40:12 +02:00
Ján Tomko
48f04627c8 build: bump minimum glib version to 2.68
We removed support for Debian 11 which only had 2.66.8.
Next stop: 2.72 after we drop Ubuntu 22.04

For libvirt, the update to the 2.68 GLib release:
* introduces g_string_replace
* deprecates g_memdup in favor of g_memdup2
* removes the need for some warning workarounds
* deprecates g_time_zone_new in favor of g_time_zone_new_identifier
  which returns NULL on error instead of returning UTC

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-09-15 12:40:12 +02:00
Michal Privoznik
a9bd4c1e0b ch: Implement virConnectDomainEventDeregister()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-12 12:23:13 +02:00
Michal Privoznik
5c04a84638 ch: Implement virConnectDomainEventRegister()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-12 12:23:03 +02:00
Michal Privoznik
76adad0b01 ch: Propagate lifecycle events
We already have a thread that listens on cloud-hypervisor's
monitor for incoming events and processes them. What is missing
though, is emitting of corresponding lifecycle events.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-12 12:23:00 +02:00
Michal Privoznik
f9c1b910bf ch: Emit event on device attach
When a device is detached from a running guest we ought to emit the
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-12 12:22:57 +02:00
Michal Privoznik
9c767752f2 ch: Emit event on device attach
When a device is attached to a running guest we ought to emit the
VIR_DOMAIN_EVENT_ID_DEVICE_ADDED event.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-12 12:22:34 +02:00
Michal Privoznik
06802eeceb ch: Unlock domain in virCHEventStopProcess() on all exit paths
The aim of virCHEventStopProcess() is to clean up after stopped
domain by calling virCHProcessStop(). But in order to do that it
needs to acquire a job and in order to do that it needs to lock
the domain object. Well, the object is not unlocked in all exit
paths, i.e. when job acquiring fails the domain object is left
locked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-11 16:31:11 +02:00
Michal Privoznik
cd00c70695 ch: Avoid memory leak in virCHProcessEvents()
The aim of virCHProcessEvents() is to read data (in JSON format)
from CH monitor and then process them. To parse incoming data
virJSONValueFromString() is used. But the corresponding
virJSONValue is freed only when processing of an even succeeds.
If processing an event fails, then the memory is not freed
leading to a memory leak.

334 (24 direct, 310 indirect) bytes in 1 blocks are definitely lost in loss record 1,975 of 2,040
   at 0x4919EF3: calloc (vg_replace_malloc.c:1675)
   by 0x4FEB249: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0x4A66162: virJSONValueNewObject (virjson.c:533)
   by 0x4A67E74: virJSONValueFromJsonC (virjson.c:1413)
   by 0x4A681A5: virJSONValueFromString (virjson.c:1484)
   by 0xB8CD9D7: virCHProcessEvents (ch_events.c:179)
   by 0xB8CDCDC: virCHReadProcessEvents (ch_events.c:251)
   by 0xB8CDEBB: virCHEventHandlerLoop (ch_events.c:284)
   by 0x4AC1EB4: virThreadHelper (virthread.c:256)
   by 0x5441DE3: start_thread (in /usr/lib64/libc.so.6)
   by 0x54C25F3: clone (in /usr/lib64/libc.so.6)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-11 16:31:11 +02:00
Américo Monteiro
39a0374d13 Translated using Weblate (Portuguese)
Currently translated at 84.2% (9223 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 84.1% (9216 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 84.1% (9210 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 83.9% (9188 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 83.1% (9108 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 82.1% (8991 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 81.1% (8887 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>

Translated using Weblate (Portuguese)

Currently translated at 80.6% (8831 of 10948 strings)

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

Signed-off-by: Américo Monteiro <a_monteiro@gmx.com>
2025-09-11 11:29:04 +02:00
Fco. Javier F. Serrador
addb80ef41 Translated using Weblate (Spanish)
Currently translated at 73.5% (8050 of 10948 strings)

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

Signed-off-by: "Fco. Javier F. Serrador" <fserrador@gmail.com>

Translated using Weblate (Spanish)

Currently translated at 73.4% (8037 of 10948 strings)

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

Signed-off-by: "Fco. Javier F. Serrador" <fserrador@gmail.com>

Translated using Weblate (Spanish)

Currently translated at 72.6% (7957 of 10948 strings)

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

Signed-off-by: "Fco. Javier F. Serrador" <fserrador@gmail.com>
2025-09-11 11:29:03 +02:00
Weblate
bbe7b999ff Translated using Weblate (Spanish)
Currently translated at 72.6% (7957 of 10948 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>

Translated using Weblate (Spanish)

Currently translated at 72.6% (7957 of 10948 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
2025-09-11 11:29:03 +02:00
joo es
0a77a035fd Added translation using Weblate (Arabic)
Signed-off-by: joo es <jonnyse@users.noreply.translate.fedoraproject.org>
2025-09-11 11:29:02 +02:00
Laine Stump
96d1bfee3e conf: auto-add a pcie-root-port when needed while plugging in pcie-to-pci-bridge
This will almost surely never come up during any normal operation[*],
which is likely why this wasn't done when pcie-to-pci-bridge support
was added back in the before-fore times. It's pretty simple to support
though - a pcie-to-pci-bridge plugs into a pcie-root-port just like
any other pcie device, and if there isn't an open slot on an existing
pcie-root-port, we can just add one.

([*] in real life, a pcie-to-pci-bridge is only auto-added by libvirt
itself, while this function is dealing with the followup to *user
added* devices. Also each pcie-to-pci-bridge has 32 slots, and it's
unlikely a domain with pcie support would be wanting more than 32
conventional PCI (i.e. not PCIe) devices)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 13:12:41 -04:00
Laine Stump
698aea684a conf: improve error message when a PCI controller can't be auto-added
Log a slightly different message when the missing-but-required slot is
conventional PCI vs PCIe. Also correct/improve the comments about why
auto-add of a PCI controller isn't supported when we're trying to
create a slot for various different pci controllers.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 13:12:41 -04:00
Laine Stump
ce74632a61 conf: add forgotten clause to virDomainPCIControllerConectTypeToModel()
When building the PCI topology of a domain that has PCI devices with
no assigned PCI addresses, the function virDomainPCIAddressSetGrow()
will attempt to add a new PCI controller with the appropriate type of
slot to connect a device that doesn't have a PCI address.

In some cases this isn't possible (for example, if the device you are
attempting to add to the topology requires a type of connection only
provided by some controller that *itself* requires a connection of a
type not available for the given architecture/machinetype, e.g. if you
want to add a pcie-root-port to a domain with a machine type that has
a pci-root (no PCIE)). In those cases, an error message is logged by
using virDomainPCIControllerConectTypeToModel() to extract the type of
device from the "flags" that are sent to virDomainPCIAddressSetGrow().
However, if virDomainPCIControllerConectTypeToModel() doesn't find a
device type in the connection flags, it will return -1, and
virDomainPCIAddressSetGrow() will log the very generic:

   Cannot automatically add a new PCI bus for a device with connect flags nnnn

Both of these functions were written prior to libvirt adding support
for the pcie-to-pci-bridge controller, and when that support was added
(in 2018), a new if() clause wasn't added to
virDomainPCIControllerConectTypeToModel(). Seven (!) years later, this
omission was noticed by someone adding a new test case to regression
testing.

This patches remedies the earlier omission, so that now when someone
tries to add a pcie-to-pci-bridge controller to a domain that doesn't
have PCIE, the message will be:

  a PCI slot is needed to connect a PCI controller model='pcie-to-pci-bridge', but none is available, and it cannot be automatically added

This is still not an ideal error message, but is arguably better.

(NB: Unfortunately it isn't possible to use a switch() statement with
no default case (in order to catch a similar error in the future),
since we are converting from bitmapped flags. Fortunately, we haven't
needed to add a new PCI controller type in the last 7 1/2 years :-)

Resolves: https://issues.redhat.com/browse/RHEL-62032
Fixes: 542f05e775
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 13:12:41 -04:00
Laine Stump
82b794ca12 qemu: fix multiple missing setup/teardown of passt process for interface type='vhostuser'
passt networking support was originally added only for <interface
type='user'>, and all of the codepaths leading to qemuPasst*()
functions were protected with

   if (net->type == VIR_DOMAIN_NET_TYPE_USER &&
       net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST)

When support was later added to use a vhost-user socket to connect
between the passt process and qemu process, *some* of the conditionals
similar to the above were changed to be

   if ((net->type == VIR_DOMAIN_NET_TYPE_USER ||
        net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) &&
       net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST)

As a matter of fact, enough of these places were changed to make
passt+vhostuser work. However I missed a few places that resulted in
the passt process not being properly shutdown/cleaned up when the
interface type was vhostuser, and also as far as I can see from
examining the code, the passt process wasn't being added to the cgroup
for the domain.

We could fix these problems by adding the extra condition to all the
missing places (checking for either 'user' or 'vhostuser' as well as
for backend type of 'passt'), but since validation already guarantees
that if backend type='passt' then the interface type MUST be either
'user' or 'vhostuser', it's really just adding extra code for no good
purpose (and would leave open the possibility of the same problem
recurring in the future if a different interface type begins using
passt as well). So the better solution is to not bother checking
net->type at all in those locations - if backend type is 'passt' then
we call the passt-related code.

Resolves: https://issues.redhat.com/browse/RHEL-80285
Resolves: https://issues.redhat.com/browse/RHEL-92842
Fixes: 1e9054b9c7
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2025-09-10 13:12:41 -04:00
Enrique Llorente via Devel
cca246e0cb qemu: support setting guest hostname/fqdn using DHCP on passt-backed interfaces
This commit introduces support for configuring hostnames in virtual
machines (VMs) using DHCP via an interface backed by the passt
transport. This is done with the new 'hostname' and 'fqdn' (Fully
Qualified Domain Name) attributes in the <backend> subelement of
<interface>. The values set in these attributes are added to the passt
commandline for the interface (with the --hostname and --fqdn
options), and passt will then send the settings to the guest by adding
options to the DHCP response when the interface is started - for IPv4,
hostname will be sent in option 12, or the FQDN will be sent in option
81, and for IPv6 the FQDN will be sent using option 39.

This will enable a management application to easily configure guest
hostnames without intervening in the guest's disk image (as long as
the guest uses DHCP for it's network interface configuration).

Here is an example of setting the hostname and fqdn for a guest (in
practice, you would only use one or the other, since according to the
RFC if option 81 is sent to the guest, option 12 should not be sent).

   <interface type='vhostuser'>
     <backend type='passt' hostname='bob' fqdn='bob.example.com'/>
     ...

Resolves: https://issues.redhat.com/browse/RHEL-79806
Signed-off-by: Enrique Llorente <ellorent@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2025-09-10 13:12:41 -04:00
Michal Privoznik
f2a6c2d39d ch: Avoid memleak on disk detach in chDomainRemoveDevice()
The aim of chDomainRemoveDevice() is to remove device from
virDomainDef. Well, in case of disks this is done by calling
virDomainDiskRemove() which merely just removes it from the array
of virDomainDiskDef-s but leaves it up to the caller to actually
free the disk def.

1,286 (560 direct, 726 indirect) bytes in 1 blocks are definitely lost in loss record 2,005 of 2,041
   at 0x4919EF3: calloc (vg_replace_malloc.c:1675)
   by 0x4FEB249: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0x4AFD9A4: virDomainDiskDefNewSource (domain_conf.c:2409)
   by 0x4B10ACA: virDomainDiskDefParseXML (domain_conf.c:8509)
   by 0x4B24F07: virDomainDeviceDefParse (domain_conf.c:14631)
   by 0xB8D8881: chDomainAttachDeviceLiveAndUpdateConfig (ch_hotplug.c:135)
   by 0xB8CCFE0: chDomainAttachDeviceFlags (ch_driver.c:2376)
   by 0xB8CD057: chDomainAttachDevice (ch_driver.c:2394)
   by 0x4DC1C7D: virDomainAttachDevice (libvirt-domain.c:8951)
   by 0x405E545: remoteDispatchDomainAttachDevice (remote_daemon_dispatch_stubs.h:3763)
   by 0x405E495: remoteDispatchDomainAttachDeviceHelper (remote_daemon_dispatch_stubs.h:3742)
   by 0x4BF3164: virNetServerProgramDispatchCall (virnetserverprogram.c:423)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 11:45:07 +02:00
Michal Privoznik
6751994950 ch: Drop useless variable in chDomainFindDisk()
The 'disk' variable inside of chDomainFindDisk() is not used
really. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 11:45:01 +02:00
Michal Privoznik
7b70c1868c ch: Drop deadcode from chDomainDetachDeviceLive()
At the end of chDomainDetachDeviceLive() there's a code that
tries to remove the disk that's being detached from the domain
definition. Well, it's a leftover from the original patch which I
forgot to remove when rewriting it to use chDomainRemoveDevice().
The disk is removed there so this code has no chance in removing
it again. Drop the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 11:44:51 +02:00
Michal Privoznik
3bd17ffe97 ch: Actually remove device in chDomainDetachDeviceLive()
Inside of chDomainDetachDeviceLive() there are two variables that
are important in this case: 'match' and 'detach'. The first one
contains device definition as parsed from user provided XML, the
other contains pointer to the device definition inside
virDomainDef (as returned by chDomainFindDisk()).

Now, when chDomainRemoveDevice() is called, it looks up the
device inside virDomainDef and removes it (using pointer
comparison). Well, that means 'detach' must be passed as an
argument instead of 'match'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 11:44:24 +02:00
Michal Privoznik
20d5c61cb4 ch: Avoid memleak in virCHDriverConfigDispose()
When virCHDriverConfig struct is initialized in
virCHDriverConfigNew() the 'configDir' member is allocated but
corresponding free is missing in virCHDriverConfigDispose().
While at it, reorder the free calls to match the order in which
they are declared in the struct so it's easier to spot missing
free call.

20 bytes in 1 blocks are definitely lost in loss record 667 of 2,033
   at 0x4912888: malloc (vg_replace_malloc.c:446)
   by 0x5436747: __vasprintf_internal (in /usr/lib64/libc.so.6)
   by 0x503EC81: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0x500805B: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0x5008124: g_strdup_printf (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0xB8C2B70: virCHDriverConfigNew (ch_conf.c:181)
   by 0xB8C9DDA: chStateInitialize (ch_driver.c:1456)
   by 0x4D9E316: virStateInitialize (libvirt.c:667)
   by 0x40539DB: daemonRunStateInit (remote_daemon.c:581)
   by 0x4AC1EB4: virThreadHelper (virthread.c:256)
   by 0x5441DE3: start_thread (in /usr/lib64/libc.so.6)
   by 0x54C25F3: clone (in /usr/lib64/libc.so.6)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2025-09-10 09:56:50 +02:00
Michal Privoznik
f35a1def9d ch: Implement VIR_DOMAIN_DESTROY_GRACEFUL flag support
The virDomainDestroyFlags() API has several flags, including
VIR_DOMAIN_DESTROY_GRACEFUL which is documented to send only
SIGTERM to the emulator process. Implement its support into CH
driver.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 08:35:25 +02:00
Michal Privoznik
e635b6a6f7 ch: Introduce flags to virCHProcessStop()
A caller (e.g. chDomainDestroyFlags()) might want to chose
whether to kill emulator process forcefully or gracefully (the
@force argument of virProcessKillPainfully()). Invent a flag to
virCHProcessStop() for this. And to keep consistent behaviour,
pass the flag everywhere for now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 08:35:17 +02:00
Michal Privoznik
fc56f7279f ch: Make sure the cloud-hypervisor process is killed in virCHProcessStop()
Currently, virCHProcessStop() is called either when the
cloud-hypervisor process dies gracefully (e.g. on shutdown
initiated from within the guest) or when virDomainDestroy() is
called (or on failed start attempt, but that's not important
right now).

At any rate, if the cloud-hypervisor process is running it's not
a child process of libvirtd rather than the init (per
virCommandDaemonize() called inside of virCHMonitorNew()). This
distinction is important because virCHProcessStop() then calls
virProcessAbort() thinking it'll kill the process. Well,
virProcessAbort() works only on child processes.

Switch to virProcessKillPainfully() which does work in such
cases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 08:34:52 +02:00
Michal Privoznik
5a89be0611 virprocess: Report errno if virProcessAbort() fails
The aim of virProcessAbort() is to reap a child process. It does
so by waitpid()-ing and possibly sending SIGTERM/SIGKILL to the
child process (and waitpid()-ing again). Nevertheless, if
everything fails a debug message is printed. But the message
mentions only the PID and not errno (set by previous waitpid())
which may be useful. For instance when virProcessAbort() is
called over a PID that's not our child:

  failed to reap child 16325, abandoning it: No child processes

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-10 08:32:14 +02:00
Daniel P. Berrangé
7afc0388b8 conf: clear the acpiNodeset field after freeing
The virDomainDeviceInfoClear method does not free the struct, only
its contents, so all pointer fields must be explicitly set to NULL
after releasing to avoid disk of double-free.

Reported by coverity:

  *** CID 895678:         Memory - corruptions  (USE_AFTER_FREE)
  /src/conf/domain_conf.c: 5926             in virDomainDeviceInfoParseXML()
  5920             goto cleanup;
  5921
  5922
  5923         ret = 0;
  5924      cleanup:
  5925         if (ret < 0)
  >>>     CID 895678:         Memory - corruptions  (USE_AFTER_FREE)
  >>>     Calling "virDomainDeviceInfoClear" frees pointer "info->acpiNodeset" which has already been freed.
  5926             virDomainDeviceInfoClear(info);
  5927         return ret;
  5928     }
  5929
  5930     static int
  5931     virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-09 10:56:59 +01:00
Peter Krempa
e7d1a3e2fe qemu: block: Always enable discard forwarding for 'throttle' filter layer
Discards ought to be forwarded to the protocol nodes where we control
if discard actually happens.

Unconditionally enable discard='unmap' for the intermediate layer.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/810
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-09-09 10:37:11 +02:00
Peter Krempa
bfc08fcfe5 datatypes: Refactor rest of 'virGet*' helpers
Similarly to the refactor of 'virGetDomain' done in commit 3de56902d3
rework the code to assume that 'virObjectNew' can't return NULL and use
the 'virCheck*Return' helpers to avoid an 'error:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-09 10:36:35 +02:00
Peter Krempa
3abc707b2c datatypes: virGetStream: Add missing 'virCheckConnectReturn' check
The 'virGet*' helpers check that the passed objects which are used to
construct the new object are valid. The check that the 'conn' object in
'virStreamGet' was missing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-09-09 10:36:35 +02:00
Andrea Righi
c3bdec1af0 NEWS: Mention new acpi-generic-initiator support
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
2025-09-08 19:12:35 +01:00
Andrea Righi
d983a6bf3b docs: Document acpi nodeset in hostdev
Add documentation for the new <acpi nodeset="..."> element in hostdev,
which allows associating devices with ACPI Generic Initiator objects in
QEMU.

A typical use case is NVIDIA Multi-Instance GPU (MIG), where a physical
GPU is partitioned into multiple isolated instances, each tied to one or
more virtual NUMA nodes. The documentation includes an example showing
how to configure <numa> cells together with a MIG device.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
2025-09-08 19:12:35 +01:00
Andrea Righi
d12d0b160d qemu: Add acpi-generic-initiator unit test
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
2025-09-08 19:12:35 +01:00
Andrea Righi
9c24784933 qemu: Generate acpi-generic-initiator command from acpi nodeset
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
2025-09-08 19:12:35 +01:00