]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agodriver.c: change URI validation to handle QEMU and vbox case
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:43 +0000 (11:56 -0300)]
driver.c: change URI validation to handle QEMU and vbox case

The existing QEMU and vbox URI path validation consider
that a privileged user can use both a "/system" and a
"/session" URI. This differs from all the other drivers
that forbids the root user to use "/session" URI.

Let's update virConnectValidateURIPath() to handle these
cases as exceptions, using the already existent 'entityName'
value to handle "QEMU" and "vbox" differently. This allows
us to use the validateURI function in these cases without
changing the existing behavior of other drivers.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agostorage_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:42 +0000 (11:56 -0300)]
storage_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agosecret_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:41 +0000 (11:56 -0300)]
secret_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonode_device_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:40 +0000 (11:56 -0300)]
node_device_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agobridge_driver.c: virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:39 +0000 (11:56 -0300)]
bridge_driver.c: virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agointerface_backend_udev.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:38 +0000 (11:56 -0300)]
interface_backend_udev.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agointerface_backend_netcf.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:37 +0000 (11:56 -0300)]
interface_backend_netcf.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agosrc/driver.c: add virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:36 +0000 (11:56 -0300)]
src/driver.c: add virConnectValidateURIPath()

The code to validate the URI path is repeated across several
files. This patch creates a common validation code to be
used across all of them.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: utility function to update entry in def->nets array
Laine Stump [Wed, 25 Sep 2019 16:42:51 +0000 (12:42 -0400)]
conf: utility function to update entry in def->nets array

