Commit Graph

5040 Commits

Author SHA1 Message Date
Michal Privoznik
ff86e79faf tests: Call virFileWrapperClearPrefixes() for tests using virFileWrapper
This is mostly to avoid a memleak that is not a true memleak
anyway - prefixes will be freed by kernel upon test exit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-03-13 14:16:46 +01:00
Michal Privoznik
6e31c4b27e virFileWrapper: Use VIR_AUTOFREE()
This enables us to simplify the code a bit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-03-13 14:16:27 +01:00
Michal Privoznik
288e0ab106 tests: Turn virFileWrapperAddPrefix to void
In theory, it's nice to have virFileWrapperAddPrefix() return a
value that indicates if the function succeeded or not. But in
practice, nobody checks for that and in fact blindly believes
that the function succeeded. Therefore, make the function return
nothing and just abort() if it would fail.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-03-13 14:15:35 +01:00
Andrea Bolognani
60943f0eec tests: Use testQemuCapsIterate()
With only a couple minor tweaks, we can make the existing
doCapsTest() functions with testQemuCapsIterate() and finally
remove the need to manually adjust the test programs every time
a new input file is introduced; moreover, this means that the
two lists can't possibly get out of sync anymore.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:12 +01:00
Andrea Bolognani
30439c1b81 tests: Introduce testQemuCapsIterate()
This function iterates over a directory containing
capabilities-related data, extract some useful bits of
information from the file name, and calls a user-provided
callback.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:10 +01:00
Andrea Bolognani
6000bd1342 tests: Add testutilsqemu dependency for qemucaps2xmltest
We're not using any of the functionality offered by the
module at the moment, but we will in just a second.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:07 +01:00
Andrea Bolognani
ad340f225a tests: Move code from DO_TEST() to doCapsTest()
This removes the awkard escaping and will allow us to perform
some more refactoring later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:06 +01:00
Andrea Bolognani
5a8ceba2f3 tests: Use virAsprintf() to build titles
We're using static string concatenation at the moment, but
that will no longer be a possibility in a bit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:04 +01:00
Andrea Bolognani
0c744afe1a tests: Move data directories into testQemuData
This removes a little duplication right away, and will allow
us to avoid introducing more later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:03 +01:00
Andrea Bolognani
c125a6ef2a tests: Move ret into testQemuData
This is not particularly useful right now, but will allow us
to refactor some functionality later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:01 +01:00
Andrea Bolognani
31044d6ff2 tests: Introduce testQemuDataInit() and testQemuDataReset()
These functions don't do anything too interesting right now,
but will be extended later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:06:56 +01:00
Michal Privoznik
68ade25372 qemu: Enable firmware autoselection
https://bugzilla.redhat.com/show_bug.cgi?id=1564270

Now that everything is prepared for qemu driver we can enable
parser feature to allow users define such domains.

At the same time, introduce bunch of tests to test the feature.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-03-12 16:09:55 +01:00
Michal Privoznik
31eb3093c0 qemufirmwaretest: Test qemuFirmwareFetchConfigs()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-03-12 15:29:44 +01:00
Michal Privoznik
04406d87d2 test: Introduce qemufirmwaretest
Test firmware description parsing so far.

The test files come from three locations:
1) ovmf-sb-keys.json and ovmf-sb.json come from OVMF
package from RHEL-7 (with slight name change to reflect their
features in filename too),

2) bios.json and aavmf.json come from example JSON documents from
firmware.json from qemu's git (3a0adfc9bf),

3) ovmf.json is then copied from ovmf-sb.json and stripped
of SECURE_BOOT and REQUIRES_SMM flags, OVMF path change,
description update and machine type expanded for both pc and q35
machine types.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2019-03-12 15:29:44 +01:00
Michal Privoznik
d21f89cc1a conf: Introduce VIR_DOMAIN_LOADER_TYPE_NONE
This is going to extend virDomainLoader enum. The reason is that
once loader path is NULL its type makes no sense. However, since
value of zero corresponds to VIR_DOMAIN_LOADER_TYPE_ROM the
following XML would be produced:

  <os>
    <loader type='rom'/>
    ...
  </os>

To solve this, introduce VIR_DOMAIN_LOADER_TYPE_NONE which would
correspond to value of zero and then use post parse callback to
set the default loader type to 'rom' if needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-03-12 15:29:44 +01:00
Andrea Bolognani
2c0b8d6a08 tests: Drop unnecessary variables
In qemuxml2xmltest, both activeVcpus and blockjobs members
of the testInfo struct have been entirely unused ever since
commit d1a7fc8bb3.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-03-12 14:09:49 +01:00
Shotaro Gotanda
60a0d32e64 tests: Run valgrind with absolute path to suppressions file
So far we are providing the suppressions file with a relative
path to valgrind. This apparently doesn't work on some distros
like Ubuntu and its derivates. Providing the absolute path fixes
the problem.

