]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agosecurity: apparmor: Pass virStorageSource to add_file_path
Cole Robinson [Tue, 8 Oct 2019 15:53:21 +0000 (11:53 -0400)]
security: apparmor: Pass virStorageSource to add_file_path

The virStorageSource must have everything it needs

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Drop disk_foreach_iterator
Cole Robinson [Tue, 8 Oct 2019 15:50:55 +0000 (11:50 -0400)]
security: apparmor: Drop disk_foreach_iterator

There's only one caller, so open code the file_add_path behavior

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Remove unused ignoreOpenFailure
Cole Robinson [Tue, 8 Oct 2019 15:42:21 +0000 (11:42 -0400)]
security: apparmor: Remove unused ignoreOpenFailure

true is always passed here, so delete the unused code path and
adjust the associated comment

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoconf: Move -virDomainDiskDefForeachPath to virt-aa-helper
Cole Robinson [Tue, 8 Oct 2019 15:40:30 +0000 (11:40 -0400)]
conf: Move -virDomainDiskDefForeachPath to virt-aa-helper

It is the only user. Rename it to match the local style

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agobuild: merge all syntax-check logic into one file
Daniel P. Berrangé [Wed, 2 Oct 2019 16:51:19 +0000 (17:51 +0100)]
build: merge all syntax-check logic into one file

The gnulib syntax-check rules are spread across GNUmakefile, cfg.mk and
maint.mk. This made sense when we were getting two of the files from the
gnulib submodule. Now that we own all files though, we can at least
merge maint.mk and cfg.mk together. GNUmakefile can be eliminated when
we switch to meson.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: delete all syntax check rules we're skipping
Daniel P. Berrangé [Wed, 2 Oct 2019 16:44:04 +0000 (17:44 +0100)]
build: delete all syntax check rules we're skipping

If we've marked rules as skipped, there's no sense keeping them in the
maint.mk file.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: remove all logic unrelated to syntax-check
Daniel P. Berrangé [Wed, 2 Oct 2019 16:36:23 +0000 (17:36 +0100)]
build: remove all logic unrelated to syntax-check

The standard maint.mk from gnulib provides alot more than just the
'syntax-check' target. This can all be purged to give a more minimal
file.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: move syntax-check code into build-aux directory
Daniel P. Berrangé [Wed, 9 Oct 2019 11:25:08 +0000 (12:25 +0100)]
build: move syntax-check code into build-aux directory

The syntax-check rules are the one bit of make usage that will
stay around for a while after the meson conversion. Move them
into the build-aux directory in preparation for refactoring
to make them independent from automake.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: import gnulib's syntax-check make rules
Daniel P. Berrangé [Wed, 2 Oct 2019 16:04:31 +0000 (17:04 +0100)]
build: import gnulib's syntax-check make rules

We're going to be eliminating autotools and gnulib, but we still wish to
have the 'make syntax-check' functionality.

This imports the minimal set of gnulib files required to keep this
working.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "qemu: Obtain reference on monConfig"
Michal Privoznik [Tue, 8 Oct 2019 07:49:18 +0000 (09:49 +0200)]
Revert "qemu: Obtain reference on monConfig"

This reverts commit a5a777a8bae61cb9e41c4dcd12d2962ad1a65a0d.

After previous commit the domain won't disappear while connecting
to monitor. There's no need to ref monitor config then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Fix @vm locking issue when connecting to the monitor
Michal Privoznik [Tue, 8 Oct 2019 07:24:23 +0000 (09:24 +0200)]
qemu: Fix @vm locking issue when connecting to the monitor

When connecting to qemu's monitor the @vm object is unlocked.
This is justified - connecting may take a long time and we don't
want to wait with the domain object locked. However, just before
the domain object is locked again, the monitor's FD is registered
in the event loop. Therefore, there is a small window where the
event loop has a chance to call a handler for an event that
occurred on the monitor FD but vm is not initalized properly just
yet (i.e. priv->mon is not set). For instance, if there's an
incoming migration, qemu creates its socket but then fails to
initialize (for various reasons, I'm reproducing this by using
hugepages but leaving the HP pool empty) then the following may
happen:

1) qemuConnectMonitor() unlocks @vm

2) qemuMonitorOpen() connects to the monitor socket and by
   calling qemuMonitorOpenInternal() which subsequently calls
   qemuMonitorRegister() the event handler is installed

3) qemu fails to initialize and exit()-s, which closes the
   monitor

4) The even loop sees EOF on the monitor and the control gets to
   qemuProcessEventHandler() which locks @vm and calls
   processMonitorEOFEvent() which then calls
   qemuMonitorLastError(priv->mon). But priv->mon is not set just
   yet.

5) qemuMonitorLastError() dereferences NULL pointer

The solution is to unlock the domain object for a shorter time
and most importantly, register event handler with domain object
locked so that any possible event processing is done only after
@vm's private data was properly initialized.

This issue is also mentioned in v4.2.0-99-ga5a777a8ba.

Since we are unlocking @vm and locking it back, another thread
might have destroyed the domain meanwhile. Therefore we have to
check if domain is still active, and we have to do it at the
same place where domain lock is acquired back, i.e. in
qemuMonitorOpen(). This creates a small problem for our test
suite which calls qemuMonitorOpen() directly and passes @vm which
has no definition. This makes virDomainObjIsActive() call crash.
Fortunately, allocating empty domain definition is sufficient.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Adapt to changed ppc64 CPU model names
Jiri Denemark [Thu, 17 May 2018 15:08:42 +0000 (17:08 +0200)]
qemu: Adapt to changed ppc64 CPU model names

