36238 Commits

Author SHA1 Message Date
Michal Privoznik
da9a804f4e vbox: Drop code supporting old VBox version
Now that only supported version of VirtualBox is 7.0.x the code
that supports older versions can be dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2025-01-31 10:54:09 +01:00
Michal Privoznik
335bceb115 vbox: Drop support for VirtualBox-6.1.x
According to VirtualBox download page [1] the support for version
6.1.x was terminated a year ago. Drop support for it.

1: https://www.virtualbox.org/wiki/Download_Old_Builds_6_1

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2025-01-31 10:54:06 +01:00
Michal Privoznik
5ca7f27f75 vbox: Report an error when VBox CAPI initialization fails
If initialization of VBOX fails inside of _pfnInitialize an
negative value is returned to signal an error condition to a
caller but no error message is printed out. Reporting an error
may shed more light into why VBOX failed to initialize.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2025-01-31 10:54:03 +01:00
Michal Privoznik
10320ad526 vbox: Use g_autofree in tryLoadOne()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2025-01-31 10:53:47 +01:00
Jim Fehlig via Devel
4118e79f3e qemu: Check for valid save image format when verifying image header
When attempting to restore a saved image, the check for a valid save image
format does not occur until the qemu process is about to be executed. Move
the check earlier in the restore process, along with the other checks that
verify a valid save image header.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-31 08:53:51 +01:00
Jim Fehlig via Devel
517248e239 qemu: Decompose qemuSaveImageOpen
Split the reading of libvirt's save image metadata from the opening
of the fd that will be passed to QEMU. This allows improved error
handling and provides more flexibility users of qemu_saveimage.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-31 08:53:51 +01:00
Jim Fehlig via Devel
50d65b94ef qemu: Move unlinking corrupt save image file to caller
qemuDomainObjRestore is the only caller of qemuSaveImageOpen that
requests an unlink of a corrupted save image. Provide a function to
check for a corrupt image and move unlinking it to qemuDomainObjRestore.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-31 08:53:51 +01:00
Daniel P. Berrangé
18f0160994 remote: add sysusers file to create 'libvirt' group
We previously added a sysusers file, but missed the 'libvirt' group.
This group is referenced in the polkit rules, so we should be
registering that too. It must be done in a separate sysusers file,
however, since it is common to all daemons.

Fixes: a2c3e390f7bedf36f4ddc544d09fe3b8772c5c6f
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-01-30 15:19:35 +00:00
Adam Julis
1e88b8983c glibcompat: Sync g_string_replace()
Ever since its introduction, g_string_replace() has received
various bugfies and improvements, e.g.:

  0a8c7e57a g_string_replace: Don't replace empty string more than once per location
  b13777841 g_string_replace: Document behaviour of zero-length match pattern
  e8517e777 remove quadratic behavior in g_string_replace
  c9e48947e gstring: Fix a heap buffer overflow in the new g_string_replace() code

to name a few. Sync our implementation with the one from current
main branch of glib. Some code style adjustments have been made
to match our coding style.

Signed-off-by: Adam Julis <ajulis@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-30 12:08:30 +01:00
Ankush Menat
8cf042d983 docs: add missing cellNum parameter in function call
Signed-off-by: Ankush Menat <ankushmenat@gmail.com>
2025-01-29 22:30:56 +05:30
kaihuan
c1166be347 qemuSnapshotDeleteValidate: Fix crash when disk is not found in VM definition
qemuDomainDiskByName() can return a NULL pointer on failure.
But this returned value in qemuSnapshotDeleteValidate is not checked.It will make libvirtd crash.

Signed-off-by: kaihuan <jungleman759@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2025-01-29 16:15:30 +01:00
Fabian Leditzky
00f9f2ca1f qemu: Check empty drives in block I/O throttle API
Provide a proper user facing error when attempting to query block
I/O throttling settings for an empty drive. Without this patch, a less
meaningful internal error produced by qemuMonitorJSONBlockIoThrottleInfo
would be propagated to the user.

Signed-off-by: Fabian Leditzky <fabian@ldsoft.dev>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2025-01-29 16:15:29 +01:00
Adam Julis
fce24e433b Support IDE/SATA disk 'product' parameter
Since we supported 'product' parameter for SCSI, just expanded existing
solution makes IDE/SATA parameter works too. QEMU requires parameter 'model'
in case of IDE/SATA (instead of 'product'), so the process of making JSON
object is slightly modified. Length of the 'product' parameter is
different in SCSI (16 chars) and ATA/SATA (40 chars).

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/697
Signed-off-by: Adam Julis <ajulis@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2025-01-29 16:15:29 +01:00
Pavel Hrdina
443ae4adec qemu_snapshot: allow reverting to external disk only snapshot
When snapshot is created with disk-only flag it is always external
snapshot without memory state. Historically when there was not support
to revert external snapshots this produced error message.

    error: Failed to revert snapshot s1
    error: internal error: Invalid target domain state 'disk-snapshot'. Refusing snapshot reversion

