]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
21 months agoconf: fix error message
Анастасия Белова [Mon, 7 Aug 2023 13:37:34 +0000 (16:37 +0300)]
conf: fix error message

In case of invalid placement its value should
be passed as a parameter of virReportError
instead of mode.

Fixes: 93e82727ec ("numatune: Encapsulate numatune configuration in order to unify results")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agolxc_container: Increase stack size for lxcContainerChild()
Michal Privoznik [Fri, 4 Aug 2023 12:56:37 +0000 (14:56 +0200)]
lxc_container: Increase stack size for lxcContainerChild()

When spawning a new container (via clone()) we allocate stack for
lxcContainerChild(). So far, we allocate 4 pages for the stack
and this used to be enough until we started rewriting everything
to glib. With glib we switched to g_strerror() which localizes
errno strings and thus increases stack usage, while the
previously used strerror_r() was more compact.

Fortunately, the solution is easy - just increase how much stack
the child can use (16 pages ought to be enough for anybody).

And while at it, lets use mmap() for allocation which offer some
nice features:

MAP_STACK - align allocation to be suitable for stack (even
            though, currently ignored on Linux),
MAP_GROWSDOWN - kernel guards out of bounds access from child

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/511
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agosrc: fix max file limits in systemd services
Daniel P. Berrangé [Wed, 2 Aug 2023 09:00:22 +0000 (10:00 +0100)]
src: fix max file limits in systemd services

This fixes

  commit 38abf9c34dc481b0dc923bdab446ee623bdc5ab6
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Jun 21 13:22:40 2023 +0100

    src: set max open file limit to match systemd >= 240 defaults

The bug referenced in that commit had suggested to set

  LimitNOFile=512000:1024

on the basis that matches current systemd default behaviour and is
compatible with old systemd. That was good except

 * The setting is LimitNOFILE and these are case sensitive
 * The hard and soft limits were inverted - soft must come
   first and so it would have been ignored even if the
   setting name was correct.
 * The default hard limit is 524288 not 512000

Reported-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agodaemon: Treat logging of VIR_ERR_MULTIPLE_INTERFACES same as VIR_ERR_NO_INTERFACE
Peter Krempa [Wed, 2 Aug 2023 08:05:57 +0000 (10:05 +0200)]
daemon: Treat logging of VIR_ERR_MULTIPLE_INTERFACES same as VIR_ERR_NO_INTERFACE

When a query for an interface via virInterfaceLookupByMACString finds
multiple interfaces an error is returned. Treat such error with the same
'debug' priority as we treat when the interface was not found to avoid
spamming logs with such configurations.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/514
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agovirLXCProcessReportStartupLogError: Strip trailing newline from error
Peter Krempa [Wed, 2 Aug 2023 07:25:22 +0000 (09:25 +0200)]
virLXCProcessReportStartupLogError: Strip trailing newline from error

Since the error message originates from a log file it contains a
trailing newline. Strip it as all error handling adds it's own newline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agovirLXCProcessReadLogOutputData: Refill buffer after filtering out noise
Peter Krempa [Wed, 2 Aug 2023 07:20:24 +0000 (09:20 +0200)]
virLXCProcessReadLogOutputData: Refill buffer after filtering out noise

The caller passes in a 1k buffer, which when debug logging is in use is
easily filled with debug messages only. Thus after the first pass which
is common if the controller process already terminated the buffer will
not contain the real error, but rather a truncated debug message,
which will result in an error such as:

  error: internal error: guest failed to start: 2023-08-01 12:58:31.948+0000: 798195: i

instead of the proper error:

 error: internal error: guest failed to start: Failure in libvirt_lxc startup: Failed to create /home/rootfs/.oldroot: Permission denied

To fix the above retry the reading loop if the filtering function made
space in the buffer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agovirLXCControllerSetupUsernsMap: Modify debug logging for clean startup errors
Peter Krempa [Tue, 1 Aug 2023 13:32:16 +0000 (15:32 +0200)]
virLXCControllerSetupUsernsMap: Modify debug logging for clean startup errors

Avoid logging multiline debug logs so that the function which attempts
to extract a non-debug log error message can work properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agolib: Prefer sizeof(variable) instead of sizeof(type) in memset
Michal Privoznik [Thu, 3 Aug 2023 08:25:43 +0000 (10:25 +0200)]
lib: Prefer sizeof(variable) instead of sizeof(type) in memset

If one of previous commits taught us something, it's that:
sizeof(variable) and sizeof(type) are not the same. Especially
because for live enough code the type might change (e.g. as we
use autoptr more). And since we don't get any warnings when an
incorrect length is passed to memset() it is easy to mess up. But
with sizeof(variable) instead, it's not as easy. Therefore,
switch to using memset(variable, 0, sizeof(*variable)), or its
alternatives, depending on level of pointers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agolib: Finish using struct zero initializer manually
Michal Privoznik [Thu, 3 Aug 2023 09:48:30 +0000 (11:48 +0200)]
lib: Finish using struct zero initializer manually

There are some cases left after previous commit which were not
picked up by coccinelle. Mostly, becuase the spatch was not
generic enough. We are left with cases like: two variables
declared on one line, a variable declared in #ifdef-s (there are
notoriously difficult for coccinelle), arrays, macro definitions,
etc.

Finish what coccinelle started, by hand.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agolib: use struct zero initializer instead of memset
Michal Privoznik [Wed, 2 Aug 2023 08:09:52 +0000 (10:09 +0200)]
lib: use struct zero initializer instead of memset

This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.

Generated using the following semantic patch:

  @@
  type T;
  identifier X;
  @@
  -  T X;
  +  T X = { 0 };
     ... when exists
  (
  -  memset(&X, 0, sizeof(X));
  |
  -  memset(&X, 0, sizeof(T));
  )

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirnetdaemon.c: Use struct zero initializer instead of memset
Michal Privoznik [Thu, 3 Aug 2023 07:45:14 +0000 (09:45 +0200)]
virnetdaemon.c: Use struct zero initializer instead of memset

