]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agosyntax-check: drop vulnerable Makefile checks
Ján Tomko [Tue, 11 Feb 2020 00:07:08 +0000 (01:07 +0100)]
syntax-check: drop vulnerable Makefile checks

As foretold, fixed automake is so common nowadays even Ubuntu 16.04
and Debian 9 have 1.11.6 as the oldest available version.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: fix sc-prohibit-cross-inclusion
Ján Tomko [Tue, 11 Feb 2020 00:07:29 +0000 (01:07 +0100)]
syntax-check: fix sc-prohibit-cross-inclusion

Using '^' in in_vc_files assumes the build is happening
in srcdir, which is no longer possible as of:
commit f96395e78eaccffbf128336382c74b1250f04032

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: do not enforce ChangeLog syntax
Ján Tomko [Tue, 11 Feb 2020 00:07:57 +0000 (01:07 +0100)]
syntax-check: do not enforce ChangeLog syntax

Our last conforming ChangeLog was removed from git in 2009 by:
commit 27b175b9a254d5dc4bbc1d6f198f58b287e516a2
    generate ChangeLog from git logs into distribution tarball

Ten years later, it reappeared in:
commit ce97c33a795dec053f1e85c65ecd924b8c6ec4ba
    maint: Stop generating ChangeLog from git
which does not have a single line complying to this syntax
check rule.

At some point between the two commits VC_LIST_EXCEPT gained
a default exception for ChangeLog and it did not seem to be
overriden anywhere.

Just remove the rule.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: virstorage: Add test cases for "json:" pseudo-URI without 'file' wrapper
Peter Krempa [Mon, 3 Feb 2020 15:40:16 +0000 (16:40 +0100)]
tests: virstorage: Add test cases for "json:" pseudo-URI without 'file' wrapper

Add few cases that prove the second format of "json:" pseudo-URIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirStorageSourceParseBackingJSON: Prevent arbitrary nesting with format drivers
Peter Krempa [Mon, 3 Feb 2020 15:25:48 +0000 (16:25 +0100)]
virStorageSourceParseBackingJSON: Prevent arbitrary nesting with format drivers

Since we parse attributes for 'raw' which is a format driver and thus
has nested 'file' structure we must prevent that this isn't nested
arbitrarily.

Add a flag for the function which allows parsing of 'format' type
drivers only on the first pass.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirStorageSourceParseBackingJSON: Allow 'json:' pseudo URIs without 'file' wrapper
Peter Krempa [Mon, 3 Feb 2020 13:07:35 +0000 (14:07 +0100)]
virStorageSourceParseBackingJSON: Allow 'json:' pseudo URIs without 'file' wrapper

There are two possibilities:
1) json:{"file":{"driver":...}}
2) json:{"driver":...}

Our code didn't work properly with the second one as it was expecting
the 'file' wrapper. Conditionalize the removal to only the situation
when the top level doesn't have "driver".

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirStorageSourceJSONDriverParser: annotate 'format' drivers
Peter Krempa [Mon, 3 Feb 2020 13:13:50 +0000 (14:13 +0100)]
virStorageSourceJSONDriverParser: annotate 'format' drivers

The parser was originally designed only for protocol parsers. Since
we already have 'raw' format driver in the list we'll need to be able
to parse it too. In later patches this will be used to prevent parsing
nested format drivers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirStorageSourceParseBackingJSON: Move deflattening of json: URIs out of recursion
Peter Krempa [Mon, 3 Feb 2020 12:21:42 +0000 (13:21 +0100)]
virStorageSourceParseBackingJSON: Move deflattening of json: URIs out of recursion

Originally virStorageSourceParseBackingJSON didn't recurse, but when
the 'raw' driver support was added we need to parse it's information
which contains nested 'file' object.

Since the deflattening helper recurses already there's no need to call
it again. Move it one level up to the entry point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirStorageSourceParseBackingJSON: Pass around original backing file string
Peter Krempa [Mon, 3 Feb 2020 12:33:06 +0000 (13:33 +0100)]
virStorageSourceParseBackingJSON: Pass around original backing file string

