]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemu: check if 'floor' is supported for given interface and network
Pavel Mores [Fri, 14 Feb 2020 16:26:20 +0000 (17:26 +0100)]
qemu: check if 'floor' is supported for given interface and network

Even if an interface of type 'network', setting 'floor' is only supported
if the network's forward type is nat, route, open or none.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fail on attempt to set 'floor' if interface type is not 'network'
Pavel Mores [Fri, 14 Feb 2020 16:26:21 +0000 (17:26 +0100)]
qemu: fail on attempt to set 'floor' if interface type is not 'network'

QoS 'floor' setting is documented to be only supported for interfaces of
type 'network'.  Fail with an error message on attempt to set 'floor' on
an interface of any other type.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: test if bandwidth has 'floor' factored out to separate function
Pavel Mores [Fri, 14 Feb 2020 16:26:19 +0000 (17:26 +0100)]
qemu: test if bandwidth has 'floor' factored out to separate function

This compound condition will be useful in several places so it
makes sense to give it a name for better readability.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size' attributes
Peter Krempa [Wed, 5 Feb 2020 17:09:55 +0000 (18:09 +0100)]
virStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size' attributes

If the parsed 'raw' format JSON string has 'offset' or 'size' attributes
parse them as the format slice.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemu: Add test data for the new <slice> element
Peter Krempa [Wed, 5 Feb 2020 17:18:39 +0000 (18:18 +0100)]
tests: qemu: Add test data for the new <slice> element

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add support for slices of type 'storage'
Peter Krempa [Mon, 10 Feb 2020 13:37:14 +0000 (14:37 +0100)]
qemu: Add support for slices of type 'storage'

Implement support for the slice of type 'storage' which allows to set
the offset and size which modifies where qemu should look for the start
of the format container inside the image.

Since slicing is done using the 'raw' driver we need to add another
layer into the blockdev tree if there's any non-raw image format driver
used to access the data.

This patch adds the blockdev integration and setup of the image data so
that we can use the slices for any backing image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Add cases for creating image overlays on top of disks with <slice>
Peter Krempa [Wed, 12 Feb 2020 16:26:18 +0000 (17:26 +0100)]
tests: qemublock: Add cases for creating image overlays on top of disks with <slice>

Add a set of test data to see whether the backing store strings are
formatted reasonably. Note that we don't support direct creation of such
images so those tests are not enabled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Properly format storage slice into backing store strings
Peter Krempa [Wed, 12 Feb 2020 16:25:12 +0000 (17:25 +0100)]
qemu: block: Properly format storage slice into backing store strings

When creating overlay images e.g. for snapshots or when merging
snapshots we often specify the backing store string to use. Make the
formatter aware of backing chain entries which have a <slice>
configured so that we record it properly. Otherwise such images
would not work without the XML (when detecting the backing chain).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Store nodenames of slice in status XML
Peter Krempa [Mon, 10 Feb 2020 13:26:08 +0000 (14:26 +0100)]
qemu: domain: Store nodenames of slice in status XML

The storage slice will require a specific node name in cases when the
image format is not raw. Store and format them in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Implement support for <slices> of disk source
Peter Krempa [Mon, 3 Feb 2020 16:36:09 +0000 (17:36 +0100)]
conf: Implement support for <slices> of disk source

Implement parsing and formatting of the 'storage' slice.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Document the new <slices> sub-element of disk's <source>
Peter Krempa [Wed, 5 Feb 2020 17:00:23 +0000 (18:00 +0100)]
docs: Document the new <slices> sub-element of disk's <source>

We are going to add support for specifying offset and size attributes
which will allow controling where the image and where the guest data
itself starts in the source of the disk. This will be represented by
a <slices> element filled with either a <slice type='storage'> for the
offset of the image format data.

Add the XML documentation and RNG schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: forbid creation of storage sources with <slice>
Peter Krempa [Wed, 12 Feb 2020 16:26:47 +0000 (17:26 +0100)]
qemu: block: forbid creation of storage sources with <slice>

Specifically creating such images via libvirt during blockjobs would
be much more hassle than it's worth. Just forbid them for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainValidateStorageSource: Reject unsupported slices
Peter Krempa [Wed, 5 Feb 2020 13:51:12 +0000 (14:51 +0100)]
qemuDomainValidateStorageSource: Reject unsupported slices

We support explicit storage slices only when using blockdev. Storage
slices expressed via the backing store string are left to qemu to
open correctly.

Reject storage slices configured via the XML for non-blockdev usage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size' for slice
Peter Krempa [Wed, 5 Feb 2020 17:08:55 +0000 (18:08 +0100)]
qemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size' for slice

If we have a 'format' type slice for a raw driver we can directly format
the values.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: virstoragefile: Add data structure for storing storage source slices
Peter Krempa [Mon, 3 Feb 2020 16:14:52 +0000 (17:14 +0100)]
util: virstoragefile: Add data structure for storing storage source slices

