]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
5 years agoqemuMigrationCookieAddNBD: Use glib memory allocators
Peter Krempa [Thu, 30 Jan 2020 13:56:05 +0000 (14:56 +0100)]
qemuMigrationCookieAddNBD: Use glib memory allocators

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieNBD: Extract embedded struct
Peter Krempa [Thu, 30 Jan 2020 13:53:26 +0000 (14:53 +0100)]
qemuMigrationCookieNBD: Extract embedded struct

Extract the struct so that it's type has a name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuMigrationCookieAddNBD: Exit early if there are no disks
Peter Krempa [Thu, 30 Jan 2020 13:47:25 +0000 (14:47 +0100)]
qemuMigrationCookieAddNBD: Exit early if there are no disks

Refactor the logic to skip the body of the function if there's nothing
to do.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRemove checking of return value of virHashNew
Peter Krempa [Tue, 28 Jan 2020 12:40:24 +0000 (13:40 +0100)]
Remove checking of return value of virHashNew

There are two calls to virHashNew which check the return value. It's not
necessary any more as virHashNew always returns a valid pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: domain: Remove checking of return value of virHashCreateFull
Peter Krempa [Tue, 28 Jan 2020 12:40:24 +0000 (13:40 +0100)]
conf: domain: Remove checking of return value of virHashCreateFull

This module has last two direct checks whether the value returned by
virHashCreateFull is NULL. Remove them so that static analyzers don't
get the false idea that checking the value is necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: hash: Use g_new0 for allocating hash internals
Peter Krempa [Tue, 28 Jan 2020 12:34:43 +0000 (13:34 +0100)]
util: hash: Use g_new0 for allocating hash internals

Use the glib helpers and remove the mention of returning NULL on failure
of virHashNew, virHashCreate and virHashCreateFull.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: update Rust releases and resources links
Sahid Orentino Ferdjaoui [Thu, 30 Jan 2020 14:19:29 +0000 (15:19 +0100)]
docs: update Rust releases and resources links

This is updating the releases and resources links so they point now to
crates.io for the releases and docs.rs for the api ref.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Update godoc URLs for Go packages
Andrea Bolognani [Thu, 30 Jan 2020 17:10:35 +0000 (18:10 +0100)]
docs: Update godoc URLs for Go packages

Since

  commit 201156ec6e65e08cdb04d6fdefe013652fb7fa87
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Mon Dec 16 10:06:50 2019 +0000

    docs: add pages to support Go module package resolution

it's possible to use

  import "libvirt.org/libvirt-go"
  import "libvirt.org/libvirt-go-xml"

in Go programs, which will result in the Go packages being
fetched directly from libvirt.org instead of GitHub.

The godoc website offers the API documentation for the updated
imports, and that's where we should send users.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Update download location for Go packages
Andrea Bolognani [Thu, 30 Jan 2020 17:05:49 +0000 (18:05 +0100)]
docs: Update download location for Go packages

We haven't ever made releases of the Go components, which makes
sense because that's just not how that specific ecosystem works.

For people who are looking to use libvirt from Go, the brief
introductory pages located at the same URLs used to import the
packages are a better entry point than an empty directory
listing, so let's send them there instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoapparmor: fix qemu_bridge_helper for named profile
Christian Ehrhardt [Thu, 30 Jan 2020 07:12:38 +0000 (08:12 +0100)]
apparmor: fix qemu_bridge_helper for named profile

Since a3ab6d42 "apparmor: convert libvirtd profile to a named profile"
the detection of the subelement for qemu_bridge_helper is wrong.

In combination with the older 123cc3e1 "apparmor: allow
/usr/lib/qemu/qemu-bridge-helper" it now detects qemu-bridge-helper no
more with its path, but instead as a proper subelement of the named profile
like: label=libvirtd//qemu_bridge_helper

In the same fashion the reverse rule in the qemu_bridge_helper
sub-profile still uses the path and not the named profile label.

Triggering denies like:
apparmor="DENIED" operation="file_inherit"
  profile="libvirtd//qemu_bridge_helper" pid=5629 comm="qemu-bridge-hel"
  family="unix" sock_type="stream" protocol=0 requested_mask="send receive"
  denied_mask="send receive" addr=none peer_addr=none peer="libvirtd"

This patch fixes the unix socket rules for the communication between
libvirtd and qemu-bridge-helper to match that.

