]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
9 months agovirPerfReadEvent: Refactor to return -errno on failure
Peter Krempa [Mon, 17 Feb 2025 13:16:04 +0000 (14:16 +0100)] 
virPerfReadEvent: Refactor to return -errno on failure

The function didn't comply with libvirt's error reporting scheme as it
reported libvirt errors only sometimes. As callers may want to ignore
errors convert it to returning -errno on failure instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsCpuCache: Don't error out
Peter Krempa [Mon, 17 Feb 2025 12:55:08 +0000 (13:55 +0100)] 
qemuDomainGetStatsCpuCache: Don't error out

The bulk domain stats API is meant to collect as much data as possible
without erroring out.

If fetching of the cache stats fails just skip outputting them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsCpuHaltPollTime: Remove return value
Peter Krempa [Mon, 17 Feb 2025 12:51:10 +0000 (13:51 +0100)] 
qemuDomainGetStatsCpuHaltPollTime: Remove return value

The function can't fail. Remove return value and refactor callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsCpuProc: Remove return value
Peter Krempa [Mon, 17 Feb 2025 12:51:10 +0000 (13:51 +0100)] 
qemuDomainGetStatsCpuProc: Remove return value

The function can't fail. Remove return value and refactor callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsCpuCgroup: Remove return value
Peter Krempa [Mon, 17 Feb 2025 12:51:10 +0000 (13:51 +0100)] 
qemuDomainGetStatsCpuCgroup: Remove return value

The function can't fail. Remove return value and refactor callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agovirBitmapFormat: Don't check return value
Peter Krempa [Mon, 17 Feb 2025 12:43:16 +0000 (13:43 +0100)] 
virBitmapFormat: Don't check return value

'virBitmapFormat' always returns a string; remove pointless checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agovirDomainCputuneDefFormat: Refactor bitmap formatting
Peter Krempa [Mon, 17 Feb 2025 12:09:41 +0000 (13:09 +0100)] 
virDomainCputuneDefFormat: Refactor bitmap formatting

Use g_autofree for the temporary variables, remove error checks for
virBitmapFormat and simplify formatting of multiple attributes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agovirDomainResctrlMonDefParse: Refactor temporary variables
Peter Krempa [Mon, 17 Feb 2025 12:01:39 +0000 (13:01 +0100)] 
virDomainResctrlMonDefParse: Refactor temporary variables

Decrease scope of temporary variables so that they don't have to be
autofreed and VIR_FREE()d at the same time.

Remove unneeded checks and temporary variables.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agovirBitmapFormat: Clarify returned values
Peter Krempa [Mon, 17 Feb 2025 11:58:22 +0000 (12:58 +0100)] 
virBitmapFormat: Clarify returned values

NULL can't be returned; don't mention it in the docs.

Avoid extra cofusing variable when returning copy of empty string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsBlockExportHeader: Remove return value
Peter Krempa [Mon, 17 Feb 2025 10:19:11 +0000 (11:19 +0100)] 
qemuDomainGetStatsBlockExportHeader: Remove return value

The function always returns 0. Remove return value and fix callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainStorageAlias: Remove NULL checks from callers
Peter Krempa [Mon, 17 Feb 2025 10:38:13 +0000 (11:38 +0100)] 
qemuDomainStorageAlias: Remove NULL checks from callers

'qemuDomainStorageAlias' always returns non-NULL pointer if it gets a
non-NULL string on input. Remove unneeded checks from callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsOneBlock: Remove return value
Peter Krempa [Mon, 17 Feb 2025 10:19:11 +0000 (11:19 +0100)] 
qemuDomainGetStatsOneBlock: Remove return value

The function always returns 0. Remove return value and fix callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsOneBlockFallback: Remove return value
Peter Krempa [Mon, 17 Feb 2025 10:19:11 +0000 (11:19 +0100)] 
qemuDomainGetStatsOneBlockFallback: Remove return value

The function always returns 0. Remove return value and fix callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsBlockExportBackendStorage: Remove return value
Peter Krempa [Mon, 17 Feb 2025 10:19:11 +0000 (11:19 +0100)] 
qemuDomainGetStatsBlockExportBackendStorage: Remove return value

The function always returns 0. Remove return value and fix callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsBlockExportFrontend: Remove return value
Peter Krempa [Mon, 17 Feb 2025 10:19:11 +0000 (11:19 +0100)] 
qemuDomainGetStatsBlockExportFrontend: Remove return value

The function always returns 0. Remove return value and fix callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9 months agoqemuDomainGetStatsBlockExportHeader: Remove return value
Peter Krempa [Mon, 17 Feb 2025 10:19:11 +0000 (11:19 +0100)] 
qemuDomainGetStatsBlockExportHeader: Remove return value

The function always returns 0. Remove return value and fix callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agobuild-aux: squelch trailing blank warnings from binary files
Daniel P. Berrangé [Mon, 17 Feb 2025 17:00:42 +0000 (17:00 +0000)] 
build-aux: squelch trailing blank warnings from binary files

These files pollute the stderr output when the sc_trailing_blank
syntax check fails.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu: Avoid crash in qemuDomainCheckCPU with unknown host CPU
Jiri Denemark [Tue, 18 Feb 2025 10:24:32 +0000 (11:24 +0100)] 
qemu: Avoid crash in qemuDomainCheckCPU with unknown host CPU

When we don't have any information about host CPU (for example when
running on an aarch64 host), the virQEMUCapsGetHostModel would return
NULL.