QEMU 2.11 for ppc64 changed all CPU model names to lower case. Since
libvirt can't change the model names for compatibility reasons, we need
to translate the matching lower case models to the names known by
libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoRevert "domcaps: Treat host models as case-insensitive strings"
Jiri Denemark [Wed, 16 May 2018 14:58:47 +0000 (16:58 +0200)]
Revert "domcaps: Treat host models as case-insensitive strings"

This reverts commit 2d8721e2606806164782028ecf1ee33a9bbaa8fe.

This fix was both incomplete and too general. It only fixed domain
startup, but libvirt would still report empty list of supported CPU
models with recent QEMU for ppc64. On the other hand, while ppc64 QEMU
ignores case when looking up CPU model names, x86_64 QEMU does case
sensitive lookup. Without reverting this patch, libvirt could happily
accept CPU model names which are not supported by QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobuild: stop clang complaining about redefined typedefs
Daniel P. Berrangé [Tue, 8 Oct 2019 14:37:11 +0000 (15:37 +0100)]
build: stop clang complaining about redefined typedefs

Clang's gnu99 mode is not quite the same as GCC's. It will complain
about redefined typedefs being a C11 feature, while GCC does not
complain and allows them in gnu99 mode.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "src: Document autostart for session demon"
Michal Privoznik [Sat, 5 Oct 2019 07:22:15 +0000 (09:22 +0200)]
Revert "src: Document autostart for session demon"

This reverts commit 61b4e8aaf1bce07f282c152de556c3d6aa8d65be.

After previous commits this is no longer needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonews: Document autostart fix
Michal Privoznik [Mon, 7 Oct 2019 09:10:13 +0000 (11:10 +0200)]
news: Document autostart fix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolib: autostart objects exactly once
Michal Privoznik [Sat, 5 Oct 2019 07:15:24 +0000 (09:15 +0200)]
lib: autostart objects exactly once

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

With the recent work in daemon split and socket activation
daemons can come and go. They can and will be started many times
during a session which results in objects being autostarted
multiple times. This is not optimal. Use
virDriverShouldAutostart() to determine if autostart should be
done or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodriver: Introduce virDriverShouldAutostart()
Michal Privoznik [Fri, 4 Oct 2019 14:57:04 +0000 (16:57 +0200)]
driver: Introduce virDriverShouldAutostart()

Some of objects we manage can be autostarted on libvirtd startup
(e.g. domains, network, storage pools). The idea was that when
the host is started up these objects are started too without need
of user intervention. However, with the latest daemon split and
switch to socket activated, short lived daemons (we put --timeout
120 onto each daemon's command line) this doesn't do what we want
it to. The problem is not new though, we already had the session
daemon come and go and we circumvented this problem by
documenting it (see v4.10.0-92-g61b4e8aaf1). But now that we meet
the same problem at all fronts it's time to deal with it.

The solution implemented in this commit is to have a file (one
per each driver) that:

  1) if doesn't exist, is created and autostart is allowed for
     given driver,

  2) if it does exist, then autostart is suppressed for given
     driver.

All the files live in a location that doesn't survive host
reboots (/var/run/ for instance) and thus the file is
automatically not there on fresh host boot.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_driver: Fix comment of qemuStateCleanup()
Michal Privoznik [Fri, 4 Oct 2019 14:33:37 +0000 (16:33 +0200)]
qemu_driver: Fix comment of qemuStateCleanup()

The comment says that the function kills domains and networks.
This is obviously not the case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agom4: fix setting of warning flags
Daniel P. Berrangé [Tue, 8 Oct 2019 12:41:19 +0000 (13:41 +0100)]
m4: fix setting of warning flags

When adding the -std=gnu99 flag, we set $wantwarn instead
of appending to it. This meant all the compiler warnings
were accidentally discarded.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: ask for -std=gnu99 explicitly
Daniel P. Berrangé [Mon, 7 Oct 2019 13:07:28 +0000 (14:07 +0100)]
build: ask for -std=gnu99 explicitly

We previously got -std=gnu99 secretly enabled as a side-effect
of requesting the 'stdarg' gnulib module. We rely on some
extensions from c99/gnu99 and while RHEL-7 supports this, it
still defaults to gnu89.  RHEL-7 also supports some newer
standards but declares them experimental/incomplete, so sticking
with gnu99 is best bet for now & matches historical usage.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: force -Werror for distcheck target
Daniel P. Berrangé [Mon, 7 Oct 2019 13:03:47 +0000 (14:03 +0100)]
build: force -Werror for distcheck target

The 'make distcheck' target validates that a tarball builds and
is ready for release. We expect that libvirt builds cleanly on
all supported platforms, so we should be enabling -Werror when
running distcheck.

This ensures that our CI systems in turn also use -Werror.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: remove the sched gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:34:39 +0000 (16:34 +0100)]
build: remove the sched gnulib module

The 'sched' module provides a sched.h header file for platforms which
lack it. We already check for the functions we need in configure, and
protect the use of sched.h where relevant, so don't need the compat
header in libvirt.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the isatty gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:29:23 +0000 (16:29 +0100)]
build: drop the isatty gnulib module

The isatty gnulib module adds a fix for Win32 platforms where it doesn't
work correctly with character devices like NUL. This is not a compelling
enough problem for libvirt to be concerned with.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the ldexp gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:27:12 +0000 (16:27 +0100)]
build: drop the ldexp gnulib module

