]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agotools: Separate snapshot related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 17:24:01 +0000 (19:24 +0200)]
tools: Separate snapshot related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
snapshot (e.g. they complete various snapshot aspects)
into virsh-completer-snapshot.c

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate secret related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 17:17:42 +0000 (19:17 +0200)]
tools: Separate secret related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
secret (e.g. they complete various secret aspects)
into virsh-completer-secret.c

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate nwfilter related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 17:02:24 +0000 (19:02 +0200)]
tools: Separate nwfilter related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
nwfilter (e.g. they complete various nwfilter aspects)
into virsh-completer-nwfilter.c

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate nodedev related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 16:57:17 +0000 (18:57 +0200)]
tools: Separate nodedev related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
nodedev (e.g. they complete various nodedev aspects)
into virsh-completer-nodedev.c

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate network related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 16:51:56 +0000 (18:51 +0200)]
tools: Separate network related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
networks (e.g. they complete various network aspects)
into virsh-completer-network.c

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate interface related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 16:45:48 +0000 (18:45 +0200)]
tools: Separate interface related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
interfaces (e.g. they complete various interface aspects)
into virsh-completer-interface.c

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate storage volume related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 16:36:26 +0000 (18:36 +0200)]
tools: Separate storage volume related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
storage volumes (e.g. they complete various storage volume
aspects) into virsh-completer-volume.c

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate storage pool related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 16:27:12 +0000 (18:27 +0200)]
tools: Separate storage pool related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
storage pools (e.g. they complete various storage pool aspects)
into virsh-completer-pool.c.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate domain related completers into a file
Michal Privoznik [Sat, 13 Jul 2019 16:00:35 +0000 (18:00 +0200)]
tools: Separate domain related completers into a file

Mixing all completers in one file does not support
maintainability. Separate those completers which relate to
domains (e.g. they complete various domain aspects) into
virsh-completer-domain.c.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Expose virshCommaStringListComplete()
Michal Privoznik [Thu, 18 Jul 2019 15:18:28 +0000 (17:18 +0200)]
tools: Expose virshCommaStringListComplete()

In next commits the virsh-completer.c is going to be split into
smaller files. Expose virshCommaStringListComplete() so that it
can still be used from those new files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: s/Nodedev/NodeDevice/
Michal Privoznik [Sun, 14 Jul 2019 09:47:34 +0000 (11:47 +0200)]
tools: s/Nodedev/NodeDevice/

The proper name is [vir|virsh]NodeDevice* and not Nodedev.
Fortunately, there are only handful of offenders.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotests: Fix message for IP parse/format failures
Roman Bolshakov [Thu, 8 Aug 2019 10:37:46 +0000 (13:37 +0300)]
tests: Fix message for IP parse/format failures

Confusing message is printed when a parse/format sockettest fails. E.g.
there's a test that parses/formats ::ffff and the format fails like that:
  38) Test format ::ffff family AF_UNSPEC ...
  Offset 2
  Expect [0.0.255.255]
  Actual [ffff]

It should be instead:
  38) Test format ::ffff family AF_UNSPEC ...
  Offset 2
  Expect [ffff]
  Actual [0.0.255.255]

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agonss: fix build on freebsd
Daniel P. Berrangé [Thu, 8 Aug 2019 14:14:03 +0000 (15:14 +0100)]
nss: fix build on freebsd

The conversion to drop gnulib in the previous patch:

  commit 8242ce4f45700f326e13e5105accd08fb4b2f0b4
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Aug 8 10:23:26 2019 +0100

    tools: avoid accidentally using files from gnulib

Missed a few conversions needed for FreeBSD. In particular
netdb.h doesn't pull in sys/socket.h or netinet/in.h

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonetwork: fix ability to use openvswitch with vlans
Daniel P. Berrangé [Thu, 8 Aug 2019 12:42:24 +0000 (13:42 +0100)]
network: fix ability to use openvswitch with vlans

Use the correct enum constant when validating vlan usage.
This fixes a merge error in

  commit 6cb0ec48bd95c95489a987e05a88e8bcf1f9109c
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Mon Sep 3 17:34:22 2018 +0100

    network: convert networkAllocateActualDevice to virNetworkPortDef

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: avoid accidentally using files from gnulib
Daniel P. Berrangé [Thu, 8 Aug 2019 09:23:26 +0000 (10:23 +0100)]
tools: avoid accidentally using files from gnulib

The AM_CPPFLAGS setting includes the gnulib headers, which
means we can get some replacement functions defined. Since
virt-login-shell and the NSS module intentionally don't link
to gnulib, these replacement functions causes link failures.

This was seen cross-compiling on Debian for example:

virt-login-shell.o: In function `main':
/builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:81: undefined reference to `rpl_strerror'
/builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:66: undefined reference to `rpl_strerror'
/builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:75: undefined reference to `rpl_strerror'

The only way to avoid these replacement gnulib headers is
to drop the -Ignulib/lib flags. We do still want to use
gnulib for configmake.h and intprops.h, but those can be
included via their full path.

We must also stop using internal.h, since that expects
-Ignulib/lib to be on the include path in order to resolve
the verify.h header.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agomaint: Update to latest gnulib
Eric Blake [Thu, 8 Aug 2019 12:16:42 +0000 (07:16 -0500)]
maint: Update to latest gnulib

