]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agoqemu: avoid deadlock in qemuDomainObjStopWorker
Nikolay Shirokovskiy [Thu, 23 Jul 2020 08:02:59 +0000 (11:02 +0300)] 
qemu: avoid deadlock in qemuDomainObjStopWorker

We are dropping the only reference here so that the event loop thread
is going to be exited synchronously. In order to avoid deadlocks we
need to unlock the VM so that any handler being called can finish
execution and thus even loop thread be finished too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovireventthread: exit thread synchronously on finalize
Nikolay Shirokovskiy [Thu, 23 Jul 2020 07:23:00 +0000 (10:23 +0300)] 
vireventthread: exit thread synchronously on finalize

It it useful to be sure no thread is running after we drop all references to
virEventThread. Otherwise in order to avoid crashes we need to synchronize some
other way or we make extra references in event handler callbacks to all the
object in use. And some of them are not prepared to be refcounted.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: don't shutdown event thread in monitor EOF callback
Nikolay Shirokovskiy [Thu, 23 Jul 2020 07:10:26 +0000 (10:10 +0300)] 
qemu: don't shutdown event thread in monitor EOF callback

This hunk was introduced in [1] in order to avoid loosing
events from monitor on stopping qemu process. But as explained
in [2] on destroy we won't get neither EOF nor any other
events as monitor is just closed. In case of crash/shutdown
we won't get any more events as well and qemuDomainObjStopWorker
will be called by qemuProcessStop eventually. Thus let's
remove qemuDomainObjStopWorker from qemuProcessHandleMonitorEOF
as it is not useful anymore.

[1] e6afacb0f: qemu: start/stop an event loop thread for domains
[2] d2954c072: qemu: ensure domain event thread is always stopped

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpc: finish all threads before exiting main loop
Nikolay Shirokovskiy [Thu, 23 Jul 2020 06:53:04 +0000 (09:53 +0300)] 
rpc: finish all threads before exiting main loop

Currently we have issues like [1] on libvirtd shutdown as we cleanup while RPC
and other threads are still running. Let's finish all threads other then main
before cleanup.

The approach to finish threads is suggested in [2]. In order to finish RPC
threads serving API calls we let the event loop run but stop accepting new API
calls and block processing any pending API calls. We also inform all drivers of
shutdown so they can prepare for shutdown too. Then we wait for all RPC threads
and driver's background thread to finish. If finishing takes more then 15s we
just exit as we can't safely cleanup in time.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1828207
[2] https://www.redhat.com/archives/libvir-list/2020-April/msg01328.html

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpc: add shutdown facilities to netserver
Nikolay Shirokovskiy [Thu, 23 Jul 2020 06:50:25 +0000 (09:50 +0300)] 
rpc: add shutdown facilities to netserver

virNetServerClose and virNetServerShutdownWait are used to start net server
threads shutdown and wait net server threads to actually finish respectively
during net daemon shutdown procedure.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agorpc: add virNetDaemonSetShutdownCallbacks
Nikolay Shirokovskiy [Thu, 23 Jul 2020 06:43:46 +0000 (09:43 +0300)] 
rpc: add virNetDaemonSetShutdownCallbacks

The function is used to set shutdown prepare and wait callbacks. Prepare
callback is used to inform other threads of the daemon that the daemon will be
closed soon so that they can start to shutdown. Wait callback is used to wait
for other threads to actually finish.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agorpc: don't unref service ref on socket behalf twice
Nikolay Shirokovskiy [Thu, 9 Jul 2020 07:59:33 +0000 (10:59 +0300)] 
rpc: don't unref service ref on socket behalf twice

Second unref was added in [1]. We don't need it actually as
we pass free callback to virNetSocketAddIOCallback thus
when we call virNetSocketRemoveIOCallback the extra ref for
callback will be dropped without extra efforts.

[1] 355d8f470f9: virNetServerServiceClose: Don't leak sockets

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: add stop/drain functions to thread pool
Nikolay Shirokovskiy [Thu, 9 Jul 2020 07:58:02 +0000 (10:58 +0300)] 
util: add stop/drain functions to thread pool

Stop just send signal for threads to exit when they finish with
current task. Drain waits when all threads will finish.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: always initialize priority condition
Nikolay Shirokovskiy [Fri, 10 Jul 2020 11:36:54 +0000 (14:36 +0300)] 
util: always initialize priority condition

Even if we have no priority threads on pool creation we can add them thru
virThreadPoolSetParameters later.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agolibvirt: add stateShutdownPrepare/stateShutdownWait to drivers
Nikolay Shirokovskiy [Thu, 9 Jul 2020 07:46:34 +0000 (10:46 +0300)] 
libvirt: add stateShutdownPrepare/stateShutdownWait to drivers

stateShutdownPrepare is supposed to inform driver that it will be closed soon
so that the driver can prepare and finish all background threads quickly on
stateShutdownWait call.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: Fix comment in qemuProcessSetupPid
Martin Kletzander [Sun, 6 Sep 2020 11:44:27 +0000 (13:44 +0200)] 
qemu: Fix comment in qemuProcessSetupPid

This was supposed to be done in commit 3791f29b085c, but I missed a spot.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agonews: qemu: Allow migration over UNIX sockets
Martin Kletzander [Mon, 24 Aug 2020 21:48:04 +0000 (23:48 +0200)] 
news: qemu: Allow migration over UNIX sockets

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Allow migration over UNIX socket
Martin Kletzander [Wed, 2 Sep 2020 10:06:12 +0000 (12:06 +0200)] 
qemu: Allow migration over UNIX socket

This allows:

 a) migration without access to network

 b) complete control of the migration stream

 c) easy migration between containerised libvirt daemons on the same host

Resolves: https://bugzilla.redhat.com/1638889

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agonetwork: drop use of dummy tap device in bridges
Daniel P. Berrangé [Mon, 3 Aug 2020 13:52:13 +0000 (14:52 +0100)] 
network: drop use of dummy tap device in bridges

A long time ago we introduced a dummy tap device (e.g. virbr0-nic) that
we attached to the bridge device created for virtual networks:

  commit 5754dbd56d4738112a86776c09e810e32f7c3224
  Author: Laine Stump <laine@redhat.com>
  Date:   Wed Feb 9 03:28:12 2011 -0500

    Give each virtual network bridge its own fixed MAC address

This was a hack to workaround a Linux kernel bug where it would not
honour any attempt to set a MAC address on a bridge. Instead the
bridge would adopt the numerically lowest MAC address of all NICs
attached to the bridge. This lead to the MAC addrss of the bridge
changing over time as NICs were attached/detached.

