]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agonetwork: force re-creation of iptables private chains on firewalld restart
Laine Stump [Fri, 8 May 2020 01:54:39 +0000 (21:54 -0400)]
network: force re-creation of iptables private chains on firewalld restart

When firewalld is stopped, it removes *all* iptables rules and chains,
including those added by libvirt. Since restarting firewalld means
stopping and then starting it, any time it is restarted, libvirt needs
to recreate all the private iptables chains it uses, along with all
the rules it adds.

We already have code in place to call networkReloadFirewallRules() any
time we're notified of a firewalld start, and
networkReloadFirewallRules() will call
networkPreReloadFirewallRules(), which calls
networkSetupPrivateChains(); unfortunately that last call is called
using virOnce(), meaning that it will only be called the first time
through networkPreReloadFirewallRules() after libvirtd starts - so of
course when firewalld is later restarted, the call to
networkSetupPrivateChains() is skipped.

The neat and tidy way to fix this would be if there was a standard way
to reset a pthread_once_t object so that the next time virOnce was
called, it would think the function hadn't been called, and call it
again. Unfortunately, there isn't any official way of doing that (we
*could* just fill it with 0 and hope for the best, but that doesn't
seem very safe.

So instead, this patch just adds a static variable called
chainInitDone, which is set to true after networkSetupPrivateChains()
is called for the first time, and then during calls to
networkPreReloadFirewallRules(), if chainInitDone is set, we call
networkSetupPrivateChains() directly instead of via virOnce().

It may seem unsafe to directly call a function that is meant to be
called only once, but I think in this case we're safe - there's
nothing in the function that is inherently "once only" - it doesn't
initialize anything that can't safely be re-initialized (as long as
two threads don't try to do it at the same time), and it only happens
when responding to a dbus message that firewalld has been started (and
I don't think it's possible for us to be processing two of those at
once), and even then only if the initial call to the function has
already been completed (so we're safe if we receive a firewalld
restart call at a time when we haven't yet called it, or even if
another thread is already in the process of executing it. The only
problematic bit I can think of is if another thread is in the process
of adding an iptable rule at the time we're executing this function,
but 1) none of those threads will be trying to add chains, and 2) if
there was a concurrency problem with other threads adding iptables
rules while firewalld was being restarted, it would still be a problem
even without this change.

This is yet another patch that fixes an occurrence of this error:

COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --insert LIBVIRT_INP --in-interface virbr0 --protocol tcp --destination-port 67 --jump ACCEPT' failed: iptables: No chain/target/match by that name.

In particular, this resolves: https://bugzilla.redhat.com/1813830

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonetwork: make it safe to call networkSetupPrivateChains() multiple times
Laine Stump [Fri, 8 May 2020 02:32:59 +0000 (22:32 -0400)]
network: make it safe to call networkSetupPrivateChains() multiple times

networkSetupPrivateChains() is currently called only once per run of
libvirtd, so it can assume that errInitV4 and errInitV6 are empty/null
when it is called. In preparation for potentially calling this
function multiple times during one run, this patch moves the reset of
errInitV[46] to the top of the function, to assure no memory is
leaked.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirDevMapperGetTargetsImpl: quit early if device is not a devmapper target
Michal Privoznik [Fri, 24 Apr 2020 11:17:51 +0000 (13:17 +0200)]
virDevMapperGetTargetsImpl: quit early if device is not a devmapper target

As suggested in the linked bug, libvirt should firstly check
whether the major number of the device is device mapper major.
Because if it isn't subsequent DM_DEVICE_DEPS task may not only
fail, but also yield different results. In the bugzilla this is
demonstrated by creating a devmapper target named 'loop0' and
then creating loop target /dev/loop0. When the latter is then
passed to a domain, our virDevMapperGetTargetsImpl() function
blindly asks devmapper to provide target dependencies for
/dev/loop0 and because of the way devmapper APIs work, it will
'sanitize' the input by using the last component only which is
'loop0' and thus return different results than expected.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1823976
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: Document list-tables as recommended
Andrea Bolognani [Thu, 7 May 2020 12:45:03 +0000 (14:45 +0200)]
docs: Document list-tables as recommended

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: Use definition list instead of table in coding style
Andrea Bolognani [Thu, 7 May 2020 12:38:35 +0000 (14:38 +0200)]
docs: Use definition list instead of table in coding style

This format is much easier to tweak and update.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: Drop glib-adoption.rst
Andrea Bolognani [Thu, 7 May 2020 17:28:30 +0000 (19:28 +0200)]
docs: Drop glib-adoption.rst

It's been more than six months since we adopted GLib and we've
been pretty aggressive at replacing our homegrown APIs with more
standard ones, so by now most of the symbols mentioned in this
document haven't been around for quite a long time already.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: introduce a page showing a overall CI dashboard
Daniel P. Berrangé [Mon, 4 May 2020 12:15:43 +0000 (13:15 +0100)]
docs: introduce a page showing a overall CI dashboard

With the move to GitLab CI one of the things we miss from Jenkins is a
single page dashboard showing CI status across all projects. This is a
very simple replacement that uses badges for CI pipeline status.

A CSS tweak is needed because RST->HTML adds redundant <p> tags inside
table cells which causes excessive vertical whitespace to appear.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemuDomainCleanupRun: Actually run cleanup callbacks in reverse order
Michal Privoznik [Tue, 5 May 2020 11:45:44 +0000 (13:45 +0200)]
qemuDomainCleanupRun: Actually run cleanup callbacks in reverse order

We have a framework to register cleanup callbacks that are run
when a domain is shut down. The idea is to run callbacks in
reverse order than they were registered. However, looking at the
code this is not the case. Fortunately, this framework is used to
register a single callback and a single callback only -
qemuMigrationDstPrepareCleanup() - therefore there was no problem
just yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: Fix the libxl xml2domconfig test
Jim Fehlig [Thu, 7 May 2020 23:38:41 +0000 (17:38 -0600)]
tests: Fix the libxl xml2domconfig test

