]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
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>