The Linux bug was actually fixed 3 years before the libvirt
workaround was added in:

  commit 92c0574f11598c8036f81e27d2e8bdd6eed7d76d
  Author: Stephen Hemminger <shemminger@vyatta.com>
  Date:   Tue Jun 17 16:10:06 2008 -0700

    bridge: make bridge address settings sticky

    Normally, the bridge just chooses the smallest mac address as the
    bridge id and mac address of bridge device. But if the administrator
    has explictly set the interface address then don't change it.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
but libvirt needed to support RHEL-5 kernels at that time, so
none the less added the workaround.

We have long since dropped support for RHEL-5 vintage distros,
so there's no reason to keep the dummy tap device for the purpose
of setting the bridge MAC address.

Later the dummy TAP device was used for a second purpose related
to IPv6 DAD (Duplicate Address Detection) in:

  commit db488c79173b240459c7754f38c3c6af9b432970
  Author: Benjamin Cama <benoar@dolka.fr>
  Date:   Wed Sep 26 21:02:20 2012 +0200

    network: fix dnsmasq/radvd binding to IPv6 on recent kernels

This was again dealing with a regression in the Linux kernel, where
if there were no devices attached to the bridge in the UP state,
IPv6 DAD would not be performed. The virbr0-nic was attached but
in the DOWN state, so the above libvirt fix tenporarily brought
the NIC online. The Linux commit causing the problem was in v2.6.38

  commit 1faa4356a3bd89ea11fb92752d897cff3a20ec0e
  Author: stephen hemminger <shemminger@vyatta.com>
  Date:   Mon Mar 7 08:34:06 2011 +0000

    bridge: control carrier based on ports online

A short while later Linux was tweaked so that DAD would still occur
if the bridge had no attached devices at all in 3.1:

  commit b64b73d7d0c480f75684519c6134e79d50c1b341
  Author: stephen hemminger <shemminger@vyatta.com>
  Date:   Mon Oct 3 18:14:45 2011 +0000

    bridge: leave carrier on for empty bridge

IOW, the only reason we need the DAD hack of bringing virbr0-nic
online is because virbr0-nic exists. Once it doesn't exist, then
we hit the "empty bridge" case which works in Linux.

We can rely on distros having Linux kernel >= 3.1, so both things
that the virbr0-nic are doing are redundant.

Fixes https://gitlab.com/libvirt/libvirt/-/issues/53
Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agocpu_map: Use g_auto* in cpuMapLoad
Tim Wiederhake [Fri, 4 Sep 2020 12:26:07 +0000 (14:26 +0200)] 
cpu_map: Use g_auto* in cpuMapLoad

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: add device name in errors from ethtool ioctls
Daniel P. Berrangé [Wed, 2 Sep 2020 18:32:49 +0000 (19:32 +0100)] 
util: add device name in errors from ethtool ioctls

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Do not error out when setting affinity failed
Martin Kletzander [Fri, 4 Sep 2020 12:17:30 +0000 (14:17 +0200)] 
qemu: Do not error out when setting affinity failed

Consider a host with 8 CPUs. There are the following possible scenarios

1. Bare metal; libvirtd has affinity of 8 CPUs; QEMU should get 8 CPUs

2. Bare metal; libvirtd has affinity of 2 CPUs; QEMU should get 8 CPUs

3. Container has affinity of 8 CPUs; libvirtd has affinity of 8 CPus;
   QEMU should get 8 CPUs

4. Container has affinity of 8 CPUs; libvirtd has affinity of 2 CPus;
   QEMU should get 8 CPUs

5. Container has affinity of 4 CPUs; libvirtd has affinity of 4 CPus;
   QEMU should get 4 CPUs

6. Container has affinity of 4 CPUs; libvirtd has affinity of 2 CPus;
   QEMU should get 4 CPUs

Scenarios 1 & 2 always work unless systemd restricted libvirtd privs.

Scenario 3 works because libvirt checks current affinity first and
skips the sched_setaffinity call, avoiding the SYS_NICE issue

Scenario 4 works only if CAP_SYS_NICE is availalbe

Scenarios 5 & 6 works only if CAP_SYS_NICE is present *AND* the cgroups
cpuset is not set on the container.

If libvirt blindly ignores the sched_setaffinity failure, then scenarios
4, 5 and 6 should all work, but with caveat in case 4 and 6, that
QEMU will only get 2 CPUs instead of the possible 8 and 4 respectively.
This is still better than failing.

Therefore libvirt can blindly ignore the setaffinity failure, but *ONLY*
ignore it when there was no affinity specified in the XML config.
If user specified affinity explicitly, libvirt must report an error if
it can't be honoured.

Resolves: https://bugzilla.redhat.com/1819801

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: re-add conditional for ifi_iqdrops field for macOS
Daniel P. Berrangé [Fri, 4 Sep 2020 09:13:48 +0000 (10:13 +0100)] 
util: re-add conditional for ifi_iqdrops field for macOS

The conditional was removed in

  commit ebbf8ebe4fa6f9d43b40673f0f2dad6bf50e2085
  Author: Ján Tomko <jtomko@redhat.com>
  Date:   Tue Sep 1 22:56:37 2020 +0200

    util: virnetdevtap: stats: fix txdrop on FreeBSD

That commit was correct about this no longer being required for FreeBSD,
but missed that the code is also built on macOS.

Rather than testing for this field in meson though, we can simply use
a platform conditional test in the code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotools: avoid unused parameter warning when readline is disabled
Daniel P. Berrangé [Fri, 4 Sep 2020 09:17:30 +0000 (10:17 +0100)] 
tools: avoid unused parameter warning when readline is disabled

The vshReadlineHistoryAdd stub method does not use its parameter.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopeer2peer migration: allow connecting to local sockets
Martin Kletzander [Mon, 24 Aug 2020 22:31:23 +0000 (00:31 +0200)] 
peer2peer migration: allow connecting to local sockets

Local socket connections were outright disabled because there was no "server"
part in the URI.  However, given how requirements and usage scenarios are
evolving, some management apps might need the source libvirt daemon to connect
to the destination daemon over a UNIX socket for peer2peer migration.  Since we
cannot know where the socket leads (whether the same daemon or not) let's decide
that based on whether the socket path is non-standard, or rather explicitly
specified in the URI.  Checking non-standard path would require to ask the
daemon for configuration and the only misuse that it would prevent would be a
pretty weird one.  And that's not worth it.  The assumption is that whenever
someone uses explicit UNIX socket paths in the URI for migration they better
know what they are doing.