Fixes: a3ab6d42d825499af44b8f19f9299e150d9687bc
Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1655111
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agonwfilter: Use immediate packet delivery mode rather than buffering
Erik Skultety [Thu, 30 Jan 2020 12:51:30 +0000 (13:51 +0100)]
nwfilter: Use immediate packet delivery mode rather than buffering

Our nwfilter code doesn't set any timeout on the pcap packet buffer which
means that when DHCP snooping is enabled on a guest interface and
libvirt is trying to learn the IP address from guest's DHCP traffic, it
takes up to 4x longer to ping a guest successfully compared to a case
where nwfilter isn't enabled at all or libvirt uses the cached nwfilter
leases to populate the corresponding rules to ebtables.
With the pcap filter and rate limiting already in place, we should be
able to afford enabling the immediate packet delivery, FWIW immediate
mode was actually the default prior libpcap-1.5.0 (CentOS 6) regardless
of whether a buffer was requested.

The lack of any kind of timeout on the pcap buffer messed with the
libvirt TCK test suite which, even with a generous timeout in place,
timeouts every single time simply because it takes a while until
guest actually starts producing any kind of traffic to fill up
the buffer in place (apart from the DHCP traffic which happens fairly
early on).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibpcap: Bump the minimum required version to >= 1.5.0
Erik Skultety [Thu, 30 Jan 2020 12:05:54 +0000 (13:05 +0100)]
libpcap: Bump the minimum required version to >= 1.5.0

libpcap-1.5.0 introduced a function to enforce immediate mode (on all
platforms) which the follow-up patches will rely on.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoAdd a space before ending a comment
Ján Tomko [Fri, 24 Jan 2020 20:30:04 +0000 (21:30 +0100)]
Add a space before ending a comment

Also add a space after the start in some of the cases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoapparmor: Drop 'Last modified' comment from profiles
Michal Privoznik [Thu, 30 Jan 2020 06:58:25 +0000 (07:58 +0100)]
apparmor: Drop 'Last modified' comment from profiles

At the beginning of each profile we have a comment that says when
the profile was last updated. In theory, it makes sense because
one can see immediately if they are using an outdated profile.
However, we don't do a good job in keeping the comments in sync
with reality and also sysadmins should rather use their package
manager to find out libvirt version which installed the profiles.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoapparmor: Allow some more BIOS/UEFI paths
Michal Privoznik [Sat, 25 Jan 2020 08:38:53 +0000 (09:38 +0100)]
apparmor: Allow some more BIOS/UEFI paths

There are two more paths that we are missing in the default
domain profile: /usr/share/edk2-ovmf/ and /usr/share/sgabios/.
These exist on my Gentoo box and contain UEFI and BIOS images
respectively.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoapparmor: Sort paths in blocks in libvirt-qemu profile
Michal Privoznik [Sat, 25 Jan 2020 08:28:47 +0000 (09:28 +0100)]
apparmor: Sort paths in blocks in libvirt-qemu profile

Even though we construct a domain specific profile for each
domain we start (which should cover domain specific paths), there
is also another file that is included from the profile and which
contains domain agnostic paths (e.g. to cover libraries that qemu
links with). The paths in the file are split into blocks divided
by comments. Sort the paths in each block individually (ignoring
case sensitivity).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agolibxl: support getting and setting parameters for the Credit2
Dario Faggioli [Wed, 29 Jan 2020 11:05:15 +0000 (12:05 +0100)]
libxl: support getting and setting parameters for the Credit2

With Credit2 being Xen default scheduler, it's definitely the case to
allow Credit2's scheduling parameters to be get and set via libvirt.

This is easy, as Credit and Credit2 have (at least as of now) the very
same parameters ('weight' and 'cap'). So we can just let credit2 pass
the scheduler-type check and the same code will work for both.

Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agodocs: document <interface> subelement <teaming>
Laine Stump [Fri, 24 Jan 2020 02:34:01 +0000 (21:34 -0500)]
docs: document <interface> subelement <teaming>

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: add wait-unplug to qemu migration status enum
Laine Stump [Wed, 15 Jan 2020 21:38:57 +0000 (16:38 -0500)]
qemu: add wait-unplug to qemu migration status enum

Aside from itinerant error (actually warning) messages due to an
unrecognized response from qemu, this isn't even necessary - the
migration proceeds successfully to completion anyway.

(I'm not sure where to see this status reported in the API though - do
we need to add an extra state, or recognition of a new event somewhere?)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: allow migration with assigned PCI hostdev if <teaming> is set
Laine Stump [Fri, 10 Jan 2020 00:39:47 +0000 (19:39 -0500)]
qemu: allow migration with assigned PCI hostdev if <teaming> is set