A virDomainNetDef object in a domain's nets array might contain a
virDomainHostdevDef, and when this is the case, the domain's hostdevs
array will also have a pointer to this embedded hostdev (this is done
so that internal functions that need to perform some operation on all
hostdevs won't leave out the type='hostdev' network interfaces).

When a network device was updated with virDomainUpdateDeviceFlags(),
we were replacing the entry in the nets array (and free'ing the
original) but forgetting about the pointer in the hostdevs array
(which would then point to the now-free'd hostdev contained in the old
net object.) This often resulted in a libvirtd crash.

The solution is to add a function, virDomainNetUpdate(), called by
qemuDomainUpdateDeviceConfig(), that updates the hostdevs array
appropriately along with the nets array.

Resolves: https://bugzilla.redhat.com/1558934

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodomain_conf: Unref video private data in virDomainVideoDefClear()
Michal Privoznik [Thu, 26 Sep 2019 14:17:49 +0000 (16:17 +0200)]
domain_conf: Unref video private data in virDomainVideoDefClear()

The private data for video definition is created in
virDomainVideoDefNew() and we attempt to free it in
virDomainVideoDefFree(). This seems to work, except
the free function calls clear function which zeroes
out the whole structure and thus virObjectUnref()
which is called on private data does nothing.

2,568 bytes in 107 blocks are definitely lost in loss record 207 of 213
   at 0x4A35476: calloc (vg_replace_malloc.c:752)
   by 0x50A6048: virAllocVar (viralloc.c:346)
   by 0x513CC5A: virObjectNew (virobject.c:243)
   by 0x4DC1DEE: qemuDomainVideoPrivateNew (qemu_domain.c:1337)
   by 0x51A6BD6: virDomainVideoDefNew (domain_conf.c:2831)
   by 0x51B9F06: virDomainVideoDefParseXML (domain_conf.c:15541)
   by 0x51CB761: virDomainDefParseXML (domain_conf.c:21158)
   by 0x51C5973: virDomainDefParseNode (domain_conf.c:21708)
   by 0x51C583A: virDomainDefParse (domain_conf.c:21663)
   by 0x51C58AE: virDomainDefParseFile (domain_conf.c:21688)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agospec: Drop unittest overrides
Cole Robinson [Tue, 24 Sep 2019 17:21:13 +0000 (13:21 -0400)]
spec: Drop unittest overrides

nodinfotest.c doesn't exist anymore

seclabeltest.c has changed substantially since this behavior was
added to the spec, and in my testing doesn't have any problems
running in mock

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: driver: Remove unused cleanup labels in stats gathering functions
Peter Krempa [Thu, 19 Sep 2019 09:32:09 +0000 (11:32 +0200)]
qemu: driver: Remove unused cleanup labels in stats gathering functions

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportFro...
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportFrontend

The macro now became unused so it was deleted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportBac...
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportBackendStorage

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlock
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlock

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlockFallback
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlockFallback

The open-coded version does not take much more space and additionally we
get rid of the hidden goto.

This also requires us to remove the 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use virTypedParamList in the bulk stats gathering functions
Peter Krempa [Thu, 19 Sep 2019 08:36:28 +0000 (10:36 +0200)]
qemu: Use virTypedParamList in the bulk stats gathering functions

The bulk stats functions are specific as they pass around the list into
many sub-functions and also a substantial amount of the entries uses
formatted names for indexing purposes. This makes them ideal to be
converted to the new virTypedParamList helpers.

Unfortunately given how the functions are used this requires a big-bang
rewrite of all of the calls to add entries to the parameter list.

Given that a substantial simplification is achieved as well as a pretty
significant change to the original code is required some macros which
were used only sporadically were replaced by inline calls rather than
tweaking the macros first and deleting them later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Remove QEMU_ADD_BLOCK_PARAM_LL macro
Peter Krempa [Thu, 15 Aug 2019 09:38:08 +0000 (11:38 +0200)]
qemu: driver: Remove QEMU_ADD_BLOCK_PARAM_LL macro

Use QEMU_ADD_BLOCK_PARAM_ULL instead since all parameters are now
unsigned.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Don't return anything from qemuDomainBlockStatsGatherTotals
Peter Krempa [Mon, 16 Sep 2019 16:58:25 +0000 (18:58 +0200)]
qemu: driver: Don't return anything from qemuDomainBlockStatsGatherTotals

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Remove pointless macro QEMU_BLOCK_STAT_TOTAL
Peter Krempa [Mon, 16 Sep 2019 16:57:53 +0000 (18:57 +0200)]
qemu: driver: Remove pointless macro QEMU_BLOCK_STAT_TOTAL

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Change fields in qemuBlockStats to 'unsigned'
Peter Krempa [Thu, 15 Aug 2019 09:32:28 +0000 (11:32 +0200)]
qemu: monitor: Change fields in qemuBlockStats to 'unsigned'

None of the fields actually return negative values. The internal
implementation of BlockAcctStats struct in qemu uses uint64_t and the
last place using -1 in libvirt was in the HMP monitor code which was
deleted.

Change the internal type to unsigned long long and ensure that all
public conversions don't overflow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Refactor cleanup in qemuMonitorJSONGetAllBlockStatsInfo
Peter Krempa [Mon, 16 Sep 2019 14:19:33 +0000 (16:19 +0200)]
qemu: monitor: Refactor cleanup in qemuMonitorJSONGetAllBlockStatsInfo

Use VIR_AUTOPTR and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Refactor cleanup in qemuMonitorJSONGetOneBlockStatsInfo
Peter Krempa [Mon, 16 Sep 2019 14:19:33 +0000 (16:19 +0200)]
qemu: monitor: Refactor cleanup in qemuMonitorJSONGetOneBlockStatsInfo

Use VIR_AUTOFREE and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Refactor cleanup in qemuMonitorJSONBlockStatsCollectData
Peter Krempa [Mon, 16 Sep 2019 14:19:33 +0000 (16:19 +0200)]
qemu: monitor: Refactor cleanup in qemuMonitorJSONBlockStatsCollectData

Use VIR_AUTOFREE and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Remove stale comment for qemuDomainBlockStats
Peter Krempa [Mon, 16 Sep 2019 14:18:21 +0000 (16:18 +0200)]
qemu: Remove stale comment for qemuDomainBlockStats

We no longer use HMP for this API.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: typedparam: Simplify handling of lists of typed parameters
Peter Krempa [Thu, 19 Sep 2019 07:20:49 +0000 (09:20 +0200)]
util: typedparam: Simplify handling of lists of typed parameters

Introduce a new set of helpers including a new data structure which
simplifies keeping and construction of lists of typed parameters.

The use of VIR_RESIZE_N in the virTypedParamsAdd API has performance
benefits but requires passing around 3 arguments. Use of them lead to a
set of macros with embedded jumps used in the qemu statistics code.

This patch introduces 'virTypedParamList' type which aggregates the
necessary list-keeping variables and also a new set of functions to add
new typed parameters to a list.

These new helpers use printf-like format string and arguments to format
the argument name as the stats code often uses indexed typed parameters.

The accessor function then allows extracting the typed parameter list in
the same format as virTypedParamsAdd* functions would do.

One additional benefit is also that the list function can easily be used
with VIR_AUTOPTR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: typedparam: Optionally copy strings passed to virTypedParameterAssignValue
Peter Krempa [Wed, 14 Aug 2019 12:52:46 +0000 (14:52 +0200)]
util: typedparam: Optionally copy strings passed to virTypedParameterAssignValue

Some code paths already pass in pointers to strings which should be
added directly as the value of the typed parameter. To allow more
universal use of virTypedParameterAssignValue add a flag which allows to
copy the value in place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: typedparam: Separate code to assign value to typed parameter
Peter Krempa [Wed, 14 Aug 2019 11:00:13 +0000 (13:00 +0200)]
util: typedparam: Separate code to assign value to typed parameter

The code will be reused in other function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: typedparam: Remove pointless cleanup label from virTypedParameterAssignFromStr
Peter Krempa [Tue, 17 Sep 2019 17:55:37 +0000 (19:55 +0200)]
util: typedparam: Remove pointless cleanup label from virTypedParameterAssignFromStr

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: typedparam: Move and unexport virTypedParameterAssignFromStr
Peter Krempa [Tue, 17 Sep 2019 17:45:39 +0000 (19:45 +0200)]
util: typedparam: Move and unexport virTypedParameterAssignFromStr

The function is only used as a helper in virTypedParamsAddFromString.
Make it static and move it to virtypedparam-public.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: typedparam: Purge public bits from virTypedParamsGetStringList
Peter Krempa [Tue, 17 Sep 2019 17:35:51 +0000 (19:35 +0200)]
util: typedparam: Purge public bits from virTypedParamsGetStringList

The function is not exported in the public API thus the error
dispatching is not required.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: typedparam: Split out public APIs into a separate file
Peter Krempa [Tue, 17 Sep 2019 17:21:14 +0000 (19:21 +0200)]
util: typedparam: Split out public APIs into a separate file

Some of the typed parameter APIs are exported publicly, but the
implementation was intermixed with private functions. Introduce
virtypedparam-public.c, move all public API functions there and purge
the comments stating that some functions are public.

This will decrease the likelihood of messing up the expectations as well
as it will become more clear which of them are actually public.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_blockjob: Remove secdriver metadata for whole backing chain on job completion
Michal Privoznik [Mon, 16 Sep 2019 10:28:48 +0000 (12:28 +0200)]
qemu_blockjob: Remove secdriver metadata for whole backing chain on job completion

Turns out, block mirror is not the only job a disk can have. It
can also do commits of one layer into the other. Or possibly some
other tricks too. Problem is that while we set seclabels on given
layers of backing chain when the job is starting (via
qemuDomainStorageSourceAccessAllow()) we don't restore them when
job finishes. This leaves XATTRs set and corresponding images
unusable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agodomain_conf: Fix str2enum translation of video driver name
Michal Privoznik [Wed, 25 Sep 2019 07:54:49 +0000 (09:54 +0200)]
domain_conf: Fix str2enum translation of video driver name

In bc1e924cf0d we've introduced video driver name and whilst
doing so we've utilized VIR_ENUM_IMPL() macro. Then, in domain
XML parsing code the generated
virDomainVideoBackendTypeFromString() is called and its return
value is assigned directly to an unsigned int variable which is
wrong. Also, the video driver enum has 'default' value which is
not formatted into domain XML but is accepted during parsing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: checkpoint: Don't forbid checkpoint when VM is marked for autodestroy
Peter Krempa [Tue, 24 Sep 2019 12:42:27 +0000 (14:42 +0200)]
qemu: checkpoint: Don't forbid checkpoint when VM is marked for autodestroy

The check was copied from the snapshot code and makes even less sense
here.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: snapshot: Don't forbid snapshot if autodestroy is registered
Peter Krempa [Tue, 24 Sep 2019 12:39:21 +0000 (14:39 +0200)]
qemu: snapshot: Don't forbid snapshot if autodestroy is registered

Semantically VIR_DOMAIN_START_AUTODESTROY doesn't really clash with
snapshot operations as the VM stays on the same host and thus bound to
the same connection. Saving the state also doesn't differ from modifying
the state of the VM which is allowed.

Remove the check as it doesn't make much sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: migration: Forbid only remote migration if autodestroy is active for VM
Peter Krempa [Tue, 24 Sep 2019 12:59:04 +0000 (14:59 +0200)]
qemu: migration: Forbid only remote migration if autodestroy is active for VM

Semantically we can't guarantee that we'll be able to destroy the VM on
the remote host, thus we can't allow remote migration. All other forms
of migration (e.g. saving to file) are okay though as they don't clash
with semantics of the flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agolib: Lessen restrictions on VIR_DOMAIN_START_AUTODESTROY
Peter Krempa [Tue, 24 Sep 2019 12:55:15 +0000 (14:55 +0200)]
lib: Lessen restrictions on VIR_DOMAIN_START_AUTODESTROY

Apart from migrating the VM to a remote host where we can't honour the
VIR_DOMAIN_START_AUTODESTROY flag properly, restricting APIs which just
modify the state of the VM does not make much sense.

Change the wording of the documentation for VIR_DOMAIN_START_AUTODESTROY
so that snapshots and saving to a file may be permitted as they
semantically don't clash with the flag itself. Otherwise we'd have to
forbid other APIs, such as virDomainDestroy as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agotests: add vhost-user-gpu xml2argv tests
Marc-André Lureau [Mon, 23 Sep 2019 10:44:43 +0000 (14:44 +0400)]
tests: add vhost-user-gpu xml2argv tests

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: build vhost-user GPU devices
Marc-André Lureau [Mon, 23 Sep 2019 10:44:42 +0000 (14:44 +0400)]
qemu: build vhost-user GPU devices

For each vhost-user GPUs,
- build a socket chardev, and pass the vhost-user socket to it
- build a vhost-user video device and associate it with the chardev

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: start/stop the vhost-user-gpu external device
Marc-André Lureau [Mon, 23 Sep 2019 10:44:41 +0000 (14:44 +0400)]
qemu: start/stop the vhost-user-gpu external device

Each vhost-user-gpu needs its own helper gpu process.
Start/stop them, and apply the emulator cgroup controller.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: prepare domain for vhost-user GPU
Marc-André Lureau [Mon, 23 Sep 2019 10:44:40 +0000 (14:44 +0400)]
qemu: prepare domain for vhost-user GPU

Call qemuExtVhostUserGPUPrepareDomain() to fill the domain with the
location of the vhost-user binary to start.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agotests: wrap vhost-user paths in qemuxml2argvtest
Marc-André Lureau [Mon, 23 Sep 2019 10:44:39 +0000 (14:44 +0400)]
tests: wrap vhost-user paths in qemuxml2argvtest

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agotests: mock execv/execve
Marc-André Lureau [Mon, 23 Sep 2019 10:44:38 +0000 (14:44 +0400)]
tests: mock execv/execve

Learn to override the paths to the program to execute (vhost-user
helpers are executed to check for runtime capabilities).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: add vhost-user-gpu helper unit
Marc-André Lureau [Mon, 23 Sep 2019 10:44:37 +0000 (14:44 +0400)]
qemu: add vhost-user-gpu helper unit

Similar to the qemu_tpm.c, add a unit with a few functions to
start/stop and setup the cgroup of the external vhost-user-gpu
process. See function documentation.

The vhost-user connection fd is set on qemuDomainVideoPrivate struct.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: add qemuDomainVideoPrivate
Marc-André Lureau [Mon, 23 Sep 2019 10:44:36 +0000 (14:44 +0400)]
qemu: add qemuDomainVideoPrivate

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoconf: add privateData to virDomainVideoDef
Marc-André Lureau [Mon, 23 Sep 2019 10:44:35 +0000 (14:44 +0400)]
conf: add privateData to virDomainVideoDef

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: add qemuSecurityStartVhostUserGPU helper
Marc-André Lureau [Mon, 23 Sep 2019 10:44:34 +0000 (14:44 +0400)]
qemu: add qemuSecurityStartVhostUserGPU helper

See function documentation. Used in a following patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: add vhost-user helpers
Marc-André Lureau [Mon, 23 Sep 2019 10:44:33 +0000 (14:44 +0400)]
qemu: add vhost-user helpers

Add qemuVhostUserFetchConfigs() to discover vhost-user helpers.

qemuVhostUserFillDomainGPU() will find the first matching GPU helper
with the required capabilities and set the associated
vhost_user_binary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: restrict 'virgl=' option to non-vhostuser video type
Marc-André Lureau [Mon, 23 Sep 2019 10:44:32 +0000 (14:44 +0400)]
qemu: restrict 'virgl=' option to non-vhostuser video type

vhost-user device doesn't have a virgl option, it is passed to the
vhost-user-gpu helper process instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: validate virtio-gpu with vhost-user
Marc-André Lureau [Mon, 23 Sep 2019 10:44:31 +0000 (14:44 +0400)]
qemu: validate virtio-gpu with vhost-user

Check qemu capability, and accept 3d acceleration. 3d acceleration
support is checked when looking for a suitable vhost-user helper.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: check that qemu is vhost-user-vga capable
Marc-André Lureau [Mon, 23 Sep 2019 10:44:30 +0000 (14:44 +0400)]
qemu: check that qemu is vhost-user-vga capable

To support virtio VGA with vhost-user, vhost-user-vga device is necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: add vhost-user-gpu capabilities checks
Marc-André Lureau [Mon, 23 Sep 2019 10:44:29 +0000 (14:44 +0400)]
qemu: add vhost-user-gpu capabilities checks

Those new devices are available since QEMU 4.1.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu-cgroup: allow accel rendernode access
Marc-André Lureau [Mon, 23 Sep 2019 10:44:28 +0000 (14:44 +0400)]
qemu-cgroup: allow accel rendernode access

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodomain: add rendernode attribute on <accel>
Marc-André Lureau [Mon, 23 Sep 2019 10:44:27 +0000 (14:44 +0400)]
domain: add rendernode attribute on <accel>

vhost-user-gpu helper takes --render-node option to specify on which
GPU should the renderning be done.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: format/parse/rng/docs for video <driver name='qemu|vhostuser'/>
Marc-André Lureau [Mon, 23 Sep 2019 10:44:26 +0000 (14:44 +0400)]
conf: format/parse/rng/docs for video <driver name='qemu|vhostuser'/>

Accept a new driver name attribute to specify usage of helper process, ex:

  <video>
    <driver name='vhostuser'/>
    <model type='virtio'/>
  </video>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: generalize qemuFetchConfigs
Marc-André Lureau [Mon, 23 Sep 2019 10:44:24 +0000 (14:44 +0400)]
qemu: generalize qemuFetchConfigs

The same config files disovery & priority rules are used for
vhost-user backends.

No functional change, the only difference is that
qemuInteropFetchConfigs() takes a "name" argument and construct paths
with it (ex: "firmware").

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobuild: force a UTF-8 locale for python
Daniel P. Berrangé [Thu, 5 Sep 2019 15:45:27 +0000 (16:45 +0100)]
build: force a UTF-8 locale for python

Python3 versions less than 3.7 have very unhelpful handling
of the C locale where they assume data is 7-bit only. This
violates POSIX which requires the C locale to be 8-bit clean.
Python3 >= 3.7 now assumes that the C locale is always UTF-8.

Set env variables to force LC_CTYPE to en_US.UTF-8 so that
we get UTF-8 handling on all python versions. Note we do
not use C.UTF-8 since not all C libraries support that.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: ensure Makefile.inc.am is checked for long lines
Daniel P. Berrangé [Mon, 23 Sep 2019 11:31:57 +0000 (12:31 +0100)]
build: ensure Makefile.inc.am is checked for long lines

The filename match rule was accidentally excluding the
Makefile.inc.am files from the long lines check.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: hotplug: Use VIR_AUTOFREE() instead VIR_FREE for strings
Daniel Henrique Barboza [Wed, 18 Sep 2019 19:53:06 +0000 (16:53 -0300)]
qemu: hotplug: Use VIR_AUTOFREE() instead VIR_FREE for strings

Cleanup labels are also dropped where possible.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu: snapshot: Do ACL check prior to checkpoint interlocking
Peter Krempa [Mon, 23 Sep 2019 13:48:06 +0000 (15:48 +0200)]
qemu: snapshot: Do ACL check prior to checkpoint interlocking

Commit 7efe930ec3c introduced interlock of snapshots and checkpoints,
but the check is executed prior to the snapshot API ACL check. This
means that an unauthorized user can see whether a VM exists if it has a
checkpoint.

Move the checks to proper places.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agodocs: kbase: Add a section explaining how to verify SEV from the guest
Erik Skultety [Fri, 20 Sep 2019 11:47:09 +0000 (13:47 +0200)]
docs: kbase: Add a section explaining how to verify SEV from the guest

Commit 50dfabbb59 forgot to add this important bit on how to check that
all the changes to the XML actually worked.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_domain_address: use virPCIDeviceAddressEqual() in conditionals
Daniel Henrique Barboza [Fri, 20 Sep 2019 13:52:55 +0000 (10:52 -0300)]
qemu_domain_address: use virPCIDeviceAddressEqual() in conditionals

A common operation in qemu_domain_address is comparing a
virPCIDeviceAddress and assigning domain, bus, slot and function
to a specific value. The former can be done with the existing
virPCIDeviceAddressEqual() helper, as long as we provide
a virPCIDeviceAddress to compare it to.

The later can be done by direct assignment of the now existing
virPCIDeviceAddress struct. The defined values of domain, bus,
slot and function will be assigned to info->addr.pci, the other
values are zeroed (which happens to be their default values too).
It's also worth noticing that all these assignments are being
conditioned by virDeviceInfoPCIAddressIsPresent() calls, thus it's
sensible to discard any non-zero values that might happen to exist
in @cont->info.addr, if we settled beforehand that @cont->info.addr
is not present or bogus.

Suggested-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu_domain_address.c: use VIR_AUTOFREE() in strings
Daniel Henrique Barboza [Fri, 20 Sep 2019 13:52:54 +0000 (10:52 -0300)]
qemu_domain_address.c: use VIR_AUTOFREE() in strings

A few 'cleanup' labels gone after using VIR_AUTOFREE() on the
@addrStr variable.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: reattach interface taps to correct bridge on restart
Laine Stump [Tue, 17 Sep 2019 00:08:00 +0000 (20:08 -0400)]
conf: reattach interface taps to correct bridge on restart

When the bridge re-attach handling was moved out of the network driver
and into the hypervisor driver (commit b806a60e) as a part of the
refactor to split the network driver into a separate daemon, the check
was accidentally changed to only check for type='bridge'. The check for
type in this case needs to check for type='network' as well.

(at the time we thought that the two types could be conflated for
interface actual type, but this turned out to be too problematic to
do).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: fix enablement of IP networking in virtproxyd
Daniel P. Berrangé [Fri, 20 Sep 2019 12:11:49 +0000 (13:11 +0100)]
remote: fix enablement of IP networking in virtproxyd

This fixes

    commit b7ed8ce981127d91300fa3e372c6ff87fa9fb6ec
    Author: Daniel P. Berrangé <berrange@redhat.com>
    Date:   Thu Jul 4 12:33:23 2019 +0100

      remote: introduce virtproxyd daemon to handle IP connectivity

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agognulib: remove uneccessary func module
Daniel P. Berrangé [Mon, 16 Sep 2019 12:15:04 +0000 (13:15 +0100)]
gnulib: remove uneccessary func module

The gnulib 'func' modules provides portability to compilers which lack
the '__func__' symbol. We only care about GCC and CLang compilers so do
not need this compatibility code.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agognulib: remove unused secure_getenv function replacement
Daniel P. Berrangé [Mon, 16 Sep 2019 12:15:04 +0000 (13:15 +0100)]
gnulib: remove unused secure_getenv function replacement

We removed use of the secure_getenv recently in

  commit 2b0d597670fb5504b7ad1411c31b8af1d3016c1b
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Aug 1 13:35:56 2019 +0100

    util: get rid of virGetEnv{Allow,Block}SUID functions

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: monitor: Remove qemuMonitorHMPCommand in favor of qemuMonitorJSONHumanCommand
Peter Krempa [Thu, 19 Sep 2019 15:56:18 +0000 (17:56 +0200)]
qemu: monitor: Remove qemuMonitorHMPCommand in favor of qemuMonitorJSONHumanCommand

Use the function directly rather than having a wrapper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: monitor: Don't handle HMP in qemuMonitorJSONArbitraryCommand
Peter Krempa [Thu, 19 Sep 2019 15:53:45 +0000 (17:53 +0200)]
qemu: monitor: Don't handle HMP in qemuMonitorJSONArbitraryCommand

Call to qemuMonitorJSONHumanCommand directly from
qemuMonitorArbitraryCommand.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: monitor: Don't include text monitor in json monitor
Peter Krempa [Thu, 19 Sep 2019 15:50:17 +0000 (17:50 +0200)]
qemu: monitor: Don't include text monitor in json monitor

It was necessary for fallback functions but last one was deleted in
d828b744acae967c79513631425c685faf356be0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: monitor: Remove HMP command (un)escaping infrastructure
Peter Krempa [Thu, 19 Sep 2019 15:46:12 +0000 (17:46 +0200)]
qemu: monitor: Remove HMP command (un)escaping infrastructure

We don't need to escape the commands any more since we use QMP
passthrough, which means we can delete the functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: monitor: Don't escape HMP commands just to unescape them right away
Peter Krempa [Thu, 19 Sep 2019 15:37:57 +0000 (17:37 +0200)]
qemu: monitor: Don't escape HMP commands just to unescape them right away

Historically HMP commands needed to be escaped to work properly.

The backdoor for calling HMP commands via QMP must unescape them so that
arguments aren't messed up.

Since we now only support the QMP passthrough the escape->unescape dance
is pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: monitor: Remove support for HMP commands with fds
Peter Krempa [Thu, 19 Sep 2019 15:13:31 +0000 (17:13 +0200)]
qemu: monitor: Remove support for HMP commands with fds

The remaining HMP commands don't require fd passing so we can purge
filedescriptor passing support from qemuMonitorJSONHumanCommandWitFd and
rename it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: monitor: Remove qemuMonitorHMPCommand macro
Peter Krempa [Thu, 19 Sep 2019 14:51:54 +0000 (16:51 +0200)]
qemu: monitor: Remove qemuMonitorHMPCommand macro

qemuMonitorHMPCommandWithFd is only called via qemuMonitorHMPCommand
macro, so we can remove the macro and the extra unused cruft from the
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: monitor: Remove legacy monitor commands for FD manipulation
Peter Krempa [Thu, 19 Sep 2019 15:01:55 +0000 (17:01 +0200)]
qemu: monitor: Remove legacy monitor commands for FD manipulation

The handlers for 'add-fd' and 'remove-fd' are unused now and riddled
with legacy cruft. Purge them.

Last use was removed in f2019083de3430101b94d4991a38fd947a08fd32.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemuCheckDiskConfigAgainstDomain: Validate disk's SCSI address iff disk is SCSI
Xu Yandong [Thu, 19 Sep 2019 08:02:36 +0000 (04:02 -0400)]
qemuCheckDiskConfigAgainstDomain: Validate disk's SCSI address iff disk is SCSI

Check the disk SCSI address only when the disk actually is of
SCSI type.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuSharedDeviceEntryRemove: Free domain name before VIR_DELETE_ELEMENT
Xu Yandong [Thu, 19 Sep 2019 08:02:07 +0000 (04:02 -0400)]
qemuSharedDeviceEntryRemove: Free domain name before VIR_DELETE_ELEMENT

The macro VIR_DELETE_ELEMENT assume that the items being deleted
have already been cleared, so we must explicitly free domain name
from the list of domains using the shared device to prevent a
memory leak.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoobject_event: reference state only if virEventAddTimeout succeeded
Xu Yandong [Thu, 19 Sep 2019 08:02:15 +0000 (04:02 -0400)]
object_event: reference state only if virEventAddTimeout succeeded

When registering new callback for an event, the event loop timer
must be created and registered. The timer has domain event state
object as an opaque argument which must be ref()-ed but only if
the timer was being created and registered successfully. We must
not ref it every time the virObjectEventStateRegisterID() runs.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoremote: fix a memory free error
Xu Yandong [Thu, 19 Sep 2019 08:00:56 +0000 (04:00 -0400)]
remote: fix a memory free error

In function remoteDeserializeDomainDiskErrors, there is a typo.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoRevert "configure: Colorize output"
Peter Krempa [Wed, 18 Sep 2019 06:27:41 +0000 (08:27 +0200)]
Revert "configure: Colorize output"

The colors are not based on the semantics of the message but rather
on the message itself. This means that the default human-perceived
semantics (red = bad, green = good) don't really apply and spotting a
color does not mean anythting.

This is amplified by the sheer amount of output which configure produces
and the fact that some of the messages have negative semantics or
additional output.

In case of any problem the user will have to go through everything
anyways as spotting a red or yellow line has 0 information value.

Here are a few examples:

1) some 'no' messages are not a problem:

  checking minix/config.h presence... no