There are a few error messages which might want to report the original
backing store string. Pass it around rather than trying to re-generate
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Fix handling of the 'copy-on-read' layer with blockdev
Peter Krempa [Thu, 6 Feb 2020 11:14:32 +0000 (12:14 +0100)]
qemu: hotplug: Fix handling of the 'copy-on-read' layer with blockdev

My original implementation was completely broken because it attempted to
use object-add/del instead of blockdev-add/del.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuMonitorBlockdevAdd: Take double pointer argument
Peter Krempa [Thu, 6 Feb 2020 12:13:32 +0000 (13:13 +0100)]
qemuMonitorBlockdevAdd: Take double pointer argument

Modify qemuMonitorBlockdevAdd so that it takes a double pointer for the
@props argument so that it's cleared inside the call. This allows
writing cleaner callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuMonitorJSONBlockdevDel: Refactor cleanup
Peter Krempa [Thu, 6 Feb 2020 12:03:07 +0000 (13:03 +0100)]
qemuMonitorJSONBlockdevDel: Refactor cleanup

Use automatic variable freeing and get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuMonitorJSONBlockdevAdd: Refactor cleanup
Peter Krempa [Thu, 6 Feb 2020 12:03:07 +0000 (13:03 +0100)]
qemuMonitorJSONBlockdevAdd: Refactor cleanup

Use automatic variable freeing and get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirDomainDiskTranslateSourcePool: Translate 'volume' disks in whole backing chain
Peter Krempa [Wed, 5 Feb 2020 12:05:05 +0000 (13:05 +0100)]
virDomainDiskTranslateSourcePool: Translate 'volume' disks in whole backing chain

Now that we accept full backing chains on input nothing should prevent
users from also using disk type 'VOLUME' for specifying the backing
images.

Do the translation for the whole backing chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskTranslateSourcePool: split code to setup one storage source
Peter Krempa [Wed, 5 Feb 2020 11:08:54 +0000 (12:08 +0100)]
virDomainDiskTranslateSourcePool: split code to setup one storage source

Extract all the code setting up one storage source from the rest which
sets up the whole disk. This will allow us to prepare the whole backing
chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskTranslateISCSIDirect: Take virStorageSourcePtr instead of virDomainDiskD...
Peter Krempa [Wed, 5 Feb 2020 11:39:41 +0000 (12:39 +0100)]
virDomainDiskTranslateISCSIDirect: Take virStorageSourcePtr instead of virDomainDiskDefPtr

Only 'def->src' was ever used in this function. Use the source directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskTranslateSourcePoolAuth: Take virStorageSourcePtr instead of virDomainDi...
Peter Krempa [Wed, 5 Feb 2020 11:39:41 +0000 (12:39 +0100)]
virDomainDiskTranslateSourcePoolAuth: Take virStorageSourcePtr instead of virDomainDiskDefPtr

Only 'def->src' was ever used in this function. Use the source directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskAddISCSIPoolSourceHost: Take virStorageSourcePtr instead of virDomainDis...
Peter Krempa [Wed, 5 Feb 2020 11:39:41 +0000 (12:39 +0100)]
virDomainDiskAddISCSIPoolSourceHost: Take virStorageSourcePtr instead of virDomainDiskDefPtr

Only 'def->src' was ever used in this function. Use the source directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskAddISCSIPoolSourceHost: Remove ternary operator
Peter Krempa [Wed, 5 Feb 2020 11:30:31 +0000 (12:30 +0100)]
virDomainDiskAddISCSIPoolSourceHost: Remove ternary operator

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskAddISCSIPoolSourceHost: Remove 'cleanup' label
Peter Krempa [Wed, 5 Feb 2020 11:28:35 +0000 (12:28 +0100)]
virDomainDiskAddISCSIPoolSourceHost: Remove 'cleanup' label

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskAddISCSIPoolSourceHost: use g_new0 instead of VIR_ALLOC_N
Peter Krempa [Wed, 5 Feb 2020 11:27:18 +0000 (12:27 +0100)]
virDomainDiskAddISCSIPoolSourceHost: use g_new0 instead of VIR_ALLOC_N

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirDomainDiskAddISCSIPoolSourceHost: Sanitize handling of string list
Peter Krempa [Wed, 5 Feb 2020 11:24:28 +0000 (12:24 +0100)]
virDomainDiskAddISCSIPoolSourceHost: Sanitize handling of string list