Normally a PCI hostdev can't be migrated, so
qemuMigrationSrcIsAllowedHostdev() won't permit it. In the case of a a
hostdev network interface that has <teaming type='transient'/> set,
QEMU will automatically unplug the device prior to migration, and
re-plug a corresponding device on the destination. This patch modifies
qemuMigrationSrcIsAllowedHostdev() to allow domains with those devices
to be migrated.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: support interface <teaming> functionality
Laine Stump [Thu, 23 Jan 2020 20:34:53 +0000 (15:34 -0500)]
qemu: support interface <teaming> functionality

The QEMU driver uses the <teaming type='persistent|transient'
persistent='blah'/> element to setup a "failover" pair of devices -
the persistent device must be a virtio emulated NIC, with the only
extra configuration being the addition of ",failover=on" to the device
commandline, and the transient device must be a hostdev NIC
(<interface type='hostdev'> or <interface type='network'> with a
network that is a pool of SRIOV VFs) where the extra configuration is
the addition of ",failover_pair_id=$aliasOfVirtio" to the device
commandline. These new options are supported in QEMU 4.2.0 and later.

Extra qemu-specific validation is added to ensure that the device
type/model is appropriate and that the qemu binary supports these
commandline options.

The result of this will be:

1) The virtio device presented to the guest will have an extra bit set
in its PCI capabilities indicating that it can be used as a failover
backup device. The virtio guest driver will need to be equipped to do
something with this information - this is included in the Linux
virtio-net driver in kernel 4.18 and above (and also backported to
some older distro kernels). Unfortunately there is no way for libvirt
to learn whether or not the guest driver supports failover - if it
doesn't then the extra PCI capability will be ignored and the guest OS
will just see two independent devices. (NB: the current virtio guest
driver also requires that the MAC addresses of the two NICs match in
order to pair them into a bond).

2) When a migration is requested, QEMu will automatically unplug the
transient/hostdev NIC from the guest on the source host before
starting migration, and automatically re-plug a similar device after
restarting the guest CPUs on the destination host. While the transient
NIC is unplugged, all network traffic will go through the
persistent/virtio device, but when the hostdev NIC is plugged in, it
will get all the traffic. This means that in normal circumstances the
guest gets the performance advantage of vfio-assigned "real hardware"
networking, but it can still be migrated with the only downside being
a performance penalty (due to using an emulated NIC) during the
migration.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: parse/format <teaming> subelement of <interface>
Laine Stump [Wed, 22 Jan 2020 21:24:10 +0000 (16:24 -0500)]
conf: parse/format <teaming> subelement of <interface>

The subelement <teaming> of <interface> devices is used to configure a
simple teaming association between two interfaces in a domain. Example:

  <interface type='bridge'>
    <source bridge='br0'/>
    <model type='virtio'/>
    <mac address='00:11:22:33:44:55'/>
    <alias name='ua-backup0'/>
    <teaming type='persistent'/>
  </interface>
  <interface type='hostdev'>
    <source>
      <address type='pci' bus='0x02' slot='0x10' function='0x4'/>
    </source>
    <mac address='00:11:22:33:44:55'/>
    <teaming type='transient' persistent='ua-backup0'/>
  </interface>

The interface with <teaming type='persistent'/> is assumed to always
be present, while the interface with type='transient' may be be
unplugged and later re-plugged; the persistent='blah' attribute (and
in the one currently available implementation, also the matching MAC
addresses) is what associates the two devices with each other. It is
up to the hypervisor and the guest network drivers to determine what
to do with this information.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: add capabilities flag for failover feature
Laine Stump [Sun, 8 Dec 2019 19:22:34 +0000 (14:22 -0500)]
qemu: add capabilities flag for failover feature

Presence of the virtio-net-pci option called "failover" indicates
support in a qemu binary of a simplistic bonding of a virtio-net
device with another PCI device. This feature allows migration of
guests that have a network device assigned to a guest with VFIO, by
creating a network bond device in the guest consisting of the
VFIO-assigned device and a virtio-net-pci device, then temporarily
(and automatically) unplugging the VFIO net device prior to migration
(and hotplugging an equivalent device on the migration
destination). (The feature is called "failover" because the bond
device uses the vfio-pci netdev for normal guest networking, but
"fails over" to the virtio-net-pci netdev once the vfio-pci device is
unplugged for migration.)