Partially resolves: https://bugzilla.redhat.com/1638889

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Allow NBD migration over UNIX socket
Martin Kletzander [Mon, 24 Aug 2020 13:42:31 +0000 (15:42 +0200)] 
qemu: Allow NBD migration over UNIX socket

Adds new typed param for migration and uses this as a UNIX socket path that
should be used for the NBD part of migration.  And also adds virsh support.

Partially resolves: https://bugzilla.redhat.com/1638889

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agotests: Add simple test for virDomainMigrateCheckNotLocal
Martin Kletzander [Thu, 20 Sep 2018 11:33:45 +0000 (13:33 +0200)] 
tests: Add simple test for virDomainMigrateCheckNotLocal

For this we need to make the function accessible (at least privately).  The
behaviour will change in following patches and the test helps explaining the
change.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Rework starting NBD server for migration
Martin Kletzander [Mon, 24 Aug 2020 19:24:13 +0000 (21:24 +0200)] 
qemu: Rework starting NBD server for migration

Clean up the semantics by using one extra self-describing variable.
This also fixes the port allocation when the port is specified.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agovirsh: Reuse existing variable when parsing migrate --disks-port
Martin Kletzander [Mon, 24 Aug 2020 13:43:50 +0000 (15:43 +0200)] 
virsh: Reuse existing variable when parsing migrate --disks-port

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Rework qemuMigrationSrcConnect
Martin Kletzander [Mon, 24 Aug 2020 20:29:14 +0000 (22:29 +0200)] 
qemu: Rework qemuMigrationSrcConnect

Instead of saving some data from a union up front and changing an overlayed
struct before using said data, let's just set the new values after they are
decided.  This will increase the readability of future commit(s).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Use g_autofree in qemuMigrationSrcConnect
Martin Kletzander [Mon, 24 Aug 2020 20:27:30 +0000 (22:27 +0200)] 
qemu: Use g_autofree in qemuMigrationSrcConnect

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu_namespace: Be tolerant to non-existent files when populating /dev
Michal Privoznik [Thu, 3 Sep 2020 16:07:43 +0000 (18:07 +0200)] 
qemu_namespace: Be tolerant to non-existent files when populating /dev

In 6.7.0 release I've changed how domain namespace is built and
populated. Previously it used to be done from a pre-exec hook
(ran in the forked off child, just before dropping all privileges
and exec()-ing QEMU), which not only meant we had to have two
different code paths for creating a node in domain's namespace
(one for this pre-exec hook, the other for hotplug ran from the
daemon), it also proved problematic because it was leaking FDs
into QEMU process.

To mitigate this problem, we've not only ditched libdevmapper
from the NS population process, I've also dropped the pre-exec
code and let the NS be populated from the daemon (using the
hotplug code). But, I was not careful when doing so, because the
pre-exec code was tolerant to files that doesn't exist, while
this new code isn't. For instance, the very first thing that is
done when the new NS is created is it's populated with
@defaultDeviceACL which contain files like /dev/null, /dev/zero,
/dev/random and /dev/kvm (and others).  While the rest will
probably exist every time, /dev/kvm might not and thus the new
code I wrote has to be tolerant to that.

Of course, users can override the @defaultDeviceACL (by setting
cgroup_device_acl in qemu.conf) and remove /dev/kvm (which is
acceptable workaround), but we definitely want libvirt to work
out of the box even on hosts without KVM.

Fixes: 9048dc4e627ddf33996084167bece7b5fb83b0bc
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virnetdevtap: stats: fix txdrop on FreeBSD
Ján Tomko [Tue, 1 Sep 2020 20:56:37 +0000 (22:56 +0200)] 
util: virnetdevtap: stats: fix txdrop on FreeBSD

For older FreeBSD, we needed an ifdef guard to use
if_data.ifi_oqdrops, which was introduced by:

commit 61bbdbb94ce3e2f5e969c9bddb443427db07bf61
    Implement interface stats for BSD

But when we dropped the check because we deprecated
building on FreeBSD-10 in:

commit 83131d9714db7ee77ab220186b6b0d8b6c22b09e
    configure: drop check for unsupported FreeBSD

We started building the wrong side of the ifdef.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 83131d9714db7ee77ab220186b6b0d8b6c22b09e
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
4 years agoremote: adapt augeas test case for dynamic polkit config change
Daniel P. Berrangé [Thu, 3 Sep 2020 14:54:28 +0000 (15:54 +0100)] 
remote: adapt augeas test case for dynamic polkit config change

We need to use @default_auth@ in the augeas test case to match
its use in the main libvirtd.conf.in file.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobuild-aux: use GNU sed for syntax-check on FreeBSD
Roman Bogorodskiy [Wed, 5 Aug 2020 15:49:02 +0000 (19:49 +0400)] 
build-aux: use GNU sed for syntax-check on FreeBSD

BSD sed(1) and GNU sed(1) syntax are not compatible, and as
synax-check.mk uses the GNU flavor, set SED variable to
'gsed' by default.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovsh: Define HAVE_STDARG_H before including readline
Michal Privoznik [Wed, 2 Sep 2020 14:37:04 +0000 (16:37 +0200)] 
vsh: Define HAVE_STDARG_H before including readline

As it turned out my previous commits which switched from HAVE_ to
WITH_ and dropped stdarg.h detection were a bit too aggressive.
Because of reasons described in 9ea3424a178 we need to define
HAVE_STDARG_H before including readline otherwise macos build
fails. Honestly, I still don't fully understand the problem so I
am not going to bother you with "explanation".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovsh: Introduce wrapper for add_history()
Michal Privoznik [Thu, 3 Sep 2020 08:02:52 +0000 (10:02 +0200)] 
vsh: Introduce wrapper for add_history()

This allows us to drop include of readline header files from
virsh.c and virt-admin.c because they needed it only because of
the add_history() function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agomeson: add -Wall and -Wextra explicitly
Pavel Hrdina [Tue, 1 Sep 2020 12:54:27 +0000 (14:54 +0200)] 
meson: add -Wall and -Wextra explicitly

If someone runs `meson setup --buildtype plain` meson ignores
warning_level=2 that is in our meson.build file. The implication is
that Meson will not automatically add -Wall which enables -Wformat.

This breaks building libvirt from git with the buildtype set to plain.

There is an issue reported [1] to not ignore warning_level silently
and the change to ignore it was done by upstream commit [2].

This change makes Meson print warnings about using warning_level which
as described above doesn't work for all build types.