Now we can simply consider this as reverting to offline snapshot as the
possible damage to file system is already done at the point of snapshot
creation.

Resolves: https://issues.redhat.com/browse/RHEL-21549
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2025-01-29 15:50:19 +01:00
Assaf Admi
f6d76aad80 docs: Document that 'vcpu.delay' statistic is in nanoseconds
Add nanoseconds units for vcpu.delay doc, as it's based on
'/proc/<pid>/task/<tid>/schedstat' (see 'qemuGetSchedstatDelay()').

'schedstat' is in nanoseconds, according to
https://docs.kernel.org/scheduler/sched-stats.html#proc-pid-schedstat.

Signed-off-by: aadmi <aadmi@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2025-01-29 12:42:27 +01:00
Peter Krempa
72142dcde3 qemuProcessHandleIOError: Refactor to extract 'priv' instead of 'driver'
The VM private data will be used in a sub-sequent patch. To minimize
churn, refactor the function before changing the logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-01-28 17:04:39 +01:00
Peter Krempa
420c39d6bd build: Bump minimum glib2 version to 2.66.0
Per our supported platforms the minimum available versions are:

         CentOS Stream 9: 2.68.4
               Debian 11: 2.66.8
               Fedora 39: 2.78.6
      openSUSE Leap 15.6: 2.78.6
            Ubuntu 22.04: 2.72.4
           FreeBSD ports: 2.80.5
          macOS homebrew: 2.82.4
          macOS macports: 2.78.4

Bump to 2.66 which is limited by Debian 11. While ideally we'd bump to
2.68 which would give us 'g_strv_builder' and friends 2.66 is enough for
g_ptr_array_steal() which can be used to emulate the former with almost
no extra code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2025-01-28 17:04:39 +01:00
Adam Julis
62b961d64c conf: check size of secret file for secret object
Since the empty file with a .base64 value wasn't recognized during the loading
process (starting of libvirtd), attempting to get a value for the UUID resulted
in an undefined error. This patch resolves the issue by checking the size of
the file and ensuring that the stored value is as expected (NULL).

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Adam Julis <ajulis@redhat.com>
2025-01-28 11:08:58 +00:00
Michal Privoznik
4819a14fec ch: Include unistd.h in ch_events.c
There's a call to read() in the file but corresponding include of
unistd.h is missing causing a build failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2025-01-27 17:35:53 +01:00
Jiri Denemark
8b1578ab4b qemu: Allow virDomainBlockJobSetSpeed during migration
When a migration with non-shared storage is started with
VIR_MIGRATE_PARAM_BANDWIDTH set, it will be applied to both memory
migration and each block job started for storage migration. Once the
migration is running virDomainMigrateSetMaxSpeed may be used to change
the bandwidth used by memory migration, but there was no way of changing
storage migration speed. Let's allow virDomainBlockJobSetSpeed during
migration to enable the missing functionality.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-27 16:32:57 +01:00
Jiri Denemark
d9fca42e40 qemu: Add support for avail-switchover-bandwidth migration parameter
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-27 16:32:57 +01:00
Andrea Bolognani
676453a0a7 meson: Unify handling of directories used for loadable modules
Currently the directories that are searched for each possible
kind of loadable module are created as a side effect of
installing the corresponding module, which means that their
availability depends on the exact list of features that have
been enabled.

Create them explicitly ahead of time instead, ensuring
consistency.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-27 11:30:21 +01:00
Anirudh Rayabharam
e797c3e3b3 ch: implement domainInterfaceAddresses
Implement domainInterfaceAddresses for the Cloud Hypervisor driver.
Support VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE and
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP sources. Implementation is
similar to other drivers.

