]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agognulib: delete all gnulib integration
Daniel P. Berrangé [Fri, 17 Jan 2020 16:00:27 +0000 (16:00 +0000)]
gnulib: delete all gnulib integration

This deletes all trace of gnulib from libvirt. We still
have the keycodemapdb submodule to deal with. The simple
solution taken was to update it when running autogen.sh.

Previously gnulib could auto-trigger refresh when running
'make' too. We could figure out a solution for this, but
with the pending meson rewrite it isn't worth worrying
about, given how infrequently keycodemapdb changes.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: delete the poll() based event loop impl
Daniel P. Berrangé [Tue, 14 Jan 2020 12:40:14 +0000 (12:40 +0000)]
util: delete the poll() based event loop impl

It is no longer require since switching to the GLib based
event loop impl.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: switch to use the GLib event loop impl
Daniel P. Berrangé [Tue, 14 Jan 2020 12:34:09 +0000 (12:34 +0000)]
util: switch to use the GLib event loop impl

This sets the GLib event loop as the impl when calling
virEventRegisterDefaultImpl(). This remains a private
impl detail of libvirt, so applications must *NOT*
assume that a call to virEventRegisterDefaultImpl()
results in a GLib based event loop.

They should continue to use the libvirt-glib API
gvir_event_register() if they explicitly want to guarantee
a GLib event loop.

This follows the general principal that the libvirt public
API should not expose the fact that GLib is being used
internally.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: import an event loop impl based on GMainContext
Daniel P. Berrangé [Tue, 14 Jan 2020 12:34:09 +0000 (12:34 +0000)]
util: import an event loop impl based on GMainContext

The libvirt-glib project has provided a GMainContext based
event loop impl for applications. This imports it and sets
it up for use by libvirt as the primary event loop. This
remains a private impl detail of libvirt.

IOW, applications must *NOT* assume that a call to
"virEventRegisterDefaultImpl" results in a GLib based
event loop. They should continue to use the libvirt-glib
API gvir_event_register() if they explicitly want to
guarantee a GLib event loop.

This follows the general principle that the libvirt public
API should not expose the fact that GLib is being used
internally.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: convert RPC client to use GMainLoop instead of poll
Daniel P. Berrangé [Thu, 16 Jan 2020 11:21:44 +0000 (11:21 +0000)]
rpc: convert RPC client to use GMainLoop instead of poll

To eliminate the dependancy on GNULIB's poll impl, we need
to change the RPC client code to use GMainLoop. We don't
really want to use GIOChannel, but it provides the most
convenient way to do socket event watches with Windows
portability. The other alternative would be to use GSocket
but that is a much more complex change affecting libvirt
more broadly.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: introduce helper API for creating GSource for socket
Daniel P. Berrangé [Fri, 24 Jan 2020 13:44:29 +0000 (13:44 +0000)]
src: introduce helper API for creating GSource for socket

We need to be able to create event loop watches using the
GSource API for sockets. GIOChannel is able todo this, but
we don't want to use the GIOChannel APIs for reading/writing,
and testing shows just using its GSource APIs is unreliable
on Windows.

This patch thus creates a standalone helper API for creating
a GSource for a socket file descriptor. This impl is derived
from code in QEMU's io/channel-watch.c file that was written
by myself & Paolo Bonzini & thus under Red Hat copyright.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: rewrite interactive job monitoring logic
Daniel P. Berrangé [Wed, 5 Feb 2020 14:16:16 +0000 (14:16 +0000)]
tools: rewrite interactive job monitoring logic

For long running jobs (save, managed save, dump & live migrate)
virsh runs a background thread for executing the job and then
has the main thread catch Ctrl-C for graceful shutdown, as well
as displaying progress info.

The monitoring code is written using poll, with a pipe used
to get the completion status from the thread. Using a pipe
and poll is problematic for Windows portability. This rewrites
the code to use a GMainLoop instance for monitoring stdin and
doing progress updates. The use of a pipe is entirely eliminated,
instead there is just a shared variable between both threads
containing the job completion status.

No mutex locking is used because the background thread writes
to the variable only when the main loop is still running,
while the foreground thread only reads it after the main loop
has exited.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: avoid referencing stale readdir pointer
Daniel P. Berrangé [Fri, 7 Feb 2020 14:51:26 +0000 (14:51 +0000)]
tests: avoid referencing stale readdir pointer

The contents of 'struct dirent' are only valid until the next call to
readdir() or closedir(). It is thus invalid to save a pointer to the
'd_name' field. Somehow this hasn't affected the test suite until
recently when FreeBSD 12 started showing use of uninitialized memory
resulting in test failures.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: support Panic Crashloaded event handling
zhenwei pi [Tue, 4 Feb 2020 07:41:00 +0000 (15:41 +0800)]
qemu: support Panic Crashloaded event handling

Pvpanic device supports bit 1 as crashloaded event, it means that
guest actually panicked and run kexec to handle error by guest side.

Handle crashloaded as a lifecyle event in libvirt.