2) some 'no' messages are actually positive:

  checking for special C compiler options needed for large files... no

3) in some cases a 'yes' would mean that something is broken or needs
   workaround

  checking whether stat file-mode macros are broken... no
  checking whether wint_t is too small... no
  checking whether stdint.h predates C++11... no
  checking whether the inttypes.h PRIxNN macros are broken... no
  checking whether clang gives bogus warnings for -Wdouble-promotion... no
  checking whether gettimeofday clobbers localtime buffer... no

4) due to string match based colors extra text makes messages yellow

  checking for a traditional french locale... none
  checking for working nanosleep... no (mishandles large arguments)
  checking for library containing gethostbyname... none required
  checking whether mbrtowc handles incomplete characters... (cached) guessing yes

5) in some cases the yes/no is very context dependant

  checking whether pthread_rwlock_rdlock prefers a writer to a reader... no
  checking whether this build is done by a static analysis tool... no

6) detected paths to binaries and libs are yellow despite being present

  checking for objdump... objdump
  checking for atomic ops implementation... gcc

As of the reasons above I don't think the colorization of the configure
output helps users or developers to debug the build process and
thus is not worth the extra code or output clutter.

This reverts commit c98174ce087fe23f567292132e961d4685faf337.

ACKed-by: Michal Prívozník <mprivozn@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agoRevert "virt-result.m4: Colourize summary printings"
Peter Krempa [Wed, 18 Sep 2019 06:18:53 +0000 (08:18 +0200)]
Revert "virt-result.m4: Colourize summary printings"