Signed-off-by: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <praveenkpaladugu@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-24 17:18:35 +01:00
Purna Pavan Chandra Aekkaladevi
90299b0c6c ch: events: facilitate lifecycle events handling
Implement `virCHProcessEvent` that maps event string to corresponding
event type and take appropriate actions. As part of this, handle the
shutdown event by correctly updating the domain state. This change also
facilitates the handling of other VM lifecycle events, such as booting,
rebooting, pause, resume, etc.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-24 17:03:56 +01:00
Purna Pavan Chandra Aekkaladevi
104b0036ad ch: events: Read and parse cloud-hypervisor events
Implement `chReadProcessEvents` and `chProcessEvents` to read events from
event monitor FIFO file and parse them accordingly.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Co-authored-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-24 17:03:56 +01:00
Purna Pavan Chandra Aekkaladevi
3015c28c1e ch: start a new thread for handling ch events
Use a FIFO(named pipe) for --event-monitor option in CH. Introduce a new
thread, `virCHEventHandlerLoop`, to continuously monitor and handle
events from cloud-hypervisor.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Co-authored-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-24 17:03:56 +01:00
Purna Pavan Chandra Aekkaladevi
d7c9660b15 ch: pass --event-monitor option to cloud-hypervisor
The `--event-monitor` option in cloud-hypervisor outputs events to a
specified file. This file can then be used to monitor VM lifecycle,
other vmm events and trigger appropriate actions.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Co-authored-by: Vineeth Pillai <viremana@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-24 17:03:56 +01:00
Daniel Henrique Barboza
5624489251 qemu: add RISC-V 'aia' command line
The 'aia' feature is added as a machine type option for the 'virt'
RISC-V machine, e.g. "-machine virt,aia=<val>".

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2025-01-24 07:30:52 -03:00
Daniel Henrique Barboza
817eabd0cc conf,qemu: implement RISC-V 'aia' virt domain feature
This feature is implemented as a string that can range from "none",
"aplic" and "aplic-imsic".

If the feature isn't present in the domain XML the hypervisor default
will be used. For QEMU, at least up to 9.2, the default is "none".

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2025-01-24 07:30:47 -03:00
Daniel Henrique Barboza
34d7f53d1b qemu: add capability for RISC-V AIA feature
AIA (Advanced Interrupt Architecture) support was introduced in QEMU 7.0
for the 'virt' machine type. It allows the guest to choose from a more
modern interrupt model than the default (CLINT - Core Logical Interrupt
Controller).

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2025-01-24 07:30:34 -03:00
Heinrich Schuchardt
3e9440dbcb virsysinfo: fix RISC-V detection
The correct compiler define to detect the RISC-V architecture is __riscv.

Fixes: b902cfece0db ("virsysinfo: Try reading DMI table")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2025-01-23 15:05:21 +01:00
Jiri Denemark
0ca8d870a2 qemu: Fix hang when migration is canceled at the last moment
When a migration is canceled very late once virtual CPUs are already
stopped, QEMU will automatically resume them. If this happens after we
exited a waiting loop in qemuMigrationSrcWaitForCompletion, but before a
loop that tries to make sure CPUs are stopped by waiting for the
appropriate event, we may end up waiting forever because the CPUs are
running (they were resumed by migrate_cancel), but the STOP event is
already gone.

This is possible because we enter monitor for fetching migration
statistics at which point other APIs can be processed and migration may
change its state. We should recheck the state when we get back from the
monitor code.

https://issues.redhat.com/browse/RHEL-52493

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-21 15:04:36 +01:00
Peter Krempa
22034bb77e storage_file_backend_fs: Compile out 'chown' backend on mingw
Otherwise build on mingw complains:

  src/storage_file/storage_file_backend_fs.c:142:12: error: implicit declaration of function 'chown

Fixes: f8558a87ac8525b16f4cbba4f24e0885fde2b79e
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2025-01-20 16:47:24 +01:00
Peter Krempa
f8558a87ac storage_file: de-modularize the local file backend
The 'storage_file' infrastructure serves as an abstraction on top of
file-looking storage technologies. Apart from local file it currently
implements also a backend for 'gluster'.

Historically it was all modularized and the local file module was
usually packaged with the 'core' part of the storage driver. Now with
split daemons one can install e.g. 'virqemud' without the storage driver
core which contains the 'fs' backend module. Since the qemu driver uses
the storage file backends to e.g. create storage for snapshots and
backups this allows users to create a deployment where some things will
not work properly.

As the 'fs' backend doesn't use any code that wouldn't be linked
directly anyways there's no point in actually shipping it as a module.

Let's compile it in so that all deployments can use it.

To achieve that, compile the source directly into the
'virt_storage_file_lib' static library and remove the loading code. Also
adjust the spec file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-01-20 13:28:09 +01:00
Peter Krempa
87a4fe2906 storage_file: Refuse qcow2 images with empty string as 'data_file'
In certain buggy conditions qemu can create an image which has empty
string stored as 'data_file'. While probing libvirt would consider the
empty string as a relative file name and construct the path using the
path of the parent image stripping the last component and appending the
empty string. This results into attempting to using a directory as an
image and thus the following error when attempting to start VM with such
an image:

 error: unsupported configuration: storage type 'dir' requires use of storage format 'fat'