Test case:
Guest side:
before testing, we need make sure kdump is enabled,
1, build new pvpanic driver (with commit from upstream
   e0b9a42735f2672ca2764cfbea6e55a81098d5ba
   191941692a3d1b6a9614502b279be062926b70f5)
2, insmod new kmod
3, enable crash_kexec_post_notifiers,
  # echo 1 > /sys/module/kernel/parameters/crash_kexec_post_notifiers
4, trigger kernel panic
  # echo 1 > /proc/sys/kernel/sysrq
  # echo c > /proc/sysrq-trigger

Host side:
1, build new qemu with pvpanic patches (with commit from upstream
   600d7b47e8f5085919fd1d1157f25950ea8dbc11
   7dc58deea79a343ac3adc5cadb97215086054c86)
2, build libvirt with this patch
3, handle lifecycle event and trigger guest side panic
  # virsh event stretch --event lifecycle
  event 'lifecycle' for domain stretch: Crashed Crashloaded
  events received: 1

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
5 years agodocs: render class="literal" with monospace font
Daniel P. Berrangé [Thu, 6 Feb 2020 12:49:09 +0000 (12:49 +0000)]
docs: render class="literal" with monospace font

When using ``....`` in RST, this results in <span class="literal">...</span>
instead of <code>...</code>. We thus need an extra rule to render it
with a monospace font. Colouring a light gray also helps the text
stand out a little more and matches background of <pre> blocks.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_capabilities: Disable CPU models on old s390 machine types
Jiri Denemark [Thu, 6 Feb 2020 09:22:23 +0000 (10:22 +0100)]
qemu_capabilities: Disable CPU models on old s390 machine types

Starting a KVM domain on s390 with old machine type (such as
s390-ccw-virtio-2.5) and without any guest CPU model configured fails
with

    CPU models are not available: KVM doesn't support CPU models

QEMU error. This is cause by libvirt using host-model CPU as the default
CPU based on QEMU reporting "host" CPU model as being the default one
(see commit v5.9.0-402-g24d8202294: qemu: Use host-model CPU on s390 by
default). However, even though both QEMU and KVM support CPU models on
s390 and QEMU can give us the host-model CPU, we can't use it with old
machine types which only support -cpu host.

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

Reported-by: Christian Ehrhardt <paelzer@gmail.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2*test: Add default CPU tests for s390-ccw-virtio-2.7 machines
Jiri Denemark [Thu, 6 Feb 2020 09:18:49 +0000 (10:18 +0100)]
qemuxml2*test: Add default CPU tests for s390-ccw-virtio-2.7 machines

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Pass machine type to virQEMUCapsIsCPUModeSupported
Jiri Denemark [Wed, 5 Feb 2020 14:51:09 +0000 (15:51 +0100)]
qemu: Pass machine type to virQEMUCapsIsCPUModeSupported

The usability of a specific CPU mode may depend on machine type, let's
prepare for this by passing it to virQEMUCapsIsCPUModeSupported.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolxc: Fix wrong addresses statements for IPv{4, 6} in native network definitions
Julio Faracco [Thu, 6 Feb 2020 04:19:56 +0000 (01:19 -0300)]
lxc: Fix wrong addresses statements for IPv{4, 6} in native network definitions

After LXC version 3, some settings were changed to new names. Same as
network. LXC introduced network indexes and changed IPv{4,6} addresses
fields. Before, users should only pass `lxc.network.ipv4` to define an
IPv4 address. Now, on version 3, users need to pass
`lxc.net.X.ipv4.address` to specify the same thing. Same for IPv6.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: Fix segfault when lxc.network does not start with 'type'
Julio Faracco [Thu, 6 Feb 2020 02:12:05 +0000 (23:12 -0300)]
lxc: Fix segfault when lxc.network does not start with 'type'

To configure network settings using config file, legacy LXC settings
require starting them with 'lxc.network.type' entry. If someone
accidentally starts with 'lxc.network.name', libvirt will crash with
segfault. This patch checks if this case is happening.

Sample invalid settings:
lxc.network.link = eth0
lxc.network.type = phys
lxc.network.name = eth1
lxc.network.ipv4 = 192.168.122.2/24
lxc.network.ipv4.gateway = 192.168.122.1

Now, libvirt only see error without segmentation fault.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: fix deadlock in eventtest
Pavel Hrdina [Thu, 6 Feb 2020 12:00:25 +0000 (13:00 +0100)]
tests: fix deadlock in eventtest

There is a race deadlock in eventtest after the recent rewrite to drop
GNULIB from libvirt code base.

The issue happens when the callbacks testPipeReader() or testTimer()
are called before waitEvents() starts waiting on `eventThreadCond`.
It will never happen because the callbacks are already done and there
is nothing that will signal the condition again.

Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agotests: Add test for domain XML with tpm-spapr TPM device model
Stefan Berger [Wed, 5 Feb 2020 18:35:50 +0000 (13:35 -0500)]
tests: Add test for domain XML with tpm-spapr TPM device model