The colorization based on the string itself makes little to no sense as
the semantic meaning of the color (red = bad, green = good) is not
extracted from the semantics of the message:

1) If there is some additional string a 'yes' is marked yellow:

configure:       driver_modules: yes (CFLAGS='' LIBS='-ldl')

2) In some cases a 'no' is actually good:

configure:                  hal: no

3) Few good/recommended configuration options are still yellow:

configure:                 QEMU: qemu:qemu

while using 'root:root' would still be yellow.

4) fields dumping config (e.g. the warning flags line) is a giant blob
  of colored text which makes little sense

configure:        Warning Flags:  -fno-common -W -Wabsolute-value
-Waddress -Waddress-of-packed-member -Waggressive-loop-optimizations
-Wall -Wattribute-warning -Wattributes -Wbad-function-cast
-Wbool-compare -Wbool-operation -Wbuiltin-declaration-mismatch
-Wbuiltin-macro-redefined -Wcannot-profile -Wcast-align
-Wcast-align=strict -Wcast-function-type -Wchar-subscripts -Wclobbered
-Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdangling-else
-Wdate-time -Wdeprecated-declarations -Wdesignated-init
-Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wdiv-by-zero
-Wdouble-promotion -Wduplicated-cond -Wduplicate-decl-speci ...

In addition if the idea is to switch to a more usable build system it
does not make sense to clutter the current one with more code.