Requires adjustments to use verify_expr() which replaces
verify_true(), and to disable the new syntax check
'sc_prohibit_gnu_make_extensions' since we require GNU make.

Signed-off-by: Eric Blake <eblake@redhat.com>
5 years agoRevert "build: Solve mingw build clash with DATADIR"
Eric Blake [Thu, 8 Aug 2019 02:11:15 +0000 (21:11 -0500)]
Revert "build: Solve mingw build clash with DATADIR"

This reverts commit 8a8e86564ac22792d9abcd33c16c25493ca4ab2e.

The patch was premature, as it still fails to build on mingw at least
in the environment used by
https://travis-ci.org/libvirt/libvirt/jobs/569132417

Signed-off-by: Eric Blake <eblake@redhat.com>
5 years agobuild: Solve mingw build clash with DATADIR
Eric Blake [Wed, 31 Jul 2019 18:48:54 +0000 (13:48 -0500)]
build: Solve mingw build clash with DATADIR

Commit fed58d83 was a hack to fix a mingw build failure due to header
inclusion order resulting in a clash over the use of DATADIR,
repeating a trick made several other times in the past.  Better is to
revert that, and instead use pragmas to avoid the clash in the first
place, regardless of header ordering, solving it for everyone.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonss: fix indentation in aiforaf() method
Daniel P. Berrangé [Wed, 7 Aug 2019 13:32:52 +0000 (14:32 +0100)]
nss: fix indentation in aiforaf() method

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: only link to yajl library and nothing else
Daniel P. Berrangé [Wed, 31 Jul 2019 13:48:50 +0000 (14:48 +0100)]
nss: only link to yajl library and nothing else

Now that the code does not refer to any libvirt headers,
except internal.h macros, it does not need to link to
any libvirt code, nor gnulib either. The only thing it
needs is yajl.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: remove last usages of libvirt headers
Daniel P. Berrangé [Wed, 31 Jul 2019 13:35:34 +0000 (14:35 +0100)]
nss: remove last usages of libvirt headers

Use the plain libc APIs to avoid a dependancy on the main libvirt
code from the nss module.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: directly use getnameinfo/getaddrinfo
Daniel P. Berrangé [Wed, 31 Jul 2019 12:46:42 +0000 (13:46 +0100)]
nss: directly use getnameinfo/getaddrinfo

Use the plain libc socket APIs to avoid a dependancy on the main
libvirt code from the nss module.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: custom parser for loading .leases file
Daniel P. Berrangé [Wed, 31 Jul 2019 09:40:39 +0000 (10:40 +0100)]
nss: custom parser for loading .leases file

The .leases file is currently loaded using the virLease class,
which in turn uses the virJSON parsing code. This pulls in a
heap of libvirt code (logging, hash tables, etc) which we do
not wish to depend on.

This uses the yajl parser code directly, so the only dep is
yajl and plain libc functions.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: custom parser for loading .macs file
Daniel P. Berrangé [Wed, 31 Jul 2019 09:40:39 +0000 (10:40 +0100)]
nss: custom parser for loading .macs file

The .macs file is currently loaded using the virMacMap class,
which in turn uses the virJSON parsing code. This pulls in a
heap of libvirt code (logging, hash tables, objects, etc) which
we do not wish to depend on.

This uses the yajl parser code directly, so the only dep is
yajl and plain libc functions.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: refactor code for processing mac addresses
Daniel P. Berrangé [Tue, 30 Jul 2019 16:10:33 +0000 (17:10 +0100)]
nss: refactor code for processing mac addresses

Build a list of mac addresses immediately, so that later code
searching for leases can be simplified and avoid needing to
use the virMacMap object.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: remove use for virFile helper APIs
Daniel P. Berrangé [Tue, 30 Jul 2019 14:33:20 +0000 (15:33 +0100)]
nss: remove use for virFile helper APIs

Use the plain libc APIs to avoid a dependancy on the main libvirt
code from the nss module.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: remove use for virString helper APIs
Daniel P. Berrangé [Tue, 30 Jul 2019 14:33:20 +0000 (15:33 +0100)]
nss: remove use for virString helper APIs

Use the plain libc APIs to avoid a dependancy on the main libvirt
code from the nss module.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: remove use for virDir helper APIs
Daniel P. Berrangé [Tue, 30 Jul 2019 14:33:20 +0000 (15:33 +0100)]
nss: remove use for virDir helper APIs

Use the plain libc APIs to avoid a dependancy on the main libvirt
code from the nss module.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: get rid of virGetEnv{Allow,Block}SUID functions
Daniel P. Berrangé [Thu, 1 Aug 2019 12:35:56 +0000 (13:35 +0100)]
util: get rid of virGetEnv{Allow,Block}SUID functions

Now that 100% of libvirt code is forbidden in a SUID environment,
we no longer need to worry about whether env variables are
trustworthy or not. The virt-login-shell setuid program, which
does not link to any libvirt code, will purge all environment
variables, except $TERM, before invoking the virt-login-shell-helper
program which uses libvirt.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: simplify virCommand APIs for env passthrough.
Daniel P. Berrangé [Thu, 1 Aug 2019 12:52:00 +0000 (13:52 +0100)]
util: simplify virCommand APIs for env passthrough.