Introduce virStorageSourceSlice which will store the 'offset' and 'size'
of a virStorageSource and declare it as 'sliceStorage' and 'sliceFormat'
attributes of a virStorageSource.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virstorage: Add test data for json specified raw image with offset/size
Peter Krempa [Thu, 16 Jan 2020 15:02:15 +0000 (16:02 +0100)]
tests: virstorage: Add test data for json specified raw image with offset/size

QEMU allows specifying the offset and size into a raw file to expose a
sub-slice of the image to the guest with the raw driver. Libvirt
currently doesn't support it but we can add test case for future
reference.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: formatdomain: Close <source> on one of disk examples
Peter Krempa [Wed, 5 Feb 2020 16:59:38 +0000 (17:59 +0100)]
docs: formatdomain: Close <source> on one of disk examples

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Refactor formatting of node names into status XML
Peter Krempa [Mon, 10 Feb 2020 13:23:30 +0000 (14:23 +0100)]
qemu: domain: Refactor formatting of node names into status XML

Use virXMLFormatElement to simplify the logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_domain: Modify access to a NVMe disk iff needed
Michal Privoznik [Fri, 14 Feb 2020 12:59:02 +0000 (13:59 +0100)]
qemu_domain: Modify access to a NVMe disk iff needed

If a domain has a NVMe disk it already has the access configured.
Trying to configure it again on a commit or some other operation
is wrong and condemned to failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonews: Mention the armvtimer timer
Andrea Bolognani [Fri, 7 Feb 2020 13:00:22 +0000 (14:00 +0100)]
news: Mention the armvtimer timer

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: List the armvtimer timer among all others
Andrea Bolognani [Fri, 7 Feb 2020 12:35:00 +0000 (13:35 +0100)]
docs: List the armvtimer timer among all others

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Add test case for the armvtimer timer
Andrea Bolognani [Fri, 7 Feb 2020 12:11:42 +0000 (13:11 +0100)]
tests: Add test case for the armvtimer timer

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Format the armvtimer timer on the command line
Andrea Bolognani [Fri, 7 Feb 2020 11:45:49 +0000 (12:45 +0100)]
qemu: Format the armvtimer timer on the command line

Its behavior is controlled by a KVM-specific CPU feature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Validate configuration for the armvtimer timer
Andrea Bolognani [Fri, 7 Feb 2020 09:15:02 +0000 (10:15 +0100)]
qemu: Validate configuration for the armvtimer timer

Its use is limited to certain guest types, and it only supports
a subset of all possible tick policies.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Introduce VIR_DOMAIN_TIMER_NAME_ARMVTIMER
Andrea Bolognani [Thu, 6 Feb 2020 15:54:45 +0000 (16:54 +0100)]
conf: Introduce VIR_DOMAIN_TIMER_NAME_ARMVTIMER

This new timer model will be used to control the behavior of the
virtual timer for KVM ARM/virt guests.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add the QEMU_CAPS_CPU_KVM_NO_ADJVTIME capability
Andrea Bolognani [Fri, 31 Jan 2020 13:28:57 +0000 (14:28 +0100)]
qemu: Add the QEMU_CAPS_CPU_KVM_NO_ADJVTIME capability

We will use this capability to detect whether the QEMU binary
supports the kvm-no-adjvtime CPU feature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use switch statement in qemuBuildCpuCommandLine()
Andrea Bolognani [Fri, 7 Feb 2020 09:22:08 +0000 (10:22 +0100)]
qemu: Use switch statement in qemuBuildCpuCommandLine()

Make sure we are taking all possible virDomainTimerNameType values
into account. This will make upcoming changes easier.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: drop support for monitor connections on PTYs
Daniel P. Berrangé [Wed, 12 Feb 2020 10:50:49 +0000 (10:50 +0000)]
qemu: drop support for monitor connections on PTYs

Libvirt switched to using a UNIX socket for monitors in
2009 for version 0.7.0. It seems unlikely that there is
a running QEMU process that hasn't been restarted for
11 years while also taking a libvirt upgrade. Therefore
we can drop support for opening a PTY for the QEMU
monitor.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: use closefrom() for mass closing of FDs
Your Name [Wed, 12 Feb 2020 10:53:59 +0000 (10:53 +0000)]
src: use closefrom() for mass closing of FDs

On FreeBSD 12 the default ulimit settings allow for 100,000
open file descriptors. As a result spawning processes in
libvirt is abominably slow. Fortunately FreeBSD has long
since provided a good solution in the form of closefrom(),
which closes all FDs equal to or larger than the specified
parameter.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirt-aa-helper: Add support for smartcard host-certificates
Arnaud Patard [Thu, 5 Dec 2019 17:11:41 +0000 (18:11 +0100)]
virt-aa-helper: Add support for smartcard host-certificates