Use virStringSplitCount instead of virStringSplit so that we can drop
the call to virStringListLength and use VIR_AUTOSTRINGLIST to declare
it and allow removal of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuBlockStorageSourceGetBackendProps: Report errors on all switch cases
Peter Krempa [Thu, 6 Feb 2020 09:07:44 +0000 (10:07 +0100)]
qemuBlockStorageSourceGetBackendProps: Report errors on all switch cases

Few switch cases returned failure but didn't report an error. For a
situation when the backingStore type='volume' was not translated the
following error would occur:

 $ virsh start VM
 error: Failed to start domain VM
 error: An error occurred, but the cause is unknown

After this patch:

 $ virsh start VM
 error: Failed to start domain VM
 error: internal error: storage source pool 'tmp' volume 'pull3.qcow2' is not translated

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: Allow extracting 'return' section of QMP command in 'qemu-monitor-command'
Peter Krempa [Wed, 11 Dec 2019 13:16:22 +0000 (14:16 +0100)]
virsh: Allow extracting 'return' section of QMP command in 'qemu-monitor-command'

Simplify gathering the actual return value from a passed-through QMP
command when using 'qemu-monitor-command' by adding '--return-value'
switch which just extracts the 'return' section and alternatively
reports an error if the section is not present.

This simplifies gathering of some test data where the full reply would
need to be trimmed just for the actual return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agodocs: virsh: Modernize docs for qemu-monitor-command
Peter Krempa [Fri, 7 Feb 2020 06:53:36 +0000 (07:53 +0100)]
docs: virsh: Modernize docs for qemu-monitor-command

Mention that we actually by default use QMP and clarify the rest
of the documentation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: preserve error on bandwidth rollback
Ján Tomko [Fri, 7 Feb 2020 11:40:51 +0000 (12:40 +0100)]
qemu: preserve error on bandwidth rollback

We call APIs that reset the error in the rollback code.
Preserve the error from the original call that failed.

This turns the boringly cryptic:
  error: Unable to set interface parameters
  error: An error occurred, but the cause is unknown
to the unexpectedly anarchist:
  error: internal error: Child process (/usr/sbin/tc filter add
  dev vnet1 parent ffff: protocol all u32 match u32 0 0 police
  rate 4294968kbps burst 4294968kb mtu 64kb drop flowid :1)
  unexpected exit status 1: Illegal "rate"
  Illegal "police"

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f02e21cb3379a41cd42f2d8116f2d10dabace83b
https://bugzilla.redhat.com/show_bug.cgi?id=1800505
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: do not revert to NULL bandwidth
Ján Tomko [Fri, 7 Feb 2020 11:40:39 +0000 (12:40 +0100)]
qemu: do not revert to NULL bandwidth

Otherwise an attempt to set an invalid value:
  virsh domiftune rhel8.2 vnet0 --outbound 4294968
on an interface with no bandwidth set crashes.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f02e21cb3379a41cd42f2d8116f2d10dabace83b
https://bugzilla.redhat.com/show_bug.cgi?id=1800505
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agotestutils: print a helpful summary of failed tests
Ján Tomko [Thu, 6 Feb 2020 16:31:04 +0000 (17:31 +0100)]
testutils: print a helpful summary of failed tests

When debugging test failures in seven independent test
cases, it might be helpful to only gather the debug output
of the failing cases.

Record the indexes of the tests that fail and print them
in the VIR_TEST_RANGE of the command line that will result
in only those tests being run.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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>