Commit a13b2905f7 missed an adjustment to a test that is only run when
building against xen <= 4.9, where LIBXL_HAVE_BUILDINFO_NESTED_HVM is
not defined. Adjust fullvirt-cpuid-legacy-nest test similar to the others.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
4 years agolibxl: vga.kind none when no device specified
Artur Puzio [Thu, 7 May 2020 11:24:35 +0000 (13:24 +0200)]
libxl: vga.kind none when no device specified

When no video device is specified in config we should set both
hvm.nographic to 1 and hvm.vga.kind to NONE.

Without hvm.vga.kind=LIBXL_VGA_INTERFACE_TYPE_NONE both -nographic and
-device 'cirrus-vga' are on qemu cmdline.

Signed-off-by: Artur Puzio <contact@puzio.waw.pl>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agoRevert "tests: Use qemu:///embed to simplify fakerootdir management"
Andrea Bolognani [Thu, 7 May 2020 20:31:04 +0000 (22:31 +0200)]
Revert "tests: Use qemu:///embed to simplify fakerootdir management"

Turns out that it's not enough to pass the qemu:///embed root to
virQEMUDriverConfigNew(), you also have to make sure the same
string is copied into the virQEMUDriver structure yourself, and
not doing so in our case resulted in the cleanup never happening
and in distcheck failing because of that.

On the other hand, actually setting config->embeddedRoot would
result in different paths being generated for each test run, which
would obviously break qemuxml2argvtest, so that's not an option
either.

This reverts commit d98cc1968e7961cb02ed07406451a7b710cc2f24.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agotests: Use qemu:///embed to simplify fakerootdir management
Andrea Bolognani [Wed, 6 May 2020 11:38:40 +0000 (13:38 +0200)]
tests: Use qemu:///embed to simplify fakerootdir management

Now that the QEMU driver natively supports storing all its runtime
data inside an arbitrary directory, we can avoid having multiple
copies of the same logic in the test suite.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: poison $HOME and $XDG_RUNTIME_DIR env variables
Daniel P. Berrangé [Mon, 4 May 2020 12:09:45 +0000 (13:09 +0100)]
tests: poison $HOME and $XDG_RUNTIME_DIR env variables

To attempt to catch unit tests which accidentally create files in $HOME,
or $XDG_RUNTIME_DIR, poison these env vars by pointing them to
directories which don't exist. This should give easier to debug test
failures. For example:

$ VIR_TEST_DEBUG=1 ./qemuhotplugtest
Could not initialize HostdevManager - operation failed: Failed to create state dir '/bad-test-used-env-xdg-runtime-dir/libvirt/hostdevmgr'

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agokeycodemapdb: update submodule for win32 keycode fix
Daniel P. Berrangé [Tue, 5 May 2020 12:57:56 +0000 (13:57 +0100)]
keycodemapdb: update submodule for win32 keycode fix

Fix win32 keycode for VK_OEM_102

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: document protected branches and tags
Daniel P. Berrangé [Wed, 6 May 2020 11:08:56 +0000 (12:08 +0100)]
docs: document protected branches and tags

We need to prevent accidental deletion of release tags and maint
branches.

We need to ensure that shared CI runners are enabled on all repos.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: Introduce virhostdevmock
Andrea Bolognani [Wed, 6 May 2020 12:38:42 +0000 (14:38 +0200)]
tests: Introduce virhostdevmock

We need this for all tests that use virHostdevManager, because
during creation of this object for unprivileged connections
like those used in the test suite we would end up writing inside
the user's home directory.

That's bad manners in general, but when running the test suite
inside a purposefully constrained environment such as the one
exposed by pbuilder, it turns into an outright test failure:

  Could not initialize HostdevManager - operation failed: Failed
  to create state dir '/nonexistent/.cache/libvirt/hostdevmgr'

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Add capabilities for QEMU 5.0.0 on riscv64
Andrea Bolognani [Wed, 6 May 2020 08:33:58 +0000 (10:33 +0200)]
tests: Add capabilities for QEMU 5.0.0 on riscv64

The churn in the output files is caused primarily by the fact that
blockdev support has been introduced.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Update capabilities for QEMU 5.0.0 on ppc64
Andrea Bolognani [Wed, 6 May 2020 09:05:39 +0000 (11:05 +0200)]
tests: Update capabilities for QEMU 5.0.0 on ppc64

The churn in the output files is caused primarily by the fact that
replies were generated on a POWER9 machine, which is good because
we didn't have coverage of that before.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Update capabilities for QEMU 5.0.0 on aarch64
Andrea Bolognani [Wed, 6 May 2020 09:19:14 +0000 (11:19 +0200)]
tests: Update capabilities for QEMU 5.0.0 on aarch64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agogitlab: move some jobs onto CentOS 8
Daniel P. Berrangé [Mon, 4 May 2020 16:21:35 +0000 (17:21 +0100)]
gitlab: move some jobs onto CentOS 8

So that we don't have to chase frequent Fedora releases, move the
non-build related jobs onto the long life CentOS 8 distro.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: Enable directory override for qemucapsprobe
Andrea Bolognani [Wed, 6 May 2020 09:50:31 +0000 (11:50 +0200)]
tests: Enable directory override for qemucapsprobe

Currently, qemucapsprobe fails when libvirt is not already installed
on the system:

  $ ./tests/qemucapsprobe /path/to/qemu-system-ppc64 >/dev/null
  I/O warning : failed to load external entity "/usr/share/libvirt/cpu_map/index.xml"
  2020-05-06 09:49:59.136+0000: 269822: info : libvirt version: 6.4.0
  2020-05-06 09:49:59.136+0000: 269822: info : hostname: [...]
  2020-05-06 09:49:59.136+0000: 269822: warning : virQEMUCapsLogProbeFailure:5127 :
  Failed to probe capabilities for /path/to/qemu-system-ppc64: XML error: failed to
  parse xml document '/usr/share/libvirt/cpu_map/index.xml'