The ldexp gnulib module adds "-lm" to the $LIBS variable if-and-only-if
the ldexp() function require linking to libm. There is no harm in
linking to libm even if it isn't required for ldexp(), so simply drop
the gnulib module.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the ignore-value gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:25:45 +0000 (16:25 +0100)]
build: drop the ignore-value gnulib module

We don't need to care about very old GCC versions, so implementing the
ignore_value macro directly is not a significant burden.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: remove all gnulib bit manipulation modules
Daniel P. Berrangé [Thu, 3 Oct 2019 14:51:30 +0000 (15:51 +0100)]
build: remove all gnulib bit manipulation modules

We're using gnulib to get ffs, ffsl, rotl32, count_one_bits,
and count_leading_zeros. Except for rotl32 they can all be
replaced with gcc/clangs builtins. rotl32 is a one-line
trivial function.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agofixed handling of sourceless disks in 'domblkinfo' cmd
Pavel Mores [Fri, 4 Oct 2019 11:35:09 +0000 (13:35 +0200)]
fixed handling of sourceless disks in 'domblkinfo' cmd

virDomainGetBlockInfo() returns error if called on a disk with no
source (a sourceless disk might be a removable media drive with no
media in it, for instance an empty CDROM or floppy drive).

So far this caused the virsh domblkinfo --all command to abort and
ignore any remaining (not yet displayed) disk devices.  This patch
fixes the problem by first checking for existence of a <source>
element in the corresponding XML.  If none is found, we avoid calling
virDomainGetBlockInfo() altogether as we know it's bound to fail in
that case.

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

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemuxml2argv: Make use of versioned cpu-tsc-frequency and cpu-host-model-cmt...
Peter Krempa [Mon, 7 Oct 2019 06:55:31 +0000 (08:55 +0200)]
tests: qemuxml2argv: Make use of versioned cpu-tsc-frequency and cpu-host-model-cmt tests

Commit fb973cfbb4de added versioned test outputs for the above mentioned
tests but didn't actually enable them. Fix that mistake and fix the
output of the tsc-frequency test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Remove unused output of 'mlock-on' legacy test
Peter Krempa [Mon, 7 Oct 2019 06:47:56 +0000 (08:47 +0200)]
tests: qemuxml2argv: Remove unused output of 'mlock-on' legacy test

The test data was modernized to use actual caps but commit 4dadcaa98e5
forgot to delete this test data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Remove unused data for s390 keywrap
Peter Krempa [Mon, 7 Oct 2019 07:00:01 +0000 (09:00 +0200)]
tests: qemuxml2argv: Remove unused data for s390 keywrap

The last use was removed in 7b604379ba747cd8 when we deleted the old
commandline parser.

The argv generator tests are provided by:
machine-aeskeywrap-on-caps
machine-aeskeywrap-on-cap
machine-aeskeywrap-off-caps
machine-aeskeywrap-off-cap
machine-deakeywrap-on-caps
machine-deakeywrap-on-cap
machine-deakeywrap-off-caps
machine-deakeywrap-off-cap

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Remove unused data for 'pseries-disk'
Peter Krempa [Mon, 7 Oct 2019 06:50:10 +0000 (08:50 +0200)]
tests: qemuxml2argv: Remove unused data for 'pseries-disk'

The last use was removed in 7b604379ba747cd8 when we deleted the old
commandline parser. The same functionality is tested by many tests for
pseries guests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Remove unused data for 'serial-pty'
Peter Krempa [Mon, 7 Oct 2019 06:40:02 +0000 (08:40 +0200)]
tests: qemuxml2argv: Remove unused data for 'serial-pty'

The last use was removed in 7b604379ba747cd8 when we deleted the old
commandline parser. The same functionality is tested by
'serial-pty-chardev'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobuild: drop the pthread gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:19:18 +0000 (18:19 +0100)]
build: drop the pthread gnulib module

This was fixing a problem with old versions of mingw which had a
pthread.h that polluted the namespace with random symbols. This is no
longer relevant on our mingw platform targets.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the perror gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:15:55 +0000 (18:15 +0100)]
build: drop the perror gnulib module

This fixes a problem on mingw where it doesn't know how to report
certain errnos defined by POSIX, but not used on Windows. These are
not a real problem for libvirt.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the gitlog-to-changelog gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:14:06 +0000 (18:14 +0100)]
build: drop the gitlog-to-changelog gnulib module

The use of this script was discontinued when we stopped providing a full
ChangeLog in the dist with:

  commit ce97c33a795dec053f1e85c65ecd924b8c6ec4ba
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Mon Apr 1 17:33:03 2019 +0200

    maint: Stop generating ChangeLog from git

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the stdarg gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:02:43 +0000 (18:02 +0100)]
build: drop the stdarg gnulib module

gnulib fixes a portability problem on AIX which is a platform we have
never targetted.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "build: use autobuild module to make build logs nicer"
Daniel P. Berrangé [Wed, 2 Oct 2019 15:34:10 +0000 (16:34 +0100)]
Revert "build: use autobuild module to make build logs nicer"

This reverts commit 83aca30f1e8be524780a60b9dd8a14ec5f9de878.

While the motivation of the original commit is fine, we are intending to
drop autoconf in favour of meson, and similarly wish to drop use of
gnulib. Removing this feature is part of that conversion work.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: drop the stpcpy gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 15:14:45 +0000 (16:14 +0100)]
util: drop the stpcpy gnulib module