Signed-off-by: Shotaro Gotanda <g.sho1500@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-03-11 14:59:08 +01:00
Martin Kletzander
bc2502f0fc virfilewrapper: Fix indentation
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2019-03-11 10:11:43 +01:00
Andrea Bolognani
186bb479d0 qemu: Allow creating ppc64 guests with graphics and no USB mouse
The existing behavior for ppc64 guests is to always add a USB
keyboard and mouse combo if graphics are present; unfortunately,
this means any attempt to use a USB tablet will cause both pointing
devices to show up in the guest, which in turn will result in poor
user experience.

We can't just stop adding the USB mouse or start adding a USB tablet
instead, because existing applications and users might rely on the
current behavior; however, we can avoid adding the USB mouse if a USB
tablet is already present, thus allowing users and applications to
create guests that contain a single pointing device.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-03-11 09:59:34 +01:00
Andrea Bolognani
4d7ea75e1e tests: Add simple guests with graphics to qemuxml2argv
These are similar to the existing simple headless guests, but
also include a graphical output and some input devices.

Input files were generated by running

  $ virt-install \
    --name guest --os-variant fedora29 \
    --vcpus 4 --memory 4096 --disk size=5 \
    --graphics vnc \
    --print-xml

followed by minor tweaks.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-03-11 09:59:11 +01:00
Andrea Bolognani
ff3f22e0ec qemu: Improve validation for virtio input devices
While the parser and schema have to accept all possible models,
virtio-(non-)transitional models are only applicable to
type=passthrough and should be otherwise rejected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-03-11 09:53:40 +01:00
Pavel Hrdina
e387afeb9a conf: fix title and description for virDomainSetMetadata API
If we pass XML to virDomainDefineXML API with these two elements:

    ...
    <title></title>
    <description></description>
    ...

libvirt correctly ignores these two elements and they will not appear
in the parsed XML.

However, if we use virDomainSetMetadata API and with "" as value for
title or description we will end up with the parsed XML that contains
these empty elements.

Let's fix the behavior of this API to behave the same as
virDomainDefineXML.

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

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-03-08 14:59:20 +01:00
Eric Blake
c502955909 snapshot: Give virDomainSnapshotDefFormat its own flags
virDomainSnapshotDefFormat currently takes two sets of knobs:
an 'unsigned int flags' argument that can currently just be
VIR_DOMAIN_DEF_FORMAT_SECURE, and an 'int internal' argument used as
a bool to determine whether to output an additional element.  It
then reuses the 'flags' knob to call into virDomainDefFormatInternal(),
which takes a different set of flags. In fact, prior to commit 0ecd6851
(1.2.12), the 'flags' argument actually took the public
VIR_DOMAIN_XML_SECURE, which was even more confusing.  Let's borrow
from the style of that earlier commit, by introducing a function
for translating from the public flags (VIR_DOMAIN_SNAPSHOT_XML_SECURE
was just recently introduced) into a new enum specific to snapshot
formatting, and adjust all callers to use snapshot-specific enum
values when formatting, and where the formatter now uses a new
variable 'domainflags' to make it obvious when we are translating
from snapshot flags back to domain flags.  We don't even have to
use the conversion function for drivers that don't accept the
public VIR_DOMAIN_SNAPSHOT_XML_SECURE flag.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-03-07 17:31:40 -06:00
Andrea Bolognani
956817ef49 util: Make virStringStripSuffix() return bool
While this function is not, strictly speaking, a predicate,
it still mostly behaves like one as evidenced by the vast
majority of its callers, so using bool rather than int as
the return type makes sense.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
2019-03-07 17:55:29 +01:00
Michal Privoznik
d7e5baa5a1 virmock: Initialize both symbols in VIR_MOCK_REAL_INIT_ALT
It may happen that both symbols are present. Especially when
chaining mocks. For instance if a test is using virpcimock and
then both stat and __xstat would be present in the address space
as virpcimock implements both. Then, if the test would try to use
say virfilewrapper (which again uses VIR_MOCK_REAL_INIT_ALT() to
init real_stat and real___xstat) it would find stat() from
virpcimock and stop there. The virfilewrapper.c:real___xstat
wouldn't be initialized and thus it may result in a segfault.

The reason for segfault is that sys/stat.h may redefine stat() to
call __xstat().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-03-07 13:40:17 +01:00
Pavel Hrdina
8c0fe9c649 tests: use VIR_AUTOUNREF in storagepoolcapstest
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-03-07 12:12:11 +01:00
Pavel Hrdina
9dadc73029 caps: drop requiredSourceElements from storage pool capabilities
Capabilities should not duplicate data that are obvious from our
documentation and will not change with different QEMU binaries
or the way how we compile libvirt.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-03-07 12:01:09 +01:00
Pavel Hrdina
0b5b221300 tests: invert the return logic in storagepoolcapstest
This way if the first test "full" fails we will run the second test as
well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-03-07 12:01:09 +01:00
Pavel Hrdina
a59590c7eb tests: use virTestCompareToFile in storagepoolcapstest
This will allow to use VIR_TEST_REGENERATE_OUTPUT.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-03-07 12:01:09 +01:00
Andrea Bolognani
094f29df07 Use virStringHasSuffix() where possible
When dealing with internal paths we don't need to worry about
whether or not suffixes are lowercase since we have full control
over them, which means we can avoid performing case-insensitive
string comparisons.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
2019-03-07 10:10:49 +01:00
Andrea Bolognani
9c5fa79fd7 util: Rename virFileStripSuffix() to virStringStripSuffix()
Despite its name, this is really just a general-purpose string
manipulation function, so it should be moved to the virstring
module and renamed accordingly.