This reverts commit 4b3ab5d2135a0dccd654491ef3a4f5b71575deae.

ACKed-by: Michal Prívozník <mprivozn@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agoconf: secret: Refactor cleanup in secretXMLParseNode
Peter Krempa [Mon, 16 Sep 2019 11:44:39 +0000 (13:44 +0200)]
conf: secret: Refactor cleanup in secretXMLParseNode

Use VIR_AUTO* for temporary locals and get rid of the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: secret: Register VIR_AUTOPTR function for virSecretDef
Peter Krempa [Mon, 16 Sep 2019 11:23:51 +0000 (13:23 +0200)]
conf: secret: Register VIR_AUTOPTR function for virSecretDef

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: domain: Refactor cleanup in virDomainDefParseNode
Peter Krempa [Mon, 16 Sep 2019 11:43:44 +0000 (13:43 +0200)]
conf: domain: Refactor cleanup in virDomainDefParseNode

Use VIR_AUTOPTR for temporary locals and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: domain: Register VIR_AUTOPTR function for virDomainDef
Peter Krempa [Mon, 16 Sep 2019 11:23:00 +0000 (13:23 +0200)]
conf: domain: Register VIR_AUTOPTR function for virDomainDef

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: Use VIR_AUTOPTR for xmlDoc and xmlXPath objects
Peter Krempa [Mon, 16 Sep 2019 11:16:36 +0000 (13:16 +0200)]
conf: Use VIR_AUTOPTR for xmlDoc and xmlXPath objects