This patch adds a test case for domain XML with the tpm-spapr TPM device
model.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Extend ppc64 capabilities data with TPM related XML and responses
Stefan Berger [Wed, 5 Feb 2020 18:35:49 +0000 (13:35 -0500)]
tests: Extend ppc64 capabilities data with TPM related XML and responses

This patch extends the ppc64 capabilities data with TPM related XML
and responses. The replies and xml files are copies of the 4.2.0 version
of these files with TPM related data added.

We also need to copy qemu_4.2.0.ppc64.xml to qemu_5.0.0.ppc64.xml.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Extend QEMU with tpm-spapr support
Stefan Berger [Wed, 5 Feb 2020 18:35:48 +0000 (13:35 -0500)]
qemu: Extend QEMU with tpm-spapr support

Extend QEMU with tpm-spapr support. Assign a device address to the
vTPM device model.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Extend QEMU capabilities with 'tpm-spapr'
Stefan Berger [Wed, 5 Feb 2020 18:35:47 +0000 (13:35 -0500)]
qemu: Extend QEMU capabilities with 'tpm-spapr'

Extend the QEMU capabilties with tpm-spapr support.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Add support for tpm-spapr to domain XML
Stefan Berger [Wed, 5 Feb 2020 18:35:46 +0000 (13:35 -0500)]
conf: Add support for tpm-spapr to domain XML

This patch adds support for the tpm-spapr device model for ppc64. The XML for
this type of TPM looks as follows:

 <tpm model='tpm-spapr'>
   <backend type='emulator'/>
 </tpm>

Extend the documentation.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Introduce VIR_DOMAIN_TPM_MODEL_DEFAULT as default model
Stefan Berger [Wed, 5 Feb 2020 18:35:45 +0000 (13:35 -0500)]
conf: Introduce VIR_DOMAIN_TPM_MODEL_DEFAULT as default model

Introduce VIR_DOMAIN_TPM_MODEL_DEFAULT as a default model which we use
in case the user does not provide a model in the device XML. It has
the TIS's previous value of '0'. In the post parsing function
we change this default value to 'TIS' to have the same model as before.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agorpc: gendispatch: trim Flags from the return struct name
Ján Tomko [Sat, 1 Feb 2020 12:38:19 +0000 (13:38 +0100)]
rpc: gendispatch: trim Flags from the return struct name

This lets it generate the remote dispatch for StorageVolGetInfoFlags.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: use correct free function for virDomainVsockDef
Ján Tomko [Wed, 5 Feb 2020 00:11:53 +0000 (01:11 +0100)]
conf: use correct free function for virDomainVsockDef

Technically, there is no memleak here, since the only
allocations are filled by virDomainDeviceInfoParseXML,
which cleans up after itself.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: use correct free function for virDomainDeviceDef
Ján Tomko [Tue, 4 Feb 2020 23:58:52 +0000 (00:58 +0100)]
conf: use correct free function for virDomainDeviceDef

Simple g_autofree is not enough if we put allocated
data into the device structure.

Define the AUTOPTR_CLEANUP function and use it here.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Xu Yandong <xuyandong2@huawei.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agosrc: remove virFilePrintf in favour of g_fprintf
Daniel P. Berrangé [Mon, 27 Jan 2020 12:52:23 +0000 (12:52 +0000)]
src: remove virFilePrintf in favour of g_fprintf

The virFilePrintf function was a wrapper for fprintf() to provide
Windows portability, since gnulib's fprintf() replacement was
license restricted. This is no longer needed now we have the
g_fprintf function available.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: ensure use of g_printf / g_fprintf functions
Daniel P. Berrangé [Mon, 27 Jan 2020 13:58:51 +0000 (13:58 +0000)]
src: ensure use of g_printf / g_fprintf functions

The printf/fprintf function impls provided on Windows do
not follow the normal syntax for format specifiers as
the UNIX hosts. Currently we use GNULIB to provide a
portability fix for this. GLib has also imported the
GNULIB impl for this same reason, and thus we can rely
on the g_printf / g_fprintf functions.

This identified a couple of places not explicitly
linking to glib.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: optionally include xlocale.h header
Daniel P. Berrangé [Mon, 27 Jan 2020 10:59:19 +0000 (10:59 +0000)]
src: optionally include xlocale.h header

On macOS some definitions are in xlocale.h, instead of in
locale.h. GNULIB hides this difference by making the latter
include the former.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: add define of ENOMSG for MinGW
Daniel P. Berrangé [Fri, 24 Jan 2020 18:22:47 +0000 (18:22 +0000)]
src: add define of ENOMSG for MinGW

MinGW lacks ENOMSG until version 6.0.0 (Fedora 31).

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: assume sys/sysmacros.h always exists on Linux
Daniel P. Berrangé [Fri, 24 Jan 2020 17:32:48 +0000 (17:32 +0000)]
src: assume sys/sysmacros.h always exists on Linux

All our supported Linux distros now have this header.
It has never existed on FreeBSD / macOS / Mingw.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agom4: add check for pthread library
Daniel P. Berrangé [Fri, 17 Jan 2020 15:30:51 +0000 (15:30 +0000)]
m4: add check for pthread library