[1] <https://github.com/mesonbuild/meson/issues/7399>
[2] <https://github.com/mesonbuild/meson/commit/8ee1c9a07a3a35e3ed262fbc358fd86c257a966e>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoremote: use SocketMode=0600 when polkit is not compiled
Daniel P. Berrangé [Fri, 7 Aug 2020 12:37:05 +0000 (13:37 +0100)] 
remote: use SocketMode=0600 when polkit is not compiled

The systemd .socket unit files we ship for libvirt daemons use
SocketMode=0666 on the assumption that libvirt is built with
polkit which provides access control.

Some people, however, may have explicitly turned off polkit at
build time and not realize that leaves them insecure unless
they also change the SocketMode.  This addresses that problem
by making the SocketMode default to 0600 when polkit is
disabled at compile time.

Note we cannot automatically fix the case where the user
compiles polkit, but then overrides the libvirtd.conf defaults
to disable polkit. This is what lead to CVE-2020-15708 in
Ubuntu 20.10.  We can at least improve the inline comments
in the config file to give a clearer warning though, which
may have helped avoid the mistaken config.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonews: qemu: Support TLS for NBD connections for pull mode backup
Yanqiu Zhang [Thu, 3 Sep 2020 02:56:48 +0000 (02:56 +0000)] 
news: qemu: Support TLS for NBD connections for pull mode backup

Signed-off-by: Yanqiu Zhang <yanqzhan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agotests: change confusing macro agument names
Jonathon Jongsma [Wed, 2 Sep 2020 19:45:38 +0000 (14:45 -0500)] 
tests: change confusing macro agument names

Rather than use the names "fial" and "kep", use "fail" and "keep". In
the DO_TEST() macro, to prevent the preprocessor replacing the struct
member names during assignment, use the names "fail_" and "keep_"
instead.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoqemu_validate: Only allow none address for watchdog ib700
Han Han [Tue, 1 Sep 2020 14:15:27 +0000 (22:15 +0800)] 
qemu_validate: Only allow none address for watchdog ib700

Since QEMU 1.5.3, the ib700 watchdog device has no options for address,
and not address in device tree:

$ /usr/libexec/qemu-kvm -version
QEMU emulator version 1.5.3 (qemu-kvm-1.5.3-175.el7), Copyright (c) 2003-2008 Fabrice Bellard
$ /usr/libexec/qemu-kvm -device ib700,\?
$ virsh qemu-monitor-command seabios --hmp info qtree|grep ib700 -A 2
        dev: ib700, id "watchdog0"
        dev: isa-serial, id "serial0"
          index = 0

So only allow it to use none address.

Fixes: 8a54cc1d08a333283c9cfc3fd7788be2642ca71a
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1509908

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Fix domfsinfo for non-PCI device information from guest agent
Thomas Huth [Mon, 20 Jul 2020 10:22:33 +0000 (12:22 +0200)] 
qemu: Fix domfsinfo for non-PCI device information from guest agent

qemuAgentFSInfoToPublic() currently only sets the devAlias for PCI devices.
However, the QEMU guest agent could also provide the device name in the
"dev" field of the response for other devices instead (well, at least after
fixing another problem in the current QEMU guest agent...). So if creating
the devAlias from the PCI information failed, let's fall back to the name
provided by the guest agent. This helps to fix the empty "Target" fields
that occur when running "virsh domfsinfo" on s390x where CCW devices are
used for the guest instead of PCI devices.

Also add a proper debug message here in case we completely failed to set the
device alias, since this problem here was very hard to debug: The only two
error messages that I've seen were "Unable to get filesystem information"
and "Unable to encode message payload" - which only indicates that something
went wrong in the RPC call. No debug message indicated the real problem, so
I had to learn the hard way why the RPC call failed (it apparently does not
like devAlias left to be NULL) and where the real problem comes from.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1755075
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agoqemu: Do not silently allow non-available timers on non-x86 systems
Thomas Huth [Wed, 5 Aug 2020 10:22:26 +0000 (12:22 +0200)] 
qemu: Do not silently allow non-available timers on non-x86 systems

libvirt currently silently allows <timer name="kvmclock"/> and some
other timer tags in the guest XML definition for timers that do not
exist on non-x86 systems. We should not silently ignore these tags
since the users might not get what they expected otherwise.
Note: The error is only generated if the timer is marked with
present="yes" - otherwise we would suddenly refuse XML definitions
that worked without problems before.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1754887
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoAUTHORS: Remove Emacs file variables
Andrea Bolognani [Tue, 25 Aug 2020 16:07:01 +0000 (18:07 +0200)] 
AUTHORS: Remove Emacs file variables

vim seems to be able to process the file just fine without a
modeline, so it's probably fair to assume Emacs doesn't need
any extra help either.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoAUTHORS: Convert to reStructuredText
Andrea Bolognani [Tue, 25 Aug 2020 15:52:24 +0000 (17:52 +0200)] 
AUTHORS: Convert to reStructuredText

Now that we have moved to Meson, we are no longer required to
use a specific name for this file, and since the rest of our
documentation is in reStructuredText format and uses a matching
file extension, we can give the AUTHORS file the same treatment.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agolib: Prefer WITH_* prefix for #if conditionals
Michal Privoznik [Tue, 1 Sep 2020 11:27:44 +0000 (13:27 +0200)] 
lib: Prefer WITH_* prefix for #if conditionals

Currently, we are mixing: #if HAVE_BLAH with #if WITH_BLAH.
Things got way better with Pavel's work on meson, but apparently,
mixing these two lead to confusing and easy to miss bugs (see
31fb929eca for instance). While we were forced to use HAVE_
prefix with autotools, we are free to chose our own prefix with
meson and since WITH_ prefix appears to be more popular let's use
it everywhere.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agonss: Drop needless include of rpc/types.h
Michal Privoznik [Tue, 1 Sep 2020 12:30:42 +0000 (14:30 +0200)] 
nss: Drop needless include of rpc/types.h

In packet-libvirt.c in wireshark dissector we include rpc/types.h
but guard the include with a condition (that is supposed to be
true if we detected during configure phase that the host system
has the header file). Thing is, it looks like we were never doing
the configure check and thus the file was never included and yet,
the NSS plugin works. Drop the include then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agomeson: Drop checks for some functions and header files
Michal Privoznik [Tue, 1 Sep 2020 12:30:34 +0000 (14:30 +0200)] 
meson: Drop checks for some functions and header files