Fixes: f928eb5fc80ca0ed7277f2513b63aed36c09d275
Fixes: https://gitlab.com/libvirt/libvirt/-/issues/747
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Tested-by: Jaroslav Suchanek <jsuchane@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoutil: fix compile warning in virsystemd.c during mingw builds
Laine Stump [Tue, 18 Feb 2025 04:00:58 +0000 (23:00 -0500)] 
util: fix compile warning in virsystemd.c during mingw builds

A function was changed from having no arguments to having a single
argument, but the entire body of the function was #ifdefed out for
windows builds, leaving that new argument unused. Surprisingly this
didn't cause the build to fail, but I happened to notice it flit by
during an rpm build.

Fixes: 785cd56e5803fbbf60715fb6c7536360df5b4b9e
Signed-off-by: Laine Stump <laine@redhat.com>
10 months agoutils: Canonicalize paths before comparing them
Andrea Bolognani [Thu, 13 Feb 2025 08:54:05 +0000 (09:54 +0100)] 
utils: Canonicalize paths before comparing them

In virFileIsSharedFSOverride() we compare a path against a list
of overrides looking for a match.

All overrides are canonicalized ahead of time though, so e.g.
/var/run/foo will be turned into /run/foo due to /var/run being
a symlink on modern Linux systems. But the path we're trying to
match with the overrides doesn't get the same treatment, so in
this scenario the comparison will always fail.

Canonicalizing the path as well solves the issue.

Resolves: https://issues.redhat.com/browse/RHEL-79165
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agodocs: index: fix VMware capitalization
Ján Tomko [Mon, 17 Feb 2025 14:07:56 +0000 (15:07 +0100)] 
docs: index: fix VMware capitalization

Reported-by: Mark Phillips
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 months agonews: include info about supporting vhostuser+passt combination
Laine Stump [Sat, 15 Feb 2025 14:02:09 +0000 (09:02 -0500)] 
news: include info about supporting vhostuser+passt combination

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agodocs: document using passt backend with <interface type='vhostuser'>
Laine Stump [Sat, 15 Feb 2025 04:35:56 +0000 (23:35 -0500)] 
docs: document using passt backend with <interface type='vhostuser'>

Almost everything is already there (in the section for using passt
with type='user'), so we just need to point to that from the
type='vhostuser' section (and vice versa), and add a bit of glue.

Also updated a few related details that have changed (e.g. default
model type for vhostuser is now 'virtio', and source type/mode are now
optional), and changed "vhost-user interface" to "vhost-user
connection" because the interface is a virtio interface, and
vhost-user is being used to connect that interface to the outside.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agodocs: improve type='user' docs to higlight differences between SLIRP and passt
Laine Stump [Sat, 15 Feb 2025 03:43:03 +0000 (22:43 -0500)] 
docs: improve type='user' docs to higlight differences between SLIRP and passt

This reorganizes the section about <interface type='user'> and
describes the differences in behavior between SLIRP and passt.

Resolves: https://issues.redhat.com/browse/RHEL-46601
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: fail validation if a domain def has vhostuser/passt but no shared mem
Laine Stump [Fri, 14 Feb 2025 18:10:19 +0000 (13:10 -0500)] 
qemu: fail validation if a domain def has vhostuser/passt but no shared mem

This can/should also be done for a traditional vhost-user interface
(ie not backend type='passt') but that will be a separate change.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: complete vhostuser + passt support
Laine Stump [Wed, 12 Feb 2025 21:16:44 +0000 (16:16 -0500)] 
qemu: complete vhostuser + passt support

<interface type='vhostuser'><backend type='passt'/> needs to run the
passt command just as is done for interface type='user', but then add
vhostuser bits to the qemu commandline/monitor command.

There are some changes to the parsing/validation along with changes to
the vhostuser codepath do do the extra stuff for passt. I tried
keeping them separated into different patches, but then the unit test
failed in a strange way deep down in the bowels of the commandline
generation, so this patch both 1) makes the final changes to
parsing/formatting and 2) adds passt stuff at appropriate places for
vhostuser (as well as making a couple of things *not* happen when the
passt backend is chosen). The result is that you can now have:

    <interface type='vhostuser'>
      <backend type='passt'/>
      ...
    </interface>

Then as long as you also have the following as a subelement of
<domain>:

    <memoryBacking>
      <access mode='shared'/>
    </memoryBacking>