stpcpy returns a pointer to the end of the string just copied
which in theory makes it easier to then copy another string
after it. We only use stpcpy in one place though and that
is trivially rewritten to avoid stpcpy with no loss in code
clarity or efficiency.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the mktempd gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 11:09:08 +0000 (12:09 +0100)]
build: drop the mktempd gnulib module

The mktempd module in gnulib provides an equivalent to 'mktemp -d' on
platforms which lack this shell command. All platforms on which libvirt
runs the affected tests have 'mktemp -d' support, so the gnulib module
is not required.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the inet_pton gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 11:04:07 +0000 (12:04 +0100)]
build: drop the inet_pton gnulib module

All use of this function was purged a long time ago in favour
of getaddrinfo

  commit a8ae7d19f4ace62ff3f364c628cbc16baa9b080c
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Thu Oct 21 11:13:05 2010 +0100

    Remove all use of inet_pton and inet_ntop

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the getopt-posix gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 10:42:07 +0000 (11:42 +0100)]
build: drop the getopt-posix gnulib module

The getopt-posix module fixes a problem with optind being incorrectly
set after a failed option parse. It was also previously used to allow
the bhyve driver to access a private internal reentrant getopt impl.
None of this matters to libvirt code any more.

This partially reverts

  commit b436a8ae5ccb04f8cf893d882d52ab5efc713307
  Author: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
  Date:   Thu Jun 9 00:50:35 2016 +0000

    gnulib: add getopt module

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: stop using private gnulib _getopt_internal_r func
Daniel P. Berrangé [Thu, 3 Oct 2019 13:35:44 +0000 (14:35 +0100)]
bhyve: stop using private gnulib _getopt_internal_r func

The _getopt_internal_r func is not intended for public use, it is an
internal function shared between the gnulib getopt and argp modules.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: capabilities: Fill in bochs-display info
Fabiano Fidêncio [Thu, 3 Oct 2019 13:28:40 +0000 (15:28 +0200)]
qemu: capabilities: Fill in bochs-display info

086c19d69 added bochs-display capability but didn't fill in the info for
domain capabilities.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver: hook up query-cpu-model-comparison
Collin Walling [Thu, 19 Sep 2019 20:25:05 +0000 (16:25 -0400)]
qemu_driver: hook up query-cpu-model-comparison

This command is hooked into the virsh hypervisor-cpu-compare command.
As such, the CPU model XML provided to the command will be compared
to the hypervisor CPU contained in the QEMU capabilities file for the
appropriate QEMU binary (for s390x, this CPU definition can be observed
via virsh domcapabilities).

QMP will report that the XML CPU is either identical to, a subset of,
or incompatible with the hypervisor CPU. s390 can also report that
the XML CPU is a "superset" of the hypervisor CPU. This response is
presented as incompatible, as this CPU model would not be able to run
on the hypervisor.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Message-Id: <1568924706-2311-15-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agocpu_conf: xml to cpu definition parse helper
Collin Walling [Thu, 19 Sep 2019 20:25:04 +0000 (16:25 -0400)]
cpu_conf: xml to cpu definition parse helper

Implement an XML to virCPUDefPtr helper that handles the ctxt
prerequisite for virCPUDefParseXML.

This does not alter any functionality.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-14-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON
Collin Walling [Thu, 19 Sep 2019 20:25:03 +0000 (16:25 -0400)]
qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON

This capability enables comparison of CPU models via QMP.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Message-Id: <1568924706-2311-13-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: implement query-cpu-model-comparison
Collin Walling [Thu, 19 Sep 2019 20:25:02 +0000 (16:25 -0400)]
qemu_monitor: implement query-cpu-model-comparison

Interfaces with QEMU to compare CPU models. The command takes two CPU
models, A and B, that are given a model name and an optional list of
CPU features. Through the query-cpu-model-comparison command issued
via QMP, a result is produced that contains the comparison evaluation
string (identical, superset, subset, incompatible).

The list of properties (aka CPU features) that is returned from the QMP
response is ignored.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-12-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_driver: expand cpu features after baseline
Collin Walling [Wed, 2 Oct 2019 11:48:17 +0000 (13:48 +0200)]
qemu_driver: expand cpu features after baseline

Perform a full CPU model expansion on the result of the baselined
model name when the features flag is present.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-11-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_driver: hook up query-cpu-model-baseline
Collin Walling [Thu, 19 Sep 2019 20:25:00 +0000 (16:25 -0400)]
qemu_driver: hook up query-cpu-model-baseline

This command is hooked into the virsh hypervisor-cpu-baseline command.
The CPU models provided in the XML sent to the command will be baselined
via the query-cpu-model-baseline QMP command. The resulting CPU model
will be reported.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-10-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_BASELINE
Collin Walling [Thu, 19 Sep 2019 20:24:59 +0000 (16:24 -0400)]
qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_BASELINE

This capability enables baselining of CPU models via QMP.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Message-Id: <1568924706-2311-9-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: implement query-cpu-model-baseline
Collin Walling [Thu, 19 Sep 2019 20:24:58 +0000 (16:24 -0400)]
qemu_monitor: implement query-cpu-model-baseline

Interfaces with QEMU to baseline CPU models. The command takes two
CPU models, A and B, that are given a model name and an optional list
of CPU features. Through the query-cpu-model-baseline command issued
via QMP, a result is produced that contains a new baselined CPU model
that is guaranteed to run on both A and B.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-8-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: make qemuMonitorJSONParseCPUModelData command-agnostic
Collin Walling [Thu, 19 Sep 2019 20:24:57 +0000 (16:24 -0400)]
qemu_monitor: make qemuMonitorJSONParseCPUModelData command-agnostic

