Commit Graph

5279 Commits

Author SHA1 Message Date
Jonathon Jongsma
c35d8a7d5e tests: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-19 17:12:34 +02:00
Yi Li
cdd362e0e7 storage: escape ipv6 for ceph mon hosts to librados
Hosts for rbd are ceph monitor daemons. These have fixed IP addresses,
so they are often referenced by IP rather than hostname for
convenience, or to avoid relying on DNS. Using IPv4 addresses as the
host name works already, but IPv6 addresses require rbd-specific
escaping because the colon is used as an option separator in the
string passed to librados.

Escape these colons, and enclose the IPv6 address in square brackets
so it is distinguished from the port, which is currently mandatory.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-18 17:14:17 +02:00
Michal Privoznik
68e503ee70 virpcitest: Separate two functions properly
There is a missing empty line between two functions since its
introduction in v1.2.0-rc1~150.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-06-17 17:47:18 +02:00
Daniel P. Berrangé
90064d76bc conf: record a portid against the domain conf
The portid will be the UUID of the virNetworkPort object associated
with the network interface when a guest is running.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-06-17 15:45:09 +01:00
Daniel P. Berrangé
4b4a981d60 conf: introduce virNetworkPortDefPtr struct and XML support
Introduce a virNetworkPortDefPtr struct to represent the data associated
with a virtual network port. Add APIs for parsing/formatting XML docs
with the data.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-06-17 15:19:54 +01:00
Daniel P. Berrangé
c0c37de2d6 conf: allow bandwidth parsing / formatting to include class ID
The domain conf actual network def stores a <class id='3'/> element
separately from the <bandwidth>. The class ID should really just be
an attribute on the <bandwidth> element. We can't change existing
XML, and this isn't visible to users since it is internal XML only.
When we expose the new network port XML to users though, we should
get the design right.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-06-17 15:19:54 +01:00
Ján Tomko
e6d6a56fef tests: qemuMonitorTestAddInvalidCommandResponse: VIR_AUTOFREE
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
3f0713a0b1 tests: qemuMonitorTestAddUnexpectedErrorResponse: VIR_AUTOFREE
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
f6d1e243cc tests: refactor qemuMonitorTestProcessCommandDefaultValidate
Use VIR_AUTO* for cleanup and virBufferCurrentContent instead
of virBufferContentAndReset.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
4659a1985c tests: refactor qemuMonitorTestProcessCommandDefault
Use VIR_AUTOPTR and get rid of the 'ret' variable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
20d3c483e8 tests: qemuMonitorReportError: use VIR_AUTOFREE
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
6d11c756f2 tests: remove text monitor testing infrastructure
We removed testing for text monitor some time ago, remove
the remains from the test infrastructure.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
fba29dff83 tests: qemuMonitorReportError: use tmp variable properly
There is no obvious benefit in putting the escaped message
back into msg while tmp holds the original message.

Remove the assignment and use 'tmp' directly'.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
87bd437777 tests: qemuMonitorTestAddErrorResponse: use VIR_AUTOFREE
Use VIR_AUTOFREE.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
6806051078 tests: always assume JSON in qemuMonitorTestNew
Now that all the callers call qemuMonitorTestNew with json=true,
remove the argument and always assume JSON.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Ján Tomko
92f130a2e1 tests: assume JSON monitor in qemuMonitorTestNewSimple
The only user of the qemuMonitorTestNewSimple macro is using JSON.
Always pass 'true' to qemuMonitorTestNew and remove the 'json'
argument.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-17 16:12:57 +02:00
Andrea Bolognani
73cfc36211 tests: Include LDADDS in qemu_LDADDS
At this point, all test programs that use qemu_LDADDS also
use LDADDS, so we can remove a bunch of repetition by simply
including the latter in the former.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-06-12 20:31:23 +02:00
Andrea Bolognani
6b8048b48d tests: Tweak vircapstest_LDADD
We optionally include QEMU and LXC support in this test and
depending on which is enabled (if either is enabled at all) we
need to link in different objects.