Now that 100% of libvirt code is forbidden in a SUID environment,
we no longer need to worry about whether env variables are
trustworthy or not. The virt-login-shell setuid program, which
does not link to any libvirt code, will purge all environment
variables, except $TERM, before invoking the virt-login-shell-helper
program which uses libvirt.

Thus we only need one API for env passthrough in virCommand.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: get rid of virIsSUID method
Daniel P. Berrangé [Thu, 1 Aug 2019 13:13:20 +0000 (14:13 +0100)]
util: get rid of virIsSUID method

Now that none of the libvirt.so code will ever run in a setuid
context, we can remove the virIsSUID() method. The global
initializer function can just inline the check itself. The new
inlined check is slightly stronger as it also looks for a
setgid situation.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop libvirt setuid library build
Daniel P. Berrangé [Tue, 30 Jul 2019 12:44:37 +0000 (13:44 +0100)]
build: drop libvirt setuid library build

The virt-login-shell setuid program is now a tiny piece of code
that only uses standard libc functions, and santizes the execution
environment before invoking the real virt-login-shell-helper.
The latter is thus able to use the normal libvirt.so build,
allowing us to delete the special cut down setuid library build.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: split virt-login-shell into two binaries
Daniel P. Berrangé [Thu, 1 Aug 2019 09:58:31 +0000 (10:58 +0100)]
tools: split virt-login-shell into two binaries

The virt-login-shell binary is a setuid program that takes
no arguments. When invoked it looks at the invoking uid,
resolves it to a username, and finds an LXC guest with the
same name. It then starts the guest and runs the shell in
side the namespaces of the container.

Given this set of tasks the virt-login-shell binary needs
to connect to libvirtd, make various other libvirt API calls.
This is a problem for setuid binaries as various libraries
that libvirt.so links to are not safe. For example, they have
constructor functions which execute an unknown amount of code
that can be influenced by env variables.

For this reason virt-login-shell doesn't use libvirt.so,
but instead links to a custom, cut down, set of source files
sufficient to be a local client only.

This introduces a problem for integrating glib2 into libvirt
though, as once integrated, there would be no way to build
virt-login-shell without an external dependancy on glib2 and
this is definitely not setuid safe.

To resolve this problem, we split the virt-login-shell binary
into two parts. The first part is setuid and does almost
nothing. It simply records the original uid+gid, and then
invokes the virt-login-shell-helper binary. Crucially when
it does this it completes scrubs all environment variables.
It is thus safe for virt-login-shell-helper to link to the
normal libvirt.so. Any things that constructor functions
do cannot be influenced by user control env vars or cli
args.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: rename source for virt-login-shell
Daniel P. Berrangé [Thu, 1 Aug 2019 09:57:39 +0000 (10:57 +0100)]
tools: rename source for virt-login-shell

We'll shortly be renaming the binary to virt-login-shell-helper
and introducing a new tool as virt-login-shell. Renaming the
source file first gives a much more usefull diff for the next
commit.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: fix double error reporting in virt-login-shell
Daniel P. Berrangé [Thu, 1 Aug 2019 12:02:57 +0000 (13:02 +0100)]
tools: fix double error reporting in virt-login-shell

The public API entry points will call virDispatchError which
will print to stderr by default. We then jump to a cleanup
path which calls virDispatchError again.

We tried to stop the entry points printing to stderr, but
incorrectly called virSetErrorFunc. It needs a real function
that is a no-op, not a NULL function.

Once we fix virSetErrorFunc, then we need to use fprintf in
the cleanup path instead of virDispatchError.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: fix crash in virt-login-shell if config doesn't exist
Daniel P. Berrangé [Thu, 1 Aug 2019 11:07:47 +0000 (12:07 +0100)]
tools: fix crash in virt-login-shell if config doesn't exist

If the 'allowed_users' config setting in virt-login-shell.conf
does not exist, we dereference a NULL pointer resulting in a
crash. We should check for this case and thus ensure the user
is denied access gracefully.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: Fix memory leak in mymain
John Ferlan [Wed, 7 Aug 2019 13:57:46 +0000 (09:57 -0400)]
tests: Fix memory leak in mymain

Commit d2899a648 added a new exit path, but didn't free @fakerootdir.
Let's just use VIR_AUTOFREE instead to make life easier.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Fix possible NULL deref in qemuDomainGetResctrlMonData
John Ferlan [Wed, 7 Aug 2019 13:54:06 +0000 (09:54 -0400)]
qemu: Fix possible NULL deref in qemuDomainGetResctrlMonData

If virQEMUDriverGetCapabilities returns NULL, then a subsequent
deref of @caps would cause an error, so we just return failure.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobuild: bump min required gcc to 4.8
Daniel P. Berrangé [Tue, 30 Jul 2019 13:07:24 +0000 (14:07 +0100)]
build: bump min required gcc to 4.8

The previous bump to 4.4 was done in:

  commit 24241c236e5e0b0b51a33ba539b40f5429a0df0e
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Jul 5 10:35:32 2017 +0100

    Require use of GCC 4.4 or CLang compilers

