Commit Graph

5919 Commits

Author SHA1 Message Date
Ján Tomko
f331a9ef64 Remove virutil.h where possible
Historically, this file was a dump for most of our helper
functions and needed almost everywhere.
With the introduction of virfile.h and virstring.h,
and more importantly, virenum.h and the introduction
of GLib, that is no longer true.

Remove its include from C files that don't even use it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-02-24 23:15:49 +01:00
Ján Tomko
a504a3c377 virhostdev: move to src/hypervisor
This module depends on domain_conf and is used directly by various
hypervisor drivers.

Move it to src/hypervisor.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-02-24 16:47:21 +01:00
Peter Krempa
e5c8f6e080 tests: virstorage: Fix backing file format of created image
We create some images for testing our code. We've recorded wrong format
of the backing file for one of the images though.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-24 15:12:32 +01:00
Ryan Moeller
b4a076ea78 bhyve: simplify driver caps helpers
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-24 01:52:22 +01:00
Michal Privoznik
6d371d92f8 qemuTestParseCapabilitiesArch: Free @binary
The variable is allocated, but never freed.

==119642== 29 bytes in 1 blocks are definitely lost in loss record 409 of 671
==119642==    at 0x483579F: malloc (vg_replace_malloc.c:309)
==119642==    by 0x5AB075F: __vasprintf_internal (in /lib64/libc-2.29.so)
==119642==    by 0x57C1A28: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
==119642==    by 0x579A0CC: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
==119642==    by 0x4AE6D58: vir_g_strdup_printf (glibcompat.c:197)
==119642==    by 0x136EEE: qemuTestParseCapabilitiesArch (testutilsqemu.c:291)
==119642==    by 0x138506: testQemuInfoSetArgs (testutilsqemu.c:763)
==119642==    by 0x135FFF: mymain (qemuxml2argvtest.c:3093)
==119642==    by 0x13A60E: virTestMain (testutils.c:839)
==119642==    by 0x1368C2: main (qemuxml2argvtest.c:3121)

Fixes: 42b3e5b9e4
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-21 11:13:20 +01:00
Collin Walling
fa2404bf4f qemumonitorjsontest: add test for cpu baseline
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-02-21 10:50:25 +01:00
Collin Walling
eee09435ee qemumonitorjsontest: add tests for cpu comparison
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-02-21 10:50:21 +01:00
Collin Walling
6523a7ea5d qemumonitorjsontest: load schema based on specified arch
There are some architectures that support capabilities that others
do not (e.g. s390x supports cpu comparison and baseline via QEMU).

Let's make testQEMUSchemaLoad accept a string to specify the schema
to load based on the specified arch.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-02-21 10:50:10 +01:00
Laine Stump
2b8fd7334d qemu/lxc: plumb isolatedPort from config down through bridge attachment
This patch pushes the isolatedPort setting from the <interface> down
all the way to the callers of virNetDevBridgeAddPort(), and sets
BR_ISOLATED on the port (using virNetDevBridgePortSetIsolated()) after
the port has been successfully added to the bridge.

Signed-off-by: Laine Stump <laine@redhat.com>

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-20 23:13:15 -05:00
Laine Stump
31d95b182e conf: parse/format <port isolated='yes|no'/>
This is a very simple thing to parse and format, but needs to be done
in 4 places, so two trivial utility functions have been made that can
be called from all the higher level parser/formatters:

  <domain><interface>
  <domain><interface><actual> (only in domain status)
  <network>
  <networkport>

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-20 23:09:27 -05:00
Jiri Denemark
0905f222f1 cpu_conf: Format vendor_id for host-model CPUs
In commit v5.9.0-400-gaf8e39921a I removed printing model's fallback and
vendor_id attributes when no model is specified. However, vendor_id
makes sense even without a specific CPU model (for host-model CPUs).

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-19 15:11:40 +01:00
Jiri Denemark
1939fbef98 qemuxml2xmltest: Add case for host-model vendor_id
This patch shows a bug in our code: the

    <model vendor_id="Libvirt QEMU"/>