When emulating smartcard with host certificates, qemu needs to
be able to read the certificates files. Add necessary code to
add the smartcard certificates file path to the apparmor profile.

Passthrough support has been tested with spicevmc and remote-viewer.

v2:
- Fix CodingStyle
- Add support for 'host' case.
- Add a comment to mention that the passthrough case doesn't need
  some configuration
- Use one rule with '{,*}' instead of two rules.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agodocs: Improve documentation for <serial> and <console>
Andrea Bolognani [Tue, 11 Feb 2020 14:37:05 +0000 (15:37 +0100)]
docs: Improve documentation for <serial> and <console>

Users expect to be able to configure the <console> element and see
that configuration reflected into the <serial> element or at least
sticking, however due to our crazy back-compat code that doesn't
always happen.

There's really not much we can do to make this kind of corner cases
work as the user would expect, especially not without introducing
additional complexity in a part of libvirt that already has more
than a fair share of it; we can, however, improve the documentation
so that it will nudge said users in the right direction.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotestutils: remove now unused virTestCaptureProgramOutput
Ján Tomko [Sun, 9 Feb 2020 01:04:13 +0000 (02:04 +0100)]
testutils: remove now unused virTestCaptureProgramOutput

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirshtest: use virCommand instead of custom impl
Ján Tomko [Sun, 9 Feb 2020 01:00:06 +0000 (02:00 +0100)]
virshtest: use virCommand instead of custom impl

Our virCommand helper API already has the ability to capture
program output, there's no need to open-code it.

Apart from simplifying the code, the test is marginally faster
due to recent improvements in virCommandMassClose.

Until now, both stderr and stdout were stored in the same buffer.
This change stores stderr separately and expects it to be empty
for all the tests we currently run.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirshtest: refactor testCompareOutputLit
Ján Tomko [Sun, 9 Feb 2020 01:07:19 +0000 (02:07 +0100)]
virshtest: refactor testCompareOutputLit

Use g_autofree and get rid of the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotestutils: remove unnecessary labels
Ján Tomko [Sun, 9 Feb 2020 00:57:06 +0000 (01:57 +0100)]
testutils: remove unnecessary labels

The cleanups made some labels redundant.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotestutils: use g_autoptr
Ján Tomko [Sun, 9 Feb 2020 00:51:37 +0000 (01:51 +0100)]
testutils: use g_autoptr

Use g_autoptr where possible.

virTestCapsBuildNUMATopology is not converted completely,
because while the VIR_FREE call on cell_cpus is technically
wrong, neither VIR_ALLOC_N nor virBitmapNew can return
an allocation error now so it is effectively dead code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotestutils: use g_autofree
Ján Tomko [Sun, 9 Feb 2020 00:47:22 +0000 (01:47 +0100)]
testutils: use g_autofree

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotestutils: check return value of g_setenv
Ján Tomko [Sun, 9 Feb 2020 00:26:08 +0000 (01:26 +0100)]
testutils: check return value of g_setenv

The function returns gboolean.
Compare against the FALSE value from GLib.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 2c3353242337bb50fe5abc9454fd5fc98236d4ef
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosyntax-check: remove some exception mechanisms
Ján Tomko [Tue, 11 Feb 2020 00:05:21 +0000 (01:05 +0100)]
syntax-check: remove some exception mechanisms

Do not look for exception patterns in ${srcdir}./x-$@
nor the VC_LIST_EXCEPT_DEFAULT variable.

This also removes the default exception for ChangeLog.

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

This exception is no longer useful since README is just a symlink
to README.md, which is a subject to this check already.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: exclude: remove virstring
Ján Tomko [Tue, 11 Feb 2020 00:10:47 +0000 (01:10 +0100)]
syntax-check: exclude: remove virstring

We no longer implement a wrapper over strdup - g_strdup
is preferred.

The use of strncpy was removed in:
commit 7d70a63b947e9a654a4e3fffa0ffa355f5549ec7
    util: Improve virStrncpy() implementation

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: exclude: remove deleted files
Ján Tomko [Tue, 11 Feb 2020 00:10:29 +0000 (01:10 +0100)]
syntax-check: exclude: remove deleted files

Both xen/xend_internal and bootstrap.conf have been deleted from git.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: drop update-NEWS-hash
Ján Tomko [Tue, 11 Feb 2020 00:08:36 +0000 (01:08 +0100)]
syntax-check: drop update-NEWS-hash

NEWS was replaced by docs/news.html, so the pre-requisite for this
rule is not fulfilled.

Also, PREV_VERSION_REGEXP does not seem to be defined anywhere.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: drop CVS keyword expansion check
Ján Tomko [Tue, 11 Feb 2020 00:08:03 +0000 (01:08 +0100)]
syntax-check: drop CVS keyword expansion check

  $ date +%Y
  2020

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
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>