with 4.4 picked due to RHEL-6. Since we dropped RHEL-6, the
next oldest distro is RHEL-7 (4.8.5), and thus we pick 4.8
as the new min.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotest_driver: implement virDomainSetTime
Ilias Stamatis [Wed, 7 Aug 2019 10:22:56 +0000 (12:22 +0200)]
test_driver: implement virDomainSetTime

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: make testDomainGetTime read time from vm-private data
Ilias Stamatis [Wed, 7 Aug 2019 10:22:55 +0000 (12:22 +0200)]
test_driver: make testDomainGetTime read time from vm-private data

Until now, testDomainGetTime would always return the same fixed values
everytime it was called. By using domain-private data we can make this
API return the values previously set with testDomainSetTime, or use the
same old fixed values in case testDomainSetTime hasn't been called at all.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosrc: security: Replace bitwise OR with logical OR
Erik Skultety [Wed, 7 Aug 2019 10:08:46 +0000 (12:08 +0200)]
src: security: Replace bitwise OR with logical OR

Typo introduced by commit d73f3f58360.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: implement virDomainReset
Ilias Stamatis [Tue, 6 Aug 2019 15:56:23 +0000 (17:56 +0200)]
test_driver: implement virDomainReset

The qemu and vz implementations don't emit any signals when this API is
called, so we can do the same here for now and succeed by doing nothing.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu: Move rng model validation to domcaps
Cole Robinson [Sun, 31 Mar 2019 21:56:48 +0000 (17:56 -0400)]
qemu: Move rng model validation to domcaps

The qemu driver already does some <rng> model validation, based on
qemuCaps. However, the logic for exposing <rng> model values in domcaps
is basically identical. This drops the qemuCaps checking and compares
against the domCaps data directly.

This approach makes it basically impossible to add a new <rng> model to
the qemu driver without extending domcaps. The validation can also
be shared with other drivers eventually.

Reviewed-by: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: domain: Call virDomainCapsDeviceDefValidate
Cole Robinson [Sun, 31 Mar 2019 21:42:08 +0000 (17:42 -0400)]
qemu: domain: Call virDomainCapsDeviceDefValidate

Fill in virDomainCaps at Validate time and use it to call
virDomainCapsDeviceDefValidate

Reviewed-by: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoconf: domcaps: Add virDomainCapsDeviceDefValidate
Cole Robinson [Thu, 4 Apr 2019 17:09:18 +0000 (13:09 -0400)]
conf: domcaps: Add virDomainCapsDeviceDefValidate

This is an entrypoint to validate a virDomainDeviceDef against
values filled into virDomainCaps.

Currently it's just a stub

Reviewed-by: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: conf: Cache domCaps in qemuCaps
Cole Robinson [Thu, 4 Apr 2019 21:06:12 +0000 (17:06 -0400)]
qemu: conf: Cache domCaps in qemuCaps

qemuCaps is tied to a binary on disk. domCaps is tied to a combo
of binary+machine+arch+virttype values. For the qemu driver this almost
entirely translates to a permutation of qemuCaps though

Upcoming patches want to use the domCaps data store at XML validate
time, but we need to cache the data so we aren't repeatedly
regenerating it.

Add a domCapsCache hash table to qemuCaps. This ensures that the domCaps
cache is blown away whenever qemuCaps needs to be regenerated. Similarly
when qemuCaps is invalidated, the next call to virQEMUCapsCacheLookup
will unref qemuCaps and free our cache as well.

Adjust virQEMUDriverGetDomainCapabilities to search the cache and add
to it if we don't find a hit.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: conf: add virQEMUDriverGetDomainCapabilities
Cole Robinson [Thu, 4 Apr 2019 21:31:00 +0000 (17:31 -0400)]
qemu: conf: add virQEMUDriverGetDomainCapabilities

For now it's just a helper for building a qemu virDomainCapsPtr,
used in qemuConnectGetDomainCapabilities

Reviewed-by: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: capabilities: fill in domcaps <rng>
Cole Robinson [Sun, 31 Mar 2019 21:19:40 +0000 (17:19 -0400)]
qemu: capabilities: fill in domcaps <rng>

The model logic is taken from qemuDomainRNGDefValidate

Reviewed-by: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoconf: domcaps: Report device <rng>
Cole Robinson [Sun, 31 Mar 2019 21:19:33 +0000 (17:19 -0400)]
conf: domcaps: Report device <rng>

This adds device <rng> reporting. Example output:

    <rng supported='yes'>
      <enum name='model'>
        <value>virtio</value>
        <value>virtio-transitional</value>
        <value>virtio-non-transitional</value>
      </enum>
      <enum name='backendModel'>
        <value>random</value>
        <value>egd</value>
      </enum>
     </rng>

Reviewed-by: Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemuDomainGetResctrlMonData: Switch to switch()
Michal Privoznik [Tue, 6 Aug 2019 11:45:42 +0000 (13:45 +0200)]
qemuDomainGetResctrlMonData: Switch to switch()

This way it is obvious when adding a new resource control type
that stats helper func needs to be updated too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainGetResctrlMonData: Dereference resctrl monitor iff not NULL
Michal Privoznik [Tue, 6 Aug 2019 11:44:17 +0000 (13:44 +0200)]
qemuDomainGetResctrlMonData: Dereference resctrl monitor iff not NULL