When we get rid of GNULIB, we need to check for -lpthread
support.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: conditionalize use of O_SYNC flag
Daniel P. Berrangé [Fri, 24 Jan 2020 15:22:41 +0000 (15:22 +0000)]
tools: conditionalize use of O_SYNC flag

The O_SYNC flag is not defined on Windows platforms.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: convert code to use virPipe APIs
Daniel P. Berrangé [Fri, 24 Jan 2020 15:22:12 +0000 (15:22 +0000)]
src: convert code to use virPipe APIs

This addreses portability to Windows and standardizes
error reporting. This fixes a number of places which
failed to set O_CLOEXEC or failed to report errors.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: introduce a wrapper for the pipe2() system call
Daniel P. Berrangé [Fri, 24 Jan 2020 15:21:00 +0000 (15:21 +0000)]
src: introduce a wrapper for the pipe2() system call

This hides the differences between Windows and UNIX,
and adds standard error reporting.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoexamples: remove obsolete workaround for mingw
Daniel P. Berrangé [Fri, 24 Jan 2020 15:19:55 +0000 (15:19 +0000)]
examples: remove obsolete workaround for mingw

The build still succeeds with the workaround removed, so
whatever was causing the problem no longer exists.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconfigure: request 64-bit APIs on 32-bit platforms
Daniel P. Berrangé [Fri, 17 Jan 2020 11:26:26 +0000 (11:26 +0000)]
configure: request 64-bit APIs on 32-bit platforms

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: remove sys/wait.h from many files
Daniel P. Berrangé [Thu, 16 Jan 2020 11:38:18 +0000 (11:38 +0000)]
src: remove sys/wait.h from many files

Most code now uses the virProcess / virCommand APIs, so
the need for sys/wait.h is quite limited. Removing this
include removes the dependency on GNULIB providing a
dummy sys/wait.h for Windows.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: conditionalize FD stream to exclude WIN32
Daniel P. Berrangé [Tue, 14 Jan 2020 16:47:32 +0000 (16:47 +0000)]
util: conditionalize FD stream to exclude WIN32

Almost none of the virFDStream code will actually work
on WIN32 builds, nor is it used except for in the
virtualbox driver for screenshots. It is simpler to
wrap it all in a '#ifndef WIN32'.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize / remove use of poll.h
Daniel P. Berrangé [Fri, 17 Jan 2020 11:19:13 +0000 (11:19 +0000)]
src: conditionalize / remove use of poll.h

Remove imports of poll.h which are redundant, and
conditionalize remaining usage that needs to compile
on Windows platforms.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: refactor event test to not run lock step
Daniel P. Berrangé [Fri, 17 Jan 2020 10:55:48 +0000 (10:55 +0000)]
tests: refactor event test to not run lock step

The current event loop test suite has two threads running
in lockstep. This was just about viable when we have full
control over the internal details of the event loop impl.
When we're using the GLib event loop though there are
things going on that we don't know about, such as use of
eventfd() file descriptors. This will break the assumptions
in the test suite, causing non-deterministic failures.

This change switches the event loop thread to run fully
asynchronously from the test suite cases. This is slightly
weaker validation, but the only way we can get a reliable
test suite.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: remove event loop from command test
Daniel P. Berrangé [Fri, 17 Jan 2020 10:52:46 +0000 (10:52 +0000)]
tests: remove event loop from command test

This effectively reverts

  commit 39c77fe586baccd0a4a9862e8cf7c78ac7af3494
  Author: Michal Prívozník <mprivozn@redhat.com>
  Date:   Wed Jan 16 11:58:00 2013 +0100

    Introduce event loop to commandtest

because nothing in the current test suite needs this
event loop.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: convert eventtest to use public event APIs
Daniel P. Berrangé [Thu, 16 Jan 2020 11:56:28 +0000 (11:56 +0000)]
tests: convert eventtest to use public event APIs

The event test directly calls the internal poll event impl
APIs. It does not rely on any specific details of the poll
impl, so it is better to use the public APIs.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: domaincaps: Mention VIR_DOMAIN_UNDEFINE_CHECKPOINTS_METADATA
Peter Krempa [Mon, 27 Jan 2020 16:17:01 +0000 (17:17 +0100)]
docs: domaincaps: Mention VIR_DOMAIN_UNDEFINE_CHECKPOINTS_METADATA

The flag for the virDomainUndefine API is supported even if we report
that <backup supported='no'/>. Mention it in the docs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemuDomainBlockPivot: Copy bitmaps backing checkpoints for virDomainBlockCopy
Peter Krempa [Thu, 30 Jan 2020 07:50:05 +0000 (08:50 +0100)]
qemuDomainBlockPivot: Copy bitmaps backing checkpoints for virDomainBlockCopy

Use qemuBlockBitmapsHandleBlockcopy to calculate bitmaps to copy over
for a block-copy job.