Modify the error messages in qemuMonitorJSONParseCPUModelData to print
the command name provided to the function.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-7-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: allow cpu props to be optional
Collin Walling [Thu, 19 Sep 2019 20:24:56 +0000 (16:24 -0400)]
qemu_monitor: allow cpu props to be optional

Some older s390 CPU models (e.g. z900) will not report props as a
response from query-cpu-model-expansion. As such, we should make the
props field optional when parsing the return data from the QMP response.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-6-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: add features to CPU model for QMP command
Collin Walling [Thu, 19 Sep 2019 20:24:55 +0000 (16:24 -0400)]
qemu_monitor: add features to CPU model for QMP command

query-cpu-model-baseline/comparison will accept a list of features
as part of the command. Since CPUs may be defined with CPU feature
policies, let's parse it to the appropriate boolean that the QMP
command expects.

A feature that is set to required, force, or if it is a hypervisor
CPU feature (-1), then set the property value to true. Otherwise
(optional, disabled) set the value to false.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-5-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: use cpu def instead of char for expansion
Collin Walling [Thu, 19 Sep 2019 20:24:54 +0000 (16:24 -0400)]
qemu_monitor: use cpu def instead of char for expansion

When expanding a CPU model via query-cpu-model-expansion, any features
that were a part of the original model are discarded. For exmaple,
when expanding modelA with features f1, f2, a full expansion may reveal
feature f3, but the expanded model will not include f1 or f2.

Let's pass a virCPUDefPtr to the expansion function in preparation for
taking features into consideration.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-4-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: expansion cleanups
Collin Walling [Thu, 19 Sep 2019 20:24:53 +0000 (16:24 -0400)]
qemu_monitor: expansion cleanups

With refactoring most of the expansion function, let's take care of
some additional cleanups.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-3-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: refactor cpu model expansion
Collin Walling [Thu, 19 Sep 2019 20:24:52 +0000 (16:24 -0400)]
qemu_monitor: refactor cpu model expansion

Refactor some code in qemuMonitorJSONGetCPUModelExpansion to be later
used for the comparison and baseline functions.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <1568924706-2311-2-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agomaint: Post-release version bump to 5.9.0
Peter Krempa [Mon, 7 Oct 2019 06:00:47 +0000 (08:00 +0200)]
maint: Post-release version bump to 5.9.0

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agoRelease of libvirt-5.8.0
Daniel Veillard [Sat, 5 Oct 2019 07:45:29 +0000 (09:45 +0200)]
Release of libvirt-5.8.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agoremove a now redundant call to virDiskNameToIndex()
Pavel Mores [Mon, 30 Sep 2019 13:41:01 +0000 (15:41 +0200)]
remove a now redundant call to virDiskNameToIndex()

Parseability of disk name is now checked in qemuDomainDeviceDefValidateDisk().

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Refuse partitions in disk targets
Pavel Mores [Mon, 30 Sep 2019 13:41:00 +0000 (15:41 +0200)]
qemu: Refuse partitions in disk targets

The way in which the qemu driver generates aliases for disks involves
ignoring the partition number part of a target dev name.  This means that
all partitions of a block device and the device itself all end up with the
same alias.  If multiple such disks are specified in XML, the resulting
name clash makes qemu invocation fail.

Since attaching partitions to qemu VMs doesn't seem to make much sense
anyway, disallow partitions in target specifications altogether.

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

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoremote: don't pull anonymous enums into rpc protocol structs
Daniel P. Berrangé [Tue, 17 Sep 2019 11:24:25 +0000 (12:24 +0100)]
remote: don't pull anonymous enums into rpc protocol structs

The VIR_TYPED_PARAM_* enum fields are defined in libvirt-common.h, not
in the remote protcol, so shouldn't be part of the protocol structs
output check. This avoids similar problems hitting when we add use of
glib, which has other such anonymous enums.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: attempt to document the general libvirt dev strategy
Daniel P. Berrangé [Thu, 19 Sep 2019 11:48:15 +0000 (12:48 +0100)]
docs: attempt to document the general libvirt dev strategy

There are various ideas / plans floating around for future libvirt work,
some of which is actively in progress. Historically we've never captured
this kind of information anywhere, except in mailing list discussions.
In particular guidelines in hacking.html.in don't appear until a policy
is actively applied.

This patch attempts to fill the documentation gap, by creating a new
"strategy" page which outlines the general vision for some notable
future changes. The key thing to note is that none of the stuff on this
page is guaranteed, plans may change as new information arises. IOW this
is a "best guess" as to the desired future.

This doc has focused on three areas, related to the topic of language
usage / consolidation

 - Use of non-C languages for the library, daemons or helper tools
 - Replacement of autotools with meson
 - Use of RST and Sphinx for documentation (website + man pages)

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 agorpc: fix escaping of shell path for netcat binary
Daniel P. Berrangé [Thu, 19 Sep 2019 11:47:54 +0000 (12:47 +0100)]
rpc: fix escaping of shell path for netcat binary

Consider having a nc binary in the path with a space in its name,
for example '/tmp/fo o/nc'

This results in libvirt running SSH with the following arg value

  "'if ''/tmp/fo o/nc'' -q 2>&1 | grep \"requires
    an argument\" >/dev/null 2>&1; then ARG=-q0;
    else ARG=;fi;''/tmp/fo o/nc'' $ARG -U
    /var/run/libvirt/libvirt-sock'"