your passt interfaces will benefit from the greatly improved
efficiency of a vhost-user data path, and all without requiring
special privileges or capabilities *anywhere* (i.e. it works for
unprivileged libvirt (qemu:///session) as well as privileged libvirt).

Resolves: https://issues.redhat.com/browse/RHEL-69455
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: make qemuPasstCreateSocketPath() public
Laine Stump [Wed, 12 Feb 2025 17:12:04 +0000 (12:12 -0500)] 
qemu: make qemuPasstCreateSocketPath() public

When passt is used with vhostuser, the vhostuser code that builds the
qemu commandline will need to have the same socket path that is given
to the passt command, so this patch makes it visible outside of
qemu_passt.c.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: use switch instead of if in qemuProcessPrepareDomainNetwork()
Laine Stump [Tue, 11 Feb 2025 21:30:11 +0000 (16:30 -0500)] 
qemu: use switch instead of if in qemuProcessPrepareDomainNetwork()

qemuProcessPrepareDomain()'s comments say that it should be the only
place to change the "live XML" of a domain (i.e. the public parts of
the virDomainDef object that is shown in the domain's status
XML), and that seems like a reasonable idea (although there aren't
many users of it to date).

qemuProcessPrepareDomainNetwork() is called by the aforementioned
qemuProcessPrepareDomain() - this patch changes the "if (type ==
HOSTDEV)" in that function to a "switch(type)" so it's simpler to add
DomainDef modifications for various other types of virDomainNetDef,
and also so that anyone who adds a new interface type is forced to
look at the code and decide if anything needs to be done here for the
new type.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoconf/qemu: make <source> element *almost* optional for type=vhostuser
Laine Stump [Mon, 10 Feb 2025 03:52:54 +0000 (22:52 -0500)] 
conf/qemu: make <source> element *almost* optional for type=vhostuser

For some reason, when vhostuser interface support was added in 2014,
the parser required that the XML for the <interface> have a <source>
element with type, mode, and path, all 3 also required. This in spite
of the fact that 'unix' is the only possible valid setting for type,
and 95% of the time the mode is set to 'client' (as I understand from
comments in the code, normally a guest will use mode='client' to
connect to an existing socket that is precreated (by OVS?), and the
only use for mode='server' is for test setups where one guest is setup
with a listening vhostuser socket (i.e. 'server') and another guest
connects to that socket (i.e. 'client')). (or maybe one guest connects
to OVS in server mode, and all the others connect in client mode, not
sure - I don't claim to be an expert on vhost-user.)

So from the point of view of existing vhost-user functionality, it
seems reasonable to make 'type' and 'mode' optional, and by default
fill in the vhostuser part of the NetDef as if they were 'unix' and
'client'.

In theory, the <source> element itself is also not *directly* required
after this patch, however, the path attribute of <source> *is*
required (for now), so effectively the <source> element is still
required.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: do all vhostuser attribute validation in qemu driver
Laine Stump [Mon, 10 Feb 2025 00:01:32 +0000 (19:01 -0500)] 
qemu: do all vhostuser attribute validation in qemu driver

Since vhostuser is only used/supported by the QEMU driver, and all the
rest of the vhostuser-specific validation is done in QEMU's
validation, lets move the final check (to see if they've tried to
enable auto-reconnect when this interface is on the server side of the
vhostuser socket) to the QEMU validate.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: automatically set model type='virtio' for interface type='vhostuser'
Laine Stump [Sun, 9 Feb 2025 23:23:03 +0000 (18:23 -0500)] 
qemu: automatically set model type='virtio' for interface type='vhostuser'

Both vdpa and vhostuser require that the guest device be virtio, and
for interface type='vdpa', we already set <model type='virtio'/> if it
is unspecified in the input XML, so let's be just as courteous for
interface type='vhostuser'.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: validate that model is virtio for vhostuser and vdpa interfaces in the same...
Laine Stump [Sun, 9 Feb 2025 23:46:00 +0000 (18:46 -0500)] 
qemu: validate that model is virtio for vhostuser and vdpa interfaces in the same place

Both vhostuser and vdpa interface types must use the virtio model in
the guest (because part of the functionality is implemented in the
guest virtio driver). Due to ["because that's the way it happened"]
this has been validated for vhostuser in the hypervisor-agnostic
validate function, but for vdpa it has been done in the QEMU-specific
validate. Since these interface models are only supported by QEMU
anyway, validate for both of them in the QEMU validation function.

Take advantage of this change to switch to using
virDomainNetIsVirtioModel(net) instead of "net->model ==
VIR_DOMAIN_NET_MODEL_VIRTIO" (the former also matches
...VIRTIO_TRANSITIONAL and ...VIRTIO_NON_TRANSITIONAL, so is more
correct).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: fix qemu validation to forbid guest-side IP address for type='vdpa'
Laine Stump [Tue, 4 Feb 2025 21:06:18 +0000 (16:06 -0500)] 
qemu: fix qemu validation to forbid guest-side IP address for type='vdpa'

Because all the checks for VIR_DOMAIN_NET_TYPE_VDPA were inside an
else-if clause that was immediately followed by another else-if clause
that forbid setting guestIP.ips or guestIP.routes, we've been allowing
users to set guestIP.* for vdpa interfaces (but then not doing
validation of the attributes that should have been done if we *did*
support setting IPs for vdpa (but we don't anyway, so :shrug:.)

This can be fixed by turning the vdpa else-if clause into a top-level
if - this way vdpa interfaces will hit the "else if
(net->guestIP.nips)" clause and reject guest-side IP address setting.

Also, since there are currently *no* interface types for QEMU that
support adding guest-side routes, we put that check by itself (I think
it may be possible to set some guest routes for passt interfaces, but
we don't do that)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoconf: change virDomainHostdevInsert() to return void
Laine Stump [Tue, 11 Feb 2025 21:44:49 +0000 (16:44 -0500)] 
conf: change virDomainHostdevInsert() to return void

We haven't checked for memalloc failure in many years, and that was
the only reason this function would have ever failed.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoNEWS: Document ccwgroup based qeth device support
Boris Fiuczynski [Thu, 13 Feb 2025 14:09:30 +0000 (15:09 +0100)] 
NEWS: Document ccwgroup based qeth device support

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoremote_daemon: Silence DBus errors
Michal Privoznik [Wed, 12 Feb 2025 11:25:42 +0000 (12:25 +0100)] 
remote_daemon: Silence DBus errors

When a daemon (like libvirtd, virtqemud, etc.) is started as an
unprivileged user (which is exactly how KubeVirt does it), then
it tries to register on both session and system DBus-es so that
it can shut itself down (e.g. when system is powering off or user
logs out). It's worth noting that this is just opportunistic and
if no DBus is available then no error is reported.

Or at least that's what we thought. Because the way our
virGDBusGetSessionBus() and virGDBusGetSystemBus() are written an
error is actually reported every time the daemon starts.

Use virGDBusHasSessionBus() and virGDBusHasSystemBus() to check
if corresponding bus is available.

Resolves: https://issues.redhat.com/browse/RHEL-79088
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
10 months agovirgdbus: Introduce virGDBusHasSessionBus()
Michal Privoznik [Wed, 12 Feb 2025 13:17:34 +0000 (14:17 +0100)] 
virgdbus: Introduce virGDBusHasSessionBus()

This is just like virGDBusHasSystemBus() except it checks for the
session bus instead of the system one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
10 months agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Thu, 13 Feb 2025 08:08:45 +0000 (09:08 +0100)] 
Translated using Weblate (English (United Kingdom))

Currently translated at 48.7% (5257 of 10781 strings)

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

Signed-off-by: Andi Chandler <andi@gowling.com>
10 months agoqemu: add 'auto_start_delay' configuration parameter
Daniel P. Berrangé [Mon, 16 Dec 2024 19:49:33 +0000 (19:49 +0000)] 
qemu: add 'auto_start_delay' configuration parameter

This allows a user specified delay between autostart of each VM, giving
parity with the equivalent feature of libvirt-guests.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agohypervisor: add support for delay interval during autostart
Daniel P. Berrangé [Mon, 16 Dec 2024 19:45:23 +0000 (19:45 +0000)] 
hypervisor: add support for delay interval during autostart

This delay can reduce the CPU/IO load storm when autostarting many
guests.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agosrc: convert drivers over to use new autostart helper
Daniel P. Berrangé [Mon, 16 Dec 2024 19:26:13 +0000 (19:26 +0000)] 
src: convert drivers over to use new autostart helper

This eliminates some duplicated code patterns aross drivers.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agohypervisor: introduce helper for autostart
Daniel P. Berrangé [Mon, 16 Dec 2024 18:53:28 +0000 (18:53 +0000)] 
hypervisor: introduce helper for autostart

There's a common pattern for autostart of iterating over VMs, acquiring
a lock and ref count, then checking the autostart & is-active flags.
Wrap this all up into a helper method.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoremote: notify systemd when reloading config
Daniel P. Berrangé [Tue, 7 Jan 2025 15:29:20 +0000 (15:29 +0000)] 
remote: notify systemd when reloading config

Switch to the 'notify-reload' service type and send notifications to
systemd when reloading configuration.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoutil: add APIs for more systemd notifications
Daniel P. Berrangé [Mon, 6 Jan 2025 18:58:05 +0000 (18:58 +0000)] 
util: add APIs for more systemd notifications

We have a way to notify systemd when we're done starting the daemon.

Systemd supports many more notifications, however, and many of them
are quite relevant to our needs:

  https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html

This renames the existing notification API to better reflect its
semantics, and adds new APIs for reporting

 * Initiation of config file reload
 * Initiation of daemon shutdown process
 * Adhoc progress status messages
 * Request to extend service shutdown timeout

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agobhyve: stop opening & passing connection to bhyveProcessStart
Daniel P. Berrangé [Mon, 3 Feb 2025 15:11:32 +0000 (15:11 +0000)] 
bhyve: stop opening & passing connection to bhyveProcessStart

A connection object is not required because autostarted domains are
never marked for autodestroy.

The comment about needing a connection for the network driver is
obsolete since we can auto-open a connection on demand.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agobhyve: add 'driver' to bhyveProcessStart method
Daniel P. Berrangé [Mon, 3 Feb 2025 15:09:29 +0000 (15:09 +0000)] 
bhyve: add 'driver' to bhyveProcessStart method

This allows for passinga  NULL connection object in cases where
domain autodestroy is not required.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu: migration: Reactivate block nodes after migration if VM is left paused
Peter Krempa [Mon, 10 Feb 2025 18:49:10 +0000 (19:49 +0100)] 
qemu: migration: Reactivate block nodes after migration if VM is left paused

On incoming migration qemu doesn't activate the block graph nodes right
away. This is to properly facilitate locking of the images.

The block nodes are normally re-activated when starting the CPUs after
migration, but in cases (e.g. when a paused VM was migrated) when the VM
is left paused the block nodes are not re-activated by qemu.

This means that blockjobs which would want to write to an existing
backing chain member would fail. Generally read-only jobs would succeed
with older qemu's but this was not intended.

Instead with new qemu you'll always get an error if attempting to access
a inactive node:

 error: internal error: unable to execute QEMU command 'blockdev-mirror': Inactive 'libvirt-1-storage' can't be a backing child of active '#block052'

This is the case for explicit blockjobs (virsh blockcopy) but also for
non shared-storage migration (virsh migrate --copy-storage-all).

Since qemu now provides 'blockdev-set-active' QMP command which can
on-demand re-activate the nodes we can re-activate them in similar cases
as when we'd be starting vCPUs if the VM weren't left paused.

The only exception is on the source in case of a failed post-copy
migration as the VM already ran on destination so it won't ever run on
the source even when recovered.

Resolves: https://issues.redhat.com/browse/RHEL-78398
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemu: monitor: Add monitor backend for 'blockdev-set-active'
Peter Krempa [Mon, 10 Feb 2025 16:51:31 +0000 (17:51 +0100)] 
qemu: monitor: Add monitor backend for 'blockdev-set-active'

The command will be used to re-activate block nodes after migration when
we're leaving the VM paused so that blockjobs can be used.

As the 'node-name' field is optional the 'qemumonitorjsontest' case
tests both variants.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemu: capabilies: Introduce QEMU_CAPS_BLOCKDEV_SET_ACTIVE
Peter Krempa [Mon, 10 Feb 2025 16:57:01 +0000 (17:57 +0100)] 
qemu: capabilies: Introduce QEMU_CAPS_BLOCKDEV_SET_ACTIVE

The flag signals presence of the 'blockdev-set-active' QMP command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemucapabilitiestest: Update 'caps_10.0.0_x86_64' to 'v9.2.0-1636-gffaf7f0376'
Peter Krempa [Fri, 7 Feb 2025 16:48:36 +0000 (17:48 +0100)] 
qemucapabilitiestest: Update 'caps_10.0.0_x86_64' to 'v9.2.0-1636-gffaf7f0376'

Notable changes:
    - 'blockdev-set-active' QMP command and the corresponding 'active'
      flag for instantiating blockdev backends added

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemu-replies-tool: Dump also query string for optional members
Peter Krempa [Mon, 10 Feb 2025 17:29:14 +0000 (18:29 +0100)] 
qemu-replies-tool: Dump also query string for optional members

The query language allows querying whether a member is optional by using
the '*' "operator" but the dumper script didn't output those query
strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemu: snapshot: Limit scope of checkpoint-snapshot interlock
Peter Krempa [Mon, 3 Feb 2025 14:45:49 +0000 (15:45 +0100)] 
qemu: snapshot: Limit scope of checkpoint-snapshot interlock

'qemuDomainSupportsCheckpointsBlockjobs()' should really be used only
with active VMs based on the scope of interlocking it does.

This means that the inactive snapshot code path needs to do the
interlocking based on what's supported:
 - external snapshot support was not implemented yet
    (bitmaps need to be propagated to the new overlay image)
 - internal snapshot support can be deferred to qemu

Move the check inside qemuSnapshotPrepare() which has knowledge about
the snapshot type and implement an explicit check for the inactive case.

See: https://gitlab.com/libvirt/libvirt/-/issues/739
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoqemu: fix qemuDomainSaveImageDefineXML
Pavel Hrdina [Wed, 12 Feb 2025 10:12:03 +0000 (11:12 +0100)] 
qemu: fix qemuDomainSaveImageDefineXML

The commit in question made an incorrect change that resulted in getting
O_RDONLY FD instead of O_RDWR preventing any writes to happen with the
following error:

virQEMUSaveDataWrite:176 : failed to write header to domain save file '/path/to/save.img': Bad file descriptor

Pass 'bypass_cache' as proper bool as the original code did.

Fixes: 517248e2394476a3105ff5866b0b718fc6583073
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoci: refresh with 'lcitool manifest'
Daniel P. Berrangé [Tue, 11 Feb 2025 17:15:45 +0000 (17:15 +0000)] 
ci: refresh with 'lcitool manifest'

This replaces Fedora 39 with Fedora 41, updates the FreeBSD
Cirrus CI image names, and tweaks some package names

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agonode_device: Do not lock the driver state needlessly
Martin Kletzander [Fri, 7 Feb 2025 14:43:52 +0000 (15:43 +0100)] 
node_device: Do not lock the driver state needlessly

When processing the PCI devices we can only read the configs for each of
them if running as privileged.  That information is saved in the driver
state as a boolean introduced in commit 643c74abff01.  However since
that version it is only written to once during nodeStateInitialize() and
only read from that point (apart from some commits around v3.9.0 release
when it was not even set, but that was fixed before v3.10.0).  And it is
only read once, just to store that boolean in a temporary variable which
is also used in only one condition.

Rewrite this without locking and save few lines of code.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Tue, 11 Feb 2025 12:00:55 +0000 (13:00 +0100)] 
Translated using Weblate (English (United Kingdom))

Currently translated at 48.6% (5241 of 10781 strings)

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

Signed-off-by: Andi Chandler <andi@gowling.com>
10 months agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Tue, 11 Feb 2025 12:00:54 +0000 (13:00 +0100)] 
Translated using Weblate (Romanian)

Currently translated at 20.1% (2175 of 10781 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
10 months agoTranslated using Weblate (Spanish)
Nicolás Gal [Tue, 11 Feb 2025 12:00:54 +0000 (13:00 +0100)] 
Translated using Weblate (Spanish)

Currently translated at 52.8% (5700 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 52.6% (5679 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 52.6% (5676 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 52.6% (5674 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 52.6% (5671 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 52.2% (5634 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
10 months agonode_device_udev: add error reporting to udevProcessCCWGroup
Boris Fiuczynski [Thu, 6 Feb 2025 16:27:52 +0000 (17:27 +0100)] 
node_device_udev: add error reporting to udevProcessCCWGroup

Add reporting an internal error when the string to type conversion of
devtype fails as this indicates a serious problem since devtype was used
to get into this method during the udev event handling.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: domain: Initialize FD passthrough for a virStorageSource before using it
Peter Krempa [Thu, 6 Feb 2025 15:20:45 +0000 (16:20 +0100)] 
qemu: domain: Initialize FD passthrough for a virStorageSource before using it

The call to 'qemuBlockStorageSourceNeedsFormatLayer()' bases the
decision also on the state of the passed FD, so we must initialize the
passthrough data via 'qemuDomainPrepareStorageSourceFDs()' before the
aforementioned call.

In the test change it's visible that we didn't add the necessary 'raw'
driver which allows the 'protocol' blockdev to be opened in 'rw' mode so
that qemu picks the proper file descriptior while keeping the device
read-only.

Resolves: https://issues.redhat.com/browse/RHEL-37519
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemuxmlconftest: Add testing of FDs with 'writable' flag in 'disk-source-fd'
Peter Krempa [Thu, 6 Feb 2025 14:55:37 +0000 (15:55 +0100)] 
qemuxmlconftest: Add testing of FDs with 'writable' flag in 'disk-source-fd'

Add few examples of fd groups with the 'writable' flag set, when passing
a single FD. Notably as a top level image of a readonly disk (even when
that doesn't make much sense) and also as a base image of a chain.

Note that this documents a status quo of a bug fixed in upcoming patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemuxmlconftest: Allow testing of the 'writable' flag for passed FDs for disks
Peter Krempa [Thu, 6 Feb 2025 14:50:35 +0000 (15:50 +0100)] 
qemuxmlconftest: Allow testing of the 'writable' flag for passed FDs for disks

Pass also the 'writable' state to the fake passed FDs so that we can
test it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoTranslated using Weblate (Spanish)
Nicolás Gal [Thu, 6 Feb 2025 12:58:21 +0000 (13:58 +0100)] 
Translated using Weblate (Spanish)

Currently translated at 51.9% (5600 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 51.5% (5557 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 51.2% (5522 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 51.2% (5522 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 51.0% (5507 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 50.7% (5472 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 50.6% (5458 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 50.4% (5437 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
10 months agodocs: Reword virDomainGetEmulatorPinInfo description
Martin Kletzander [Mon, 13 Jan 2025 14:27:10 +0000 (15:27 +0100)] 
docs: Reword virDomainGetEmulatorPinInfo description

This API only queries the XML settings and not the running threads
themselves.  In order to avoid confusion, change the wording slightly.

Resolves: https://issues.redhat.com/browse/RHEL-72052
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agotests: qemuxmlconfdata: Update launch-security-sev-snp.xml
Michal Privoznik [Mon, 27 Jan 2025 09:46:17 +0000 (10:46 +0100)] 
tests: qemuxmlconfdata: Update launch-security-sev-snp.xml

Recently, I was part of a discussion where it was suspected that
libvirt does not pick up correct FW for SEV-SNP guests. Update
our test to demonstrate it does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
10 months agonodedev: udev: Hook up virFileWaitForExist to address uevent race of pci device
Guoyi Tu [Thu, 19 Dec 2024 15:07:35 +0000 (23:07 +0800)] 
nodedev: udev: Hook up virFileWaitForExist to address uevent race of pci device

Similarly to commit 1af45804 we should be safer by waiting for the whole
sysfs tree is created for the device.

Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
10 months agoqemu: Attach persistent reservations manager if block-copy target requires it
Peter Krempa [Tue, 4 Feb 2025 17:06:00 +0000 (18:06 +0100)] 
qemu: Attach persistent reservations manager if block-copy target requires it

Users can choose to copy a disk into a destination where they want to
use persistent reservations. Start the daemon if the configuration
requires it.

Resolves: https://issues.redhat.com/browse/RHEL-7342
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: blockjob: Remove persistent reservations manager when dropping disk images
Peter Krempa [Tue, 4 Feb 2025 16:59:06 +0000 (17:59 +0100)] 
qemu: blockjob: Remove persistent reservations manager when dropping disk images

Check if the persistent reservations manager daemon is still needed
after a disk (sub)-chain was dropped after a blockjob.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: hotplug: Export persistent reservations manager helper functions
Peter Krempa [Tue, 4 Feb 2025 16:51:57 +0000 (17:51 +0100)] 
qemu: hotplug: Export persistent reservations manager helper functions

Export qemuHotplugAttachManagedPR/qemuHotplugRemoveManagedPR for reuse
in blockjob code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agovirDomainDefHasManagedPR: Consider also disk's 'mirror' chain
Peter Krempa [Tue, 4 Feb 2025 16:55:14 +0000 (17:55 +0100)] 
virDomainDefHasManagedPR: Consider also disk's 'mirror' chain

Consider also the destination of a block-copy job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu_hotplug.h: Reformat according to new coding style
Peter Krempa [Tue, 4 Feb 2025 16:45:37 +0000 (17:45 +0100)] 
qemu_hotplug.h: Reformat according to new coding style

Fix the mixed style by unifying the formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemucapabilitiestest: Add data for the qemu-10.0 dev cycle on x86_64
Peter Krempa [Tue, 4 Feb 2025 16:12:00 +0000 (17:12 +0100)] 
qemucapabilitiestest: Add data for the qemu-10.0 dev cycle on x86_64

Add data based on 'v9.2.0-1537-gd922088eb4'

Notable changes:
    - '10.0' machine types added
    - 'hub' chardev backend added
    - 'cpr' migrate channel added
    - 'nsamples' field for 'dbus' audio backend now reported
    - 'ClearwaterForest-v1' cpu model added
    - 'SierraForest-v2' cpu model added
    - 'ivshmem-flat' device added
    - new qom objects:
        - 'virtio-mem-system-reset'
        - 'vmclock'
    - default value of 'rombar' changed from 1 to -1 for all devices
    - 'intel-iommu' device:
        - default value of 'aw-bit' changed from '39' to '48'
        - 'fs1gp' boolean added
        - 'x-flts' boolean added
    - 'virtio-balloon-pci'/'virtio-mem-pci':
        - 'ioeventfd' added
        - 'vectors' added

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemucapabilitiestest: Final update for qemu-9.2 release on x86_64
Peter Krempa [Thu, 28 Nov 2024 08:52:32 +0000 (09:52 +0100)] 
qemucapabilitiestest: Final update for qemu-9.2 release on x86_64

Update the data after the release.

Notable changes:
 - the 6.2 machine types became deprecated

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: snapshot: Ensure that NVRAM image exists when taking inactive internal snapshot
Peter Krempa [Mon, 3 Feb 2025 16:52:50 +0000 (17:52 +0100)] 
qemu: snapshot: Ensure that NVRAM image exists when taking inactive internal snapshot

Attempting to take an internal snapshot of a freshly defined VM with
qcow2 backed NVRAM results in failure as the NVRAM image doesn't get
populated until the VM is started for the first time.

Fix this by invoking qemuPrepareNVRAM() when qcow2 nvram is defined.

Resolves: https://issues.redhat.com/browse/RHEL-73315
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
10 months agoqemu: process: Export qemuPrepareNVRAM for use in snapshot code
Peter Krempa [Mon, 3 Feb 2025 16:48:05 +0000 (17:48 +0100)] 
qemu: process: Export qemuPrepareNVRAM for use in snapshot code

Export qemuPrepareNVRAM so that it doesn't require the VM object. The
snapshot code needs in the corner case of creating a snapshot of a
freshly defined VM ensure that the nvram image exists in order to
snapshot it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
10 months agoqemuSnapshotForEachQcow2: Don't initialize 'nrollback'
Peter Krempa [Mon, 3 Feb 2025 17:23:29 +0000 (18:23 +0100)] 
qemuSnapshotForEachQcow2: Don't initialize 'nrollback'

The variable holds the amount of disks to roll back the snapshot for.
The value must be set before the code jumps to the 'rollback:' label so
the best situation is to not initialize it and let the compiler catch
errors rather than initialize the unsigned variable to -1 and let it
crash.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
10 months agonode_device_udev: Fix build failure in ccw device code
Peter Krempa [Wed, 5 Feb 2025 18:27:36 +0000 (19:27 +0100)] 
node_device_udev: Fix build failure in ccw device code

clang complains:

../../../libvirt/src/node_device/node_device_udev.c:1408:82: error: result of comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-unsigned-enum-zero-compare]
 1408 |     if ((data->ccwgroup_dev.type = virNodeDevCCWGroupCapTypeFromString(devtype)) < 0)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
1 error generated.

Fix it by adding a temporary int variable to facilitate the check before
assigning to the unsigned enum value.

Fixes: 985cb9c32a6
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 months agonodedev: add qeth layer2 and layer3 device types
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:43 +0000 (18:11 +0100)] 
nodedev: add qeth layer2 and layer3 device types

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: add ccwgroup capability support to ccw devices
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:42 +0000 (18:11 +0100)] 
nodedev: add ccwgroup capability support to ccw devices

Add the group membership information to a CCW device. Allow to filter
CCW devices based on a group membership.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: add ccwgroup node device support
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:41 +0000 (18:11 +0100)] 
nodedev: add ccwgroup node device support

Add ccwgroup node device type supporting qeth generic driver.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: refactor udevCCWGetState
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:40 +0000 (18:11 +0100)] 
nodedev: refactor udevCCWGetState

Refactor method to be only ccw state type depended to allow reuse in a
later patch.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: refactor CCW state format for use in ccwgroup
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:39 +0000 (18:11 +0100)] 
nodedev: refactor CCW state format for use in ccwgroup

Refactor to allow reuse in ccwgroup.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: remove virNodeDeviceCapCCWDefFormat
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:38 +0000 (18:11 +0100)] 
nodedev: remove virNodeDeviceCapCCWDefFormat

Directly use virCCWDeviceAddressFormat.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: refactor CCW device address
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:37 +0000 (18:11 +0100)] 
nodedev: refactor CCW device address

Replace cssid, ssid and devno elements with virCCWDeviceAddress.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: refactor CCW device address format
Boris Fiuczynski [Tue, 4 Feb 2025 17:11:36 +0000 (18:11 +0100)] 
nodedev: refactor CCW device address format

Refactor for reuse in the following patch.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agodocs: fix 'virsh domstats --vcpu' measure units and descriptions
Fabricio Duarte [Mon, 16 Dec 2024 22:02:44 +0000 (19:02 -0300)] 
docs: fix 'virsh domstats --vcpu' measure units and descriptions

The fields are in nanoseconds, not microseconds. Also fixes the
description of `vcpu.<num>.wait`, as it does not actually represent the
time waiting on I/O.

Signed-off-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
10 months agoTranslated using Weblate (Chinese (Traditional) (zh_TW))
Daniel P. Berrangé [Mon, 3 Feb 2025 14:39:59 +0000 (15:39 +0100)] 
Translated using Weblate (Chinese (Traditional) (zh_TW))

Currently translated at 2.4% (265 of 10781 strings)

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

Signed-off-by: "Daniel P. Berrange" <berrange@redhat.com>
Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 93.3% (10067 of 10781 strings)

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

Signed-off-by: "Daniel P. Berrange" <berrange@redhat.com>
10 months agoTranslated using Weblate (Spanish)
Nicolás Gal [Mon, 3 Feb 2025 14:39:58 +0000 (15:39 +0100)] 
Translated using Weblate (Spanish)

Currently translated at 51.0% (5507 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 50.7% (5472 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 50.6% (5458 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
Translated using Weblate (Spanish)

Currently translated at 50.4% (5437 of 10781 strings)

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

Signed-off-by: Nicolás Gal <nialegal@yandex.com>
10 months agoNEWS: Mention preserving I/O error messages for qemu VMs
Peter Krempa [Tue, 28 Jan 2025 16:22:19 +0000 (17:22 +0100)] 
NEWS: Mention preserving I/O error messages for qemu VMs

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoinclude: libvirt-domain: Add 'message' @reason of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
Peter Krempa [Fri, 24 Jan 2025 15:26:54 +0000 (16:26 +0100)] 
include: libvirt-domain: Add 'message' @reason of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON

In case when the hypervisor does report the reason for the I/O error as
an unstable string to display to users we can add a @reason possibility
for the I/O error event noting that the error is available.

Add 'message' as a reason enumeration value and document it
to instruct users to look at the logs or virDomainGetMessages().

The resulting event looks like:

 event 'io-error' for domain 'cd': /dev/mapper/errdev0 (virtio-disk0) report due to message

Users then can look at the virDomainGetMessages() API:

 I/O error: disk='vda', index='1', path='/dev/mapper/errdev0', timestamp='2025-01-28 15:47:52.776+0000', message='Input/output error'

Or in the VM log file:

 2025-01-28 15:47:52.776+0000: IO error device='virtio-disk0' node-name='libvirt-1-storage' reason='Input/output error'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoinclude: libvirt-domain: Reword documentation for @reason of VIR_DOMAIN_EVENT_ID_IO_E...
Peter Krempa [Mon, 27 Jan 2025 14:50:34 +0000 (15:50 +0100)] 
include: libvirt-domain: Reword documentation for @reason of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON

Emphasise that it's an enumeration and convert the possibilities to a
list of values with explanation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agovirDomainGetMessages: Introduce VIR_DOMAIN_MESSAGE_IOERRORS
Peter Krempa [Mon, 27 Jan 2025 18:13:43 +0000 (19:13 +0100)] 
virDomainGetMessages: Introduce VIR_DOMAIN_MESSAGE_IOERRORS

Report any stored I/O error messages reported by the hypervisor when
reporting messages of a domain. As the I/O error may be already stale we
report also the timestamp when it was recorded.

Example message:

 I/O error: disk='vda', index='1', path='/dev/mapper/errdev0', timestamp='2025-01-28 15:47:52.776+0000', message='Input/output error'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agovirDomainObjGetMessages: Refactor using GPtrArray
Peter Krempa [Mon, 27 Jan 2025 16:38:51 +0000 (17:38 +0100)] 
virDomainObjGetMessages: Refactor using GPtrArray

Simplify the function especially by rewriting it using GPtrArray to
construct the string list, especially for the upcoming case when the
number of added elements will not be known beforehand and when
hypervisor specific data will be added.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agolibxlDomainGetMessages: Add existing flags to 'virCheckFlags'
Peter Krempa [Tue, 28 Jan 2025 13:06:16 +0000 (14:06 +0100)] 
libxlDomainGetMessages: Add existing flags to 'virCheckFlags'

The two VIR_DOMAIN_MESSAGE_* flags were not listed in the virCheckFlags
check in 'libxl' but were present in 'test' and 'qemu' driver impls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemuProcessHandleIOError: Log IO errors in the VM log file
Peter Krempa [Fri, 24 Jan 2025 16:01:34 +0000 (17:01 +0100)] 
qemuProcessHandleIOError: Log IO errors in the VM log file

Add a log entry to the VM log file for every time we receive an IO error
event from qemu. The log entry is as follows:

 2025-01-24 16:03:28.928+0000: IO error device='virtio-disk0' node-name='libvirt-1-storage' reason='other: Input/output error'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemuProcessHandleIOError: Populate I/O error reason to virStorageSource
Peter Krempa [Mon, 27 Jan 2025 18:17:16 +0000 (19:17 +0100)] 
qemuProcessHandleIOError: Populate I/O error reason to virStorageSource

Record the last I/O error reason and timestamp which happened with the
corresponding virStorageSource struct.

This will later allow querying the last error e.g. via the
virDomainGetMessages() API.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agovirStorageSource: Add fields for storing last I/O error message
Peter Krempa [Mon, 27 Jan 2025 15:20:43 +0000 (16:20 +0100)] 
virStorageSource: Add fields for storing last I/O error message

Hypervisors may report a I/O error message (unstable; for human use)
to libvirt. In order to store it with the appropriate virStorageSource
so that it can be later queried we need to add fields to
virStorageSource to store the timestamp and message.

The message is deliberately not copied via virStorageSourceCopy.

The messages are also not serialized to the status XML as losing them on
a daemon restart as they're likely to be stale anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemuMonitorJSONHandleIOError: Propagate new 'qom-path' field
Peter Krempa [Tue, 28 Jan 2025 09:39:52 +0000 (10:39 +0100)] 
qemuMonitorJSONHandleIOError: Propagate new 'qom-path' field

QEMU commit v9.1.0-1065-ge67b7aef7c added 'qom-path' as an optional
field for the BLOCK_IO_ERROR event. Extract and propagate it as an
alternative to lookup via 'node-name' and 'device' (alias).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemuProcessHandleIOError: Prefer lookup by node name
Peter Krempa [Fri, 24 Jan 2025 16:17:51 +0000 (17:17 +0100)] 
qemuProcessHandleIOError: Prefer lookup by node name

When qemu reports a node name for an I/O error we should prefer the
lookup by node name instead as it gives us the path to the specific
image which caused the error instead of the top level image path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemuMonitorJSONHandleIOError: Do not munge 'reason' field of IO error event
Peter Krempa [Mon, 27 Jan 2025 12:53:36 +0000 (13:53 +0100)] 
qemuMonitorJSONHandleIOError: Do not munge 'reason' field of IO error event

Leave the interpretation of the event to 'qemuProcessHandleIOError()'
which will create it's own variant of the messages for the user-facing
libvirt events. qemuMonitorJSONHandleIOError() will pass through the raw
data it got from qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>