In meson.build, we check for presence of unshare() function
explicitly (even though there is the function usability check a
few hundred lines below), but never have any code depending on
HAVE_UNSHARE. The same applies to stdarg.h and sys/sysctl.h
header files - either we simply include them or guard their
include using different conditionals.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirfile.c: Remove some #endif comments
Michal Privoznik [Tue, 1 Sep 2020 12:23:32 +0000 (14:23 +0200)] 
virfile.c: Remove some #endif comments

There are couple of conditional #includes at the beginning of
virfile.c and they try to be nice and document #endifs. But they
are mostly wrong because either they have the condition in the
comment inverted or the comment refers to a different condition
than they belong to. Just remove the comments as these #includes
are single line mostly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: Check for HAVE_NET_IF_H correctly
Michal Privoznik [Tue, 1 Sep 2020 12:21:41 +0000 (14:21 +0200)] 
util: Check for HAVE_NET_IF_H correctly

There are two places where we try to check whether the host
system has net/if.h before including it. But the check is missing
'_H' suffix.

Fixes: 7f3eb533f44742071366e07a35ab41070956707b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Add e1000e/vmxnet3 IFF_VNET_HDR support
Patrick Magauran [Sat, 8 Aug 2020 13:59:13 +0000 (09:59 -0400)] 
qemu: Add e1000e/vmxnet3 IFF_VNET_HDR support

Setting IFF_VNET_HDR for a tap device passes the whole packet to the
host, reducing emulation overhead and improving performance.

Libvirt bases its decision about applying IFF_VNET_HDR to the tap
interface on whether or not the model of the emulated network device
is virtio.  Originally, virtio was the only model to support
IFF_VNET_HDR in QEMU; however, the e1000e & vmxnet3 adapters have also
supported it since their introductions - QEMU commit
786fd2b0f87 for vmxnet3, and QEMU commit 6f3fbe4ed0 for e1000e, so it
should be set for those models too.

Signed-off-by: Patrick Magauran <patmagauran.j@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agotests/meson: fix mock library link on MacOS
Scott Shambarger [Fri, 28 Aug 2020 19:35:01 +0000 (12:35 -0700)] 
tests/meson: fix mock library link on MacOS

MacOS can not pre-load modules, so mock libraries must be built
as shared libraries (without asneeded striping, and undefined
symbols allowed).

Signed-off-by: Scott Shambarger <scott-libvirt@shambarger.net>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: fix enum conversion
Ján Tomko [Tue, 1 Sep 2020 21:30:35 +0000 (23:30 +0200)] 
conf: fix enum conversion