We copy them when pivoting to the new image as at that point we are
certain that we don't dirty any bitmap unnecessarily.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add tests for qemuBlockBitmapsHandleBlockcopy
Peter Krempa [Wed, 29 Jan 2020 16:12:47 +0000 (17:12 +0100)]
tests: qemublock: Add tests for qemuBlockBitmapsHandleBlockcopy

Use some of the existing bitmap data to add tests for
qemuBlockBitmapsHandleBlockcopy.

As the output depends on the ordering in the hash table we must also
install the "virdeterministichash" mock preload library.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Introduce function to calculate bitmap handling for block-copy
Peter Krempa [Wed, 29 Jan 2020 11:16:12 +0000 (12:16 +0100)]
qemu: block: Introduce function to calculate bitmap handling for block-copy

Add a function calculating which bitmaps to copy to the mirror during
a block-copy operation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublocktest: Add another synthetic test case for broken bitmaps
Peter Krempa [Wed, 29 Jan 2020 14:48:36 +0000 (15:48 +0100)]
tests: qemublocktest: Add another synthetic test case for broken bitmaps

Add a case where a bitmap spanning multiple images is missing one of the
intermediate components.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Add validator for bitmap chains accross backing chains
Peter Krempa [Wed, 29 Jan 2020 11:08:50 +0000 (12:08 +0100)]
qemu: block: Add validator for bitmap chains accross backing chains

Add a validator which checks that a bitmap spanning multiple backing
chain members doesn't look broken. The current rules are that no
intermediate birmaps are missing (unfortunately it's hard to know
whether the topmost or bottommost bitmap is missing) and none of the
components is inconsistent.

We can obviously improve it over time.

The validator is also tested against the existing bitmap data we have
for the backup merging test as well as some of the existing broken
bitmap synthetic test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Store 'flags' for all the block job types
Peter Krempa [Thu, 30 Jan 2020 13:02:55 +0000 (14:02 +0100)]
qemu: blockjob: Store 'flags' for all the block job types

The flags may control important aspects of the block job which may
influence also the termination of the job. Store the 'flags' for all
the block job types.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Store 'jobflags' with block job data
Peter Krempa [Fri, 31 Jan 2020 12:00:29 +0000 (13:00 +0100)]
qemu: blockjob: Store 'jobflags' with block job data

Add a variable which will store the contents of the 'flags' variable as
passed in by the individual block jobs. Since the flags may influence
behaviour of the jobs it's important to preserve them to the
finalization steps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirHashAddOrUpdateEntry: Simplify allocation of new entry
Peter Krempa [Fri, 31 Jan 2020 07:41:55 +0000 (08:41 +0100)]
virHashAddOrUpdateEntry: Simplify allocation of new entry

Use g_new0 and skip checking of the return value of keyCopy callback
as both are bound to return a valid pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirhash: Fix the expectations of virHashKeyEqual implementations
Peter Krempa [Fri, 31 Jan 2020 07:34:57 +0000 (08:34 +0100)]
virhash: Fix the expectations of virHashKeyEqual implementations

Tweak the return value expectation comment so that it doesn't
necessarily require to allocate memory and refactor the implementations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirJSONValueNewArray: Use g_new0 to allocate and remove NULL checks from callers
Peter Krempa [Fri, 31 Jan 2020 07:18:36 +0000 (08:18 +0100)]
virJSONValueNewArray: Use g_new0 to allocate and remove NULL checks from callers

Use the glib allocation function that never returns NULL and remove the
now dead-code checks from all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: json: Introduce virJSONValueArrayConcat
Peter Krempa [Tue, 28 Jan 2020 14:26:49 +0000 (15:26 +0100)]
util: json: Introduce virJSONValueArrayConcat

Add a helper that concatenates the second array into the first.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Extract calls of qemuBlockGetNamedNodeData into a helper function
Peter Krempa [Tue, 21 Jan 2020 14:10:27 +0000 (15:10 +0100)]
qemu: block: Extract calls of qemuBlockGetNamedNodeData into a helper function

Create a wrapper for qemuBlockGetNamedNodeData named
qemuBlockGetNamedNodeData. The purpose of the wrapper is to integrate
the monitor handling functionality and in the future possible
qemuCaps-based flags.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: checkpoint: Track and relabel images for bitmap merging
Peter Krempa [Thu, 9 Jan 2020 16:34:29 +0000 (17:34 +0100)]
qemu: checkpoint: Track and relabel images for bitmap merging

Allow qemu access to modify backing files in case when we want to delete
a checkpoint.

This patch adds tracking of which images need to be relabelled when
calculating the transaction, the code to relabel them and rollback.

To verify that stuff works we also output the list of images to relabel
into the test case output files in qemublocktest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add checkpoint deletion tests for some special cases
Peter Krempa [Thu, 9 Jan 2020 15:37:43 +0000 (16:37 +0100)]
tests: qemublock: Add checkpoint deletion tests for some special cases

Use the synthetic test data to verify that the algorithm correctly picks
bitmaps to merge when the bitmap is changed along with the image itself.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add checkpoint deletion test for deep backing chain
Peter Krempa [Thu, 9 Jan 2020 14:10:43 +0000 (15:10 +0100)]
tests: qemublock: Add checkpoint deletion test for deep backing chain