It would be great if the tool could work entirely out of the build
directory, and this patch achieves just that.

Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Don't use CPU from host capabilities as host-model on ARM
Jiri Denemark [Tue, 5 May 2020 16:35:26 +0000 (18:35 +0200)]
qemu: Don't use CPU from host capabilities as host-model on ARM

We never supported host-model CPUs on ARM and we don't want to support
them even once patches for direct detection of host CPU are merged. And
since using host CPU definition for host-model CPUs exists only for
backward compatibility, we should not use it for any host-model support
added in the future. Such enhancement should exclusively use the result
of query-cpu-model-expansion. Until proper host-model support is
implemented for ARM (if ever), we need to make sure the detected host
CPU is not accidentally used for host-model CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemucapabilitiesdata: Add test data for x86_64 for the qemu-5.1 dev cycle
Peter Krempa [Thu, 30 Apr 2020 10:16:10 +0000 (12:16 +0200)]
qemucapabilitiesdata: Add test data for x86_64 for the qemu-5.1 dev cycle

Start the new capability file for the new development cycle of QEMU.

Note that compared to previous version this was generated on an AMD cpu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemucapabilitiesdata: Update x86_64 capabilities to 5.0.0 release
Peter Krempa [Thu, 30 Apr 2020 10:09:41 +0000 (12:09 +0200)]
qemucapabilitiesdata: Update x86_64 capabilities to 5.0.0 release

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosystemd: start libvirtd after firewalld/iptables services
Laine Stump [Fri, 1 May 2020 04:05:50 +0000 (00:05 -0400)]
systemd: start libvirtd after firewalld/iptables services

When a system has enabled the iptables/ip6tables services rather than
firewalld, there is no explicit ordering of the start of those
services vs. libvirtd. This creates a problem when libvirtd.service is
started before ip[6]tables, as the latter, when it finally is started,
will remove all of the iptables rules that had previously been added
by libvirt, including the custom chains where libvirt's rules are
kept. This results in an error message similar to the following when a
user subsequently tries to start a new libvirt network:

 "Error while activating network: Call to virNetworkCreate failed:
 internal error: Failed to apply firewall rules
 /usr/sbin/ip6tables -w --table filter --insert LIBVIRT_FWO \
   --in-interface virbr2 --jump REJECT:
 ip6tables: No chain/target/match by that name."

(Prior to logging this error, it also would have caused failure to
forward (or block) traffic in some cases, e.g. for guests on a NATed
network, since libvirt's rules to forward/block had all been deleted
and libvirt didn't know about it, so it couldn't fix the problem)

When this happens, the problem can be remedied by simply restarting
libvirtd.service (which has the side-effect of reloading all
libvirt-generated firewall rules)

Instead, we can just explicitly stating in the libvirtd.service file
that libvirtd.service should start after ip6tables.service and
ip6tables.service, eliminating the race condition that leads to the
error.