../src/conf/domain_conf.c:8144:78: error: result of comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-unsigned-enum-zero-compare]
        if ((def->writeFiltering = virTristateBoolTypeFromString(filtering)) < 0) {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 9d15647dcb96831c93ac8c1d67c47265b5ed9072
4 years agotests: fix license blurb in virsh-undefine
Ján Tomko [Tue, 4 Aug 2020 14:40:34 +0000 (16:40 +0200)] 
tests: fix license blurb in virsh-undefine

Assume commit 0466ff28f2 used case-insensitive replace s/OUT/EXP/
by mistake and this file is still licensed under GPLv2.0+

Undo the change.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
FIxes: 0466ff28f23f4c430906efd5859f87672cf08782
Cc: Cole Robinson <crobinso@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Pino Toscano <ptoscano@redhat.com>
4 years agoNews: Advertise support for writeFiltering attribute of PCI hostdevs
Jim Fehlig [Fri, 14 Aug 2020 21:30:17 +0000 (15:30 -0600)] 
News: Advertise support for writeFiltering attribute of PCI hostdevs

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoXen: Add support for writeFiltering in config converter
Jim Fehlig [Fri, 14 Aug 2020 20:47:09 +0000 (14:47 -0600)] 
Xen: Add support for writeFiltering in config converter

Add support for the writeFiltering attribute in the domXML to native
config converter. Also include a test.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoXen: Add writeFiltering option for PCI devices
Jim Fehlig [Fri, 14 Aug 2020 16:28:38 +0000 (10:28 -0600)] 
Xen: Add writeFiltering option for PCI devices

By default Xen only allows guests to write "known safe" values into PCI
configuration space, yet many devices require writes to other areas of
the configuration space in order to operate properly. To allow writing
any values Xen supports the 'permissive' setting, see xl.cfg(5) man page.

This change models Xen's permissive setting by adding a writeFiltering
attribute on the <source> element of a PCI hostdev. When writeFiltering
is set to 'no', the Xen permissive setting will be enabled and guests
will be able to write any values into the device's configuration space.
The permissive setting remains disabled in the absense of the
writeFiltering attribute, of if it is explicitly set to 'yes'.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Check for changes in qemu modules directory
Jim Fehlig [Thu, 20 Aug 2020 21:52:17 +0000 (15:52 -0600)] 
qemu: Check for changes in qemu modules directory

Add a configuration option for specifying location of the qemu modules
directory, defaulting to /usr/lib64/qemu. Then use this location to
check for changes in the directory, indicating that a qemu module has
changed and capabilities need to be reprobed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoPrefer https: everywhere where possible
Ján Tomko [Tue, 25 Aug 2020 22:44:00 +0000 (00:44 +0200)] 
Prefer https: everywhere where possible

Use https: links for websites that support them.

The URIs which are used as namespace identifiers
are left alone.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agoPrefer https: for libguestfs.org links
Ján Tomko [Tue, 25 Aug 2020 22:52:40 +0000 (00:52 +0200)] 
Prefer https: for libguestfs.org links

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agoPrefer https: for Red Hat websites
Ján Tomko [Tue, 25 Aug 2020 22:49:31 +0000 (00:49 +0200)] 
Prefer https: for Red Hat websites

The list archives, people.redhat.com and bugzilla all support
https.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agoPrefer https: for Wikipedia links
Ján Tomko [Tue, 25 Aug 2020 22:46:53 +0000 (00:46 +0200)] 
Prefer https: for Wikipedia links

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agovbox: do not repeat the innotek namespace url
Ján Tomko [Tue, 25 Aug 2020 22:42:56 +0000 (00:42 +0200)] 
vbox: do not repeat the innotek namespace url

Also, remove the url from the translatable string,
reducing it to the generic message already used
by virXMLNamespaceRegister.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agotools: wireshark: fix link to wireshark repo
Ján Tomko [Wed, 26 Aug 2020 12:47:18 +0000 (14:47 +0200)] 
tools: wireshark: fix link to wireshark repo

It seems wireshark has migrated to gitlab in the meantime.
Point there instead of to the dead svn repo.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agodocs: tlscerts: fix link to certtool invocation
Ján Tomko [Wed, 26 Aug 2020 15:05:35 +0000 (17:05 +0200)] 
docs: tlscerts: fix link to certtool invocation

The docs have moved to gnutls.org.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agolibxl: do not include math.h
Ján Tomko [Tue, 25 Aug 2020 15:34:03 +0000 (17:34 +0200)] 
libxl: do not include math.h

The include was introduced by:
  commit 3d6fe99c5c3b862db1b345da3598a920f1079b6e
    Add vcpu functions to libxl driver
which used ceil() and floor(), but these were later
removed by:
  commit 3eb869a04bdeaddbe10e74568540e865fb79e412
    libxl: avoid compiler warning
which did not remove the include.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
4 years agoutil: assign tap device names using a monotonically increasing integer
Laine Stump [Mon, 24 Aug 2020 01:20:13 +0000 (21:20 -0400)] 
util: assign tap device names using a monotonically increasing integer

When creating a standard tap device, if provided with an ifname that
contains "%d", rather than taking that literally as the name to use
for the new device, the kernel will instead use that string as a
template, and search for the lowest number that could be put in place
of %d and produce an otherwise unused and unique name for the new
device. For example, if there is no tap device name given in the XML,
libvirt will always send "vnet%d" as the device name, and the kernel
will create new devices named "vnet0", "vnet1", etc. If one of those
devices is deleted, creating a "hole" in the name list, the kernel
will always attempt to reuse the name in the hole first before using a
name with a higher number (i.e. it finds the lowest possible unused
number).

The problem with this, as described in the previous patch dealing with
macvtap device naming, is that it makes "immediate reuse" of a newly
freed tap device name *much* more common, and in the aftermath of
deleting a tap device, there is some other necessary cleanup of things
which are named based on the device name (nwfilter rules, bandwidth
rules, OVS switch ports, to name a few) that could end up stomping
over the top of the setup of a new device of the same name for a
different guest.

Since the kernel "create a name based on a template" functionality for
tap devices doesn't exist for macvtap, this patch for standard tap
devices is a bit different from the previous patch for macvtap - in
particular there was no previous "bitmap ID reservation system" or
overly-complex retry loop that needed to be removed. We simply find
and unused name, and pass that name on to the kernel instead of
"vnet%d".

This counter is also wrapped when either it gets to INT_MAX or if the
full name would overflow IFNAMSIZ-1 characters. In the case of
"vnet%d" and a 32 bit int, we would reach INT_MAX first, but possibly
someday someone will change the name from vnet to something else.

(NB: It is still possible for a user to provide their own
parameterized template name (e.g. "mytap%d") in the XML, and libvirt
will just pass that through to the kernel as it always has.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: replace macvtap name reservation bitmap with a simple counter
Laine Stump [Sun, 23 Aug 2020 18:57:19 +0000 (14:57 -0400)] 
util: replace macvtap name reservation bitmap with a simple counter

There have been some reports that, due to libvirt always trying to
assign the lowest numbered macvtap / tap device name possible, a new
guest would sometimes be started using the same tap device name as
previously used by another guest that is in the process of being
destroyed *as the new guest is starting.

In some cases this has led to, for example, the old guest's
qemuProcessStop() code deleting a port from an OVS switch that had
just been re-added by the new guest (because the port name is based on
only the device name using the port). Similar problems can happen (and
I believe have) with nwfilter rules and bandwidth rules (which are
both instantiated based on the name of the tap device).

A couple patches have been previously proposed to change the ordering
of startup and shutdown processing, or to put a mutex around
everything related to the tap/macvtap device name usage, but in the
end no matter what you do there will still be possible holes, because
the device could be deleted outside libvirt's control (for example,
regular tap devices are automatically deleted when the qemu process
terminates, and that isn't always initiated by libvirt but could
instead happen completely asynchronously - libvirt then has no control
over the ordering of shutdown operations, and no opportunity to
protect it with a mutex.)

But this only happens if a new device is created at the same time as
one is being deleted. We can effectively eliminate the chance of this
happening if we end the practice of always looking for the lowest
numbered available device name, and instead just keep an integer that
is incremented each time we need a new device name. At some point it
will need to wrap back around to 0 (in order to avoid the IFNAMSIZ 15
character limit if nothing else), and we can't guarantee that the new
name really will be the *least* recently used name, but "math"
suggests that it will be *much* less common that we'll try to re-use
the *most* recently used name.

This patch implements such a counter for macvtap/macvlan, replacing
the existing, and much more complicated, "ID reservation" system. The
counter is set according to whatever macvtap/macvlan devices are
already in use by guests when libvirtd is started, incremented each
time a new device name is needed, and wraps back to 0 when either
INT_MAX is reached, or when the resulting device name would be longer
than IFNAMSIZ-1 characters (which actually is what happens when the
template for the device name is "maccvtap%d"). The result is that no
macvtap name will be re-used until the host has created (and possibly
destroyed) 99,999,999 devices.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agomeson: link libm
Laine Stump [Wed, 26 Aug 2020 18:22:07 +0000 (14:22 -0400)] 
meson: link libm

On some platforms libm (needed for the pow() function) isn't being
linked in somehow. This patch adds the necessary bits to assure that
it's linked in when necessary.

Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 20a62b42ec001310a6329d7ee2021f0737d534ef)

4 years agomeson: Use @BASENAME@ more
Andrea Bolognani [Tue, 25 Aug 2020 16:30:57 +0000 (18:30 +0200)] 
meson: Use @BASENAME@ more

This patch takes care of just the obvious cases: there are
many more situations where the data we pass to configure_file()
could likely be obtained in a more effective way, but we can
address the low-hanging fruits as a first approximation.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agonss: Finish renaming of HAVE_BSD_NSS macro
Michal Privoznik [Tue, 1 Sep 2020 09:19:26 +0000 (11:19 +0200)] 
nss: Finish renaming of HAVE_BSD_NSS macro

When switching to meson, some of HAVE_* macros were renamed to
WITH_ because they did not reflect whether the build platform has
or doesn't have something, but whether we are building with some
functionality turned on or off. This is the case with
HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
did not expose nss_module_register() function which made the
plugin unusable:

https://www.redhat.com/archives/libvir-list/2020-September/msg00000.html

Fixes: c74268705557a6781788ba011492c15df2e3df11
Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agorpm: Fix conditional for defining %_vpath_builddir for RHEL <= 7
Neal Gompa [Sun, 30 Aug 2020 00:09:18 +0000 (20:09 -0400)] 
rpm: Fix conditional for defining %_vpath_builddir for RHEL <= 7

