]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoremote: get rid of bogus ATTRIBUTE_UNUSED annotation client param
Daniel P. Berrangé [Wed, 17 Jul 2019 12:48:08 +0000 (13:48 +0100)]
remote: get rid of bogus ATTRIBUTE_UNUSED annotation client param

The client parameter is always used to get access to the private data
struct.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoadmin: add ability to connect to the per-driver daemon sockets
Daniel P. Berrangé [Mon, 15 Jul 2019 16:35:07 +0000 (17:35 +0100)]
admin: add ability to connect to the per-driver daemon sockets

The admin client now supports addressing the per-driver daemons using
the obvious URI schemes for each daemon. eg virtqemud:///system
virtqemud:///session, etc.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovz: introduce virtvzd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
vz: introduce virtvzd daemon

The virtvzd daemon will be responsible for providing the vz API
driver functionality. The vz driver is still loaded by the main
libvirtd daemon at this stage, so virtvzd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: introduce virtbhyved daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
bhyve: introduce virtbhyved daemon

The virtbhyved daemon will be responsible for providing the bhyve API
driver functionality. The bhyve driver is still loaded by the main
libvirtd daemon at this stage, so virtbhyved must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: introduce virtvboxd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
vbox: introduce virtvboxd daemon

The virtvboxd daemon will be responsible for providing the vbox API
driver functionality. The vbox driver is still loaded by the main
libvirtd daemon at this stage, so virtvboxd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolxc: introduce virtlxcd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
lxc: introduce virtlxcd daemon

The virtlxcd daemon will be responsible for providing the lxc API
driver functionality. The lxc driver is still loaded by the main
libvirtd daemon at this stage, so virtlxcd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: introduce virtqemud daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
qemu: introduce virtqemud daemon

The virtqemud daemon will be responsible for providing the qemu API
driver functionality. The qemu driver is still loaded by the main
libvirtd daemon at this stage, so virtqemud must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: introduce virtxend daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
libxl: introduce virtxend daemon

The virtxend daemon will be responsible for providing the libxl API
driver functionality. The libxl driver is still loaded by the main
libvirtd daemon at this stage, so virtxend must not be running at
the same time.

This naming is slightly different than other drivers. With the libxl
driver, the user still has a 'xen:///system' URI, and we provide it
in a libvirt-daemon-xen RPM, which pulls in a
libvirt-daemon-driver-libxl RPM.

Arguably we could rename the libxl driver to "xen" since it is the
only xen driver we have these days, and that matches how we expose it
to users in the URI naming.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonwfilter: introduce virtnwfilterd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
nwfilter: introduce virtnwfilterd daemon

The virtnwfilterd daemon will be responsible for providing the nwfilter API
driver functionality. The nwfilter driver is still loaded by the main
libvirtd daemon at this stage, so virtnwfilterd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonodedev: introduce virtnodedevd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
nodedev: introduce virtnodedevd daemon

The virtnodedevd daemon will be responsible for providing the nodedev API
driver functionality. The nodedev driver is still loaded by the main
libvirtd daemon at this stage, so virtnodedevd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agostorage: introduce virtstoraged daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
storage: introduce virtstoraged daemon

The virtstoraged daemon will be responsible for providing the storage API
driver functionality. The storage driver is still loaded by the main
libvirtd daemon at this stage, so virtstoraged must not be running at
the same time.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agointerface: introduce virtinterfaced daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
interface: introduce virtinterfaced daemon

The virtinterfaced daemon will be responsible for providing the interface API
driver functionality. The interface driver is still loaded by the main
libvirtd daemon at this stage, so virtinterfaced must not be running at
the same time.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonetwork: introduce virtnetworkd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
network: introduce virtnetworkd daemon

The virtnetworkd daemon will be responsible for providing the network API
driver functionality. The network driver is still loaded by the main
libvirtd daemon at this stage, so virtnetworkd must not be running at
the same time.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecret: introduce virtsecretd daemon
Daniel P. Berrangé [Tue, 23 Jul 2019 11:22:41 +0000 (12:22 +0100)]
secret: introduce virtsecretd daemon