Add test cases for merging various pairs of bitmaps when snapshots were
created together with checkpoints.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: checkpoint: Introduce support for deleting checkpoints accross snapshots
Peter Krempa [Thu, 9 Jan 2020 13:19:07 +0000 (14:19 +0100)]
qemu: checkpoint: Introduce support for deleting checkpoints accross snapshots

Allow deleting of checkpoints when snapshots were created along. The
code tracks and modifies the checkpoint list so that backups can still
be taken with such a backing chain. This unfortunately requires to
rename few bitmaps (by copying and deleting them) in some cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add synthetic snapshot+checkpoint test data
Peter Krempa [Thu, 9 Jan 2020 14:32:49 +0000 (15:32 +0100)]
tests: qemublock: Add synthetic snapshot+checkpoint test data

Add a faked qemu output which would simulate scenario where libvirt
would take a snapshot and checkpoint simultaneously. This is visible in
libvirt-2-format node where bitmap 'c' appears, but bitmap 'b' which is
active in the previous layer is not present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add few more test cases for checkpoint deletion
Peter Krempa [Wed, 8 Jan 2020 16:09:25 +0000 (17:09 +0100)]
tests: qemublock: Add few more test cases for checkpoint deletion

Add all intermediate steps and deletion of the current checkpoint on a
flat (single-image) disk image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add test for checkpoint deletion bitmap merge
Peter Krempa [Wed, 8 Jan 2020 13:56:45 +0000 (14:56 +0100)]
tests: qemublock: Add test for checkpoint deletion bitmap merge

Add test infrastructure and a basic test for bitmap deletion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Fix virt-aa-helper location
Michal Privoznik [Thu, 30 Jan 2020 13:57:04 +0000 (14:57 +0100)]
docs: Fix virt-aa-helper location

The location of virt-aa-helper shown in the docs is incorrect.
The helper binary is installed under libexec dir.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoapparmor: Reflect paths from configure in profiles
Michal Privoznik [Thu, 30 Jan 2020 10:06:47 +0000 (11:06 +0100)]
apparmor: Reflect paths from configure in profiles

The configure script allows users to specify different paths for
/etc/, /usr/sbin/, /var/run/ and /usr/libexec/. Instead of
assuming user will pass expected value, generate the apparmor
profiles using the actual values.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: tpm: remove unused labels
Ján Tomko [Fri, 31 Jan 2020 23:16:06 +0000 (00:16 +0100)]
qemu: tpm: remove unused labels

Remove all the labels that are now redundant.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: tpm: use g_autoptr where applicable
Ján Tomko [Fri, 31 Jan 2020 23:11:22 +0000 (00:11 +0100)]
qemu: tpm: use g_autoptr where applicable

This requires stealing one cmd pointer before returning it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: tpm: use g_autofree
Ján Tomko [Fri, 31 Jan 2020 23:01:13 +0000 (00:01 +0100)]
qemu: tpm: use g_autofree

Mark eligible declarations as g_autofree and remove
the corresponding VIR_FREE calls.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: tpm: remove unused pidfile variable
Ján Tomko [Fri, 31 Jan 2020 23:07:44 +0000 (00:07 +0100)]
qemu: tpm: remove unused pidfile variable

qemuExtTPMSetupCgroup declares pidfile but never uses it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovirBufferTrim: do not accept len
Ján Tomko [Sun, 2 Feb 2020 19:26:38 +0000 (20:26 +0100)]
virBufferTrim: do not accept len

Always trim the full specified suffix.

All of the callers outside of tests were passing either
strlen or the actual length of the string.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoUse virBufferTrimLen when applicable
Ján Tomko [Sun, 2 Feb 2020 19:17:20 +0000 (20:17 +0100)]
Use virBufferTrimLen when applicable

Replace all the cases that only supply the length
and do not care about matching a suffix, as well
as that one test case that does.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoutil: introduce virBufferTrimLen
Ján Tomko [Sun, 2 Feb 2020 19:16:36 +0000 (20:16 +0100)]
util: introduce virBufferTrimLen

Just like the existing virBufferTrim, but only
does one thing at a time.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agolib: Prohibit parallel connections with tunneled migration
Jim Fehlig [Fri, 17 Jan 2020 17:36:32 +0000 (10:36 -0700)]
lib: Prohibit parallel connections with tunneled migration

As discussed on the developer list, parallel migration connections
are not compatible with tunneled migration

https://www.redhat.com/archives/libvir-list/2020-January/msg00463.html

Prohibit the concurrent use of parallel and tunneled migration options.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: update LXC config dataset to support V3 indexes
Julio Faracco [Mon, 3 Feb 2020 01:28:35 +0000 (22:28 -0300)]
tests: update LXC config dataset to support V3 indexes

LXC version 3 config files are still using network old style definition.
So, as LXC supports it now, they can be converted to use this new
definition.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: remove domain definition from lxc network struct
Julio Faracco [Mon, 3 Feb 2020 01:28:34 +0000 (22:28 -0300)]
lxc: remove domain definition from lxc network struct