The conditional was incorrectly overriding %_vpath_builddir when
%rhel is not defined, which led to surprising behavior when the
global %_vpath_builddir path is set on Fedora already.

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
Message-Id: <20200830000918.11431-1-ngompa13@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Validate memory hotplug in domainValidateCallback instead of cmd line generator
Michal Privoznik [Tue, 28 Jul 2020 08:51:32 +0000 (10:51 +0200)] 
qemu: Validate memory hotplug in domainValidateCallback instead of cmd line generator

When editing a domain with hotplug enabled, I removed the only
NUMA node it had and got no error. I got the error later though,
when starting the domain. This is not as user friendly as it can
be. Move the validation call out from command line generator and
into domain validator (which is called prior to starting cmd line
generation anyway).

When doing this, I had to remove memory-hotplug-nonuma xml2xml
test case because there is no way the test case can succeed,
obviously.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoPost-release version bump to 6.8.0
Jiri Denemark [Tue, 1 Sep 2020 07:10:30 +0000 (09:10 +0200)] 
Post-release version bump to 6.8.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoRelease of libvirt-6.7.0 v6.7.0
Jiri Denemark [Tue, 1 Sep 2020 07:08:47 +0000 (09:08 +0200)] 
Release of libvirt-6.7.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoRNG: Allow interleaving of /domain/cpu/numa/cell children
Michal Privoznik [Mon, 31 Aug 2020 09:35:47 +0000 (11:35 +0200)] 
RNG: Allow interleaving of /domain/cpu/numa/cell children

