Commit Graph

4324 Commits

Author SHA1 Message Date
John Ferlan
713342e953 tests: Return failure if log not fopen'd
If @log is not fopen'd then, going to cleanup and calling fclose
will make for an unhappy callee. So just fail immediately instead
since there's nothing to clean up.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-04-19 14:24:12 -04:00
Andrea Bolognani
931144858f qemu: Figure out nodeset bitmap size correctly
The current private XML parsing code relies on the assumption
that NUMA node IDs start from 0 and are densely allocated,
neither of which is necessarily the case.

Change it so that the bitmap size is dynamically calculated by
looking at NUMA node IDs instead, which ensures all nodes will
be able to fit and thus the bitmap will be parsed successfully.

Update one of the test cases so that it would fail with the
previous approach, but passes with the new one.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-19 17:57:54 +02:00
Andrea Bolognani
4fe4ffdbdf tests: Create full host NUMA topology in more cases
vircapstest has code to add a full host NUMA topology, that
is, one that includes all information about nodes and CPUs
including IDs; testQemuCapsInit(), which is used to create a
mock virCapsPtr for QEMU tests, however, just fakes it by
setting nnumaCell_max to some number.

While the latter approach has served us well so far, we're
going to need all the information to be filled in soon. In
order to do that, we can just move the existing code from
vircapstest to testutils and, with some renaming and
trivial tweaking, use it as-is.

Interestingly, the NUMA topology generated by the function
is rigged up so that the NUMA nodes aren't (necessarily)
numbered starting from 0, which is a nice way to spot
mistaken assumptions in our codebase.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-19 17:57:52 +02:00
Peter Krempa
327430fcfc qemu: Format 'write-cache' parameter for disk frontends
The disk cache mode translates to various frontend and backend
attributes for the qemu block layer. For the frontend device the
'writeback' parameter is used and provided as 'write-cache'. Implement
this so that we can later switch to using -blockdev where we will not
pass the cachemode directly any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Peter Krempa
955df88de6 qemu: caps: Add capability for 'write-cache' parameter of disk frontends
QEMU translates the cache mode of a disk internally into 3 flags.
'write-cache' is a flag of the frontend while others are flag of the
backing storage. Add capability which will allow expressing it via the
frontend attribute.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Peter Krempa
cf44d63a83 tests: qemuxml2argv: Test formatting of 'write-cache' parameter
Prepare the tests for adding the new parameter. The parameter was
introduced in qemu-2.7.0, so add a forked version of the test case to
see that it is formatted properly.

This test is also an example how the new testing macros should be used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Peter Krempa
976fbb98c8 tests: qemuxml2argv: Add infrastructure for testing with real qemuCaps
Allow testing of XML->argv conversion with using a real capability map
as used in the qemucapabilitiestest. This allows specifying the required
qemu version with the test rather than having to enumerate all the
required capabilities or allows to use the newest capabilities present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Peter Krempa
f4f7d0da8b tests: qemuxml2argv: Add infrastructure to pass output file suffix
To allow having more than one output file in the qemuxml2argvtest add a
suffix member to the testInfo struct which will allow testing the same
XML file with multiple capabilities files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Peter Krempa
e831821cbc tests: qemu: Add helper code to lookup latest capability file
The helper iterates the directory with files for the capability test and
looks up the most recent one for the given architecture. This will allow
testing against the newest qemu capabilities so that we can catch
regressions in behaviour more easily.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Nikolay Shirokovskiy
0c8f0fb653 cputest: New test for Intel Core i5-650
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-04-18 11:39:53 +02:00
Michal Privoznik
10f94828ea virobject: Introduce VIR_CLASS_NEW() macro
So far we are repeating the following lines over and over:

  if (!(virSomeObjectClass = virClassNew(virClassForObject(),
                             "virSomeObject",
                             sizeof(virSomeObject),
                             virSomeObjectDispose)))
      return -1;

While this works, it is impossible to do some checking. Firstly,
the class name (the 2nd argument) doesn't match the name in the
code in all cases (the 3rd argument). Secondly, the current style
is needlessly verbose. This commit turns example into following:

  if (!(VIR_CLASS_NEW(virSomeObject,
                      virClassForObject)))
      return -1;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-18 10:04:55 +02:00
Michal Privoznik
4e42981b36 src: Unify virObject member name
Whenever we declare a new object the first member of the struct
has to be virObject (or any other member of that family). Now, up
until now we did not care about the name of the struct member.
But lets unify it so that we can do some checks at compile time
later.