Reject empty strings passed in as 'data_file'.

Note that we do not have the same problem with 'backing store' as an
empty string there is interpreted as no backing file both by qemu and
libvirt.

Resolves: https://issues.redhat.com/browse/RHEL-70627
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-20 13:25:51 +01:00
Daniel P. Berrangé
a10728dc5b util: avoid overflow in hextable buffer
The assigned string is 17 chars long once the trailing nul is taken
into account. This triggers a warning with GCC 15

 src/util/virsystemd.c: In function ‘virSystemdEscapeName’:
 src/util/virsystemd.c:59:38: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
    59 |     static const char hextable[16] = "0123456789abcdef";
       |                                      ^~~~~~~~~~~~~~~~~~

Switch to a dynamically sized array as used in all the other places
we have a hextable array.

See also: https://gcc.gnu.org/PR115185
Reported-by: Yaakov Selkowitz <yselkowi@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-01-20 10:08:44 +00:00
Jiri Denemark
095760cddc cpu_x86: Probe host CPU for all MSR features
The list of CPU features we probe from various MSR grew significantly
over time and the CPU map currently mentions 11 distinct MSR indexes.
But the code for directly probing host CPU features was still reading
only the original 0x10a index. Thus the CPU model in host capabilities
was missing a lot of features.

Instead of specifying a static list of indexes to read (which we would
forget to update in the future), let's just read all indexes found in
the CPU map.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-17 12:52:28 +01:00
Jiri Denemark
3766891c59 qemu_migration: Do not automatically resume domain after I/O error
When an I/O error happens (causing a domain to be paused) during live
migration which is later cancelled by a user, trying to resume the
domain doesn't make sense.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-17 12:44:42 +01:00
Jiri Denemark
e46e64be50 qemu_migration: Refactor qemuMigrationSrcRestoreDomainState
None of the callers really care about the return value so we can drop it
and simplify the code a bit.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-17 12:44:38 +01:00
Jiri Denemark
899bf2746a qemu: Report error from both sides of migration
When migration fails in Perform phase, we call Finish on the destination
host with cancelled=1 and get the error from there and report it to the
user. This works well if the error on the destination caused the
migration to fail. But in other cases the main error may reported by the
source and the destination would just be complaining about broken
migration stream.

In other words, we don't really know which error caused the migration to
fail and we have no way of detecting that. So instead of choosing one
error, this patch will combine the error messages from both sides of
migration into a single message and report it to the user. The result
would be, for example:

    operation failed: migration failed. Message from the source host:
    operation failed: job 'migration out' failed: Certificate does not
    match the hostname ble.bla. Message from the destination host:
    operation failed: job 'migration in' failed: load of migration
    failed: Invalid argument

And yes, this is ugly, but I wasn't able to come up with a better way of
fixing this issue.

https://issues.redhat.com/browse/RHEL-58933

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2025-01-17 12:44:17 +01:00
Martin Kletzander
a4def2eb95 conf: Do not parse hyperv features with passthrough mode
The schema does not allow that anyway and we then format them all back
which leads to libvirt producing an invalid XML.

Resolves: https://issues.redhat.com/browse/RHEL-70656
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-13 14:03:21 +01:00
Jiri Denemark
a71985f6f3 qemu_migration: Do not consider post-copy active in postcopy-recover
The postcopy-recover migration state in QEMU means a connection for the
migration stream was established. Depending on the schedulers on both
hosts a relative timing of the corresponding MIGRATION event on the
source host and the destination host may differ. Specifically it's
possible that the source sees postcopy-recover while the destination is
still in postcopy-paused.

Currently the Perform phase on the source host ends when we get
postcopy-recover event and the Finish phase on the destination host is
called. If this is fast enough we can still see postcopy-paused state
when the Finish phase starts waiting for migration to complete. This is
interpreted as a failure and reported back to the caller. Even though
the recovery may actually start just a few moments later.

To avoid this race we now don't consider post-copy migration active in
postcopy-recover state and keep waiting for postcopy-active event (in
the success path). Thus the Finish phase is entered only after the
migration switches to postcopy-active. In this state QEMU guarantees the
destination already switched at least to postcopy-recover and we won't
be confused be seeing an old postcopy-failed state.

https://issues.redhat.com/browse/RHEL-73085

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com
2025-01-13 12:18:20 +01:00
Daniel P. Berrangé
9ab2cd48ea access: fix po_check when polkit is disabled
The generated org.libvirt.api.policy.in file was recently added to the
POTFILES list as it contains translatable messages.