Refactor functions using these two object types together with
VIR_AUTOPTR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: Use automatic pointers for xmlXPathContext
Peter Krempa [Mon, 16 Sep 2019 10:52:57 +0000 (12:52 +0200)]
conf: Use automatic pointers for xmlXPathContext

Clean up functions which grab and free the context to use VIR_AUTOPTR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: Refactor resource cleanup in virDomainDeviceDefParse
Peter Krempa [Mon, 16 Sep 2019 11:36:34 +0000 (13:36 +0200)]
conf: Refactor resource cleanup in virDomainDeviceDefParse

Use VIR_AUTO* helpers to get rid of the convoluted cleanup path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: network: Use VIR_AUTOPTR in virNetworkDefUpdateSection
Peter Krempa [Mon, 16 Sep 2019 11:25:40 +0000 (13:25 +0200)]
conf: network: Use VIR_AUTOPTR in virNetworkDefUpdateSection

Add automatic cleanup for variables of xmlDoc and xmlXPathContext type
to remove the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoutil: xml: Add wrapper for xmlXPathNewContext
Peter Krempa [Mon, 9 Sep 2019 06:33:58 +0000 (08:33 +0200)]
util: xml: Add wrapper for xmlXPathNewContext

The wrapper reports libvirt errors for the libxml2 function so that
the same does not have to be repeated over and over.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agovirsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand
Peter Krempa [Mon, 9 Sep 2019 08:55:20 +0000 (10:55 +0200)]
virsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: Use VIR_AUTO machinery in cmdQemuMonitorCommand
Peter Krempa [Mon, 9 Sep 2019 08:51:25 +0000 (10:51 +0200)]
virsh: Use VIR_AUTO machinery in cmdQemuMonitorCommand

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: Use virshDomain type in 'inject-nmi'
Peter Krempa [Mon, 9 Sep 2019 08:41:15 +0000 (10:41 +0200)]
virsh: Use virshDomain type in 'inject-nmi'