The unified name is 'parent'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-18 10:04:55 +02:00
Michal Privoznik
2a7845b55d tests: Compile and link virmocklibxl with libxml
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-04-18 10:02:14 +02:00
Michal Privoznik
1c36a59b02 virmocklibxl.c: Fix include of virfile.h
Firstly, this isn't supposed to be in angle brackets because it's
not a system header file (not that gcc distinguishes these two,
it's just guide for us developers).

Secondly, no need to use util/ path prefix because CFLAGS already
contain -I$(srcdir)/util.

The include is needed because virmocklibxl is mocking
virFileMakePath() and even when VIR_MOCK_IMPL_RET_ARGS() does
forward declaration to shut up compiler we need real
virFileMakePath() declaration so that when it changes compiler
catches mismatching declarations.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-04-18 09:59:52 +02:00
Marek Marczykowski-Górecki
c961b59abc tests: add test case for CPUID in xenconfig driver
Check conversion of "cpuid" setting, check all supported policy settings
("1", "0", "x"). Also, check interaction with "nestedhvm" - should not
be included as "vmx=1" in "cpuid" setting.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
11479c3885 tests: check CPU features handling in libxl driver
Test enabling/disabling individual CPU features and also setting
nested HVM support, which is also controlled by CPU features node.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
c686f67f9c libxl: do not enable nested HVM unless global nested_hvm option enabled
Introduce global libxl option for enabling nested HVM feature, similar
to kvm module parameter. This will prevent enabling experimental feature
by mere presence of <cpu mode='host-passthrough'> element in domain
config, unless explicitly enabled. <cpu mode='host-passthrough'> element
may be used to configure other features, like NUMA, or CPUID.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
446d091498 libxl: pass driver config to libxlMakeDomBuildInfo
Preparation for global nestedhvm configuration - libxlMakeDomBuildInfo
needs access to libxlDriverConfig.
No functional change.

Adjusting tests require slightly more mockup functions, because of
libxlDriverConfigNew() call.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-04-17 21:15:27 -06:00
Viktor Mihajlovski
4093449429 tests: add testcase for s390 query-cpus-fast
The s390 testcase verifies that the s390-specific cpu-state
field is correctly mapped to the halted property.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 12:45:26 -04:00
Viktor Mihajlovski
37bd4571c7 tests: add qemumonitorjson tests for query-cpus-fast
Extended the json monitor test program with support for query-cpus-fast
and added a sample file set for x86 data obtained using the it.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 12:45:26 -04:00
Viktor Mihajlovski
41e335f99b qemu: use query-cpus-fast in JSON monitor
Use query-cpus-fast instead of query-cpus if supported by QEMU.
Based on the QEMU_CAPS_QUERY_CPUS_FAST capability.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 12:45:26 -04:00
Viktor Mihajlovski
56665e9984 test: Update qemumonitorjsontest to add halted output
Print out the halted property in the test output.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 12:45:26 -04:00
Viktor Mihajlovski
5cff7b7db7 qemu: add capability detection for query-cpus-fast
Detect whether QEMU supports the QMP query-cpus-fast API
and set QEMU_CAPS_QUERY_CPUS_FAST in this case.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2018-04-17 12:45:25 -04:00
Ján Tomko
3527f9dde6 qemu: deny privilege elevation and spawn in seccomp
If QEMU uses a seccomp blacklist (since 2.11), -sandbox on
no longer tries to whitelist all the calls, but uses sets
of blacklists:
default (always blacklisted with -sandbox on)
obsolete (defaults to deny)
elevateprivileges (setuid & co, default: allow)
spawn (fork & execve, default: allow)
resourcecontrol (setaffinity, setscheduler, default: allow)

If these are supported, default to sandbox with all four
categories blacklisted.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 16:29:38 +02:00
Ján Tomko
31ca6a542e Introduce QEMU_CAPS_SECCOMP_BLACKLIST
QEMU commit 1bd6152 changed the default behavior from whitelist
to blacklist and introduced a few sets of system calls.

Use the 'elevateprivileges' parameter of -sandbox as a witness
of this change.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 16:29:38 +02:00
Peter Krempa
7de761a67b tests: utils: Allow parsing test capability file without virCaps
virCaps was used only to propagate the host architecture, so the
function can be extracted in a way which does not require it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-17 15:51:46 +02:00
Ján Tomko
53fa2edb62 qemu: deprecate QEMU_CAPS_MACHINE_USB_OPT
Implied by QEMU >= 1.3.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:50:25 +02:00
Ján Tomko
5a41bd6df2 qemu: deprecate QEMU_CAPS_DISPLAY
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:49:21 +02:00
Ján Tomko
4a42ece13a qemu: deprecate QEMU_CAPS_HOST_PCI_MULTIDOMAIN
Implied by QEMU >= 1.2.0.
Delete the negative test cases now that they always pass.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:40:38 +02:00
Ján Tomko
027b7f9edf qemu: deprecate QEMU_CAPS_VNC_SHARE_POLICY
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:37:50 +02:00
Ján Tomko
84b40886f2 qemu: deprecate QEMU_CAPS_DUMP_GUEST_CORE
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:35:09 +02:00
Ján Tomko
69420756b2 qemu: deprecate QEMU_CAPS_MACHINE_OPT
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:24:09 +02:00
Ján Tomko
31413101a8 tests: mock qemuInterfaceOpenVhostNet
This functions contains logic that tries to use vhost for virtio
interfaces, even if <driver name='vhost'/> was not supplied.
In this case, a failure is non-fatal.

On my system, /dev/vhost-net was not accessible to the user running
'make check', but we should not depend on that.

Mock it to prevent accessing /dev/vhost-net and return some predictable
file descriptor numbers instead.

Introduced by commit c1f684e - deprecate QEMU_CAPS_VHOST_NET.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Jiří Denemark <jdenemar@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2018-04-17 14:02:09 +02:00
Ján Tomko
374777ee74 tests: remove double space
Commit 70255fa5 introduced a double space before the newline-escaping
backslash and broke syntax check.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 14:02:09 +02:00
Martin Kletzander
70255fa596 tests: Fix up test numbering in qemuxml2argvtest
Due to conditional execution of virTestRun(), the testCounter was incremented
only if all the cases were run.  When using VIR_TEST_RANGE=x-y, first x/2 of the
increments were skipped and that made figuring out a precise case a PITA.
Moving the condition into the test function makes it way nicer to find out the
test numbers to use in VIR_TEST_RANGE.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-04-17 13:50:20 +02:00
Ján Tomko
fd247f8fe7 qemu: deprecate QEMU_CAPS_IPV6_MIGRATION
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:01:28 +02:00
Ján Tomko
2089a801ba qemu: deprecate QEMU_CAPS_DTB
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:01:10 +02:00
Ján Tomko
766d5c1b5a qemu: deprecate QEMU_CAPS_SECCOMP_SANDBOX
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:53 +02:00
Ján Tomko
d91890f30c qemu: deprecate QEMU_CAPS_NETDEV_BRIDGE
Unused since commit <2d80fbb1>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:35 +02:00
Ján Tomko
da6df1be8c qemu: deprecate QEMU_CAPS_WAKEUP
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:18 +02:00
Ján Tomko
47b12ecfdf qemu: deprecate QEMU_CAPS_DRIVE_IOTUNE
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:06 +02:00
Ján Tomko
b6389394e0 qemu: deprecate QEMU_CAPS_FSDEV_WRITEOUT
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 12:57:14 +02:00
Ján Tomko
08ad06ca68 qemu: deprecate QEMU_CAPS_DRIVE_COPY_ON_READ
Implied by QEMU >= 1.2.0.

Also delete the now redundant disk-drive-copy-on-read test.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 12:56:49 +02:00
Ján Tomko
dd924fb05c qemu: deprecate QEMU_CAPS_FSDEV_READONLY
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 12:33:00 +02:00
Jiri Denemark
0272a3ffae qemuxml2xmltest: Add status XML tests for migration params
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
82a2123699 qemu: Store API flags for async jobs in status XML
This will help us decide what to do when libvirtd is restarted while an
async job is running.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
f3a89d7c01 qemumigparamstest: Add test data for TLS parameters
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
b60a1185ce qemumigparamstest: Add basic test data
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
40b186de27 tests: Add tests for QEMU migration parameters
This is an enhanced replacement for the original test from
qemumonitorjsontest which was dropped earlier in this series. More data
files with some real data will be added in the following patches.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
0cd77cd18b qemu: Move qemuMonitorMigrationCaps enum
Since the monitor code no longer needs to see this enum, we move it
to the place where migration parameters are defined and drop the
"monitor" reference from the name.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00