The use of the single quote escaping was introduced by

  commit 6ac6238de33fc74e7545b245ae273d1bfd658808
  Author: Guido Günther <agx@sigxcpu.org>
  Date:   Thu Oct 13 21:49:01 2011 +0200

    Use virBufferEscapeShell in virNetSocketNewConnectSSH

    to escape the netcat command since it's passed to the shell. Adjust
    expected test case output accordingly.

While the intention of this change was good, the result is broken as it
is still underquoted.

On the SSH server side, SSH itself runs the command via the shell.
Our command is then invoking the shell again. Thus we see

$ virsh -c qemu+ssh://root@domokun/system?netcat=%2Ftmp%2Ffo%20o%2Fnc list
error: failed to connect to the hypervisor
error: End of file while reading data: sh: /tmp/fo: No such file or directory: Input/output error

With the second level of escaping added we can now successfully use a nc
binary with a space in the path.

The original test case added was misleading as it illustrated using a
binary path of 'nc -4' which is not a path, it is a command with a
separate argument, which is getting interpreted as a path.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoadmin: fix memory leak of typed parameters getting client info
Daniel P. Berrangé [Mon, 30 Sep 2019 15:56:33 +0000 (16:56 +0100)]
admin: fix memory leak of typed parameters getting client info

In the error code path, the temporary parameters are not freed.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_capabilities: Put only unique FW images into domcaps
Michal Privoznik [Thu, 12 Sep 2019 11:07:31 +0000 (13:07 +0200)]
qemu_capabilities: Put only unique FW images into domcaps

In the domain capabilities XML there are FW image paths printed.
There are two sources for the image paths (in order of
preference):

  1) firmware descriptor files - as returned by
  qemuFirmwareGetSupported()

  2) a compile time list of FW:NRAM pairs which can be overridden
  in qemu.conf

If either of those contains a duplicate FW image path (which is
a valid use case) it is printed twice in the capabilities XML.
While it's technically not a bug, it doesn't look good.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: checkpoint: Don't update current checkpoint until we are done
Peter Krempa [Mon, 30 Sep 2019 14:37:48 +0000 (16:37 +0200)]
qemu: checkpoint: Don't update current checkpoint until we are done

Similarly to the snapshot code there's no reason to modify current
checkpoint until we are done creating the new one.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: snapshot: Don't update current snapshot until we're done
Peter Krempa [Mon, 30 Sep 2019 14:22:08 +0000 (16:22 +0200)]
qemu: snapshot: Don't update current snapshot until we're done

Since commit f105627992e we store whether a snapshot is current globally
rather than locally in the snapshot object.

This means that we don't have to unset the current snapshot prior to
taking/reverting the snapshot and we can do it only when everything is
done successfully.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoclarify the xml example for NVDIMM more clealy
Luyao Zhong [Mon, 23 Sep 2019 10:06:22 +0000 (18:06 +0800)]
clarify the xml example for NVDIMM more clealy

The NVDIMM backend file can be a normal file or a real device file,
Current xml example and explainations may mislead users. So add more
info about the NVDIMM related elements and update the xml examples.

Signed-off-by: Luyao Zhong <luyao.zhong@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosecurity: AppArmor profile fixes for swtpm
Chris Coulson [Tue, 24 Sep 2019 19:25:14 +0000 (20:25 +0100)]
security: AppArmor profile fixes for swtpm

The AppArmor profile generated by virt-aa-helper is too strict for swtpm.
This change contains 2 small fixes:
- Relax append access to swtpm's log file to permit write access instead.
Append access is insufficient because the log is opened with O_CREAT.
- Permit swtpm to acquire a lock on its lock file.

Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: sanity check vhost user FD before passing to QEMU
Daniel P. Berrangé [Mon, 30 Sep 2019 11:39:17 +0000 (12:39 +0100)]
qemu: sanity check vhost user FD before passing to QEMU

Ensure that the FD we're passing to QEMU is actually open, so we get a
sane error message upfront instead of telling QEMU to use a closed FD.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: ensure vhostuser FD is initialized to -1
Daniel P. Berrangé [Fri, 27 Sep 2019 16:34:44 +0000 (17:34 +0100)]
qemu: ensure vhostuser FD is initialized to -1

The video private data was not initializing the vhostuser FD
causing us to attempt to close FD 0 many times over.

Fixes

  commit ca60ecfa8cc1bd85baf7137dd1864d5f00f019f0
  Author: Marc-André Lureau <marcandre.lureau@redhat.com>
  Date:   Mon Sep 23 14:44:36 2019 +0400

      qemu: add qemuDomainVideoPrivate

Since the test suite does not invoke qemuExtDevicesStart(), no
vhost_user_fd will be present when generating test XML. To deal
with this we can must a fake FD number. While the current XML
is using FD == 0, we pick a very interesting number that's unlikely
to be a real FD, so that we're more likely to see any mistakes
closing the invalid FD.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: monitor: unexport qemuMonitorJSONTransactionAdd
Peter Krempa [Thu, 26 Sep 2019 14:37:44 +0000 (16:37 +0200)]
qemu: monitor: unexport qemuMonitorJSONTransactionAdd

Now it's not used outside of qemu_monitor_json.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Replace open-coded transaction action generators
Peter Krempa [Thu, 26 Sep 2019 14:36:15 +0000 (16:36 +0200)]
qemu: checkpoint: Replace open-coded transaction action generators