The virtsecretd daemon will be responsible for providing the secret API
driver functionality. The secret driver is still loaded by the main
libvirtd daemon at this stage, so virtsecretd must not be running at
the same time.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: introduce virtproxyd daemon to handle IP connectivity
Daniel P. Berrangé [Thu, 4 Jul 2019 11:33:23 +0000 (12:33 +0100)]
remote: introduce virtproxyd daemon to handle IP connectivity

The libvirtd daemon provides the traditional libvirt experience where
all the drivers are in a single daemon, and is accessible over both
local UNIX sockets and remote IP sockets.

In the new world we're having a set of per-driver daemons which will
primarily be accessed locally via their own UNIX sockets.

We still, however, need to allow for case of applications which will
connect to libvirt remotely. These remote connections can be done as
TCP/TLS sockets, or by SSH tunnelling to the UNIX socket.

In the later case, the old libvirt.so clients will only know about
the path to the old libvirtd socket /var/run/libvirt/libvirt-sock,
and not the new driver sockets /var/run/libvirt/virtqemud-sock.

It is also not desirable to expose the main driver specific daemons
over IP directly to minimize their attack service.

Thus the virtproxyd daemon steps into place, to provide TCP/TLS sockets,
and back compat for the old libvirtd UNIX socket path(s). It will then
forward all RPC calls made to the appropriate driver specific daemon.

Essentially it is equivalent to the old libvirtd with absolutely no
drivers registered except for the remote driver (and other stateless
drivers in libvirt.so).

We could have modified libvirtd so none of the drivers are registed
to get the same end result. We could even add a libvirtd.conf parameter
to control whether the drivers are loaded to enable users to switch back
to the old world if we discover bugs in the split-daemon model. Using a
new daemon though has some advantages

 - We can make virtproxyd and the virtXXXd per-driver daemons all
   have "Conflicts: libvirtd.service" in their systemd unit files.
   This will guarantee that libvirtd is never started at the same
   time, as this would result in two daemons running the same driver.
   Fortunately drivers use locking to protect themselves, but it is
   better to avoid starting a daemon we know will conflict.

 - It allows us to break CLI compat to remove the --listen parameter.
   Both listen_tcp and listen_tls parameters in /etc/libvirtd/virtd.conf
   will default to zero. Either TLS or TCP can be enabled exclusively
   though virtd.conf without requiring the extra step of adding --listen.

 - It allows us to set a strict SELinux policy over virtproxyd. For
   back compat the libvirtd policy must continue to allow all drivers
   to run. We can't easily give a second policy to libvirtd which
   locks it down. By introducing a new virtproxyd we can set a strict
   policy for that daemon only.

 - It gets rid of the weird naming of having a daemon with "lib" in
   its name. Now all normal daemons libvirt ships will have "virt"
   as their prefix not "libvirt".

 - Distros can more easily choose their upgrade path. They can
   ship both sets of daemons in their packages, and choose to
   either enable libvirtd, or enable the per-driver daemons and
   virtproxyd out of the box. Users can easily override this if
   desired by just tweaking which systemd units are active.

After some time we can deprecate use of libvirtd and after some more
time delete it entirely, leaving us in a pretty world filled with
prancing unicorns.

The main downside with introducing a new daemon, and with the
per-driver daemons in general, is figuring out the correct upgrade
path.

The conservative option is to leave libvirtd running if it was
an existing installation. Only use the new daemons & virtproxyd
on completely new installs.

The aggressive option is to disable libvirtd if already running
and activate all the new daemons.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: in per-driver daemons ensure that state initialize succeeds
Daniel P. Berrangé [Tue, 23 Jul 2019 12:05:18 +0000 (13:05 +0100)]
remote: in per-driver daemons ensure that state initialize succeeds