Right now we implicitly depend on the fact that qemu_LDADDS is
empty when QEMU is not enabled to get the correct set of objects,
but it's better to be explicit about it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-06-12 20:31:18 +02:00
Andrea Bolognani
74d8909f76 tests: Tweak cputest_LDADDS
We want all test programs using qemu_LDADDS to also use LDADDS,
and cputest is the only existing exception.

We can't just replace GNULIB_LIBS with LDADDS though, even though
the latter is a superset of the former, because that would result
in a linking error due to including the same object twice:

  /usr/bin/ld:
  ../src/libvirt_probes.o:.../src/libvirt_probes.o.dtrace-temp.c:141:
  multiple definition of `libvirt_object_new_semaphore';
  ../src/libvirt_probes.o:.../src/libvirt_probes.o.dtrace-temp.c:141:
  first defined here

To work around this, we include both qemu_LDADDS and LDADDS when
QEMU support is enabled, and just LDADDS otherwise.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-06-12 20:30:46 +02:00
Peter Krempa
10e12c4009 tests: uri: Add test for urlencoded URIs
When specifying extra params for spcie TLS verification, it's necessary
to pass a weird URI to it. Let's add a test for this case where the TLS
string contains a space.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:26:25 +02:00
Peter Krempa
4977f19c54 tests: uri: Run all test cases on a single URI
Determine whether the test has failed after running all the cases so
that we don't need to rerun it multiple times to see all problems.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:26:25 +02:00
Peter Krempa
cd99bcf298 tests: uri: Use VIR_TEST_DEBUG instead of VIR_DEBUG
VIR_TEST_DEBUG can be easily made verbose in the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:26:25 +02:00
Peter Krempa
b872422a9c tests: qemumonitorjson: Replace use of virReportError
Use VIR_TEST_VERBOSE instead. This fixes the following syntax check
problem:

tests/qemumonitorjsontest.c:1409:        virReportError(VIR_ERR_INTERNAL_ERROR, "arr should have been cleared");

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 09:19:25 +02:00
Eric Blake
fbb5271c78 backup: Add new parameters to qemu monitor nbd-server-add
The upcoming virDomainBackup() API needs to take advantage of the
ability to expose a bitmap as part of nbd-server-add for a pull-mode
backup (this is the recently-added QEMU_CAPS_NBD_BITMAP capability).

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:47:13 -05:00
Eric Blake
ad1c17c8d5 backup: Add new qemu monitor bitmap
The upcoming virDomainBackup() API needs to take advantage of various
qcow2 bitmap manipulations as the basis to virDomainCheckpoints and
incremental backups.  Add four functions to expose
block-dirty-bitmap-{add,enable,disable,merge} (this is the
recently-added QEMU_CAPS_BITMAP_MERGE capability).

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:47:10 -05:00
Eric Blake
6abda7a445 backup: Add two new qemu capabilities
Add two capabilities for testing features required for the upcoming
virDomainBackupBegin: use block-dirty-bitmap-merge as the generic
witness of bitmap support needed for checkpoints (since all of the
bitmap management functionalities were finalized in the same qemu 4.0
release), and the bitmap parameter to nbd-server-add for pull-mode
backup support.  Even though both capabilities are likely to be
present or absent together (that is, it is unlikely to encounter a
qemu that backports only one of the two), it still makes sense to keep
two capabilities as the two uses are orthogonal (full backups don't
require checkpoints, push mode backups don't require NBD bitmap
support, and checkpoints can be used for more than just incremental
backups).

Existing code is not affected by the new capabilities.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:42:57 -05:00
Eric Blake
73bf0a9c28 backup: Prepare for Unix sockets in QMP nbd-server-start
Migration always uses a TCP socket for NBD servers, because we don't
support same-host migration. But upcoming pull-mode incremental backup
needs to also support a Unix socket, for retrieving the backup from
the same host. Support this by plumbing virStorageNetHostDef through
the monitor calls, since that is a nice reusable struct that can track
both TCP and Unix sockets.

Update qemumonitorjsontest to verify both forms of the QMP command.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:41:42 -05:00
Eric Blake
1ddc7e0363 qemumonitorjsontest: Simplify returns
Time to remove the cleanup labels rendered useless in the previous
patch.  There are still plenty of other tests that could be further
simplified, but I've already spent enough time in this file for now.

Signed-off-by: Eric Blake <eblake@redhat.com>
2019-06-11 21:35:39 -05:00
Eric Blake
4b658bfe4b qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.

In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.

Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:

| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
|      if (reason)
|          *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| -    if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| +    if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| +                                           "s:garbage", "foo", NULL)))
|          return -1;
|
|      if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)

Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:35:24 -05:00
Eric Blake
09083437ff qemumonitorjsontest: Use VIR_AUTOPTR support
Simplify the GEN_TEST_FUNC() and target of the DO_TEST_SIMPLE() macros
by using autoptr support.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:30:12 -05:00
Eric Blake
2ea60b6f7e qemumonitortestutils: Add VIR_AUTOPTR support
Upcoming tests are going to use VIR_AUTOPTR to simplify test cleanup.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 20:53:50 -05:00
Peter Krempa
6f15c82fda tests: qemuhotplug: Use schema testing with qemuMonitorTestNewFromFileFull
Pass in the schema since it works with the 'file' test now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-06-07 16:18:46 +02:00
Peter Krempa
1a77e0032b tests: Allow QMP schema testing in qemuMonitorTestNewFromFileFull
Pass in the schema data from the caller if QMP schema testing is
desired.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-06-07 16:18:45 +02:00
Peter Krempa
56c2f2b45b tests: qemu: Add QMP schema checking in qemuMonitorTestProcessCommandVerbatim
In case when we are testing a QMP command we can try to schema check it
so that we catch inconsistencies.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-06-07 16:18:45 +02:00
Peter Krempa
e4013f9ff7 tests: Refactor cleanup in qemuMonitorTestProcessCommandVerbatim
Use VIR_AUTOFREE and get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-06-07 16:18:45 +02:00
Erik Skultety
08ad83eee1 tests: Fix parentheses order in an assignment-comparison conditional
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1717090

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2019-06-04 20:56:58 +02:00
Andrea Bolognani
1b2ac8010c util: Introduce virBitmapUnion()
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-04 09:29:35 +02:00
Jiri Denemark
02c1d3a6e1 qemuargv2xmltest: Use mocked virQEMUCapsProbeHostCPU
The qemuTestParseCapabilitiesArch call would eventually lead to the host
CPU being probed via virCPUGetHost. Let's divert this to a mocked
version already used by the qemuxml2argvtest.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2019-06-03 18:07:16 +02:00
Jiri Denemark
dd3fc650de qemu: Make virQEMUCapsProbeHostCPUForEmulator more generic
The function is renamed as virQEMUCapsProbeHostCPU and it does not get
the list of allowed CPU models from qemuCaps anymore. This is
responsibility is moved to the caller. The result is just a very thin
wrapper around virCPUGetHost mostly required mocking in tests.

The generic function is used in place of a direct call to virCPUGetHost
in virQEMUCapsInitHostCPUModel to make sure tests don't accidentally
probe host CPU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2019-06-03 18:07:16 +02:00
Michal Privoznik
ec6ce6363a virSysinfoReadARM: Try reading DMI table
https://bugzilla.redhat.com/show_bug.cgi?id=1426162

Turns out, some aarch64 systems have SMBIOS info. That means we
can use dmidecode to fetch some information. If that fails, fall
back to the old behaviour.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2019-06-03 17:59:38 +02:00
Michal Privoznik
ac61c9cfc3 virsysinfo: Rename virSysinfoReadX86 to virSysinfoReadDMI
There's nothing x86 specific about this function. Rename the
function so that it has DMI suffix which enables it to be reused
on different arches (as using X86 from say ARM would look
suspicious).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2019-06-03 17:51:12 +02:00
Andrea Bolognani
667a373526 tests: Add aarch64-gigabyte sysinfo test case
This test case uses (anonimized) data pulled from a
GIGABYTE R120-T34 server.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2019-06-03 17:48:23 +02:00
Andrea Bolognani
43bc35ac1a tests: Tweak x86 sysinfo test case
We have a single mock dmidecode script right now, but we're
going to add another one soon, so we need to make sure its
name contains the test case name as a prefix, just like we
already do with all data files.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2019-06-03 17:46:03 +02:00
Andrea Bolognani
1462881f4e qemu: Format SMMUv3 IOMMU
https://bugzilla.redhat.com/show_bug.cgi?id=1575526

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-03 17:40:57 +02:00
Andrea Bolognani
60f4c41377 conf: Parse and format SMMUv3 IOMMU
SMMUv3 is an IOMMU implementation for ARM virt guests.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-03 17:40:48 +02:00
Andrea Bolognani
124eb803fc qemu: Introduce QEMU_CAPS_MACHINE_VIRT_IOMMU
This capability can be used to figure out whether the
QEMU binary at hand supports the machine type property
we need in order to enable SMMUv3 IOMMU support.

Unfortunately we can't avoid probing the RISC-V binaries
along with the ARM ones, since both architectures have
their own 'virt' machine type.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-03 17:40:45 +02:00
Jim Fehlig
76b420d003 build: fix linking libqemutestdriver with LTO enabled
openSUSE Factory is in the process of enabling Link Time Optimization [0]
and stumbled upon missing symbols when linking libqemutestdriver

libtool: link: gcc -shared  -fPIC -DPIC  ../src/libvirt_qemu_probes.o  \
-Wl,--whole-archive ../src/.libs/libvirt_driver_qemu_impl.a \
../src/.libs/libvirt_driver_network_impl.a \
../src/.libs/libvirt_driver_storage_impl.a -Wl,--no-whole-archive  \
-lcap-ng -lgnutls -lnl-route-3 -lnl-3 -ldbus-1 -lselinux -lapparmor \
/usr/lib/libxml2.so -ldl -lz -llzma -lm -lblkid -ltirpc  \
-fstack-protector-strong -O2 -fstack-protector-strong -flto=16 -g -O2 \
-fstack-protector-strong -flto=16 -g \
-Wl,-soname -Wl,libqemutestdriver.so -o .libs/libqemutestdriver.so
...
/usr/lib/gcc/i586-suse-linux/9/../../../../i586-suse-linux/bin/ld: ./.libs/libqemutestdriver.so: undefined reference to `mdir_name'
/usr/lib/gcc/i586-suse-linux/9/../../../../i586-suse-linux/bin/ld: ./.libs/libqemutestdriver.so: undefined reference to `rpl_ioctl'
/usr/lib/gcc/i586-suse-linux/9/../../../../i586-suse-linux/bin/ld: ./.libs/libqemutestdriver.so: undefined reference to `rpl_pipe2'
/usr/lib/gcc/i586-suse-linux/9/../../../../i586-suse-linux/bin/ld: ./.libs/libqemutestdriver.so: undefined reference to `recvfd'
/usr/lib/gcc/i586-suse-linux/9/../../../../i586-suse-linux/bin/ld: ./.libs/libqemutestdriver.so: undefined reference to `c_strcasecmp'

The missing symbols are provided by GNUlib. Add it when linking
libqemutestdriver.

[0] https://en.opensuse.org/openSUSE:LTO

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2019-05-30 09:09:10 -06:00
Daniel P. Berrangé
c6cbe18771 network: delay global firewall setup if no networks are running
Creating firewall rules for the virtual networks causes the kernel to
load the conntrack module. This imposes a significant performance
penalty on Linux network traffic. Thus we want to only take that hit if
we actually have virtual networks running.

We need to create global firewall rules during startup in order to
"upgrade" rules for any running networks created by older libvirt.
If no running networks are present though, we can safely delay setup
until the time we actually start a network.

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-05-23 16:29:48 +01:00
Andrea Bolognani
a7a78c273e qemu: Introduce qemuDomainDeviceDefValidateIOMMU()
Device validation should not have to wait until command line
generation time. Moving the code to a separate function also
allows us to avoid some unnecessary repetition.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-23 15:19:01 +02:00
Andrea Bolognani
69a8c64f4b tests: Add negative test for Intel IOMMU
Make sure validation is working as intended by trying to use
Intel IOMMU with the i440fx machine type, though we know it's
a q35-only feature, and expecting an error to be returned.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-22 14:54:32 +02:00