element present in the source XML is lost when the parsed CPU definition
is formatted back to XML.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-19 15:11:40 +01:00
Peter Krempa
e8a819e87f 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>
2020-02-14 16:32:21 +01:00
Peter Krempa
293e7750c9 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>
2020-02-14 16:32:21 +01:00
Peter Krempa
9b804ef5ef 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>
2020-02-14 16:32:21 +01:00
Peter Krempa
f36d751fa6 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>
2020-02-14 16:32:21 +01:00
Peter Krempa
554ae62637 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>
2020-02-14 16:32:21 +01:00
Andrea Bolognani
76121fc9c4 tests: Add test case for the armvtimer timer
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-02-14 12:09:17 +01:00
Andrea Bolognani
204e2306e5 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>
2020-02-14 12:09:02 +01:00
Ján Tomko
090ad3cf39 testutils: remove now unused virTestCaptureProgramOutput
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-11 16:30:18 +01:00
Ján Tomko
cf17015fde 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>
2020-02-11 16:30:18 +01:00
Ján Tomko
8bacdde9d5 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>
2020-02-11 16:30:18 +01:00
Ján Tomko
994688e0df 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>
2020-02-11 16:30:18 +01:00
Ján Tomko
f11e9abe88 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>
2020-02-11 16:30:18 +01:00
Ján Tomko
40656ff758 testutils: use g_autofree
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-11 16:30:18 +01:00
Ján Tomko
879e9db194 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: 2c33532423
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-11 16:30:18 +01:00
Peter Krempa
0d0d60ddc5 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>
2020-02-10 17:26:27 +01:00
Ján Tomko
cebb468ef5 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>
2020-02-09 02:11:07 +01:00
Daniel P. Berrangé
2621d48f00 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>
2020-02-07 15:03:54 +00:00
Daniel P. Berrangé
29c4a3c753 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>
2020-02-07 14:57:59 +00:00
Jiri Denemark
c6ff3d1535 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>
2020-02-07 09:19:02 +01:00
Jiri Denemark
8c3aed2361 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>
2020-02-07 09:19:02 +01:00
Julio Faracco
23be4887af 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>
2020-02-06 15:00:57 +01:00
Pavel Hrdina
933ad86002 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>
2020-02-06 13:41:03 +01:00
Stefan Berger
5e35d4a519 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>
2020-02-05 19:57:10 +01:00
Stefan Berger
0e4c2ed490 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>
2020-02-05 19:57:10 +01:00
Daniel P. Berrangé
4ab2120f3b 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>
2020-02-04 14:00:45 +00:00
Daniel P. Berrangé
b9103e62e4 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>
2020-02-04 14:00:45 +00:00
Daniel P. Berrangé
03c532cf97 src: assume sys/sysmacros.h always exists on Linux
All our supported Linux distros now have this header.
It has never existed on FreeBSD / macOS / Mingw.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-04 14:00:45 +00:00
Daniel P. Berrangé
f691ec63b4 m4: add check for pthread library
When we get rid of GNULIB, we need to check for -lpthread
support.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-04 14:00:45 +00:00
Daniel P. Berrangé
cc46e137eb src: convert code to use virPipe APIs
This addreses portability to Windows and standardizes
error reporting. This fixes a number of places which
failed to set O_CLOEXEC or failed to report errors.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-04 14:00:44 +00:00
Daniel P. Berrangé
bfeb56b3ad 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>
2020-02-04 14:00:44 +00:00
Daniel P. Berrangé
7aef7cdbb5 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>
2020-02-04 14:00:44 +00:00
Daniel P. Berrangé
32363452af 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>
2020-02-04 14:00:44 +00:00
Daniel P. Berrangé
abab604e30 tests: remove event loop from command test
This effectively reverts

  commit 39c77fe586
  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>
2020-02-04 14:00:44 +00:00
Daniel P. Berrangé
194382c183 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>
2020-02-04 14:00:44 +00:00
Peter Krempa
9b13af73ac 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>
2020-02-04 13:45:33 +01:00
Peter Krempa
8e29a8b151 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>
2020-02-04 13:45:33 +01:00
Peter Krempa
41c7e5c2a6 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>
2020-02-04 13:45:33 +01:00
Peter Krempa
9ba804a1d1 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>
2020-02-04 13:45:33 +01:00