It is only generated when WITH_POLKIT && WITH_LIBVIRTD is satisfied
though, resulting in the 'po_check' syntax rule failing if either of
those conditions are not met.

It is harmless to unconditionally generate this file, as a separate
rule takes care of of installing it, and the latter remains under
the build conditions.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-01-13 09:35:16 +00:00
Laine Stump
7a903458f1 qemu: support vlan change for linux host bridge during update-device
Since we previously only supported vlan tagging for interfaces
connected to an OVS bridge [*], the code in qemuChangeNet() (used by
the update-device API) assumed an interface with modified vlan config
was on an OVS bridge, and would call the OVS-specific
virNetDevOpenvswitchUpdateVlan().

Now that we support vlan tagging for interfaces connected to a
standard Linux host bridge, we must check the type of connection and
only call the OVS function when connected to an OVS bridge *both
before and after the update*. Otherwise we just set the flag to
re-connect to the bridge, which has the side effect of redoing the
vlan setup.

([*] or an SRIOV VF assigned using VFIO, but we don't support *any
runtime changes to that type of netdev so it's irrelevant here.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2025-01-13 09:58:00 +01:00
Pavel Hrdina
d51179fa82 qemu: snapshot: delete disk image only if parent snapshot is external
When we are deleting external snapshot that is not active we only need
to delete overlay disk image of the parent snapshot. This works
correctly even if parent snapshot is external and active as it will have
another overlay created when user reverted to that snapshot.

In case the parent snapshot is internal there are no overlay disk images
created as everything is stored internally within the disk image. In
this case we would delete the actual disk image storing internal
snapshots and most likely the original disk image as well resulting in
data loss once the VM is shutoff.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/734
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2025-01-10 18:57:16 +01:00
Daniel P. Berrangé
caa10431cd util: don't attempt to acquire logind inhibitor if not requested
When VIR_INHIBITOR_WHAT_NONE is passed to virInhibitorNew, it is
an indication that daemon shutdown should be inhibited, but no
OS level inhibitors acquired. This is done by the virtnetworkd
daemon, for example, to prevent shutdown while running virtual
machines are present, without blocking / delaying OS shutdown.

Unfortunately the code forgot to skip the DBus call in this case,
resulting in errors being logged.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-01-09 09:24:20 +00:00
Daniel P. Berrangé
a28a5b675d rpc: log details of OS signals received by daemon
When debugging it is useful to know what signals are being received and
metadata related to them. Log this data before calling the signal
handling callbacks.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-01-09 09:23:44 +00:00
Laine Stump
dd82e2baa8 qemu: allow migration of guest with mdev vGPU to VF vGPU
GPU vendors are moving away from using mdev to create virtual GPUs
towards using SRIOV VFs that are vGPUs. In both cases, once created
the vGPUs are assigned to guests via <hostdev> (i.e. VFIO device
assignment), and inside the guest the devices look identical, but mdev
vGPUs are located by QEMU/VFIO using a uuid, while VF vGPUs are
located with a PCI address. So although we generally require the
device on the source host to exactly match the device on the
destination host, in the case of mdev-created vGPU vs. VF vGPU
migration *can* potentially work, except that libvirt has a hard-coded
check that prevents us from even trying.

This patch loosens up that check so that we will allow attempts to
migrate a guest from a source host that has mdev-created vGPUs to a
destination host that has VF vGPUs (and vice versa). The expectation
is that if this doesn't actually work then QEMU will fail and generate
an error that we can report.

Signed-off-by: Laine Stump <laine@redhat.com>
Tested-by: Zhiyi Guo <zhguo@redhat.com>
Reviewed-by: Zhiyi Guo <zhguo@redhat.com>
2025-01-08 17:24:20 -05:00
Leigh Brown
c1a0d08518 Enable vlan support for standard linux bridges
Adjust domain and network validation to permit vlan configuration on
standard linux bridges.

Update calls to virNetDevBridgeAddPort to pass the vlan configuration.

Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
Reviewed-by: Laine Stump <laine@redhat.com>
2025-01-08 17:15:20 -05:00
Leigh Brown
582f0966f9 util: Add vlan support to virNetDevBridgeAddPort
Add virNetDevBridgeSetupVlans function to configure a bridge
interface using the passed virNetDevVlan struct.

Add virVlan parameter to the Linux version of virNetDevBridgeAddPort
and call virNetDevBridgeSetupVlans to set up the required vlan
configuration.

Update callers of virNetDevBridgeAddPort to pass NULL for now.

Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
Reviewed-by: Laine Stump <laine@redhat.com>
2025-01-08 17:04:27 -05:00