So far, the <cell/> element can have two types of children
elements: <distances/> and <cache/> (which can be repeated more
times). However, there is no reason to require specific order in
input XML. Allow elements to be interleaved.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agonews: mention removal of autogenerated macvtap names from migration XML
Laine Stump [Fri, 28 Aug 2020 17:40:40 +0000 (13:40 -0400)] 
news: mention removal of autogenerated macvtap names from migration XML

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Remove extraneous plus signs from virsh man page v6.7.0-rc2
Martin Kletzander [Fri, 28 Aug 2020 12:58:38 +0000 (14:58 +0200)] 
docs: Remove extraneous plus signs from virsh man page

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonews: mention bhyve sound support
Roman Bogorodskiy [Thu, 27 Aug 2020 14:07:48 +0000 (18:07 +0400)] 
news: mention bhyve sound support

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoNEWS: Document improvements/bug fixes for upcoming release
Michal Privoznik [Fri, 28 Aug 2020 11:33:11 +0000 (13:33 +0200)] 
NEWS: Document improvements/bug fixes for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agonews: Document the `role` attribute for shmem device
Wang Xin [Fri, 21 Aug 2020 08:53:00 +0000 (16:53 +0800)] 
news: Document the `role` attribute for shmem device

Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 27 Aug 2020 08:44:15 +0000 (10:44 +0200)] 
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10366 of 10366 strings)

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

Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
4 years agoUpdate translation files
Weblate [Thu, 27 Aug 2020 08:44:11 +0000 (10:44 +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/

Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
4 years agoTranslated using Weblate (Polish)
Piotr Drąg [Thu, 27 Aug 2020 08:44:05 +0000 (10:44 +0200)] 
Translated using Weblate (Polish)

Currently translated at 23.6% (2447 of 10349 strings)

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

Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
Translated using Weblate (Polish)

Currently translated at 23.6% (2447 of 10349 strings)

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

Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
4 years agoTranslated using Weblate (Polish)
Szymon Scholz [Thu, 27 Aug 2020 08:44:01 +0000 (10:44 +0200)] 
Translated using Weblate (Polish)

Currently translated at 23.6% (2445 of 10349 strings)

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

Signed-off-by: Szymon Scholz <szymonscholz@gmail.com>
Translated using Weblate (Polish)

Currently translated at 23.6% (2445 of 10349 strings)

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

Signed-off-by: Szymon Scholz <szymonscholz@gmail.com>
4 years agoTranslated using Weblate (Polish)
Piotr Drąg [Thu, 27 Aug 2020 08:43:58 +0000 (10:43 +0200)] 
Translated using Weblate (Polish)

Currently translated at 23.6% (2445 of 10349 strings)

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

Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
4 years agoTranslated using Weblate (Polish)
Szymon Scholz [Thu, 27 Aug 2020 08:43:53 +0000 (10:43 +0200)] 
Translated using Weblate (Polish)

Currently translated at 23.6% (2443 of 10349 strings)

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

Signed-off-by: Szymon Scholz <szymonscholz@gmail.com>
Translated using Weblate (Polish)

Currently translated at 23.6% (2443 of 10349 strings)

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

Signed-off-by: Szymon Scholz <szymonscholz@gmail.com>
4 years agoTranslated using Weblate (Polish)
Piotr Drąg [Thu, 27 Aug 2020 08:43:49 +0000 (10:43 +0200)] 
Translated using Weblate (Polish)

Currently translated at 23.6% (2443 of 10349 strings)

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

Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
4 years agoTranslated using Weblate (Polish)
Szymon Scholz [Thu, 27 Aug 2020 08:43:44 +0000 (10:43 +0200)] 
Translated using Weblate (Polish)

Currently translated at 23.5% (2437 of 10349 strings)

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

Signed-off-by: Szymon Scholz <szymonscholz@gmail.com>
4 years agodocs: add kbase entry for migrationinternals
Fangge Jin [Thu, 20 Aug 2020 10:09:24 +0000 (18:09 +0800)] 
docs: add kbase entry for migrationinternals

Commit c051e56d27 added migrationinternals.rst in kbase, but the
entry was missing.

Signed-off-by: Fangge Jin <fjin@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: formatdomain: fix `since` tag
Ján Tomko [Tue, 11 Aug 2020 23:05:03 +0000 (01:05 +0200)] 
docs: formatdomain: fix `since` tag

Fix the `since` tag for the disk target.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agomeson: don't install sysconf files unconditionally
Roman Bogorodskiy [Wed, 26 Aug 2020 13:47:14 +0000 (17:47 +0400)] 
meson: don't install sysconf files unconditionally

There's no need to install sysconf files when init script installation
was not requested, i.e. when configured with init_script=none.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpm: always disable ceph on 32-bit
Daniel P. Berrangé [Fri, 21 Aug 2020 11:29:02 +0000 (12:29 +0100)] 
rpm: always disable ceph on 32-bit

The logic to disable Ceph on 32-bit was protected by a Fedora
conditional. This is redundant as RHEL hasn't shipped any
32-bit platforms for years.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: Refresh potfile for v6.7.0 v6.7.0-rc1
Jiri Denemark [Wed, 26 Aug 2020 09:18:25 +0000 (11:18 +0200)] 
po: Refresh potfile for v6.7.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoapparmor: allow libvirtd to call virtiofsd
Kevin Locke [Tue, 25 Aug 2020 13:31:27 +0000 (07:31 -0600)] 
apparmor: allow libvirtd to call virtiofsd

When using [virtiofs], libvirtd must launch [virtiofsd] to provide
filesystem access on the host.  When a guest is configured with
virtiofs, such as:

    <filesystem type='mount' accessmode='passthrough'>
      <driver type='virtiofs'/>
      <source dir='/path'/>
      <target dir='mount_tag'/>
    </filesystem>

Attempting to start the guest fails with:

    internal error: virtiofsd died unexpectedly

/var/log/libvirt/qemu/$name-fs0-virtiofsd.log contains (as a single
line, wrapped below):

    libvirt:  error : cannot execute binary /usr/lib/qemu/virtiofsd:
    Permission denied

dmesg contains (as a single line, wrapped below):

    audit: type=1400 audit(1598229295.959:73): apparmor="DENIED"
    operation="exec" profile="libvirtd" name="/usr/lib/qemu/virtiofsd"
    pid=46007 comm="rpc-worker" requested_mask="x" denied_mask="x"
    fsuid=0 ouid=0

To avoid this, allow execution of virtiofsd from the libvirtd AppArmor
profile.

[virtiofs]: https://libvirt.org/kbase/virtiofs.html
[virtiofsd]: https://www.qemu.org/docs/master/interop/virtiofsd.html

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agoutil: use host module suffix when loading drivers
Scott Shambarger [Tue, 25 Aug 2020 23:47:07 +0000 (16:47 -0700)] 
util: use host module suffix when loading drivers

Driver module loaders current hardcode ".so" as the file
extension.  On MacOS, meson uses ".dylib" as a module file extension.
This patch adds VIR_FILE_MODULE_EXT to virfile.h defined as the
hosts module extension, and updates driver module loaders to make
use of it.

Signed-off-by: Scott Shambarger <scott-libvirt@shambarger.net>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agodomaincapsmock: mock virHostCPUGetMicrocodeVersion()
Daniel Henrique Barboza [Mon, 24 Aug 2020 13:27:54 +0000 (10:27 -0300)] 
domaincapsmock: mock virHostCPUGetMicrocodeVersion()

Previous patch handled the runtime case where a non-x86 host is
fetching /proc/cpuinfo data for a microcode info that we know
it doesn't exist. This change alone speeded everything by a
bit for non-x86, but there is at least one major culprit left.

qemuxml2argvtest does several arch-specific tests, and a good
chunk of them are x86 exclusive. This means that 'hostArch'
will be seen as x86 for these tests, even when running in
non-x86 hosts. In a Power 9 server with 128 CPUs, qemuxml2argvtest
takes 298 seconds to complete in average, and 'perf record'
indicates that 95% of the time is spent in
virHostCPUGetMicrocodeVersion().

This patch mocks virHostCPUGetMicrocodeVersion() to always return
0 in the tests, avoiding /proc/cpuinfo reads. This will make all
tests behave arch-agnostic, and the microcode value being 0 has no
impact on any existing test.

This is a CI speed across the board for all archs, including x86,
given that we're not reading /proc/cpuinfo in the tests. For
a Thinkpad T480 laptop with 8 Intel i7 CPUs, qemuxml2argvtest
went from 15.50 sec to 12.50 seconds. The performance gain is even
more noticeable for huge servers with lots of CPUs. For the
Power 9 server mentioned above, this patch speeds qemuxml2argvtest
to 9 seconds, down from 298 sec.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirhostcpu.c: skip non x86 hosts in virHostCPUGetMicrocodeVersion()
Daniel Henrique Barboza [Mon, 24 Aug 2020 13:27:53 +0000 (10:27 -0300)] 
virhostcpu.c: skip non x86 hosts in virHostCPUGetMicrocodeVersion()

Non-x86 archs does not have a 'microcode' version like x86. This is
covered already inside the function - just return 0 if no microcode
is found. Regardless of that, a read of /proc/cpuinfo is always made.
Each read will invoke the kernel to fill in the CPU details every time.

Now let's consider a non-x86 host, like a Power 9 server with 128 CPUs.
Each /proc/cpuinfo read will need to fetch data for each CPU and it
won't even matter because we know beforehand that PowerPC chips don't
have microcode information.

We can do better for non-x86 hosts by skipping this process entirely.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirhostcpu.c: modernize virHostCPUGetMicrocodeVersion()
Daniel Henrique Barboza [Mon, 24 Aug 2020 13:27:52 +0000 (10:27 -0300)] 
virhostcpu.c: modernize virHostCPUGetMicrocodeVersion()

Use g_autofree and remove the cleanup label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agobuild: add -Wdeclaration-after-statement
Ján Tomko [Mon, 27 Jul 2020 20:49:55 +0000 (22:49 +0200)] 
build: add -Wdeclaration-after-statement

Now that all the users have been converted or silenced,
let's enable this warning.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: use VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
Ján Tomko [Mon, 3 Aug 2020 15:32:22 +0000 (17:32 +0200)] 
tests: use VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT

Some test rely too much on declaring variables in the middle
of the function. Use the macro to locally suppress the warning

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc: internal: add VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
Ján Tomko [Mon, 3 Aug 2020 15:31:32 +0000 (17:31 +0200)] 
src: internal: add VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT

Add a macro to suppress the warning.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoVIR_XPATH_NODE_AUTORESTORE: remove semicolon from users
Ján Tomko [Tue, 28 Jul 2020 19:47:48 +0000 (21:47 +0200)] 
VIR_XPATH_NODE_AUTORESTORE: remove semicolon from users

Since the macro no longer includes the 'ignore_value'
statement, stop putting another empty statement after it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: xml: use pragma in VIR_XPATH_NODE_AUTORESTORE
Ján Tomko [Tue, 28 Jul 2020 19:47:29 +0000 (21:47 +0200)] 
util: xml: use pragma in VIR_XPATH_NODE_AUTORESTORE

The VIR_XPATH_NODE_AUTORESTORE contains an ignore_value
statement to silence an unused variable warning on clang.

Use a pragma instead, which is not a statement.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>