When running in libvirtd, we are happy for any of the drivers to simply
skip their initialization in virStateInitialize, as other drivers are
still potentially useful.

When running in per-driver daemons though, we want the daemon to abort
startup if the driver cannot initialize itself, as the daemon will be
useless without it.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: refactor how list of systemd unit files is built
Daniel P. Berrangé [Thu, 18 Jul 2019 15:38:36 +0000 (16:38 +0100)]
remote: refactor how list of systemd unit files is built

The make logic assumes that the SYSTEMD_UNIT_FILES var can be built from
SYSTEMD_UNIT_FILES_IN by simply dropping the directory prefix and the
.in suffix.

This won't work in future when a single .in unit file can be used to
generate multiple different units.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: conditionalize systemd socket unit files
Daniel P. Berrangé [Thu, 18 Jul 2019 15:34:41 +0000 (16:34 +0100)]
remote: conditionalize systemd socket unit files

Prepare for reusing libvirtd socket unit files with other daemons by
making various parts of their config conditionally defined by the make
rules.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: reduce duplication in systemd unit file make rules into one
Daniel P. Berrangé [Thu, 18 Jul 2019 15:31:45 +0000 (16:31 +0100)]
remote: reduce duplication in systemd unit file make rules into one

The make rules for the systemd socket unit files are all essentially
identical and can be collapsed into a single generic rule. The service
unit file rule can be simplified too.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: don't hardcode /etc in the config related files
Daniel P. Berrangé [Thu, 18 Jul 2019 15:17:07 +0000 (16:17 +0100)]
build: don't hardcode /etc in the config related files

Substitute in the @sysconfigdir@ value instead of /etc.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: refactor & rename variables for building libvirtd
Daniel P. Berrangé [Wed, 3 Jul 2019 13:00:33 +0000 (14:00 +0100)]
remote: refactor & rename variables for building libvirtd

The same make variables will be useful for building both libvirtd and
the split daemons, so refactor & rename variables to facilitate reuse.

Automake gets annoyed if you define a variable ending LDFLAGS:

src/remote/Makefile.inc.am:53: warning: variable 'REMOTE_DAEMON_LDFLAGS' is defined but no program or
src/remote/Makefile.inc.am:53: library has 'REMOTE_DAEMON' as canonical name (possible typo)

So we trick it by using an LD_FLAGS or LD_ADD suffix instead.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: remove useless $(LIBSOCKET) variable
Daniel P. Berrangé [Thu, 1 Aug 2019 15:46:25 +0000 (16:46 +0100)]
remote: remove useless $(LIBSOCKET) variable

GNULIB sets $(LIBSOCKET) on mingw to pull in the windows socket
APIs. This is trivially not required, since we don't build libvirtd
on mingw.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: conditionalize IP socket config in augeas definitions
Daniel P. Berrangé [Fri, 21 Jun 2019 16:19:11 +0000 (17:19 +0100)]
remote: conditionalize IP socket config in augeas definitions

Prepare for reusing libvirtd augeas defintions with other daemons by
making the config parameters for IP sockets conditionally defined by
the make rules.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: conditionalize IP socket config in libvirtd.conf
Daniel P. Berrangé [Fri, 21 Jun 2019 16:19:11 +0000 (17:19 +0100)]
remote: conditionalize IP socket config in libvirtd.conf

Prepare for reusing libvirtd config to create other daemons by making
the config parameters for IP sockets conditionally defined by the make
rules.

The main libvirtd daemon will retain IP listen ability, but all the
driver specific daemons will be local UNIX sockets only. Apps needing
IP connectivity will connect via the libvirtd daemon which will proxy
to the driver specfic daemon.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: use @CONFIG@ instead of ::CONFIG:: in augeas tests
Daniel P. Berrangé [Mon, 29 Jul 2019 11:30:07 +0000 (12:30 +0100)]
build: use @CONFIG@ instead of ::CONFIG:: in augeas tests