There is also nothing (that I can see) in the systemd .service files
to guarantee that firewalld.service will be started (if enabled) prior
to libvirtd.service. The same error scenario given above would occur
if libvirtd.service started before firewalld.service.  Even before
that, though libvirtd would have detected that firewalld.service was
disabled, and then turn off all firewalld support. So, for example,
firewalld's libvirt zone wouldn't be used, and most likely traffic
from guests would therefore be blocked (all with no external
indication of the source of the problem other than a debug-level log
when libvirtd was started saying that firewalld wasn't in use); also
libvirtd wouldn't notice when firewalld reloaded its rules (which also
simultaneously deletes all of libvirt's rules).

I'm not aware of any reports that have been traced back to
libvirtd.service starting before firewalld.service, but have seen that
error reported multiple times, and also don't see an existing
dependency that would guarantee firewalld.service starts before
libvirtd.service, so it's possible it's been happening and we just
haven't gotten to the bottom of it.

This patch adds an After= line to the libvirtd.service file for each
of iptables.service, ip6tables.service, and firewalld.servicee, which
should guarantee that libvirtd.service isn't started until systemd has
started whichever of the others is enabled.

This race was diagnosed, and patch proposed, by Jason Montleon in
https://bugzilla.redhat.com/1723698 . At the time (April 2019) danpb
agreed with him that this change to libvirtd.service was a reasonable
thing to do, but I guess everyone thought someone else was going to
post a patch, so in the end nobody did.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: note that <dnsmasq:option> was added in libvirt 5.6.0
Laine Stump [Thu, 30 Apr 2020 20:33:00 +0000 (16:33 -0400)]
docs: note that <dnsmasq:option> was added in libvirt 5.6.0

To make it simpler to answer questions of "Why doesn't this thing work
for me?"

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Xen improvements
Jim Fehlig [Mon, 4 May 2020 21:52:34 +0000 (15:52 -0600)]
docs: Xen improvements

In formatdomain, using 'libxl' and 'xen' is redundant since they now
both refer to the same driver. 'xen' predates 'libxl' and unambiguously
identifies the Xen hypervisor, so drop the use of 'libxl'.

In aclpolkit, the connection URI was erroneously identified as 'libxl'
and the name 'xenlight'. Change the URI to 'xen' and driver name to 'Xen'.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: Clarify that 'xenlight' should only be used internally
Jim Fehlig [Mon, 4 May 2020 21:20:37 +0000 (15:20 -0600)]
libxl: Clarify that 'xenlight' should only be used internally

The libxl driver has suffered an identity crisis since its introduction.
It took on the name 'libxl' since at the time libvirt already contained
a 'xen' driver for the old Xen toolstack implementation. 'libxl' is short
for libxenlight, which is often called xenlight. Unfortunately all forms
of the name are used in the libxl driver.

The only remaining use of the 'xenlight' form is when interacting with
the host device manager, which is difficult to change since it would
cause problems when upgrading the driver.

Rename the #define to make it clear the 'xenlight' form is internal and
add a comment describing why the name exists and that its use should be
discouraged.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: Use the name 'Xen' in driver tables
Jim Fehlig [Mon, 4 May 2020 20:51:32 +0000 (14:51 -0600)]
libxl: Use the name 'Xen' in driver tables

The libxl driver declares its name as 'Xen' through the public
virConnectGetType() API. In the virHypervisorDriver table the name is
set to 'xenlight'. To add more confusion, the name is set to 'LIBXL'
in the virStateDriver. For consistency, use the same name in the driver
tables as reported in the public virConnectGetType() API.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: fix driver name check for libxl driver
Daniel P. Berrangé [Mon, 4 May 2020 16:41:46 +0000 (17:41 +0100)]
remote: fix driver name check for libxl driver

The virConnectGetType() returns "Xen" for libxl, not "LIBXL".

This prevents users opening a connection to the libxl driver when using
the modular daemons.

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirt-host-validate-bhyve.c: Reintroduce @ret to virHostValidateBhyve()
Michal Privoznik [Tue, 5 May 2020 12:34:00 +0000 (14:34 +0200)]
virt-host-validate-bhyve.c: Reintroduce @ret to virHostValidateBhyve()

This partially reverts fe65e9c8b50c9029cba0e8c386162d293cd443d2.

In the referenced commit I removed @ret from
virHostValidateBhyve() thinking it wasn't used when in fact it is
- it's usage is hidden under MODULE_STATUS_WARN(). Reintroduce
the variable back.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: Fix boolean assignment
Michal Privoznik [Tue, 5 May 2020 06:05:18 +0000 (08:05 +0200)]
src: Fix boolean assignment

In a few places we use 0 and false, or 1 and true interchangeably
even though the variable or return type in question is boolean.
Fix those places.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolib: Drop needless ret variables
Michal Privoznik [Tue, 5 May 2020 09:14:16 +0000 (11:14 +0200)]
lib: Drop needless ret variables

There are few places where a return variable is introduced (ret
or retval), but then is never changed and is then passed to
return. Well, we can return the value that the variable is
initialized to directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: Make some functions void
Michal Privoznik [Tue, 5 May 2020 09:19:11 +0000 (11:19 +0200)]
rpc: Make some functions void

There are few functions that currently return an integer but in
fact they always return the same integer (zero). Make them void.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirnetserver: Check for virNetServerClientInitKeepAlive() retval
Michal Privoznik [Tue, 5 May 2020 09:29:13 +0000 (11:29 +0200)]
virnetserver: Check for virNetServerClientInitKeepAlive() retval

Since it's introduction in v0.9.7-147-gf4324e3292 the
virNetServerClientInitKeepAlive() function returned nothing than
a negative one. Fortunately, this did not pose any problem
because we ignored the retval happily. Well, it's time to check
for the retval because the function might fail regularly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoDrop needless variable
Michal Privoznik [Mon, 4 May 2020 15:03:42 +0000 (17:03 +0200)]
Drop needless variable

Instead of the following pattern:

  type ret;
  ...
  ret = func();
  return ret;

we can use:

  return func()

directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agomaint: Post-release version bump to 6.4.0
Michal Privoznik [Tue, 5 May 2020 08:52:22 +0000 (10:52 +0200)]
maint: Post-release version bump to 6.4.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRelease of libvirt-6.3.0
Daniel Veillard [Tue, 5 May 2020 06:49:30 +0000 (08:49 +0200)]
Release of libvirt-6.3.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agoCONTRIBUTING: Include note about build system tools
Andrea Bolognani [Mon, 27 Apr 2020 10:48:51 +0000 (12:48 +0200)]
CONTRIBUTING: Include note about build system tools

Debian always runs autoreconf at package build time, which means
that apt-get build-dep will bring in everything that's needed to
build libvirt from a git clone; Fedora and RHEL, however, skip
this step, so we have to install some extra packages manually.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoCONTRIBUTING: Indent command by three spaces
Andrea Bolognani [Mon, 27 Apr 2020 10:49:06 +0000 (12:49 +0200)]
CONTRIBUTING: Indent command by three spaces

This is the proper way to do it according to our reStructuredText
style guidelines.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agogitlab: update list of distros to use latest versions
Daniel P. Berrangé [Mon, 4 May 2020 12:06:56 +0000 (13:06 +0100)]
gitlab: update list of distros to use latest versions

Replace Fedora 30 with Fedora 32
Replace Ubuntu 16.04 with Ubuntu 20.04

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agogitlab: convert to shared container for DCO check
Daniel P. Berrangé [Fri, 1 May 2020 10:57:33 +0000 (11:57 +0100)]
gitlab: convert to shared container for DCO check

This removes the locally maintained DCO checking script in favour of the
shared container image provided by libvirt-ci.git.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirsh: Fix return code for dump
Xu Yandong [Mon, 4 May 2020 08:36:19 +0000 (16:36 +0800)]
virsh: Fix return code for dump

After the commit dc0771c, ret variable no longer
represents the status of the return code, use
data->ret replace it.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Update for libvirt 6.3.0
Michal Privoznik [Mon, 4 May 2020 07:14:33 +0000 (09:14 +0200)]
news: Update for libvirt 6.3.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Fix grammar in virsh.rst
Andrea Bolognani [Fri, 1 May 2020 09:37:19 +0000 (11:37 +0200)]
docs: Fix grammar in virsh.rst

"allows to" -> "allows one to"

Spotted by Lintian (spelling-error-in-manpage tag).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: re-add padding to the saved state images
Daniel P. Berrangé [Mon, 27 Apr 2020 13:35:43 +0000 (14:35 +0100)]
qemu: re-add padding to the saved state images

In the past we added 1024 bytes of padding to saved state images so that
users can run "virsh managedsave-edit $GUEST" and make XML changes which
increase the size of the XML document. This padding was accidentally
lost a while back

  commit 6b9b21db7079888a05d192b079e68290bdf14a76
  Author: Peter Krempa <pkrempa@redhat.com>
  Date:   Wed Feb 17 13:10:11 2016 +0100

    qemu: Remove unnecessary calculations in qemuDomainSaveMemory

The original 1024 bytes was unreasonably stingy when we consider that
the QEMU state is typically going to be many 100's of MB in size. Thus
this adds 64 KB of padding after the XML which should cope with any
plausible modifications a user will want to make.

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

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Add virQEMUCapsGetVirtType convenience function
Tobin Feldman-Fitzthum [Wed, 22 Apr 2020 21:50:43 +0000 (17:50 -0400)]
qemu: Add virQEMUCapsGetVirtType convenience function

Signed-off-by: Tobin Feldman-Fitzthum <tobin@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Fix capabilities probing with TCG
Tobin Feldman-Fitzthum [Wed, 22 Apr 2020 21:50:42 +0000 (17:50 -0400)]
qemu: Fix capabilities probing with TCG

Only probe QEMU binary with accel=tcg if TCG is not disabled.
Similarly, only add a VIR_DOMAIN_VIRT_QEMU guest if TCG
is available.

Signed-off-by: Tobin Feldman-Fitzthum <tobin@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Introduce QEMU_CAPS_TCG
Tobin Feldman-Fitzthum [Tue, 28 Apr 2020 09:04:14 +0000 (11:04 +0200)]
qemu: Introduce QEMU_CAPS_TCG

Since QEMU 2.10 it is possible to disable TCG when building
QEMU. Introduce a capability that reflects this.

Signed-off-by: Tobin Feldman-Fitzthum <tobin@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: command: make qemuBuildVirtioOptionsStr void
Bjoern Walk [Thu, 23 Apr 2020 13:15:09 +0000 (15:15 +0200)]
qemu: command: make qemuBuildVirtioOptionsStr void

Now that qemuBuildVirtioOptionsStr can not fail anymore, remove its
return value and make it void.

Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: move virtio capability validation
Bjoern Walk [Thu, 23 Apr 2020 13:15:08 +0000 (15:15 +0200)]
qemu: move virtio capability validation

Move capability validation of virtio options from command line
generation to post-parse device validation where it belongs.

Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agotests: more fine-granular tests for virtio-options
Bjoern Walk [Thu, 23 Apr 2020 13:15:07 +0000 (15:15 +0200)]
tests: more fine-granular tests for virtio-options

Add separate tests for individual options and devices for virtio-options
to have the ability to do more fine-granular testing of various
combinations.

Also, add negative tests for unavailable capabilities.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agotests: use latest caps for virtio-options test
Bjoern Walk [Thu, 23 Apr 2020 13:15:06 +0000 (15:15 +0200)]
tests: use latest caps for virtio-options test

Convert the virtio-options test in qemuxml2argv and qemuxml2xml to use
the latest available QEMU capabilities.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonews: Update for the recent added pSeries features
Daniel Henrique Barboza [Mon, 27 Apr 2020 12:14:32 +0000 (09:14 -0300)]
news: Update for the recent added pSeries features

Update news.xml to inform about the availability of CFPC, SBBC and
IBS features.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Implement the IBS pSeries feature
Daniel Henrique Barboza [Mon, 27 Apr 2020 12:14:31 +0000 (09:14 -0300)]
qemu: Implement the IBS pSeries feature

This patch adds the implementation of the IBS pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_IBS capability added
in the previous patch.

IBS can have the following values: "broken", "workaround",
"fixed-ibs", "fixed-ccd" and "fixed-na".

This is the XML format for the cap:

<features>
  <ibs value='fixed-ibs'/>
</features>

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Add capability for IBS pSeries feature
Daniel Henrique Barboza [Mon, 27 Apr 2020 12:14:30 +0000 (09:14 -0300)]
qemu: Add capability for IBS pSeries feature

IBS (Indirect Branch Speculation) is the last capability added
in QEMU 2.12 related to Spectre mitigation for Power. It was
added in commit 4be8d4e7d935.

This patch introduces it as QEMU_CAPS_MACHINE_PSERIES_CAP_IBS.
Like CFPC and SBBC, users might want to tune in IBS based on
their HW and guest OS requirements, and it's better to do it
so in a proper Libvirt feature than to put QEMU arguments
in the middle of the domain XML.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Implement the SBBC pSeries feature
Daniel Henrique Barboza [Mon, 27 Apr 2020 12:14:29 +0000 (09:14 -0300)]
qemu: Implement the SBBC pSeries feature

This patch adds the implementation of the SBBC pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC capability added
in the previous patch.

Like the previously added CFPC feature, SBBC can have the values
"broken", "workaround" or "fixed". Extra code is required to handle
it since it's not a regular tristate capability.

This is the XML format for the cap:

<features>
  <sbbc value='workaround'/>
</features>

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Add capability for SBBC pSeries feature
Daniel Henrique Barboza [Mon, 27 Apr 2020 12:14:28 +0000 (09:14 -0300)]
qemu: Add capability for SBBC pSeries feature

SBBC (Speculation Barrier Bounds Checking) is another capability
related to Spectre mitigation efforts in Power processors. It
was implemented in QEMU 2.12 by commit 09114fd81799.

This patch introduces it as QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC to
be implemented in the next patch. Like the case with the now
implemented CFPC, exposing this feature in the XML allows for
a cleaner way for users to tune the SBBC accordingly, given
that not all hypervisor and guest setups supports this
Spectre mitigation.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Implement the CFPC pSeries feature
Daniel Henrique Barboza [Mon, 27 Apr 2020 12:14:27 +0000 (09:14 -0300)]
qemu: Implement the CFPC pSeries feature

This patch adds the implementation of the CFPC pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC capability added
in the previous patch.

CPFC can have the values "broken", "workaround" or "fixed". Extra
code is required to handle it since it's not a regular tristate
capability.

This is the XML format for the cap:

<features>
  <cfpc value='workaround'/>
</features>

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Add capability for CFPC pSeries feature
Daniel Henrique Barboza [Mon, 27 Apr 2020 12:14:26 +0000 (09:14 -0300)]
qemu: Add capability for CFPC pSeries feature

CFPC (Cache Flush on Privilege Change) is one of the capabilities
added to QEMU to mitigate Spectre vulnerabilities in Power chips.
It was implemented in QEMU 2.12 by commit 6898aed77f46.

This capability is still used today due to differences in how
the host setup (hardware and firmware/kernel) can handle this
mitigation. Its default value also varies with the pseries machine
version of the time. There's also certain OSes, like AIX, that
might not support the default value of the pseries machine the
guest uses.

Exposing this in the Libvirt XML as a feature will allow users to tune
CFPC values in a cleaner way, instead of hacking parameters in
<qemu:commandline> elements.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: qcow2GetExtensions: Remove support for 'data file' extension
Peter Krempa [Fri, 24 Apr 2020 09:17:55 +0000 (11:17 +0200)]
util: qcow2GetExtensions: Remove support for 'data file' extension

The implementation was never finished in libvirt. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: Remove 'externalDataStoreRaw' field from virStorageSource
Peter Krempa [Fri, 24 Apr 2020 09:16:20 +0000 (11:16 +0200)]
util: Remove 'externalDataStoreRaw' field from virStorageSource

It's not used for anything so we don't need to extract it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: Remove 'externalDataStore' field from virStorageSource
Peter Krempa [Fri, 24 Apr 2020 09:12:27 +0000 (11:12 +0200)]
util: Remove 'externalDataStore' field from virStorageSource

It's not used for anything so we don't need to extract it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosecurity: Remove labelling of 'externalDataStore'
Peter Krempa [Fri, 24 Apr 2020 09:08:04 +0000 (11:08 +0200)]
security: Remove labelling of 'externalDataStore'

The feature was never completed and is not really being pursued. Remove
the storage driver integration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonetwork: Remove memory leak caused by wrong initialization
Julio Faracco [Sat, 25 Apr 2020 16:35:37 +0000 (13:35 -0300)]
network: Remove memory leak caused by wrong initialization

This commit fix a wrong variable initialization. There is a variable
called `new_lease` which is being initialized with the content of
parameter `lease`. To avoid memory leak, the proper way is initialize
with NULL first. This wrong statement was added by commit 97a0aa24.
There are some other improvements also.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitortestutils: Enforce consumption of all items in test monitor
Peter Krempa [Thu, 23 Apr 2020 14:57:31 +0000 (16:57 +0200)]
qemumonitortestutils: Enforce consumption of all items in test monitor

To prevent unexpected situations where a change in code would stop
looking at some of the tested commands go unnoticed add a mechanism to
force consumption of all test items.

Since there are a few tests which would be hard to fix add also a
mechanism to opt-out of the check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitortestutils: Store a string identifying test monitor entry
Peter Krempa [Thu, 23 Apr 2020 14:52:12 +0000 (16:52 +0200)]
qemumonitortestutils: Store a string identifying test monitor entry

For each test monitor entry store an optional string which will allow to
identify it. This will be used later when checking that all registered
monitor commands were used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuhotplugtest: Remove 'drive_del' expectation from failed cases
Peter Krempa [Thu, 23 Apr 2020 14:38:30 +0000 (16:38 +0200)]
qemuhotplugtest: Remove 'drive_del' expectation from failed cases

On failure 'drive_del' is not issued.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemucapabilitiesdata: riscv: Remove call to 'query-machines'
Peter Krempa [Thu, 23 Apr 2020 14:23:00 +0000 (16:23 +0200)]
qemucapabilitiesdata: riscv: Remove call to 'query-machines'

The riscv capabilities code doesn't use the data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitortestutils: Make test monitor failures more prominent
Peter Krempa [Thu, 23 Apr 2020 09:57:14 +0000 (11:57 +0200)]
qemumonitortestutils: Make test monitor failures more prominent

Until now we've tried to report errors from the test monitor code by
passing them back as failures from the qemu we simulate. This doesn't
work well in cases when the monitor logic does not detect failures or
has fallback code. Additionally there isn't much use for continuing the
test execution after first failure as in most cases the test data will
be misaligned and all other calls will fail as well.

To make the errors more obvious this patch moves away from reporting
them via the simulated monitor to reporting them to stderr and
exit()ing afterwards. While this might be less convenient
when developing tests it actually makes failures in the test suite
really obvious and doesn't require any opt-in from the tests themselves.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuhotplugtest: cpu: x86-modern-individual: Remove invalid test case
Peter Krempa [Thu, 23 Apr 2020 12:31:12 +0000 (14:31 +0200)]
qemuhotplugtest: cpu: x86-modern-individual: Remove invalid test case

One of the test cases attempted to use test data meant for modern qemu
without asserting the 'modern' flag. Since that changes the commands
used to query state it won't work with data meant for the modern case.

Remove the invalid test case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuhotplugtest: detach: Add expected 'object-del' to disk-scsi-multipath case
Peter Krempa [Thu, 23 Apr 2020 10:03:21 +0000 (12:03 +0200)]
qemuhotplugtest: detach: Add expected 'object-del' to disk-scsi-multipath case

The test verifies unplug of a disk with the persistent reservations
helper. The 'object-del' used to remove the helper was not mentioned in
the list of expected commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: monitor: Rename qemuMonitorReportError to qemuMonitorTestAddErrorResponse
Peter Krempa [Thu, 23 Apr 2020 09:50:59 +0000 (11:50 +0200)]
tests: monitor: Rename qemuMonitorReportError to qemuMonitorTestAddErrorResponse

It's a method of the test monitor and it adds a response to the monitor
output. The original qemuMonitorTestAddErrorResponse method is renamed
to qemuMonitorTestAddErrorResponseInternal

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirStorageSourceParseNBDColonString: Rewrite to match what qemu does
Peter Krempa [Fri, 24 Apr 2020 11:59:21 +0000 (13:59 +0200)]
virStorageSourceParseNBDColonString: Rewrite to match what qemu does

Our implementation wasn't quite able to parse everything that qemu does.
This patch rewrites the parser to a code that semantically resembles the
combination of 'nbd_parse_filename' and 'inet_parse' methods in qemu to
be able to parse the strings in an equivalent manner.

The only thing that libvirt doesn't do is to check the lengths of
various components in the nbd string in places where qemu uses constant
size buffers.

The test cases validate that some of the corner cases involving colons
are parsed properly.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agotravis: explicitly include gnutls to ensure it is updated
Daniel P. Berrangé [Fri, 24 Apr 2020 12:17:42 +0000 (13:17 +0100)]
travis: explicitly include gnutls to ensure it is updated

Travis includes gnutls in the default package set, but it is
an outdated version linkng to an incompatible libffi version.
The 'update: true' stanza causes the brew toolchain to be
updated but not the installed formula. It is possible to
run 'brew upgrade' to update installed formula, but this is
very slow adding more than 5 minutes to the build time.
Listing the gnutls package explicitly causes it to be updated
without extending the build time.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoschema: backup: Make 'exportname' and 'exportbitmap' independent
Peter Krempa [Fri, 24 Apr 2020 08:37:54 +0000 (10:37 +0200)]
schema: backup: Make 'exportname' and 'exportbitmap' independent

Both are optional but don't have to be specified together. Fix the
schema.

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

Suggested-by: Yi Sun <yisun@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: Document reserved PCI addresses for QEMU
Michal Privoznik [Tue, 21 Apr 2020 14:56:58 +0000 (16:56 +0200)]
docs: Document reserved PCI addresses for QEMU

From time to time we are asked which PCI addresses are reserved
in QEMU. Let's document them in one place, it's easier than
reconstructing the list from the code each time.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
5 years agodocs: Add version info for 'backingStoreInput' in domaincaps
Sebastian Mitterle [Wed, 15 Apr 2020 11:34:06 +0000 (11:34 +0000)]
docs: Add version info for 'backingStoreInput' in domaincaps

Add 'since 5.10' as commonly used in formatdomain to avoid
misunderstandings if element is not present (Is it not supported
because of my version or because of my environment?)

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agokbase: improve disk image chains documentation
Sebastian Mitterle [Wed, 15 Apr 2020 11:34:05 +0000 (11:34 +0000)]
kbase: improve disk image chains documentation

1. Use 'setup' consistently as noun, 'set up' as verb
2. Use path variables like '$IMAGE_PATH' consistently
   like in Troubleshooting to improve readability
3. Remove ':' from field names
4. Change phrasing in sentences I stumbled upon several
   times to improve readability.
5. Minor grammar/vocab fixes.

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agonews: Include new DHCP network <lease/> feature
Julio Faracco [Thu, 23 Apr 2020 23:56:51 +0000 (20:56 -0300)]
news: Include new DHCP network <lease/> feature

This commit includes an entry for new network DHCP lease time
information inside news.xml.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: qemu: support async IO mode 'io_uring'
Han Han [Tue, 21 Apr 2020 12:19:38 +0000 (20:19 +0800)]
news: qemu: support async IO mode 'io_uring'

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agotests: Tests for io mode io_uring
Han Han [Tue, 21 Apr 2020 12:19:37 +0000 (20:19 +0800)]
tests: Tests for io mode io_uring

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: Docs and rng schemas for io_uring
Han Han [Tue, 21 Apr 2020 12:19:36 +0000 (20:19 +0800)]
docs: Docs and rng schemas for io_uring

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Implement the aio mode io_uring
Han Han [Tue, 21 Apr 2020 12:19:35 +0000 (20:19 +0800)]
qemu: Implement the aio mode io_uring

This aio mode was added since Linux 5.1[1], QEMU 5.0.0[2], which will
deliever faster and more efficient I/O operations for the file,
host_device, host_cdrom backends.

Reference:
[1]: https://lwn.net/Articles/810414/
[2]: https://lists.gnu.org/archive/html/qemu-devel/2020-01/msg07686.html

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu_capabilities: Introduce QEMU_CAPS_AIO_IO_URING
Han Han [Tue, 21 Apr 2020 12:19:34 +0000 (20:19 +0800)]
qemu_capabilities: Introduce QEMU_CAPS_AIO_IO_URING

Add io_uring value to capability replies.

The capability QEMU_CAPS_AIO_IO_URING will be used for io_uring aio mode,
introduced from QEMU 5.0, linux 5.1.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Move interlocking of blockjobs and checkpoints after liveness check
Peter Krempa [Fri, 17 Apr 2020 08:58:08 +0000 (10:58 +0200)]
qemu: Move interlocking of blockjobs and checkpoints after liveness check

qemuDomainSupportsCheckpointsBlockjobs checks if the
QEMU_CAPS_INCREMENTAL_BACKUP capability is supported to do the
interlocking. Capabilities are not present when the VM isn't running
though which would create false errors.

Move the checks after the liveness check in block job implementations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agobackup: Store error message for failed backups
Peter Krempa [Thu, 16 Apr 2020 09:23:07 +0000 (11:23 +0200)]
backup: Store error message for failed backups

If a backup job fails midway it's hard to figure out what happened as
it's running asynchronous. Use the VIR_DOMAIN_JOB_ERRMSG job statistics
field to pass through the error from the first failed backup-blockjob
so that both the consumer of the virDomainGetJobStats and the
corresponding event can see the error.

event 'job-completed' for domain backup-test:
operation: 9
time_elapsed: 46
disk_total: 104857600
disk_processed: 10158080
disk_remaining: 94699520
success: 0
errmsg: No space left on device

virsh domjobinfo backup-test --completed --anystats
Job type:         Failed
Operation:        Backup
Time elapsed:     46           ms
File processed:   9.688 MiB
File remaining:   90.312 MiB
File total:       100.000 MiB
Error message:    No space left on device

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Add 'errmsg' field to qemuDomainJobInfo
Peter Krempa [Thu, 16 Apr 2020 09:21:51 +0000 (11:21 +0200)]
qemu: domain: Add 'errmsg' field to qemuDomainJobInfo

The field can be used by jobs to add an optional error message to a
completed (failed) job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoAPI: Add VIR_DOMAIN_JOB_ERRMSG domain job statistics field
Peter Krempa [Wed, 15 Apr 2020 10:27:53 +0000 (12:27 +0200)]
API: Add VIR_DOMAIN_JOB_ERRMSG domain job statistics field

In some cases it's useful to report the error which caused the domain
job to fail. Add an optional field for holding the error message so that
it can be later retrieved from statistics of a completed job.

Add the field name macro and code for extracting it in virsh.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Add free and copy function for qemuDomainJobInfo and use it
Peter Krempa [Thu, 26 Mar 2020 16:55:00 +0000 (17:55 +0100)]
qemu: Add free and copy function for qemuDomainJobInfo and use it

In order to add a string to qemuDomainJobInfo we must ensure that it's
freed and copied properly. Add helpers to copy and free the structure
and adjust the code to use them properly for the new semantics.

Additionally also allocation is changed to g_new0 as it includes the
type and thus it's very easy to grep for all the allocations of a given
type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoremote: remoteDispatchDomainGetJobStats: Encode typed parameter strings
Peter Krempa [Thu, 16 Apr 2020 09:14:00 +0000 (11:14 +0200)]
remote: remoteDispatchDomainGetJobStats: Encode typed parameter strings

String typed parameter values were introduced in v0.9.7-30-g40624d32fb.
virDomainGetJobStats was introduced in v1.0.2-239-g4dd00f4238 so all
clients already support typed parameter stings at that time thus we can
enable it unconditionally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuhotplugtest: detach: Remove commands which are not issued
Peter Krempa [Thu, 23 Apr 2020 08:36:59 +0000 (10:36 +0200)]
qemuhotplugtest: detach: Remove commands which are not issued

The 'human-monitor-command' equates to the 'drive-del' command issued by
the hotplug code on successful detach of a device. This means that it's
not issued for failed attempts and thus should not be added to the
expected list. Unfortunately our test monitor doesn't ensure that all
expected commands were consumed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agomock: qemuDomainGetUnplugTimeout: Decrease timeout
Peter Krempa [Thu, 23 Apr 2020 08:33:58 +0000 (10:33 +0200)]
mock: qemuDomainGetUnplugTimeout: Decrease timeout

We always queue the DEVICE_DELETED events before successful return from
the command so that tests are reliable. This means we can decrease the
unplug timeout as it's guaranteed to be executed in correct order.

According to my testing it shaves off ~450ms of test run:

real 0m0.721s

vs.

real 0m0.259s

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agomock:qemuDomainGetUnplugTimeout: Remove unused attribute for '@vm'
Peter Krempa [Thu, 23 Apr 2020 08:32:22 +0000 (10:32 +0200)]
mock:qemuDomainGetUnplugTimeout: Remove unused attribute for '@vm'

'@vm' is used to use a different timeout for ppc64 guests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuDomainGetUnplugTimeout: Add G_GNUC_NO_INLINE
Peter Krempa [Thu, 23 Apr 2020 08:30:13 +0000 (10:30 +0200)]
qemuDomainGetUnplugTimeout: Add G_GNUC_NO_INLINE

The function is mocked in qemuhotplugmock.so. Recent clang versions
decided to inline it so the mock stopped working resulting in
qemuhotplugtest wasting 15 seconds waiting for timeouts.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemucapstest: Refresh data for qemu 5.0 on x86_64
Peter Krempa [Wed, 22 Apr 2020 10:39:10 +0000 (12:39 +0200)]
qemucapstest: Refresh data for qemu 5.0 on x86_64

Bump to v5.0.0-rc3-8-g3119154db0 and make sure that 'liburing' is picked
up by qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSaveImageOpen: Refactor handling of errors
Peter Krempa [Wed, 22 Apr 2020 14:52:24 +0000 (16:52 +0200)]
qemuDomainSaveImageOpen: Refactor handling of errors

Return error codes directly and fix weird reporting of errors via
temporary variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSaveImageOpen: Use 'g_new0' instead of VIR_ALLOC(_N)
Peter Krempa [Wed, 22 Apr 2020 14:22:58 +0000 (16:22 +0200)]
qemuDomainSaveImageOpen: Use 'g_new0' instead of VIR_ALLOC(_N)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSaveImageOpen: Automatically close 'fd' if unneeded
Peter Krempa [Wed, 22 Apr 2020 14:19:21 +0000 (16:19 +0200)]
qemuDomainSaveImageOpen: Automatically close 'fd' if unneeded

Use VIR_AUTOCLOSE to declare it and remove all internal closing of the
filedescriptor. This will allow getting rid of 'error' completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSaveImageOpen: Use g_autoptr for 'def'
Peter Krempa [Wed, 22 Apr 2020 14:16:19 +0000 (16:16 +0200)]
qemuDomainSaveImageOpen: Use g_autoptr for 'def'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>