Ideally, these would be fixed by coccinelle (see next commit),
but because of various reasons they aren't. Fix them manually.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirnetclient: Update comment about memset()
Michal Privoznik [Thu, 3 Aug 2023 09:48:57 +0000 (11:48 +0200)]
virnetclient: Update comment about memset()

Instead of suggesting to zero structs out using memset() we
should suggest initializing structs with zero initializer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirnetlink: Drop unused variable from virNetlinkCommand()
Michal Privoznik [Thu, 3 Aug 2023 08:43:13 +0000 (10:43 +0200)]
virnetlink: Drop unused variable from virNetlinkCommand()

The fds variable inside of virNetlinkCommand() is not used
really. It's passed to memset() (hence compilers do not
complain), but that's about it. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirfirewalld: Drop useless memset() in virFirewallDApplyRule()
Michal Privoznik [Thu, 3 Aug 2023 08:30:12 +0000 (10:30 +0200)]
virfirewalld: Drop useless memset() in virFirewallDApplyRule()

This is a residue of v6.8.0-rc1~100. The error variable inside of
virFirewallDApplyRule() is already initialized to NULL. There's
no need to memset() it to zero again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoremote_driver: Drop explicit memset(&sargs) in remoteAuthSASL()
Michal Privoznik [Thu, 3 Aug 2023 07:39:03 +0000 (09:39 +0200)]
remote_driver: Drop explicit memset(&sargs) in remoteAuthSASL()

Inside of remoteAuthSASL() the sargs variable is already
initialized to zero during declaration. There's no need to
memset() it again as it's unused in between it's declaration and
said memset().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoqemu: Don't reuse variable in processSerialChangedEvent()
Michal Privoznik [Thu, 3 Aug 2023 06:52:57 +0000 (08:52 +0200)]
qemu: Don't reuse variable in processSerialChangedEvent()

When a VSERPORT_CHANGE event is processed, we firstly do a little
detour and try to detect whether the event is coming from guest
agent. If so, we notify threads that are currently talking to the
agent about this fact. Then we proceed with usual event
processing (BeginJob(), update domain def, emit event, and so
on).

In both cases we use the same @dev variable to refer to domain
device. While this works, it will make writing semantic patch
unnecessary harder (see next commit(s)). Therefore, introduce a
separate variable for the detour code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoDecrease scope of some variables
Michal Privoznik [Wed, 2 Aug 2023 13:30:04 +0000 (15:30 +0200)]
Decrease scope of some variables

There are couple of variables that are declared at function
beginning but then used solely within a block (either for() loop
or if() statement). And just before their use they are zeroed
explicitly using memset(). Decrease their scope, use struct zero
initializer and drop explicit memset().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirt-aa-helper: Use struct zero initializer instead of memset
Michal Privoznik [Wed, 2 Aug 2023 13:42:31 +0000 (15:42 +0200)]
virt-aa-helper: Use struct zero initializer instead of memset

This is similar to the previous commit, except this is for a
different type (vahControl) and also fixes the case where _ctl is
passed not initialized to vah_error() (via ctl pointer so that's
probably why compilers don't complain).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agotools: Fix vshControl declaration and initialization
Michal Privoznik [Wed, 2 Aug 2023 12:57:44 +0000 (14:57 +0200)]
tools: Fix vshControl declaration and initialization

Both virsh and virt-admin have vshControl typed variables and
also pointers to these variables. In both cases these are
declared on a single line. Do the following:

  1) break declaration into two lines,
  2) use struct zero initializer for vshControl and
     virshControl/vshAdmControl structs,
  3) drop explicit memset(.., 0, ...) ;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoqemu: don't add --mac-addr option to passt commandline
Laine Stump [Thu, 13 Jul 2023 15:51:28 +0000 (11:51 -0400)]
qemu: don't add --mac-addr option to passt commandline

When I implemented passt support in libvirt, I saw the --mac-addr
option on the passt commandline, immediately assumed that this was
used for setting the guest interface's mac address somewhere within
passt, and read no further. As a result, "--mac-addr" is always added
to the passt commandline, specifying the setting from <mac
addr='blah'/> in the guest's interface config.

But as pointed out in this bugzilla comment:

https://bugzilla.redhat.com/2184967#c8