If the host doesn't have resctrl then the monitor is going to be
NULL and we must avoid dereferencing it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainGetResctrlMonData: Don't leak @caps
Michal Privoznik [Tue, 6 Aug 2019 11:42:55 +0000 (13:42 +0200)]
qemuDomainGetResctrlMonData: Don't leak @caps

The capabilities object must be unrefed when no longer needed.
Use VIR_AUTOUNREF() for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: change the way how Hyper-V features are printed out
Vitaly Kuznetsov [Tue, 6 Aug 2019 05:52:33 +0000 (07:52 +0200)]
conf: change the way how Hyper-V features are printed out

Current code doesn't allow us to add sub-features as we always print the
closing '/>'. As a preparatory change to implementing 'direct' sub-feature
for 'stimer' feature switch to printing closing tag individually.

No functional change.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu_x86: add Edx to KVM_FEATURE_DEF()
Vitaly Kuznetsov [Tue, 6 Aug 2019 05:52:32 +0000 (07:52 +0200)]
cpu_x86: add Edx to KVM_FEATURE_DEF()

Some Hyper-V features (like the upcoming Direct Synthetic timers) are
announced by feature bits in Edx but KVM_FEATURE_DEF() supports only Eax.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_domain: Separate VFIO code
Michal Privoznik [Mon, 24 Jun 2019 08:01:16 +0000 (10:01 +0200)]
qemu_domain: Separate VFIO code

This piece of code will be re-used later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovirhostdevtest: s/CHECK_LIST_COUNT/CHECK_PCI_LIST_COUNT/
Michal Privoznik [Fri, 14 Jun 2019 12:30:13 +0000 (14:30 +0200)]
virhostdevtest: s/CHECK_LIST_COUNT/CHECK_PCI_LIST_COUNT/

In near future we will need to check for number of members of two
different types of lists: PCI and NVMe. Rename CHECK_LIST_COUNT
to CHECK_PCI_LIST_COUNT to mark explicitly what type of list it
is working with.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovirhostdevtest: Don't proceed to test cases if init failed
Michal Privoznik [Fri, 14 Jun 2019 08:39:24 +0000 (10:39 +0200)]
virhostdevtest: Don't proceed to test cases if init failed

The myInit() function is called before any of the test cases
because it prepares all internal structures for individual cases.
Well, if it fails there's no point in proceeding with testing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemuDomainDeviceDefValidateDisk: Reorder some checks
Michal Privoznik [Wed, 5 Jun 2019 11:45:35 +0000 (13:45 +0200)]
qemuDomainDeviceDefValidateDisk: Reorder some checks

I find this function more readable if checks for passed storage
source are done first and backing chain is done last. Mixing them
together does not hurt, but is less readable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovirPCIDeviceAddressAsString: Fix const correctness
Michal Privoznik [Thu, 6 Jun 2019 15:02:11 +0000 (17:02 +0200)]
virPCIDeviceAddressAsString: Fix const correctness

This function does not change any of the passed addresses. It
just reads them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovirPCIDeviceAddressEqual: Fix const correctness
Michal Privoznik [Tue, 4 Jun 2019 08:43:40 +0000 (10:43 +0200)]
virPCIDeviceAddressEqual: Fix const correctness

This function does not change any of the passed addresses. It
just reads them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agotest_driver: implement virDomainFSTrim
Ilias Stamatis [Sun, 4 Aug 2019 13:27:18 +0000 (15:27 +0200)]
test_driver: implement virDomainFSTrim

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: implement virDomainFSThaw
Ilias Stamatis [Sun, 4 Aug 2019 13:27:17 +0000 (15:27 +0200)]
test_driver: implement virDomainFSThaw

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: implement virDomainFSFreeze
Ilias Stamatis [Sun, 4 Aug 2019 13:27:16 +0000 (15:27 +0200)]
test_driver: implement virDomainFSFreeze

On success update the domain-private data. Consider / and /boot to be
the only mountpoints avaiable in order to be consistent with the other
FS-related calls.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: introduce domain-private data
Ilias Stamatis [Sun, 4 Aug 2019 13:27:15 +0000 (15:27 +0200)]
test_driver: introduce domain-private data

vm-specific data can be used by APIs that need to preserve some state
between calls

Some of them are:
- FS-related APIs for remembering which mountpoints are frozen
- virDomainSetTime / virDomainGetTime for maintaining time information
- virDomainSetIOThreadParams for storing the I/O thread parameters
- virDomainManagedSaveDefineXML for internally storing the VM definition

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: implement virDomainMemoryStats
Ilias Stamatis [Fri, 2 Aug 2019 11:13:31 +0000 (13:13 +0200)]
test_driver: implement virDomainMemoryStats

The main value here is the current balloon value which taken from the
config. All the other values (except for period) are derived by 2^n
division so that compiler prefers bitwise operations. Period value was
kept fixed in order to produce predictable results in a test environment.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: add a memballoon device in the default config
Ilias Stamatis [Fri, 2 Aug 2019 11:13:30 +0000 (13:13 +0200)]
test_driver: add a memballoon device in the default config

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: implement virDomainCreateXMLWithFile
Ilias Stamatis [Mon, 5 Aug 2019 09:02:23 +0000 (11:02 +0200)]
test_driver: implement virDomainCreateXMLWithFile