Using @VARNAME@ is a normal style of automake, so lets match that.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: conditionalize IP socket usage in libvirtd daemon
Daniel P. Berrangé [Fri, 21 Jun 2019 16:19:11 +0000 (17:19 +0100)]
remote: conditionalize IP socket usage in libvirtd daemon

Prepare for reusing libvirtd source to create other daemons by making
the use of IP sockets conditionally defined by the make rules.

The main libvirtd daemon will retain IP listen ability, but all the
driver specific daemons will be local UNIX sockets only. Apps needing
IP connectivity will connect via the libvirtd daemon which will proxy
to the driver specfic daemon.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: conditionalize driver loading in libvirtd daemon
Daniel P. Berrangé [Fri, 21 Jun 2019 16:19:11 +0000 (17:19 +0100)]
remote: conditionalize driver loading in libvirtd daemon

Prepare for reusing libvirtd source to create other daemons by making
the driver(s) to load conditionally defined by the make rules.

If nothing is set, all drivers will be loaded, ignoring any missing ones
as historically done.

If MODULE_NAME is set only one driver will be loaded and that one must
succeed.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: conditionalize daemon name in libvirtd daemon
Daniel P. Berrangé [Fri, 21 Jun 2019 16:19:11 +0000 (17:19 +0100)]
remote: conditionalize daemon name in libvirtd daemon

Prepare for reusing libvirtd source to create other daemons by making
the daemon name conditionally defined by the make rules.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: stop trying to print help as giant blocks of text
Daniel P. Berrangé [Thu, 18 Jul 2019 11:30:22 +0000 (12:30 +0100)]
remote: stop trying to print help as giant blocks of text

The remote daemon tries to print out its help text in a couple of giant
blocks of text. This has already lead to duplication of the text for the
privileged vs unprivileged execution mode. With the introduction of more
daemons, this text is going to be duplicated many more times with small
variations. This is very unfriendly to translators as they have to
translate approximately the same text many times with small tweaks.

Splitting the text up into individual strings to print means that each
piece will only need translating once. It also gets rid of all the
layout information from the translated strings, so avoids the problem of
translators breaking formatting by mistake.

Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: centralize rule for handling generated config files
Daniel P. Berrangé [Fri, 19 Jul 2019 16:48:58 +0000 (17:48 +0100)]
build: centralize rule for handling generated config files

Instead of adding generated config files to CLEANFILES and BUILT_SOURCES
in each makefile, add them all at once.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: use a common rule for checking augeas test data files
Daniel P. Berrangé [Fri, 19 Jul 2019 16:23:29 +0000 (17:23 +0100)]
build: use a common rule for checking augeas test data files

Instead of each subdir containing its own custom rule for checking the
augeas tests, use common rule for all.

The new rule searches both src + build dirs for include files, since
some augeas files will be auto-generated very shortly.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: create all augeas test files in same dir as their source
Daniel P. Berrangé [Fri, 19 Jul 2019 15:48:10 +0000 (16:48 +0100)]
build: create all augeas test files in same dir as their source

The current make rules are inconsistent about which directory the
augeas test files are created in. Put them all in the same dir as
their source.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: collapse rules adding augeas tests to CLEANFILES
Daniel P. Berrangé [Fri, 19 Jul 2019 15:52:28 +0000 (16:52 +0100)]
build: collapse rules adding augeas tests to CLEANFILES

We already have a variable that lists all augeas test files, so we can
add everything to CLEANFILES at once.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: make augeas-gentest.pl write to stdout
Daniel P. Berrangé [Wed, 17 Jul 2019 10:39:32 +0000 (11:39 +0100)]
build: make augeas-gentest.pl write to stdout

The augeas-gentest.pl program merges a config file into a augeas
file, saving the output to a new file. It is going to be useful
to further process the output file, and it would be easier if this can
be done with a pipeline, so change augeas-gentest.pl to write to stdout
instead of a file.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibvirt-admin: Add missing API arguments in debug printings
Han Han [Fri, 9 Aug 2019 06:29:41 +0000 (14:29 +0800)]
libvirt-admin: Add missing API arguments in debug printings