Use the generators provided by the monitor code instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: block: Replace snapshot transaction action generator
Peter Krempa [Thu, 26 Sep 2019 14:33:43 +0000 (16:33 +0200)]
qemu: block: Replace snapshot transaction action generator

Use the new generator residing in the monitor code rather than directly
using qemuMonitorJSONTransactionAdd.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agotests: qemumonitor: Add testing for the 'transaction' command and generators
Peter Krempa [Thu, 26 Sep 2019 14:12:20 +0000 (16:12 +0200)]
tests: qemumonitor: Add testing for the 'transaction' command and generators

Validate all the commands against the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: monitor: Add transaction generators for snapshot APIs
Peter Krempa [Thu, 26 Sep 2019 14:03:46 +0000 (16:03 +0200)]
qemu: monitor: Add transaction generators for snapshot APIs

Unify with other code that generates parameters for the 'transaction'
command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: monitor: Add transaction generators for dirty bitmap APIs
Peter Krempa [Thu, 26 Sep 2019 13:53:39 +0000 (15:53 +0200)]
qemu: monitor: Add transaction generators for dirty bitmap APIs

Rather than generating the transaction contents in random places add a
unified set of APIs to generate the contents for a 'transaction' for the
dirty bitmap APIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Base block job interlocking on QEMU_CAPS_INCREMENTAL_BACKUP
Peter Krempa [Thu, 26 Sep 2019 12:08:11 +0000 (14:08 +0200)]
qemu: domain: Base block job interlocking on QEMU_CAPS_INCREMENTAL_BACKUP

The QEMU_CAPS_INCREMENTAL_BACKUP will be enabled once all bits of the
incremental backup feature work as expected which means also properly
interacting with blockjobs and snapshots.

Thus we can allow blockjobs and snapshots if QEMU_CAPS_INCREMENTAL_BACKUP
is present even when checkpoints exist.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Aggregate interlocking of blockjobs by checkpoints in one place
Peter Krempa [Thu, 26 Sep 2019 11:54:15 +0000 (13:54 +0200)]
qemu: Aggregate interlocking of blockjobs by checkpoints in one place

Rather than having to fix 5 places once we support the combination, add
a function called by all the blockjob/snapshot APIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Forbid creating checkpoints until we support backups
Peter Krempa [Thu, 26 Sep 2019 11:25:40 +0000 (13:25 +0200)]
qemu: checkpoint: Forbid creating checkpoints until we support backups

Checkpoints by themselves are not very useful for anything else than
testing the few bitmap interactions that are currently implemented.

It's very unlikely that anybody used this feature and thus we can
disable it until we have a more complete implementation ready.

Additionally the code for deleting checkpoints has many broken failure
scenarios which should be fixed first. This will require support of
deleting a bitmap in a qemu 'transaction' which was not released yet.

Curious users obviously can use the qemu namespace in the XML to enable
this for experiments:

  <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
    ...
    <qemu:capabilities>
      <qemu:add capability='incremental-backup'/>
    </qemu:capabilities>
  </domain>

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: caps: Add capability for incremental backup support
Peter Krempa [Thu, 26 Sep 2019 11:01:30 +0000 (13:01 +0200)]
qemu: caps: Add capability for incremental backup support

Add a new all-covering capability which will be used to interlock
incremental backup support until all bits are ready.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull
Peter Krempa [Thu, 26 Sep 2019 11:50:16 +0000 (13:50 +0200)]
qemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull

Add a 'cleanup' label and use jumps as we do in other places.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Remove open-ended TODOs
Peter Krempa [Thu, 26 Sep 2019 11:21:00 +0000 (13:21 +0200)]
qemu: checkpoint: Remove open-ended TODOs

Once somebody is motivated enough to add the support for the quiesce
flag or offline checkpoint deletion they are welcome to do so but we
don't need to have a reminder.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Refactor cleanup in qemuCheckpointCreateXML
Peter Krempa [Thu, 26 Sep 2019 11:19:40 +0000 (13:19 +0200)]
qemu: checkpoint: Refactor cleanup in qemuCheckpointCreateXML

Use VIR_AUTO* helpers and get rid of the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: driver: Don't pull in qemu_monitor_json.h directly
Peter Krempa [Fri, 20 Sep 2019 11:49:55 +0000 (13:49 +0200)]
qemu: driver: Don't pull in qemu_monitor_json.h directly

There's nothing that uses it directly now. Also not allowing direct use
will promote our layering.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Move checkpoint related code to qemu_checkpoint.c
Peter Krempa [Fri, 20 Sep 2019 11:47:04 +0000 (13:47 +0200)]
qemu: domain: Move checkpoint related code to qemu_checkpoint.c

Finish the refactor by moving and renaming functions from qemu_domain.c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: driver: Move checkpoint-related code to qemu_checkpoint.c
Peter Krempa [Thu, 19 Sep 2019 14:49:21 +0000 (16:49 +0200)]
qemu: driver: Move checkpoint-related code to qemu_checkpoint.c

Move all extensive functions to a new file so that we don't just pile
everything in the common files. This obviously isn't possible with
straight code movement as we still need stubs in qemu_driver.c

Additionally some functions e.g. for looking up a checkpoint by name
were so short that moving the impl didn't make sense.