This should just forward the call to testDomainCreateXML since we
can't do anything with the provided file descriptors in the test driver.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
5 years agotest_driver: implement virDomainCreateWithFiles
Ilias Stamatis [Mon, 5 Aug 2019 09:02:22 +0000 (11:02 +0200)]
test_driver: implement virDomainCreateWithFiles

This should just forward the call to testDomainCreateWithFlags since we
can't do anything with the provided file descriptors in the test driver.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
5 years agodaemon: improve Xen support in systemd service
Jim Fehlig [Wed, 31 Jul 2019 18:02:48 +0000 (12:02 -0600)]
daemon: improve Xen support in systemd service

The xencommons service provides all the essential services such as
xenstored, xenconsoled, etc. needed by the libvirt Xen driver, so
libvirtd should be started after xencommons.

The xendomains service uses Xen's xl tool to operate on any domains it
finds running, even those managed by libvirt. Add a conflicts on the
xendomains service to ensure it is not enabled when libvirtd is enabled.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirhostdev: introduce virHostdevReattachAllPCIDevices
Daniel Henrique Barboza [Tue, 23 Jul 2019 17:35:41 +0000 (14:35 -0300)]
virhostdev: introduce virHostdevReattachAllPCIDevices

This code that executes virPCIDeviceReattach in all
virPCIDevicePtr objects of a given virPCIDeviceListPtr
list is replicated twice in the code. Putting it in a helper
function helps with readability.

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 agovirhostdev: remove virHostdevReattachPCIDevice
Daniel Henrique Barboza [Tue, 23 Jul 2019 17:35:40 +0000 (14:35 -0300)]
virhostdev: remove virHostdevReattachPCIDevice

virHostdevReattachPCIDevice() is a static that simply does
a wait loop with virPCIDeviceWaitForCleanup() before
calling virPCIDeviceReattach().

This loop traces back to commit d1e5676c0d, aiming to
solve a race condition between Libvirt returning the
device back to the host and QEMU trying to access it in
the meantime, which resulted in QEMU exiting on error
and killing the guest. This happens because device_del
is asynchronous, returning OK even if the guest didn't
release the device. Commit 01abc8a1b8 moved this code
to qemu_hostdev.c, 82e8dd4cf8 added the pci-stub conditional
for the loop, 899b261127 moved the code to virhostdev.c
where it stood until now.

The intent of this wait loop is still valid: device_del
is still not bullet proof into preventing the conditions
that commit d1e5676c0d aimed to fix, especially when considering
all the architectures we must support. However, this loop
is executed only in virHostdevReattachPCIDevice(), leaving
every other virPCIDeviceReattach() call prone to that error.

Let's move the wait loop code to virPCIDeviceReattach(). This
will:

-  make every reattach call safe from this race condition
with the pci-stub;

-  allow for a bit of code cleanup (virHostdevReattachPCIDevice()
can be erased, and virHostdevReAttachPCIDevices() can use
virPCIDeviceReattach() directly);

- make it easier to understand the overall reattach mechanisms in
Libvirt, without the risk of a newcomer wondering why reattach
is done slightly different in some instances.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirhostdev: introduce virHostdevResetAllPCIDevices
Daniel Henrique Barboza [Tue, 23 Jul 2019 17:35:39 +0000 (14:35 -0300)]
virhostdev: introduce virHostdevResetAllPCIDevices

This code that executes virPCIDeviceReset in all virPCIDevicePtr
objects of a given virPCIDeviceListPtr list is replicated twice
in the code. Putting it in a helper function helps with
readability.

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 agovirpci: Allow greater PCI domain value in virPCIDeviceAddressIsValid
Michal Privoznik [Tue, 30 Jul 2019 14:37:20 +0000 (16:37 +0200)]
virpci: Allow greater PCI domain value in virPCIDeviceAddressIsValid

There is no restriction on maximum value of PCI domain. In fact,
Linux kernel uses plain atomic inc when assigning PCI domains:

drivers/pci/pci.c:static int pci_get_new_domain_nr(void)
drivers/pci/pci.c-{
drivers/pci/pci.c-      return atomic_inc_return(&__domain_nr);
drivers/pci/pci.c-}

Of course, this function is called only if kernel was compiled
without PCI domain support or ACPI did not provide PCI domain.

However, QEMU still has the same restriction as us: in
set_pci_host_devaddr() QEMU checks if domain isn't greater than
0xffff. But one can argue that that's a QEMU limitation. We still
want to be able to cope with other hypervisors that don't have
this limitation (possibly).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolib: Format PCI address differently
Michal Privoznik [Tue, 30 Jul 2019 14:24:39 +0000 (16:24 +0200)]
lib: Format PCI address differently

Currently, the way we format PCI address is using printf-s
precision, e.g. "%.4x". This works if we don't want to print any
value outside of bounds (which is usually the case). However,
turns out, PCI domain can be 0x10000 which doesn't work well with
our format strings. However, if we change the format string to
"%04x" then we still pad small values with zeroes but also we are
able to print values that are larger than four digits. In fact,
this format string used by kernel to print a PCI address:

  "%04x:%02x:%02x.%d"