Domain definition is useless now inside network structure. This pointer
was required because new network definition was being added each time
that a new network type appeared. So, this should be processed into
old function `lxcNetworkParseDataType()`. Now, as it was moved to an
array, it can be handle together each interface pointer.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: add LXC version 3 network parser
Julio Faracco [Mon, 3 Feb 2020 01:28:33 +0000 (22:28 -0300)]
lxc: add LXC version 3 network parser

LXC version 3 or higher introduced indexes for network interfaces.
Libvirt should be able to parse entries like `lxc.net.2.KEY`. This
commit adds functions to parse this type of field. That's why array
structures are so important this time.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: refactor lxcNetworkParseData pointers to use new structures
Julio Faracco [Mon, 3 Feb 2020 01:28:32 +0000 (22:28 -0300)]
lxc: refactor lxcNetworkParseData pointers to use new structures

Struct lxcNetworkParseData is being used as a single pointer which
iterates through LXC config lines. It means that it will be applied as a
network each time that a new type appears. After, the same struct is
used to populate a new network interface. This commit changes this logic
to multiple lxcNetworkParseData to move this strcuture to an array. It
makes more sense if we are using indexes to fill interface settings.
This is better to improve code clarity.

This commit still introduces *Legacy() functions to keep support of
network old style definitions.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Add capabilities for QEMU 5.0.0 on aarch64
Andrea Bolognani [Fri, 31 Jan 2020 12:55:26 +0000 (13:55 +0100)]
tests: Add capabilities for QEMU 5.0.0 on aarch64

This will be the first QEMU version that will support the
kvm-no-adjvtime CPU feature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoDrop virAtomic module
Michal Privoznik [Fri, 31 Jan 2020 16:32:39 +0000 (17:32 +0100)]
Drop virAtomic module

Now, that every use of virAtomic was replaced with its g_atomic
equivalent, let's remove the module.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Drop virAtomicIntDecAndTest() with g_atomic_int_dec_and_test()
Michal Privoznik [Fri, 31 Jan 2020 16:12:11 +0000 (17:12 +0100)]
src: Drop virAtomicIntDecAndTest() with g_atomic_int_dec_and_test()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Replace virAtomicIntInc() with g_atomic_int_add()
Michal Privoznik [Fri, 31 Jan 2020 16:04:24 +0000 (17:04 +0100)]
src: Replace virAtomicIntInc() with g_atomic_int_add()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Replace virAtomicIntSet() with g_atomic_int_set()
Michal Privoznik [Fri, 31 Jan 2020 16:08:35 +0000 (17:08 +0100)]
src: Replace virAtomicIntSet() with g_atomic_int_set()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: Replace virAtomicIntGet() with g_atomic_int_get()
Michal Privoznik [Fri, 31 Jan 2020 16:07:00 +0000 (17:07 +0100)]
src: Replace virAtomicIntGet() with g_atomic_int_get()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Drop viratomictest
Michal Privoznik [Fri, 31 Jan 2020 16:01:47 +0000 (17:01 +0100)]
tests: Drop viratomictest

In future commits our virAtomic* APIs will be replaced with their
GLib variants. Instead of trying to update the test after each
commit and eventually removing the test anyway, remove it upfront
and save the hassle.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotest_driver: Replace virAtomicIntAdd() with g_atomic_int_add()
Michal Privoznik [Fri, 31 Jan 2020 16:13:25 +0000 (17:13 +0100)]
test_driver: Replace virAtomicIntAdd() with g_atomic_int_add()

Instead of calling virAtomicIntAdd(&var, 1); we can call
g_atomic_int_add() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: drop unused variable
Ján Tomko [Fri, 31 Jan 2020 16:02:26 +0000 (17:02 +0100)]
qemu: drop unused variable

The g_auto conversion made clang realize the variable is unused:
../../src/qemu/qemu_domain.c:10349:36: error: unused variable
    'cfg' [-Werror,-Wunused-variable]
    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 20fa2bc6e52e01feaf39d12d38bcf8eaec4c9a46
5 years agobuild: Drop execute permissions on virsh bash completion command
Jim Fehlig [Thu, 30 Jan 2020 18:29:41 +0000 (11:29 -0700)]
build: Drop execute permissions on virsh bash completion command

rpmlint complains about "script-without-shebang" due to the execute
permissions on /usr/share/bash-completion/completions/vsh. Use
INSTALL_DATA instead of INSTALL_SCRIPT to avoid the unnecessary
execute permissions.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Fix domain ID allocation
Ján Tomko [Fri, 31 Jan 2020 14:27:37 +0000 (15:27 +0100)]
qemu: Fix domain ID allocation

The rewrite to use GLib's atomic ops functions changed the behavior
of virAtomicIntInc - before it returned the pre-increment value.

Most of the callers using its value were adjusted, but the one
in qemuDriverAllocateID was not. If libvirtd would reconnect to
a running domain during startup, the next started domain would get
the same ID:

$ virsh list
 Id   Name       State
--------------------------
 1    f28live    running
 1    f28live1   running

Use the g_atomic_add function directly (as recommended in viratomic.h)
and add 1 to the result.

This also restores the usual numbering from 1 instead of 0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 7b9645a7d127a374b8d1c83fdf9789706dbab2c9
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: fix a typo
Ján Tomko [Fri, 31 Jan 2020 14:57:00 +0000 (15:57 +0100)]
docs: fix a typo

s/axnd/and/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f0f34056ab26eaa9f903a51cd1fa155088fd640f
5 years agoqemu_domain_address.c: turn qemuDomainFillDeviceIsolationGroup to void
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:48 +0000 (15:33 -0300)]
qemu_domain_address.c: turn qemuDomainFillDeviceIsolationGroup to void

Starting on commit 1f43393283ff, qemuDomainFillDeviceIsolationGroup()
returns 0 in all circunstances. Let's turn it to 'void' make it
clearer that the function will not fail. This also spares a
check for < 0 return in qemu_hotplug.c. The
qemuDomainFillDeviceIsolationGroupIter() callback now returns
0 at all times - which is already happening anyway.

Refer to 1f43393283ff commit message for more details on why
the function was changed to never return an error.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: turn qemuDomainChrDefDropDefaultPath to void
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:47 +0000 (15:33 -0300)]
qemu_domain.c: turn qemuDomainChrDefDropDefaultPath to void

qemuDomainChrDefDropDefaultPath() returns an int, but it's
always returning 0. Callers are checking for result < 0 to
run their cleanup code needlessly.

Turn the function to 'void' and adjust the callers.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: removing unneeded cleanup labels
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:46 +0000 (15:33 -0300)]
qemu_domain.c: removing unneeded cleanup labels

Previous patches deprecated some 'cleanup' labels. Let's remove
them.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: use g_autoptr when possible
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:45 +0000 (15:33 -0300)]
qemu_domain.c: use g_autoptr when possible

Avoid some of the virObjectUnref() calls by using g_autoptr.
Aside from the 'cleanup' label in qemuDomainSetFakeReboot(),
all other now deprecated cleanup labels will be removed in
the next patch.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: use g_autofree when possible
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:44 +0000 (15:33 -0300)]
qemu_domain.c: use g_autofree when possible

Use g_autofree to remove VIR_FREE() calls used for cleanups.
Labels that became deprecated will be removed in a later
patch.

In qemuDomainSetupDisk(), the 'dst' variable is not used at
all and could be removed.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_domain.c: remove redundant virObjectUnref()
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:43 +0000 (15:33 -0300)]
qemu_domain.c: remove redundant virObjectUnref()

The 'caps' variable in qemuDomainObjPrivateXMLParseAutomaticPlacement()
is set to auto clean via g_autoptr(), but a 'virObjectUnref(caps)' is
being executed in the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf/domain_addr.c: remove unneeded 'cleanup' labels
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:42 +0000 (15:33 -0300)]
conf/domain_addr.c: remove unneeded 'cleanup' labels

Previous patch used 'g_autofree' to eliminate instances of
VIR_FREE(), making some cleanup labels obsolete. This
patch removes them.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf/domain_addr.c: use g_autofree in strings
Daniel Henrique Barboza [Thu, 9 Jan 2020 18:33:41 +0000 (15:33 -0300)]
conf/domain_addr.c: use g_autofree in strings

Use g_autofree in strings when possible to spare a VIR_FREE()
call. Unneeded 'cleanup' labels will be taken care of in the
next patch.

The 'str' string in virDomainVirtioSerialAddrReserve() was
never used by the logic, only being used in cleanup by
VIR_FREE(). Let's remove it.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Fix filling of 'capacity' when blockdev is used
Peter Krempa [Thu, 30 Jan 2020 14:35:06 +0000 (15:35 +0100)]
qemuMigrationCookieAddNBD: Fix filling of 'capacity' when blockdev is used

With -blockdev we must look up via the nodename rather than the 'drive'
alias which is not present any more.

This fixes the pre-creation of storage volumes on migration with
non-shared storage.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Remove 'ret' variable and 'cleanup' label
Peter Krempa [Thu, 30 Jan 2020 14:06:14 +0000 (15:06 +0100)]
qemuMigrationCookieAddNBD: Remove 'ret' variable and 'cleanup' label

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Use virHashNew and automatic freeing of virHashTablePtr
Peter Krempa [Thu, 30 Jan 2020 14:01:41 +0000 (15:01 +0100)]
qemuMigrationCookieAddNBD: Use virHashNew and automatic freeing of virHashTablePtr

Swithc to the helper which doesn't require checking of the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Move monitor call out of the loop
Peter Krempa [Thu, 30 Jan 2020 13:57:56 +0000 (14:57 +0100)]
qemuMigrationCookieAddNBD: Move monitor call out of the loop

The data is gathered only once so we can move the whole block which
fetches the data out of the loop and get rid of the logic which
prevents multiple calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>