That is *not at all* what passt's --mac-addr option does. Instead, it
is used to force the *remote* mac address for incoming traffic to a
specific value. So setting --mac-addr results in all traffic on the
interface having the same (the guest's) mac address for both source
and destination in all traffic. Surprisingly, this still works, so
nobody noticed it during testing.

The proper thing is to not specify any mac address to passt - the
remote MAC addresses can and should remain untouched, and the local
MAC address will end up being known to passt just by the guest sending
out packets with that MAC address.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
21 months agoRevert "qemu_passt: Precreate passt logfile"
Michal Privoznik [Tue, 1 Aug 2023 14:20:58 +0000 (16:20 +0200)]
Revert "qemu_passt: Precreate passt logfile"

This reverts commit 8511b96a319836700b4829816cdae27c3630060d.

Turns out, we need to do a bit more than just plain
qemuSecurityDomainSetPathLabel() which sets svirt_image_t. Passt
has its own SELinux policy and as a part of that they invent
passt_log_t for log files. Right now, I don't know how libvirt
could query that and even if I did, passt SELinux policy would
need to permit relabelling from svirt_t to passt_log_t, which it
doesn't [1].

Until these problems are addressed we shouldn't be pre-creating
the file as it puts users into way worse position - even
scenarios that used to work don't work. But then again - using
log file for passt is usually valuable for developers only and
not regular users.

1: https://bugzilla.redhat.com/show_bug.cgi?id=2209191#c10
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agoRevert "qemu_passt: Actually use @logfd"
Michal Privoznik [Tue, 1 Aug 2023 14:18:47 +0000 (16:18 +0200)]
Revert "qemu_passt: Actually use @logfd"

This reverts commit 83686f1eea1a001a37a92f2c054ffb2689c43a40.

This is needed only so that the next revert is clean.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agodomain_event: Drop virDomainEventMemoryDeviceSizeChangePtr
Michal Privoznik [Tue, 27 Jun 2023 08:10:26 +0000 (10:10 +0200)]
domain_event: Drop virDomainEventMemoryDeviceSizeChangePtr

We dropped our private virXXXPtr typedefs in v7.3.0-rc1~229 but
somehow v7.9.0-rc1~292 introduced one back:
virDomainEventMemoryDeviceSizeChangePtr. There's no need for it
and it's internal only. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
21 months agolibvirt-guests: Remove unused variable 'libvirtd'
Jim Fehlig [Mon, 31 Jul 2023 16:53:41 +0000 (10:53 -0600)]
libvirt-guests: Remove unused variable 'libvirtd'

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agoPost-release version bump to 9.7.0
Jiri Denemark [Tue, 1 Aug 2023 09:49:29 +0000 (11:49 +0200)]
Post-release version bump to 9.7.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
21 months agoRelease of libvirt-9.6.0
Jiri Denemark [Tue, 1 Aug 2023 09:47:03 +0000 (11:47 +0200)]
Release of libvirt-9.6.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
21 months agoNEWS: Mention CVE-2023-3750 and BeeGFS migration support
Peter Krempa [Mon, 31 Jul 2023 13:54:17 +0000 (15:54 +0200)]
NEWS: Mention CVE-2023-3750 and BeeGFS migration support

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agoTranslated using Weblate (Korean)
김인수 [Sun, 30 Jul 2023 05:21:05 +0000 (07:21 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10393 of 10393 strings)

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

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
21 months agoNEWS: Document my contributions for upcoming release
Michal Privoznik [Fri, 28 Jul 2023 14:32:45 +0000 (16:32 +0200)]
NEWS: Document my contributions for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 27 Jul 2023 16:21:06 +0000 (18:21 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10393 of 10393 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
21 months agoTranslated using Weblate (Czech)
Pavel Borecki [Thu, 27 Jul 2023 16:21:06 +0000 (18:21 +0200)]
Translated using Weblate (Czech)

Currently translated at 100.0% (10393 of 10393 strings)

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

Co-authored-by: Pavel Borecki <pavel.borecki@gmail.com>
Signed-off-by: Pavel Borecki <pavel.borecki@gmail.com>
21 months agorpm: Delete unused macros
Andrea Bolognani [Wed, 5 Jul 2023 16:51:40 +0000 (18:51 +0200)]
rpm: Delete unused macros

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agorpm: Switch to new macros for handling of systemd units
Andrea Bolognani [Wed, 5 Jul 2023 16:48:32 +0000 (18:48 +0200)]
rpm: Switch to new macros for handling of systemd units

In most cases the replacement is straightforward, with the
biggest difference being that we now schedule restarts during
%pre instead of %post. This also means that we can get rid of
%post for most packages, reducing the number of scriptlets that
need to run during install/upgrade.

Notable exceptions are libvirt-guests.service, where we stop
using the standard systemd macros to adopt our custom ones, as
well as the virtlogd and virtlockd services, where the reload
operation is moved from %postun to %posttrans.

https://bugzilla.redhat.com/show_bug.cgi?id=2210058

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agorpm: Introduce new macros for handling of systemd units
Andrea Bolognani [Wed, 5 Jul 2023 16:07:34 +0000 (18:07 +0200)]
rpm: Introduce new macros for handling of systemd units

systemd provides a number of standard RPM macros but they don't
quite satisfy our requirements, as evidenced by the fact that we
have already built some custom tooling around them.

Scenarios that the standard macros don't cover and that we're
already addressing with our custom ones:

  * for some services (libvirtd, virtnetworkd, virtnwfilterd)
    there are multiple conditions that might lead to a restart,
    and we want to make sure that they're not needlessly
    restarted several times per transaction;

  * some services (virtlogd, virtlockd) must not be restarted
    during upgrade, so we have to reload them instead.

Issues that neither the standard macros nor our custom ones
address:

  * presets for units should be applied when the unit is first
    installed, not when the package that contains it is.

The package split that happened in 9.1.0 highlighted why this
last point is so important: when virtproxyd and its sockets
were moved from libvirt-daemon to the new libvirt-daemon-proxy
package, upgrades from 9.0.0 caused presets for them to be
applied.

On a platform such as Fedora, where modular daemons are the
default, this has resulted in breaking existing deployments in
at least two scenarios.

The first one is machines that were configured to use the
monolithic daemon, either because the local admin had manually
changed the configuration or because the installation dated
back to before modular daemons had become the default. In this
case, virtproxyd.socket being enabled resulted in a silent
conflict with libvirtd.socket, which by design shares the same
path, and thus a completely broken setup.

The second one is machines where virtproxy-tls.socket, which is
disabled by default, had manually been enabled: in this case,
applying the presets resulted in it being disabled and thus a
loss of remote availability.

Note that these are just two concrete scenarios, but the problem
is more generic. For example, if we were to add more units to an
existing package, per the current approach they wouldn't have
their presets applied.

The new macros are designed to avoid all of the pitfalls
mentioned above. As a bonus, they're also simpler to use: where
the current approach requires restarts and other operations to
be handled separately, the new one integrates the two so that,
for each scriptlet, a single macro call is needed.

https://bugzilla.redhat.com/show_bug.cgi?id=2210058

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agorpm: Remove custom libvirtd restart logic
Andrea Bolognani [Wed, 5 Jul 2023 15:37:34 +0000 (17:37 +0200)]
rpm: Remove custom libvirtd restart logic

This logic was necessary when socket activation was introduced
in libvirt 5.6.0/5.7.0 in order to guarantee smooth upgrades.

These days, even the oldest platform that we target ships a
version of libvirtd that implements socket activation, so the
additional code is no longer useful and we can treat libvirtd
the same as all other services.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agorpm: Reduce use of with_modular_daemons
Andrea Bolognani [Mon, 3 Jul 2023 16:41:18 +0000 (18:41 +0200)]
rpm: Reduce use of with_modular_daemons

The current implementation pretty much assumes that targets
where modular daemons are the default will stick with that
configuration, as will targets where they're not, or that
changes to these defaults will be performed by the admin after
the packages have been installed.

This is unnecessarily limiting: for example, on a target that
defaults to using the monolithic daemon, it's entirely possible
to create a local preset such as

  # /etc/systemd/system-preset/00-virt.preset
  disable libvirtd.service
  disable libvirtd*.socket
  enable virtqemud.service

to opt into a modular daemon deployment. The opposite is of
course also true. We shouldn't get in the way of these
reasonable use cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agorpm: Reorder scriptlets
Andrea Bolognani [Wed, 5 Jul 2023 16:49:17 +0000 (18:49 +0200)]
rpm: Reorder scriptlets

To make things more readable, use the same order (%pre, %post,
%posttrans, %preun, %postun) everywhere.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agorpm: Style/alignment tweaks
Andrea Bolognani [Mon, 3 Jul 2023 16:35:06 +0000 (18:35 +0200)]
rpm: Style/alignment tweaks

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agorpm: Bump min_fedora
Andrea Bolognani [Mon, 3 Jul 2023 16:25:49 +0000 (18:25 +0200)]
rpm: Bump min_fedora

According to our platform support policy, now that Fedora 38 is
out we no longer target Fedora 36 and older. This allows us to
simplify a few conditionals.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agoUpdate translation files
Weblate [Wed, 26 Jul 2023 12:06:59 +0000 (14:06 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
21 months agopo: Refresh potfile for v9.6.0
Jiri Denemark [Wed, 26 Jul 2023 12:00:00 +0000 (14:00 +0200)]
po: Refresh potfile for v9.6.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
21 months agoremote: handle partial data transmission
Oleg Vasilev [Wed, 26 Jul 2023 07:47:15 +0000 (13:47 +0600)]
remote: handle partial data transmission

A new bug was introduced as a part of use-after-free fix below:

    commit 411cbe7199ce533ae5fa78f5558dddca6f88ef1a
    Author: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
    Date:   Tue Jul 4 13:10:22 2023 +0600

        remote: fix stream use-after-free

When the message was processed partially, it is actually supposed to
stay in the queue to be processed again. In such case, reinsert it back.

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agodocs: formatdomain: Mention the QEMU requirement for discard_no_unref
Han Han [Wed, 26 Jul 2023 03:11:39 +0000 (11:11 +0800)]
docs: formatdomain: Mention the QEMU requirement for discard_no_unref

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agovirrandom: Accept "nodedev" driver in virRandomGenerateWWN()
Michal Privoznik [Mon, 17 Jul 2023 13:05:11 +0000 (15:05 +0200)]
virrandom: Accept "nodedev" driver in virRandomGenerateWWN()

The virRandomGenerateWWN() is used solely by nodedev driver to
autogenerate WWNN and WWNP when parsing a nodedev XML. Now, the
idea was (at least during monolithic daemon) that depending on
which hypervisor driver called the nodedev XML parsing (and
virRandomGenerateWWN() under the hood) the corresponding OUI is
used (e.g. "001a4a" for the QEMU driver).

But in era of split daemons things are not that easy. We do not
know which hypervisor driver called us. And there might be no
hypervisor driver at all - users are allowed to connect to
individual drivers directly (e.g. "nodedev:///system").

In this case, we can't use proper OUI. Well, do the next best
thing: pick one (QUMRANET_OUI).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
21 months agoqemu_domain: Partially validate memory amounts when auto-adding NUMA node
Michal Privoznik [Fri, 21 Jul 2023 10:57:39 +0000 (12:57 +0200)]
qemu_domain: Partially validate memory amounts when auto-adding NUMA node

When automatically adding a NUMA node (qemuDomainDefNumaAutoAdd()) the
memory size of the node is computed as:

  total_memory - sum(memory devices)

And we have a nice helper for that: virDomainDefGetMemoryInitial() so
it looks logical to just call it. Except, this code runs in post parse
callback, i.e. memory sizes were not validated and it may happen that
the sum is greater than the total memory. This would be caught by
virDomainDefPostParseMemory() but that runs only after driver specific
callbacks (i.e. after qemuDomainDefNumaAutoAdd()) and because the
domain config was changed and memory was increased to this huge
number no error is caught.

So let's do what virDomainDefGetMemoryInitial() would do, but
with error checking.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2216236
Fixes: f5d4f5c8ee44e9f1939070afcc5381bdd5545e50
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
21 months agoTranslated using Weblate (Czech)
Pavel Borecki [Sat, 22 Jul 2023 19:20:59 +0000 (21:20 +0200)]
Translated using Weblate (Czech)

Currently translated at 100.0% (10395 of 10395 strings)

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

Co-authored-by: Pavel Borecki <pavel.borecki@gmail.com>
Signed-off-by: Pavel Borecki <pavel.borecki@gmail.com>
21 months agoutil: file: Mark 'BeeGFS' as shared filesystem
Peter Krempa [Tue, 25 Jul 2023 10:38:57 +0000 (12:38 +0200)]
util: file: Mark 'BeeGFS' as shared filesystem

BeeGFS is a shared/distributed filesystem:

https://doc.beegfs.io/latest/overview/overview.html

Mark it as shared based on it's magic number:

https://git.beegfs.io/pub/v7/-/blob/master/client_module/source/filesystem/FhgfsOpsSuper.h#L14

Closes: https://gitlab.com/libvirt/libvirt/-/issues/508
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agoci: Switch to OpenSUSE Leap 15.5
Michal Privoznik [Thu, 8 Jun 2023 08:05:22 +0000 (10:05 +0200)]
ci: Switch to OpenSUSE Leap 15.5

OpenSUSE Leap was released recently (2023-06-07). Refresh our CI
with latest lcitool which brings this minor update.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agosync_qemu_models_i386.py: Add missing features
Tim Wiederhake [Thu, 13 Jul 2023 09:58:48 +0000 (11:58 +0200)]
sync_qemu_models_i386.py: Add missing features

This brings the tool's list of features in sync with qemu
commit 6f05a92ddc73ac8aa16cfd6188f907b30b0501e3.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agocpu_map: Add missing feature "pbrsb-no"
Tim Wiederhake [Thu, 13 Jul 2023 09:38:06 +0000 (11:38 +0200)]
cpu_map: Add missing feature "pbrsb-no"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agocpu_map: Add missing feature "psdp-no"
Tim Wiederhake [Thu, 13 Jul 2023 09:37:52 +0000 (11:37 +0200)]
cpu_map: Add missing feature "psdp-no"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agocpu_map: Add missing feature "fbsdp-no"
Tim Wiederhake [Thu, 13 Jul 2023 09:37:36 +0000 (11:37 +0200)]
cpu_map: Add missing feature "fbsdp-no"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agocpu_map: Add missing feature "sbdr-ssdp-no"
Tim Wiederhake [Thu, 13 Jul 2023 09:37:18 +0000 (11:37 +0200)]
cpu_map: Add missing feature "sbdr-ssdp-no"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agocpu_map: Add missing feature "mcdt-no"
Tim Wiederhake [Thu, 13 Jul 2023 09:36:51 +0000 (11:36 +0200)]
cpu_map: Add missing feature "mcdt-no"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agodocs: Mention vhostuser for queues and queue_size
Han Han [Thu, 20 Jul 2023 09:00:22 +0000 (17:00 +0800)]
docs: Mention vhostuser for queues and queue_size

These two attributes are supported for vhost-user-blk as well.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoNEWS: qemu: Implement QEMU NBD reconnect delay attribute
Han Han [Tue, 25 Jul 2023 06:43:06 +0000 (14:43 +0800)]
NEWS: qemu: Implement QEMU NBD reconnect delay attribute

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoremote: fix stream use-after-free
Oleg Vasilev [Tue, 4 Jul 2023 07:10:22 +0000 (13:10 +0600)]
remote: fix stream use-after-free

Inside daemonStreamHandleWrite on stream completion (status=OK) we
reuse msg object to send confirmation.

Only after that, msg is poped from the queue and checked for continue.
By that time, msg might've already been processed for the confirmation
and freed.

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agonet: add debug logs
Oleg Vasilev [Tue, 4 Jul 2023 07:10:21 +0000 (13:10 +0600)]
net: add debug logs

Helped to debug next patch use-after-free.

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoqemu_tpm: Try harder to create emulator state
Michal Privoznik [Fri, 21 Jul 2023 08:47:59 +0000 (10:47 +0200)]
qemu_tpm: Try harder to create emulator state

If a per-domain SWTPM state directory exists but is empty our
code still considers it a valid state and skips running
'swtpm_setup' (handled in qemuTPMEmulatorRunSetup()).
While we should not try to inspect individual files created by
swtpm, we can still consider empty folder as non-existent state.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/320
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agovirfile: Introduce virDirIsEmpty()
Michal Privoznik [Fri, 21 Jul 2023 08:41:35 +0000 (10:41 +0200)]
virfile: Introduce virDirIsEmpty()

There might be cases where we want to know whether given
directory is empty or not. Introduce a helper for that:
virDirIsEmpty().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoconf/domain_validate: Validate the disk queue_size
Han Han [Fri, 21 Jul 2023 02:36:40 +0000 (10:36 +0800)]
conf/domain_validate: Validate the disk queue_size

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoconf/domain_validate.c: Improve the err for queue validation
Han Han [Fri, 21 Jul 2023 02:36:39 +0000 (10:36 +0800)]
conf/domain_validate.c: Improve the err for queue validation

Queues is supported by virtio bus, including virtio-blk and
vhost-user-blk.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 20 Jul 2023 21:21:05 +0000 (23:21 +0200)]
Translated using Weblate (Swedish)

Currently translated at 51.0% (5310 of 10395 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
21 months agoqemu_monitor: Remove helpers for 'query-commands'
Peter Krempa [Fri, 14 Jul 2023 13:25:08 +0000 (15:25 +0200)]
qemu_monitor: Remove helpers for 'query-commands'

Now that we don't use it for probing at all we can remove all the
corresponding monitor code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemu: capabilities: Don't probe 'query-commands'
Peter Krempa [Fri, 14 Jul 2023 13:19:15 +0000 (15:19 +0200)]
qemu: capabilities: Don't probe 'query-commands'

The capability code now probes the presence of commands from the QMP
schema instead of using 'query-commands'. Don't call the command and
adjust the '.replies' files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemu: capabilities: Probe presence of commands from QMP schema instead of 'query...
Peter Krempa [Fri, 14 Jul 2023 13:16:32 +0000 (15:16 +0200)]
qemu: capabilities: Probe presence of commands from QMP schema instead of 'query-commands'

Move the probing code to extract the data from the QMP schema rather
than invoking 'query-commands'. This patch doesn't yet remove the actual
invocation of 'query-commands', just moves the actual probing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agonode_device: Don't leak error message buffer from virMdevctlListDefined|Active
Peter Krempa [Wed, 19 Jul 2023 13:22:22 +0000 (15:22 +0200)]
node_device: Don't leak error message buffer from virMdevctlListDefined|Active

nodeDeviceUpdateMediatedDevices invokes virMdevctlListDefined and
virMdevctlListActive both of which were passed the same 'errmsg' buffer.

Since virCommandSetErrorBuffer() always allocates the error buffer one
of them was leaked.

Fix it by populating the 'errmsg' buffer only on failure of
virMdevctlListActive|Defined which invoke the command.

Add a comment to nodeDeviceGetMdevctlListCommand reminding how
virCommandSetErrorBuffer() works.

Fixes: 44a0f2f0c8f
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
21 months agoqemu: capabilities: Retire QEMU_CAPS_(IDE|SCSI)_DRIVE_WWN
Peter Krempa [Tue, 18 Jul 2023 13:54:38 +0000 (15:54 +0200)]
qemu: capabilities: Retire QEMU_CAPS_(IDE|SCSI)_DRIVE_WWN

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemu: Always assume support for QEMU_CAPS_IDE_DRIVE_WWN
Peter Krempa [Tue, 18 Jul 2023 13:47:56 +0000 (15:47 +0200)]
qemu: Always assume support for QEMU_CAPS_IDE_DRIVE_WWN

The support for configuring the 'wwn' of a IDE disk was added in qemu
commit 95ebda85e09 (v1.0-1869-g95ebda85e0) and can't be compiled
out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemu: Always assume support for QEMU_CAPS_SCSI_DISK_WWN
Peter Krempa [Tue, 18 Jul 2023 13:47:56 +0000 (15:47 +0200)]
qemu: Always assume support for QEMU_CAPS_SCSI_DISK_WWN

The support for configuring the 'wwn' of a SCSI disk was added in qemu
commit 27395add759ff4caeb0 (v1.0-3326-g27395add75) and can't be compiled
out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemu: capabilities: Update capabilities test data for qemu-8.1 dev cycle
Peter Krempa [Tue, 27 Jun 2023 11:58:09 +0000 (13:58 +0200)]
qemu: capabilities: Update capabilities test data for qemu-8.1 dev cycle

Update the test data on x86_64 to v8.0.0-2835-g361d539735

Notable changes:

 - added new commands:
    - cxl-inject-dram-event
    - cxl-inject-general-media-event
    - cxl-inject-memory-module-event
    - cxl-inject-poison
    - switchover-ack
 - q35-8.1 machine type now supports 1024 cpus
 - new cpu models:
    - 'SapphireRapids-v2'
    - 'GraniteRapids-v1'
 - removed commands:
    - x-query-profile
 - cpu features which can be emulated now:
    - rdseed, rdpid, 3dnowprefetch, xsaveerptr, wbnoinvd
 - applicable CPU bug mitigation flags are now exposed to TCG guests to
   allow using more named models

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agostorage: Fix returning of locked objects from 'virStoragePoolObjListSearch'
Peter Krempa [Thu, 13 Jul 2023 14:16:37 +0000 (16:16 +0200)]
storage: Fix returning of locked objects from 'virStoragePoolObjListSearch'

CVE-2023-3750

'virStoragePoolObjListSearch' explicitly documents that it's returning
a pointer to a locked and ref'd pool that maches the lookup function.

This was not the case as in commit 0c4b391e2a9 (released in
libvirt-8.3.0) the code was accidentally converted to use 'VIR_LOCK_GUARD'
which auto-unlocked it when leaving the scope, even when the code was
originally "leaking" the lock.

Revert the corresponding conversion and add a comment that this function
is intentionally leaking a locked object.

Fixes: 0c4b391e2a9
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2221851
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemuTestDriverInit: Don't autopopulate qemu capabilities when initializing driver
Peter Krempa [Tue, 4 Jul 2023 11:36:21 +0000 (13:36 +0200)]
qemuTestDriverInit: Don't autopopulate qemu capabilities when initializing driver

In an effort to use strictly real capability testing all tests were
converted to do insertion of their own capabilities when required, thus
we don't need to popluate the capabilities. This will also promote using
proper capabilities based on what the test is trying to achieve.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoqemudomaincheckpointxml2xmltest: Use real 'x86_64' capabilities in all test data
Peter Krempa [Mon, 3 Jul 2023 11:40:38 +0000 (13:40 +0200)]
qemudomaincheckpointxml2xmltest: Use real 'x86_64' capabilities in all test data

Use the platform which is getting most development for the checkpoint XML
examples so that it's tested against latest capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoqemuagenttest: Use real x86_64 capabilities for parsing domain definitions
Peter Krempa [Tue, 4 Jul 2023 11:39:24 +0000 (13:39 +0200)]
qemuagenttest: Use real x86_64 capabilities for parsing domain definitions

Some test cases require a real definition and thus parse a XML with the
definition to obtain it. Convert the code to use real capabilities and
switch to x86_64.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agotests: qemudomainsnapshotxml2xmlout: Use real 'x86_64' capabilities in all test data
Peter Krempa [Mon, 3 Jul 2023 11:40:38 +0000 (13:40 +0200)]
tests: qemudomainsnapshotxml2xmlout: Use real 'x86_64' capabilities in all test data

Use the platform which is getting most development for the snapshot XML
examples so that it's tested against latest capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoqemumemlocktest: Use 'testQemuInsertRealCaps'
Peter Krempa [Mon, 3 Jul 2023 13:39:58 +0000 (15:39 +0200)]
qemumemlocktest: Use 'testQemuInsertRealCaps'

Rewrite the capability fetching to use the new helper, thus simplifying
the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agotestutilsqemu: Introduce 'testQemuInsertRealCaps' helper
Peter Krempa [Mon, 3 Jul 2023 13:25:30 +0000 (15:25 +0200)]
testutilsqemu: Introduce 'testQemuInsertRealCaps' helper

'testQemuInsertRealCaps' looks up and inserts real capabilities into the
capability 'file cache' for testing purposes. Effectively this helper
replaces following steps:

1) testQemuGetRealCaps
2) virFileCacheClear
3) qemuTestCapsCacheInsert

This helper doesn't copy the capabilities that are borrowed from it's
internal cache thus they must not be modified afterwards in contrast to
the above steps.

The use of this helper is in simple tests which require some form of
capabilities to parse a definition but don't care about doctoring them
in any way.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agotestQemuGetRealCaps: Extract caching of the caps into a new helper
Peter Krempa [Mon, 3 Jul 2023 12:50:42 +0000 (14:50 +0200)]
testQemuGetRealCaps: Extract caching of the caps into a new helper

Introduce testQemuGetRealCapsInternal that loads and caches the
capabilities. testQemuGetRealCaps just copies the cache entry and
returns it to the user.

The new helper will be used in a helper that doesn't modify the
capabilities and thus we don't need to copy it before use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agotestQemuGetRealCaps: Strip the default machine alias before insertion into cache
Peter Krempa [Mon, 3 Jul 2023 12:41:38 +0000 (14:41 +0200)]
testQemuGetRealCaps: Strip the default machine alias before insertion into cache

Expand the default machine type alias of the 'latest' capabilities for
an architecture before caching it rather than after copying it, so that
we don't duplicate the work all the time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agodomaincapstest: Use obviously fake firmware name in capabilities
Peter Krempa [Mon, 3 Apr 2023 11:20:47 +0000 (13:20 +0200)]
domaincapstest: Use obviously fake firmware name in capabilities

The domain capabilities data feature a firmware section which is filled
by few entries. The entries used until now looked real and it was
suspicious that a x86_64 host was listing aarch64 firmware images which
should not happen.

Fill it by an obviously fake path as it's not actually interpreted in a
meaningful way.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agotestutils: Print number of failed tests
Peter Krempa [Mon, 3 Apr 2023 11:33:52 +0000 (13:33 +0200)]
testutils: Print number of failed tests

We can easily report how many tests failed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoProperly mark auto-added 'terminator' virStorageSource
Peter Krempa [Tue, 16 May 2023 08:18:55 +0000 (10:18 +0200)]
Properly mark auto-added 'terminator' virStorageSource

All backing chain members which were auto-added by image detection,
including the terminating element, should have the 'detected' property
set to true. This is needed to properly strip the detected elements in
some cases, e.g. for the status XML where we could treat some images as
manually terminated even when it was auto-detected.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemu: driver: Reformat helpers for saving VM state
Peter Krempa [Tue, 16 May 2023 08:18:18 +0000 (10:18 +0200)]
qemu: driver: Reformat helpers for saving VM state

Rewrap argument definition of qemuDomainSaveInternal and align argument
in the invocation of the aforementioned function in
qemuDomainManagedSaveHelper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoutil: add logging about node suspend availability
Daniel P. Berrangé [Wed, 21 Jun 2023 13:31:05 +0000 (14:31 +0100)]
util: add logging about node suspend availability

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agosrc: remove dep on systemd-logind.service from unit files
Daniel P. Berrangé [Wed, 21 Jun 2023 13:06:23 +0000 (14:06 +0100)]
src: remove dep on systemd-logind.service from unit files

After the previous commit we no longer require that logind is actually
running, it merely has to be activatable.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agoutil: relax requirement for logind to be running
Daniel P. Berrangé [Wed, 21 Jun 2023 13:03:25 +0000 (14:03 +0100)]
util: relax requirement for logind to be running

Historically we wanted to check if logind was actually running, not
merely activatable, because on systems where systemd is installed,
but the OS is booted into non-systemd init, we want to fallback to
pm-utils.

Requiring logind to be running, however, forces us to serialize libvirtd
startup on startup of logind which is undesirable. We can relax this
dependancy if we check whether systemd itself is running, which implies
that logind will activated when we need it.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agosrc: set max open file limit to match systemd >= 240 defaults
Daniel P. Berrangé [Wed, 21 Jun 2023 12:22:40 +0000 (13:22 +0100)]
src: set max open file limit to match systemd >= 240 defaults

Since systemd 240, all services get an open file hard limit of
500k, and a soft limit of 1024. This limit means apps are safe
to use select() by default which is limited to 1024 FDs. Apps
which don't use select() are expected to simply set their soft
limit to match the hard limit during startup.

With our current unit file settings we've been effectively
reducing the max open files we have on most modern systems.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agorpc: automatically raise max file limit in all daemons
Daniel P. Berrangé [Wed, 21 Jun 2023 12:46:47 +0000 (13:46 +0100)]
rpc: automatically raise max file limit in all daemons

None of our daemons use select(), so it is safe to raise the max file
limit to its maximum on startup.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agoutil: add helper for raising the max files limit
Daniel P. Berrangé [Wed, 21 Jun 2023 12:44:39 +0000 (13:44 +0100)]
util: add helper for raising the max files limit

Historically the max files limit for processes has always been 1024,
because going beyond this is incompatible with the select() function.
None the less most apps these days will use poll() so should not be
limited in this way.

Since systemd >= 240, the hard limit will be 500k, while the soft
limit remains at 1k. Applications which don't use select() should
raise their soft limit to match the hard limit during their startup.

This function provides a convenient helper to do this limit raising.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agoutil: remove pointless wrappers for setrlimit/getrlimit
Daniel P. Berrangé [Wed, 21 Jun 2023 12:43:35 +0000 (13:43 +0100)]
util: remove pointless wrappers for setrlimit/getrlimit

These wrappers added no semantic difference over calling the system
function directly.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agosrc: remove deps on ip[6]tables/firewalld.service from systemd units
Daniel P. Berrangé [Wed, 21 Jun 2023 12:07:46 +0000 (13:07 +0100)]
src: remove deps on ip[6]tables/firewalld.service from systemd units

The unit files both have After=network.target, and this in turn implies
After=network-pre.target. Both iptables.service & ip6tables.service have
Before=network-pre.target since Fedora >= 35 and RHEL >= 8.4.

When we first added the deps on ip[6]tables.service in

  commit 0756415f147dda15a417bd79eef9a62027d176e6
  Author: Laine Stump <laine@redhat.com>
  Date:   Fri May 1 00:05:50 2020 -0400

    systemd: start libvirtd after firewalld/iptables services

the Before=network-pre.target didn't exist, but we can rely on it now
given our supported platforms matrix.

The firewalld.service has similarly has a Before=network-pre.target,
even when we took that commit above, so this dep was in face never
actually needed. This answers the question posed in that above commit
message about firewalld ordering.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agosrc: remove After=local-fs.target from systemd units
Daniel P. Berrangé [Wed, 21 Jun 2023 12:05:40 +0000 (13:05 +0100)]
src: remove After=local-fs.target from systemd units

All services are ordered after local-fs.target unless they have set
DefaultDependencies=no, which we do not do.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agotests: Refresh valgrind suppressions
Michal Privoznik [Sun, 26 Feb 2023 11:04:21 +0000 (12:04 +0100)]
tests: Refresh valgrind suppressions

Since nobody is expected to run valgrind over scripts now, we can
drop plenty of suppressions. Also, there are some old ones that
no longer exist and new ones, that are not covered.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
21 months agomeson: Annotate each test() with 'suite'
Michal Privoznik [Sat, 15 Jul 2023 05:52:43 +0000 (07:52 +0200)]
meson: Annotate each test() with 'suite'

A test case can be part of a test suite (just like we already
have 'syntax-check'). This then allows developers to run only a
subset of tests. For instance - when using valgrind test setup
(`meson test -C _build/ --setup valgrind`) it makes zero sense to
run syntax-check tests or other script based tests (e.g.
check-augeas-*, check-remote_protocol, etc.). What does makes
sense is to run compiled binaries.

Strictly speaking, reaching that goal is as trivial as annotating
only those compiled tests (declared in tests/meson.build) and
running them selectively:

  meson test -C _build/ --setup valgrind --suite $TAG

But it may be also desirable to run test scripts separately.

Therefore, introduce two new tags: 'bin' for compiled tests, and
'script' for script based tests and annotate each test()
accordingly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
21 months agostorage: zfs: Use 'zfs list' to check pool status
Matt Low [Mon, 3 Jul 2023 22:53:28 +0000 (16:53 -0600)]
storage: zfs: Use 'zfs list' to check pool status

The current virtStorageBackendZFSCheckPool checks for the existence of a
path under /dev/zvol/ to determine if the pool is active. ZFS does not
create a path under /dev/zvol/ if no ZFS volumes have been created under
a particular dataset, thus, empty ZFS storage pools are deactivated
whenever checkPool is called on them (as noted in referenced issue).

This commit changes virStorageBackendZFSCheckPool so that the 'zfs list'
command is used to explicitly check for the existence a dataset
specified by the pool's def->source.name.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/221

Signed-off-by: Matt Low <matt@mlow.ca>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
21 months agonodedev: report mdev persistence properly
Jonathon Jongsma [Tue, 18 Jul 2023 19:47:49 +0000 (14:47 -0500)]
nodedev: report mdev persistence properly

Since commit 44a0f2f0, we now query mdevctl for transient (active) mdevs
in order to gather attributes for the mdev. Unfortunately, this commit
introduced a regression because nodeDeviceUpdateMediatedDevice() assumed
that all mdevs returned from mdevctl were actually persistent mdevs but
we were using it to update transient mdevs. Refactor the function so
that we can use it to update both persistent and transient mdevs.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
21 months agoqemu: require memfd memory for virtio 'blob' support
Jonathon Jongsma [Tue, 18 Jul 2023 13:55:13 +0000 (08:55 -0500)]
qemu: require memfd memory for virtio 'blob' support

The virtio-gpu 'blob' support was insufficiently validated. Qemu
requires a memfd memory backing in order to use udmabuf and enable blob
support. Example error:

    $ virsh start rhel9
    error: Failed to start domain 'rhel9'
    error: internal error: qemu unexpectedly closed the monitor: 2023-07-18T02:33:57.083178Z qemu-kvm: -device {"driver":"virtio-vga","id":"video0","max_outputs":1,"blob":true,"bus":"pcie.0","addr":"0x1"}: cannot enable blob resources without udmabuf

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
21 months agoqemu: Adapt to new way of specifying PC speaker
Michal Privoznik [Fri, 16 Jun 2023 11:05:48 +0000 (13:05 +0200)]
qemu: Adapt to new way of specifying PC speaker

Historically, the way to set PC speaker for a guest was to pass:

  -soundhw pcspk

but as of QEMU commit v5.1.0-rc0~28^2~3 this is deprecated and we
should use:

  -machine pcspk-audiodev=$id

instead. The old way was then removed in commit v7.1.0-rc0~99^2~3.

Now, ideally we would have a capability selecting whether we talk
to a QEMU that understands the new way or not. But it's not that
simple - the machine attribute is just an alias to the .audiodev=
attribute of 'isa-pcspk' object and both are created in
pc_machine_initfn() function, i.e. not then the PC_MACHINE() class
is initialized, but when it's instantiated. IOW, it's not possible
for us to query whether we're dealing with older or newer QEMU.

But given that the newer version is supported since v5.1.0 and the
minimal version we require is v4.2.0 (i.e. there are two releases
which don't understand the newer cmd line) and how frequently this
feature is (un-)used (the issue was reported after ~1 year since it
stopped working), I believe we can live without any capability and
just use the newer cmd line unconditionally.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/490
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
21 months agoqemu_capabilities: Retire QEMU_CAPS_USB_STORAGE_REMOVABLE
Michal Privoznik [Wed, 19 Jul 2023 11:28:07 +0000 (13:28 +0200)]
qemu_capabilities: Retire QEMU_CAPS_USB_STORAGE_REMOVABLE

Now that the QEMU_CAPS_USB_STORAGE_REMOVABLE capability is no
longer used we can stop querying it and retire it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>