The other three format strings (for bus, device and function) are
changed too, so that we use the same format string as kernel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolib: Unify PCI address formatting
Michal Privoznik [Tue, 30 Jul 2019 12:43:44 +0000 (14:43 +0200)]
lib: Unify PCI address formatting

The format string for a PCI address is copied over and over
again, often with slight adjustments. Introduce global
VIR_PCI_DEVICE_ADDRESS_FMT macro that holds the formatting string
and use it wherever possible.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirPCIDevice: Make @name dynamically allocated
Michal Privoznik [Tue, 30 Jul 2019 09:37:43 +0000 (11:37 +0200)]
virPCIDevice: Make @name dynamically allocated

In near future, the length restriction of PCI domain is going to
be lifted. This means that our assumption that PCI address is 13
bytes long is no longer true. We can avoid this problem by making
@name dynamically allocated and thus not bother with actual
length of stringified PCI address.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirPCIDeviceNew: Prefer VIR_RETURN_PTR
Michal Privoznik [Tue, 30 Jul 2019 09:31:53 +0000 (11:31 +0200)]
virPCIDeviceNew: Prefer VIR_RETURN_PTR

This function declares @ret variable and then uses
VIR_STEAL_PTR() to avoid freeing temporary variable @dev which is
constructed. Well, as of 267f1e6da53 we have VIR_RETURN_PTR()
macro so that we can avoid this pattern.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line
Michal Privoznik [Tue, 30 Jul 2019 11:34:45 +0000 (13:34 +0200)]
qemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line

While it's true that older QEMUs were not able to deal with PCI
domains, we don't support those versions anymore (see
4a42ece13a538). Therefore it is safe to always format fully
expanded PCI address. Format PCI domain always as it will
simplify next commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Refactor and rename the function to validate a new resctrl monitor
Wang Huaqiang [Tue, 11 Jun 2019 03:31:16 +0000 (11:31 +0800)]
conf: Refactor and rename the function to validate a new resctrl monitor

A new algorithm for detecting the vcpus and monitor type conflicts
between new monitor an existing allocation and monitor groups.

After refactoring, since we are verifying both @vcpus and monitor
type @tag at the same time, the validating function name has been
renamed from virDomainResctrlMonValidateVcpus to
virDomainResctrlValidateMonitor.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: Remove unused virResctrlMonitorGetCacheOccupancy
Wang Huaqiang [Tue, 11 Jun 2019 03:31:15 +0000 (11:31 +0800)]
util: Remove unused virResctrlMonitorGetCacheOccupancy

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: Extend virresctl API to retrieve multiple monitor statistics
Wang Huaqiang [Tue, 11 Jun 2019 03:31:14 +0000 (11:31 +0800)]
util: Extend virresctl API to retrieve multiple monitor statistics

Export virResctrlMonitorGetStats and make
virResctrlMonitorGetCacheOccupancy obsoleted.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: Refactor 'virResctrlMonitorStats'
Wang Huaqiang [Tue, 11 Jun 2019 03:31:13 +0000 (11:31 +0800)]
util: Refactor 'virResctrlMonitorStats'

Refactor 'virResctrlMonitorStats' to track multiple statistical
records.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: Refactor and rename 'virResctrlMonitorFreeStats'
Wang Huaqiang [Tue, 11 Jun 2019 03:31:12 +0000 (11:31 +0800)]
util: Refactor and rename 'virResctrlMonitorFreeStats'

Refactor and rename 'virResctrlMonitorFreeStats' to
'virResctrlMonitorStatsFree' to free one
'virResctrlMonitorStatsPtr' object.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: Append 'resctrl' object according to number of monitor group directly
Wang Huaqiang [Tue, 11 Jun 2019 03:31:11 +0000 (11:31 +0800)]
conf: Append 'resctrl' object according to number of monitor group directly

'virResctrlAllocIsEmpty' checks if cache allocation or memory
bandwidth allocation settings are specified in configuration
file. It is not proper to be used in checking memory bandwidth
allocation is specified in XML settings because this function
could not distinguish memory bandwidth allocations from cache
allocations.

Here using the local variable @n, which indicates the cache
allocation groups or memory bandwidth groups depending on the
context it is in, to decide if append a new @resctrl object.

If @n is zero and no monitors groups specified in XML, then
we should not append a new @resctrl object to @def->resctrls.

This kind of replacement is also more efficient and avoiding
a long function calling path.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: refactor 'virDomainResctrlVcpuMatch' and some code cleanup
Wang Huaqiang [Tue, 11 Jun 2019 03:31:10 +0000 (11:31 +0800)]
conf: refactor 'virDomainResctrlVcpuMatch' and some code cleanup

Let 'virDomainResctrlVcpuMatch' to retrieve a pointer of
virDomainResctrlDefPtr in its third parameter instead
of virResctrlAllocPtr, if @vcpus is matched with the vcpus
of some resctrl allocation in list of @def->resctrls.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: some code cleanup
Wang Huaqiang [Tue, 11 Jun 2019 03:31:09 +0000 (11:31 +0800)]
conf: some code cleanup