With a nice side-effect of fixing alignment.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal'
Peter Krempa [Mon, 9 Sep 2019 08:39:04 +0000 (10:39 +0200)]
virsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal'

Refactor the command code to use the new type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: Allow using VIR_AUTOPTR for releasing virDomainPtr in virsh
Peter Krempa [Mon, 9 Sep 2019 08:36:39 +0000 (10:36 +0200)]
virsh: Allow using VIR_AUTOPTR for releasing virDomainPtr in virsh

I opted to alias the 'virDomainType' to 'virshDomain' so that it's
obvious in all cases that this is a virsh-only construct. This is also
somewhat consistent with virsh's use of 'virshDomainFree' wrapper for
the freeing function which actually accepts NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: remove some no-op thread functions
Daniel P. Berrangé [Mon, 16 Sep 2019 16:44:23 +0000 (17:44 +0100)]
util: remove some no-op thread functions

Neither virThreadInitialize or virThreadOnExit do anything since we
dropped the Win32 threads impl, in favour of win-pthreads with:

  commit 0240d94c36c8ce0e7c35b5be430acd9ebf5adcfa
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Jan 22 16:17:10 2014 +0000

      Remove windows thread implementation in favour of pthreads

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "qemu: add socket datagram capability"
Michal Privoznik [Tue, 10 Sep 2019 09:09:13 +0000 (11:09 +0200)]
Revert "qemu: add socket datagram capability"

This reverts commit 0cebb6422a63f5a8289ae43a36f8f33eb9956a4c.

This capability is not used anywhere and also it is not contained
in any release so it's safe to just remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Enable slirp-helper iff dbus-vmstate present
Michal Privoznik [Tue, 10 Sep 2019 08:12:24 +0000 (10:12 +0200)]
qemu: Enable slirp-helper iff dbus-vmstate present

The fact that qemu is capable -netdev socket is not enough to
start a migratable domain. It also needs dbus-vmstate capability.
Since there are already some qemu releases which have
net-socket-dgram capability and don't have dbus-vmstate we need
to check for dbus-vmstate.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoRevert "qemu_capabilities: Temporarily disable dbus-vmstate capability"
Michal Privoznik [Thu, 19 Sep 2019 09:27:12 +0000 (11:27 +0200)]
Revert "qemu_capabilities: Temporarily disable dbus-vmstate capability"

This reverts commit 929e0bd267fe735924d445df6bb5e6d02330f3c3.

I've mistakenly pushed wrong branch.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>