Note that in the move the new file also doesn't use
virQEMUMomentReparent but rather an stripped down copy. As I plan to
split out snapshot code into a separate file the unification doesn't
make sense any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Do ACL check prior to snapshot interlocking
Peter Krempa [Fri, 27 Sep 2019 08:00:39 +0000 (10:00 +0200)]
qemu: checkpoint: Do ACL check prior to snapshot interlocking

The interlocking with snapshots is executed prior to the ACL check so if
a VM has snapshots invoking the checkpoint API may leak it's existance.

Introduced with the qemuDomainCheckpointCreateXML API implementation in
commit 5f4e0796503.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agotools: fix regression passing command with virt-login-shell
Daniel P. Berrangé [Fri, 27 Sep 2019 16:18:24 +0000 (17:18 +0100)]
tools: fix regression passing command with virt-login-shell

It is documented that a command to run inside the container can be
passed with the -c arg.

  virt-login-shell -c "ls -l /"

This fixes

  commit 4feeb2d986b98013ebfb1d41ab6b9007b6cce6e2
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Aug 1 10:58:31 2019 +0100

    tools: split virt-login-shell into two binaries

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: fix systemd IP socket activation with virtproxyd
Daniel P. Berrangé [Fri, 20 Sep 2019 15:18:41 +0000 (16:18 +0100)]
remote: fix systemd IP socket activation with virtproxyd

We recently forbid the use of --listen with socket activation:

  commit 3a6a725b8f575890ee6c151ad1f46ea0ceea1f3b
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Aug 22 14:52:16 2019 +0100

      remote: forbid the --listen arg when systemd socket activation

In this change we forgot that virtproxyd doesn't have a --listen
parameter, and instead behaves as if it was always present. Thus
when systemd socket activation is present, we must disable this
built-in default

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: Record NSS dependency on symbols file
Michal Privoznik [Tue, 16 Jul 2019 10:06:20 +0000 (12:06 +0200)]
tools: Record NSS dependency on symbols file

If a symbol file for either of NSS modules is changed then
subsequent 'make' doesn't regenerate the library, because there
is no implicit dependency between the library and symbols file.
Put an explicit dependency into the Makefile then. Unfortunately,
setting _DEPENDENCIES makes us lose automake's generated
dependencies (see src/Makefile.am:592 for details). But
fortunately, the only dependency we had was _LIBADD variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolibvirt_nss.h: Separate function declarations with an empty line
Michal Privoznik [Tue, 16 Jul 2019 10:05:27 +0000 (12:05 +0200)]
libvirt_nss.h: Separate function declarations with an empty line

I find it more readable that way.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonss: Don't leak @addr in gethostbyname4()
Michal Privoznik [Sat, 28 Sep 2019 18:42:29 +0000 (20:42 +0200)]
nss: Don't leak @addr in gethostbyname4()

Similarly to gethostbyname3(), the @addr must be freed on return
from the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonss: Drop needless free() in gethostbyname3()
Michal Privoznik [Sat, 28 Sep 2019 19:24:53 +0000 (21:24 +0200)]
nss: Drop needless free() in gethostbyname3()

The findLease() function allocates @addr array iff no error
occurred and at least one satisfactory record was found.
Therefore, there is no need to call free() if findLease() failed,
or did not find any records as addr == NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonss: Compare addresses iff their family matches
Michal Privoznik [Sat, 28 Sep 2019 18:46:08 +0000 (20:46 +0200)]
nss: Compare addresses iff their family matches

When parsing leases file, appendAddr() is called to append parsed
tuple (address, expiry time, family) into an array. Whilst doing
so, the array is searched for possible duplicate. This is done by
comparing each item of the array by passed @family: if @family is
AF_INET then the item is viewed as IPv4 address. Similarly, if
@family is AF_INET6 then the item is viewed as IPv6 address. This
is not exactly right - the array can contain addresses of both
families and thus the address family of each item of the array
must be considered.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovircgroup: Add some VIR_DEBUG statements
Cole Robinson [Thu, 26 Sep 2019 19:25:52 +0000 (15:25 -0400)]
vircgroup: Add some VIR_DEBUG statements

These helped with debugging
https://bugzilla.redhat.com/show_bug.cgi?id=1612383

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agovircgroupv2: Fix VM startup when legacy cgroups are defined
Cole Robinson [Thu, 26 Sep 2019 19:00:55 +0000 (15:00 -0400)]
vircgroupv2: Fix VM startup when legacy cgroups are defined

On Fedora 31, starting a 'mock' build alters /proc/$pid/cgroup,
probably due to usage of systemd-nspawn.

Before:
$ cat /proc/self/cgroup
0::/user.slice/user-1000.slice/...

After:
$ cat /proc/self/cgroup
1:name=systemd:/
0::/user.slice/user-1000.slice/...

The cgroupv2 code mishandles that first line in the second case, which
causes VM startup to fail with: Unable to read from
'/sys/fs/cgroup/machine/cgroup.controllers': No such file or directory

The kernel docs[1] say that the cgroupv2 path will always start with
'0::', which in the code here controllers="". Only set the v2 placement
path when we see that cgroup file entry.

[1] https://www.kernel.org/doc/html/v5.3/admin-guide/cgroup-v2.html#processes

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

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: driver: Remove misplaced qemuDomainObjEndJob in qemuDomainCheckpointGetXMLDesc
Peter Krempa [Fri, 20 Sep 2019 07:08:05 +0000 (09:08 +0200)]
qemu: driver: Remove misplaced qemuDomainObjEndJob in qemuDomainCheckpointGetXMLDesc

The code that gets the job to refresh disk sizes was not merged yet so
remove this artifact.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>