Each public API is required to log all arguments it was called
with. Except, there are some missing. Fix them.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRevert "tpm: Check TPM XML device configuration changes after edit"
Ján Tomko [Fri, 9 Aug 2019 08:48:35 +0000 (10:48 +0200)]
Revert "tpm: Check TPM XML device configuration changes after edit"

Redefining a domain via virDomainDefineXML should not give different results
based on an already existing definition.

Also, there's a crasher somewhere in the code:
https://bugzilla.redhat.com/show_bug.cgi?id=1739338

This reverts commit 94b3aa55f83ada33a9fdda66068d58ef1a56c0a5

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: code comment fix for TPM version
Marc-André Lureau [Fri, 9 Aug 2019 12:23:48 +0000 (16:23 +0400)]
conf: code comment fix for TPM version

Since its introduction in commit
8737578d115b8328f59f3342377b0c7ac06f658a, the TPM version format is
"2.0" and not "2".

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass correct qemuCaps to virDomainDeviceDefPostParse
Jiri Denemark [Thu, 8 Aug 2019 13:36:00 +0000 (15:36 +0200)]
qemu: Pass correct qemuCaps to virDomainDeviceDefPostParse

Since qemuDomainDeviceDefPostParse callback requires qemuCaps, we need
to make sure it gets the capabilities stored in the domain's private
data if the domain is running. Passing NULL may cause QEMU capabilities
probing to be triggered in case QEMU binary changed in the meantime.
When this happens while a running domain object is locked, QMP event
delivered to the domain before QEMU capabilities probing finishes will
deadlock the event loop.

QEMU capabilities lookup (via domainPostParseDataAlloc callback) is
hidden inside virDomainDeviceDefPostParseOne with no way to pass
qemuCaps to virDomainDeviceDef* functions. This patch fixes all
remaining paths leading to virDomainDeviceDefPostParse.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass correct qemuCaps to virDomainDefParseNode
Jiri Denemark [Tue, 6 Aug 2019 12:19:35 +0000 (14:19 +0200)]
qemu: Pass correct qemuCaps to virDomainDefParseNode

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

Several general snapshot and checkpoint APIs were lazily passing NULL as
the parseOpaque pointer instead of letting their callers pass the right
data. This patch fixes all paths leading to virDomainDefParseNode.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass correct qemuCaps to virDomainDefPostParse
Jiri Denemark [Tue, 6 Aug 2019 11:53:11 +0000 (13:53 +0200)]
qemu: Pass correct qemuCaps to virDomainDefPostParse

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to virDomainDefPostParse.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass correct qemuCaps to virDomainDefCopy
Jiri Denemark [Tue, 6 Aug 2019 11:41:42 +0000 (13:41 +0200)]
qemu: Pass correct qemuCaps to virDomainDefCopy

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

Several general functions from domain_conf.c were lazily passing NULL as
the parseOpaque pointer instead of letting their callers pass the right
data. This patch fixes all paths leading to virDomainDefCopy to do the
right thing.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass qemuCaps to qemuMigrationCookieXMLParse
Jiri Denemark [Tue, 6 Aug 2019 10:31:45 +0000 (12:31 +0200)]
qemu: Pass qemuCaps to qemuMigrationCookieXMLParse

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to qemuMigrationCookieXMLParse.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass correct qemuCaps to virDomainDefParseString
Jiri Denemark [Mon, 5 Aug 2019 14:26:29 +0000 (16:26 +0200)]
qemu: Pass correct qemuCaps to virDomainDefParseString

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to virDomainDefParseString.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass qemuCaps to qemuMigrationAnyPrepareDef
Jiri Denemark [Mon, 5 Aug 2019 15:31:10 +0000 (17:31 +0200)]
qemu: Pass qemuCaps to qemuMigrationAnyPrepareDef

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to qemuMigrationAnyPrepareDef.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass qemuCaps to qemuDomainSaveImageOpen
Jiri Denemark [Mon, 5 Aug 2019 14:40:19 +0000 (16:40 +0200)]
qemu: Pass qemuCaps to qemuDomainSaveImageOpen

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to qemuDomainSaveImageOpen.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass qemuCaps to qemuDomainDefFormatBufInternal
Jiri Denemark [Mon, 5 Aug 2019 14:05:20 +0000 (16:05 +0200)]
qemu: Pass qemuCaps to qemuDomainDefFormatBufInternal

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to qemuDomainDefFormatBufInternal.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Pass qemuCaps to qemuDomainDefCopy
Jiri Denemark [Fri, 2 Aug 2019 15:36:56 +0000 (17:36 +0200)]
qemu: Pass qemuCaps to qemuDomainDefCopy

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to qemuDomainDefCopy.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonss: Don't leak memory on parse error
Michal Privoznik [Fri, 9 Aug 2019 08:37:05 +0000 (10:37 +0200)]
nss: Don't leak memory on parse error