A few trivial whitespace changes are squashed in.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
2019-03-07 10:10:43 +01:00
Andrea Bolognani
2de7dcba7e util: Rename virFileHasSuffix() to virStringHasCaseSuffix()
Despite its name, this is really just a general-purpose string
manipulation function, so it should be moved to the virstring
module and renamed accordingly.

In addition to the obvious s/File/String/, also tweak the name
to make it clear that the presence of the suffix is verified
using case-insensitive comparison.

A few trivial whitespace changes are squashed in.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
2019-03-07 10:08:47 +01:00
John Ferlan
73426c55b7 tests: Introduce storage pool capabilites test
Add a new test for the storage pool capabilities. There will be
one test mocked with every backend available (full) and one where
only the file system pool is available.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2019-03-06 11:12:48 -05:00
John Ferlan
5dded8c806 docs: Add schema for storage pool capabilities
Define a schema for the storage pool capabilities along with
a test to show the general format.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2019-03-06 11:12:48 -05:00
John Ferlan
4ad00278f6 conf: Remove volOptions for VIR_STORAGE_POOL_SHEEPDOG
The sheepdog pool is documented as not using the volume type,
so let's just remove it.  Besides it would have produced bad
results since the defaultType is FILE but the formatting used
the Disk types.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2019-03-06 11:12:48 -05:00
Peter Krempa
89dda12b8d conf: Avoid formatting empty <capabilities> element
If none of the 'capabilities' features are enabled we'd still format the
opening and closing tag for the <capabilities element.

The implementation is suboptimal but will be refactored for a better
approach. This is done prior to the refactor to show that tests are not
impacted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-06 15:53:53 +01:00
Jiri Denemark
4ff74a806a cpu_map: Add more signatures for Broadwell CPU models
This fixes several CPUs which were incorrectly detected as
Skylake-Client.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:47:49 +01:00
Jiri Denemark
e89f877214 cpu_map: Add more signatures for Westmere CPU model
This fixes several CPUs which were incorrectly detected as a different
CPU model.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:47:49 +01:00
Jiri Denemark
dd08d27fc2 cputest: Test CPU signatures
The signature computation code is not too complicated and it will likely
never change so testing it is not very important. We do it mostly for a
nice side effect of easily accessible signature numbers for all CPU
data files.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:47:49 +01:00
Jiri Denemark
87a46f5d8f cputest: Add data for Intel(R) Core(TM) i7-8700
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:38:35 +01:00
Jiri Denemark
483679d48f cputest: Add data for Intel(R) Xeon(R) CPU E5-2650
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:38:03 +01:00
Jiri Denemark
60046a2365 cputest: Add data for Intel(R) Xeon(R) CPU E7540
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:38:03 +01:00
Jiri Denemark
cd11ea73d0 cputest: Add data for Intel(R) Core(TM) i7-7600U
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:38:03 +01:00
Jiri Denemark
8d068f3601 cputest: Add data for Intel(R) Xeon(R) CPU E5-2630 v4
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:38:03 +01:00
Jiri Denemark
dd7682dd12 cputest: Make sure generated files pass syntax-check
The tests/cputestdata/cpu-parse.sh would produce JSON files with QEMU
replies which wouldn't pass syntax-check. Let's fix this by not emitting
an extra new line after reformatting the JSON file.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 14:38:03 +01:00
Andrea Bolognani
09a95068fb tests: Add -inactive suffix when appropriate for qemuxml2xml
Some test cases are only executed using WHEN_INACTIVE, and the
output file name should reflect this for clarity.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 10:41:10 +01:00
Andrea Bolognani
bb5c6e7a96 tests: Use WHEN_BOTH in qemuxml2xml whenever possible
There are a few cases where we are using either WHEN_ACTIVE
or WHEN_INACTIVE even though WHEN_BOTH would work perfectly
fine: for those, start using the simpler DO_TEST() macro.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 10:41:08 +01:00
Andrea Bolognani
c5bc4437ee tests: Rename some qemuxml2xml output files for clarity
disk-mirror-old has different output file for the active and
inactive parts, which should be named accordingly; on the other
hand, both output files for disk-backing-chains-noindex are
identical, so it makes sense to only keep around one and remove
the (in-)active suffix.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-03-05 10:40:50 +01:00
Cole Robinson
aa42d364a5 qemu: domcaps: Report disk <enum name="model">
This generates new XML like:

    <disk>
      <enum name='model'>
        <value>virtio</value>
        <value>virtio-transitional</value>
        <value>virtio-non-transitional</value>
      </enum>
    </disk>

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-03-04 11:08:41 -05:00
Cole Robinson
8270b3d0cd tests: domcaps: Add qemu 4.0.0 test case
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-03-04 11:08:41 -05:00