Full functioning of the feature also requires support in the
virtio-net driver in the guest OS (since that is where the bond device
resides), but if the "failover" commandline option is present for the
virtio-net-pci device in qemu, at least the qemu part of the feature
is available, and libvirt can add the proper options to both the
virtio-net-pci and vfio-pci device commandlines to indicate qemu
should attempt doing the failover during migration.

This patch just adds the qemu capabilities flag "virtio-net.failover".

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobootstrap: remove 18 more gnulib modules
Daniel P. Berrangé [Wed, 22 Jan 2020 16:04:35 +0000 (16:04 +0000)]
bootstrap: remove 18 more gnulib modules

* chown: use is conditionally compiled
* configmake: functionality imported to Makefile.am
* getaddrinfo: we have no portability problems
  with Windows impl
* getpass: simplified impl is imported
* mgetgroups: getgrouplist is used directly
* net_if: header includes are conditionalized
* netdb: header includes are conditionalized
* passfd: simplified impl is imported
* posix-shell: functionality was unused & removed
* sigaction: usage is conditionalized
* sigpipe: usage is conditionalized
* stat-time: struct stat is used directly
* strchrnul: usage is eliminated
* strtok_r: usage is not a portability problem
* sys_stat: usage is conditionalized
* uname: rewritten to use native Win32 function to
  get host arch
* waitpid: usage is conditionalized
* wcwidth: rewritten using g_unichar APIs

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize EAI_ADDRFAMILY
Daniel P. Berrangé [Thu, 23 Jan 2020 11:40:39 +0000 (11:40 +0000)]
src: conditionalize EAI_ADDRFAMILY

The EAI_ADDRFAMILY constant has been removed from FreeBSD
headers, supposedly because it is deprecated by new RFC
drafts.

Previously GNULIB was providing a replacement because
MinGW lacked it too. The replacement provided for MinGW
was thus being used on FreeBSD too, but with a completely
bogus integer value.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: conditionalize use of SIGPIPE
Daniel P. Berrangé [Wed, 22 Jan 2020 17:59:39 +0000 (17:59 +0000)]
tests: conditionalize use of SIGPIPE

SIGPIPE is not available on the Windows platform.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: convert all code to use virsocket.h
Daniel P. Berrangé [Tue, 14 Jan 2020 17:38:59 +0000 (17:38 +0000)]
src: convert all code to use virsocket.h

There are a large number of different header files that
are related to the sockets APIs. The virsocket.h header
includes all of the relevant headers for Windows and UNIX
in one convenient place. If virsocketaddr.h is already
included, then there's no need for virsocket.h

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

chown and some stat constants are not available on
the Windows platform.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of O_BINARY
Daniel P. Berrangé [Wed, 22 Jan 2020 11:48:05 +0000 (11:48 +0000)]
src: conditionalize use of O_BINARY

The O_BINARY flag is not defined on all platforms so we must
conditionalize its use once we remove GNULIB.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of O_DIRECT
Daniel P. Berrangé [Wed, 22 Jan 2020 11:46:59 +0000 (11:46 +0000)]
src: conditionalize use of O_DIRECT

The O_DIRECT flag is not available on all platforms, so we
must introduce a compat define the same way gnulib does.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionalize use of F_DUPFD_CLOEXEC
Daniel P. Berrangé [Wed, 22 Jan 2020 11:45:55 +0000 (11:45 +0000)]
src: conditionalize use of F_DUPFD_CLOEXEC

The F_DUPFD_CLOEXEC functionality is not available on
some platformms. We must thus explicitly call the
virSetCloexec function once we remove GNULIB's equiv
fix for this.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: ensure O_CLOEXEC is defined on Windows
Daniel P. Berrangé [Wed, 22 Jan 2020 11:44:16 +0000 (11:44 +0000)]
src: ensure O_CLOEXEC is defined on Windows

Windows uses _O_NOINHERIT as the name for its O_CLOEXEC
equivalent. Define O_CLOEXEC to match this to fix
portability when we remove GNULIB.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: stop using O_DIRECTORY in resctrl
Daniel P. Berrangé [Wed, 22 Jan 2020 11:42:18 +0000 (11:42 +0000)]
src: stop using O_DIRECTORY in resctrl

The O_DIRECTORY flag causes open() to return an error
if the filename is a directory. There's no obvious
reason why resctrl needs to use this, while the rest of
libvirt code does not. Removing it avoids build issues
on platforms where O_DIRECTORY is not defined, once we
remove GNULIB.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>