Creating object and judging if it is successfully created in fewer
lines.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: code cleanup for return error code directly
Wang Huaqiang [Tue, 11 Jun 2019 03:31:08 +0000 (11:31 +0800)]
conf: code cleanup for return error code directly

code cleanup for 'virDomainCachetuneDefParse' and
'virDomainMemorytuneDefParse'.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: code cleanup, remove empty line and one space
Wang Huaqiang [Tue, 11 Jun 2019 03:31:07 +0000 (11:31 +0800)]
conf: code cleanup, remove empty line and one space

Remove some redundant space and line.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil, conf: Handle default monitor group of an allocation properly
Wang Huaqiang [Tue, 11 Jun 2019 03:31:06 +0000 (11:31 +0800)]
util, conf: Handle default monitor group of an allocation properly

'default monitor of an allocation' is defined as the resctrl
monitor group that created along with an resctrl allocation,
which is created by resctrl file system. If the monitor group
specified in domain configuration file is happened to be a
default monitor group of an allocation, then it is not necessary
to create monitor group since it is already created. But if
an monitor group is not an allocation default group, you
should create the group under folder
'/sys/fs/resctrl/mon_groups' and fill the vcpu PIDs to 'tasks'
file.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: Implement domain metadata getter/setter
Michal Privoznik [Mon, 5 Aug 2019 08:42:49 +0000 (10:42 +0200)]
libxl: Implement domain metadata getter/setter

Fortunately, the code that handles metadata getting or setting is
driver agnostic, so all that is needed from individual hypervisor
drivers is to call the right functions.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotools: console: Use proper constructor
Roman Bolshakov [Mon, 5 Aug 2019 16:03:45 +0000 (19:03 +0300)]
tools: console: Use proper constructor

"virsh console" on macOS cannot attach to a domain and it doesn't matter if
it's local or remote domain:
  $ ~ virsh console vm
  Connected to domain vm
  Escape character is ^]
  error: internal error: unable to wait on console condition

The error comes from pthread_cond_wait that fails with EINVAL. The mutex
in the parent is not initialized with pthread_mutex_init and it results
in silent failure of pthead_mutex_lock and the attach failure.

Fixes: 98361cc3b95 ("tools: console: make console virLockableObject")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews.xml: Restore blank news example
Michal Privoznik [Mon, 5 Aug 2019 17:33:25 +0000 (19:33 +0200)]
news.xml: Restore blank news example

In v5.6.0-rc1~347 I've mistakenly messed up news.xml as the
change I wanted to promote was added into a comment (I blame git
rebase for that). Anyway, restore the original state of the
comment so it can be copied again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agomaint: Post-release version bump to 5.7.0
Michal Privoznik [Mon, 5 Aug 2019 17:23:46 +0000 (19:23 +0200)]
maint: Post-release version bump to 5.7.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRelease of libvirt-5.6.0
Daniel Veillard [Mon, 5 Aug 2019 17:17:01 +0000 (19:17 +0200)]
Release of libvirt-5.6.0

* docs/news.xml: updated for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agonews: Update for 5.6.0 release
Andrea Bolognani [Fri, 2 Aug 2019 17:42:21 +0000 (19:42 +0200)]
news: Update for 5.6.0 release

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Daniel Veillard <veillard@redhat.com>
5 years agotests: Fix virsh-snapshot/checkpoint without readline-devel
Eric Blake [Fri, 2 Aug 2019 13:20:08 +0000 (08:20 -0500)]
tests: Fix virsh-snapshot/checkpoint without readline-devel

readline-devel is an optional build dependency; when it is not
present, the output of 'virsh <<EOF ... EOF' is different in that the
input provided by the user is not echoed, and prompts become
interleaved on the same line as actual output, which in turn causes
the sed doing prompt filtering to mess up:

| ./virsh-snapshot
| --- exp 2019-07-31 18:42:31.107399428 -0300
| +++ out.cooked 2019-07-31 18:42:31.108399437 -0300
| @@ -1,8 +1,3 @@
| -
| -
| -Domain snapshot s3 created from 's3.xml'
| -Domain snapshot s2 created from 's2.xml'
| -Name:           s2
|  Domain:         test
|  Current:        yes
|  State:          running

Maybe we should fix virsh in interactive mode to echo regardless of
whether readline-devel was used, but the quicker fix is to make the
test use 'virsh "..."' rather than reading its input from stdin.

Reported-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonews: add entry for new max_threads_per_process option in qemu.conf
Jim Fehlig [Wed, 31 Jul 2019 17:56:17 +0000 (11:56 -0600)]
news: add entry for new max_threads_per_process option in qemu.conf

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agonews: Add news entry for checkpoints
Eric Blake [Tue, 30 Jul 2019 21:51:48 +0000 (16:51 -0500)]
news: Add news entry for checkpoints

Checkpoints are definitely a news-worthy addition, even if the
virDomainBackup API is not going to make it until a later release.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agonews: Grammar tweaks
Eric Blake [Wed, 31 Jul 2019 13:09:57 +0000 (08:09 -0500)]
news: Grammar tweaks

Wording improvements in the recent patches.

Signed-off-by: Eric Blake <eblake@redhat.com>