If yajl_parse() fails, we try to print an error message. For
that, yajl_get_error() is used. However, its documentation say
that caller is also responsible for freeing the memory it
allocates by using yajl_free_error().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: Include stdio.h and define NULLSTR when debugging is enabled
Michal Privoznik [Fri, 9 Aug 2019 08:32:15 +0000 (10:32 +0200)]
nss: Include stdio.h and define NULLSTR when debugging is enabled

The NSS module has a compile time option which when enabled makes
ERROR() and DEBUG() print messages onto stderr. But now that the
module no longer links with libvirt, we need to include stdio.h
and define NULLSTR().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonss: Don't stop parsing on unexpected key
Michal Privoznik [Fri, 9 Aug 2019 08:25:22 +0000 (10:25 +0200)]
nss: Don't stop parsing on unexpected key

Due to latest rewrite of NSS module, we are doing yajl parsing
ourselves. This means, we had to introduce couple of callback
that yajl calls. According to its documentation, a callback can
cancel parsing if it returns a zero value. Well, we do just that
in the string callback (findLeasesParserString()). If the JSON
file we are parsing contains a key that we are not interested in,
zero is returned meaning stop all parsing. This is not correct,
because the JSON file can contain some other keys which are not
harmful for our address translation (e.g. 'client-id').

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: formatdomain: explain host-model/host-passthrough requirements
Paolo Bonzini [Fri, 2 Aug 2019 12:54:15 +0000 (14:54 +0200)]
docs: formatdomain: explain host-model/host-passthrough requirements

host-passthrough documentation menions that the source and destination
hosts are not identical in both hardware and configuration.  Configuration
actually includes microcode version and QEMU version, but this is not
clear so make it explicit

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20190802125415.15227-1-pbonzini@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agotest_driver: implement virDomainGetBlockInfo
Ilias Stamatis [Thu, 8 Aug 2019 10:30:24 +0000 (12:30 +0200)]
test_driver: implement virDomainGetBlockInfo

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirsh: Introduce virshPoolTypeCompleter
Michal Privoznik [Fri, 19 Jul 2019 08:25:19 +0000 (10:25 +0200)]
virsh: Introduce virshPoolTypeCompleter

This completer can be used to complete pool types.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agovirsh-completer: Drop needless #include
Michal Privoznik [Sun, 14 Jul 2019 10:54:10 +0000 (12:54 +0200)]
virsh-completer: Drop needless #include

Now that there is no code in virsh-completer.c it doesn't make
much sense to keep those #include-s around. Delete them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate checkpoint related completers into a file
Michal Privoznik [Wed, 7 Aug 2019 07:44:55 +0000 (09:44 +0200)]
tools: Separate checkpoint related completers into a file

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agotools: Separate host related completers into a file
Michal Privoznik [Sun, 14 Jul 2019 10:24:38 +0000 (12:24 +0200)]
tools: Separate host related completers into a file

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
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>