Commit Graph

94 Commits

Author SHA1 Message Date
Andrea Bolognani
6a077cf2b3 tests/domaincaps: Use testQemuCapsIterate()
Now that the only data we need for fully testing a QEMU binary is
the (version, arch) combo, we can stop providing that information
ourselves and instead rely on testQemuCapsIterate() automatically
picking up new input files as they are added to the repository,
the same way the qemucapabilities and qemucaps2xml tests already
behave.

Unsurprisingly, this change results in a bunch of extra output
files being created, significantly expanding our test coverage.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:29 +02:00
Andrea Bolognani
79a14412b2 tests/domaincaps: Make test matrix programmatic
For each QEMU version there are usually several different,
architecture-dependedn scenarios that we're interested in testing;
however, since the test matrix has to be explicitly created by
calling DO_TEST_QEMU() multiple times with different arguments, we
end up with spotty coverage.

Fix this by implementing the arch-specific rules in code, which
result in the full coverage for a (version, arch) combo being
automatically achieved with a single call to DO_TEST_QEMU().

Unsurprisingly, this change results in a bunch of extra output
files being created.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:26 +02:00
Andrea Bolognani
5457af097d tests/domaincaps: Don't require redundant information
The full name of the test case, as well as the name of the QEMU
binary and corresponding capabilities file, can all be derived
from other information passed to the test, so there's no point in
asking the user to provide them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:24 +02:00
Andrea Bolognani
12e42f1b2b tests/domaincaps: Move most of DO_TEST_QEMU() into a function
Macros become less and less appealing the more work you perform
inside them: DO_TEST_QEMU() has arguably already crossed that
threshold, and we're going to add even more code later on.

While factoring the code out of the macro, convert it to use the
GLib string manipulation functions and take advantage of autofree.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:22 +02:00
Andrea Bolognani
63d5a597ea tests/domaincaps: Don't mess with test name
Requiring the user to provide the final string themselves will
make subsequent changes easier to implement.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:20 +02:00
Andrea Bolognani
fa20e7b1bc tests: Rename domaincapsschemadata/ -> domaincapsdata/
The usual convention is to use ${foo}test.c for the test program
itself and either ${foo}data/ or ${foo}outdata/, depending on
whether it contains both input and output files or only the latter,
for the corresponding data directory.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:16 +02:00
Ján Tomko
29b1e859e3 tests: use g_strdup instead of VIR_STRDUP
Replace all occurrences of
  if (VIR_STRDUP(a, b) < 0)
     /* effectively dead code */
with:
  a = g_strdup(b);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-21 12:51:59 +02:00
Ján Tomko
7b48bb8ca0 Use g_strdup to fill in default values
Replace:
  if (!s && VIR_STRDUP(s, str) < 0)
    goto;
with:
  if (!s)
    s = g_strdup(str);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-21 12:51:55 +02:00
Ján Tomko
426f396198 use G_GNUC_NULL_TERMINATED instead of ATTRIBUTE_SENTINEL
Prefer G_GNUC_NULL_TERMINATED which was introduced in GLib 2.8.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-15 11:25:22 +02:00
Andrea Bolognani
4d95f557d6 tests: Add capabilities for QEMU 4.2.0 on aarch64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-11 09:37:33 +02:00
Andrea Bolognani
c5330fcefa tests: Add capabilities for QEMU 4.2.0 on ppc64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-11 09:37:25 +02:00
Peter Krempa
19898df4a9 tests: add qemu capabilities data for qemu 4.2
Add capabilities test data for upcoming qemu 4.2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-27 07:20:14 +02:00
Roman Bolshakov
fde361083d tests: Add lib- prefix to all mocks
In preparation libtool "-module" flag removal, add lib prefix to all
mock shared objects.

While at it, introduce VIR_TEST_MOCK macros that makes path out of mock
name to be used with VIR_TEST_PRELOAD or VIR_TEST_MAIN_PRELOAD.  That,
hopefully, improves readability, reduces line length and allows to
tailor VIR_TEST_MOCK for specific platform if it has shared library
suffix different from ".so".

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
2019-08-23 11:26:26 +01:00
Michal Privoznik
05004165e4 tests: Remove 'kvm' PCI backend from domaincapstest
The KVM assignment was removed in qemu driver in previous commit.
Remove it from domaincapstest too which is hard coding it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-08-23 10:48:34 +02:00
Michal Privoznik
80b58a7c1a qemu: Drop KVM assignment
KVM style of PCI devices assignment was dropped in kernel in
favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since
vfio is around for quite some time now and is far superior
discourage people in using KVM style.

Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns
out qemu-3.0.0 doesn't support vfio-pci device for RISC-V.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-08-23 10:48:27 +02:00
Jiri Denemark
9ceee2f4bb tests: Add domain capabilities case for QEMU 4.1.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-20 00:22:38 +02:00
Boris Fiuczynski
6b4aea5e4d tests: domaincaps: Add QEMU 4.0.0 for s390x
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2019-05-06 14:49:26 +02:00
Andrea Bolognani
c64152b67c tests: Use TEST_QEMU_CAPS_PATH wherever possible
After the recent changes, there are only a few places left
where we use the explicit path instead of taking advantage of
the publicly available define; let's get rid of those too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-17 08:30:59 +02:00
Andrea Bolognani
947ea8665e tests: Fix MinGW build for domaincapstest
Commit 5b9819eedc started using the virFileWrapper APIs in
the test program, and correctly called them only in the section
of code guarded by WITH_QEMU; however, a single call to the
virFileWrapperClearPrefixes() function ended up in the
hypervisor-agnostic section, causing a build failure on MinGW.

Move the call to the QEMU-only section; while at it, also drop
the virFileWrapperRemovePrefix() calls, which are entirely
redundant since we'd drop all prefixes immediately afterwards
anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-10 16:08:13 +02:00
Michal Privoznik
5b9819eedc domain capabilities: Expose firmware auto selection feature
If a management application wants to use firmware auto selection
feature it can't currently know if the libvirtd it's talking to
support is or not. Moreover, it doesn't know which values that
are accepted for the @firmware attribute of <os/> when parsing
will allow successful start of the domain later, i.e. if the mgmt
application wants to use 'bios' whether there exists a FW
descriptor in the system that describes bios.

This commit then adds 'firmware' enum to <os/> element in
<domainCapabilities/> XML like this:

  <enum name='firmware'>
    <value>bios</value>
    <value>efi</value>
  </enum>

We can see both 'bios' and 'efi' listed which means that there
are descriptors for both found in the system (matched with the
machine type and architecture reported in the domain capabilities
earlier and not shown here).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2019-04-10 13:58:51 +02:00
Jiri Denemark
cf4e33651c domaincapstest: Test QEMU 3.1.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-08 15:28:08 +02:00
Cole Robinson
7cd63604cf tests: domaincapstest: Fix build on mingw
fillStringValues is only used if WITH_QEMU || WITH_BHYVE

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-03-18 12:40:03 -04:00
Cole Robinson
ad12932481 tests: domcaps: Remove 'full' test
The 'full' test verifies the output of a virDomainCapsPtr built
by hand. It has the following problems:

The domcaps test suite nowadays has 3 hypervisor driver implementations
which should give us plenty of opportunity to get full domcaps coverage.
I don't think this test has much value. And it has the following issues:

- Requires manual intervention to test new domcaps XML, which is easy
  to miss, for example gic bits aren't covered there.
- The SET_ALL_BITS trick it uses to fill in enums will output
  values that are never reported by any driver implementation
  (strings like 'default')

Let's remove it

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-03-18 10:51:02 -04:00
Cole Robinson
0b89ef5596 tests: domcaps: Remove unused typedef
Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-03-18 10:51:02 -04:00
Cole Robinson
5c11e46065 tests: domcaps: Add a default 'empty' test
The 'empty' demonstrates XML generated when only bare minimum caps
data has been filled in. This will demonstrate changes that alter
the default XML output.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-03-18 10:51:02 -04: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
Cole Robinson
b79885b7f7 tests: domcaps: Remove dependency on libxl PVUSB support
Mock out libxlCapsHasPVUSB to always return true, so test results
aren't dependent on host libxl version

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-02-11 17:40:44 -05:00
Michal Privoznik
29682196d8 Drop UML driver
The driver is unmaintained, untested and severely broken for
quite some time now. Since nobody even reported any issue with it
let us drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-12-17 17:52:46 +01:00
Daniel P. Berrangé
600462834f Remove all Author(s): lines from source file headers
In many files there are header comments that contain an Author:
statement, supposedly reflecting who originally wrote the code.
In a large collaborative project like libvirt, any non-trivial
file will have been modified by a large number of different
contributors. IOW, the Author: comments are quickly out of date,
omitting people who have made significant contribitions.

In some places Author: lines have been added despite the person
merely being responsible for creating the file by moving existing
code out of another file. IOW, the Author: lines give an incorrect
record of authorship.

With this all in mind, the comments are useless as a means to identify
who to talk to about code in a particular file. Contributors will always
be better off using 'git log' and 'git blame' if they need to  find the
author of a particular bit of code.

This commit thus deletes all Author: comments from the source and adds
a rule to prevent them reappearing.

The Copyright headers are similarly misleading and inaccurate, however,
we cannot delete these as they have legal meaning, despite being largely
inaccurate. In addition only the copyright holder is permitted to change
their respective copyright statement.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-12-13 16:08:38 +00:00
Boris Fiuczynski
efc29ab2e5 tests: domaincaps: Add QEMU 3.0 for s390x
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2018-09-20 16:24:58 -04:00
Erik Skultety
5165ff0971 src: More cleanup of some system headers already contained in internal.h
All of the ones being removed are pulled in by internal.h. The only
exception is sanlock which expects the application to include <stdint.h>
before sanlock's headers, because sanlock prototypes use fixed width
int, but they don't include stdint.h themselves, so we have to leave
that one in place.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-20 10:16:39 +02:00
Daniel P. Berrangé
81950efa0b qemu: rename method for getting preferred machine type
The virQEMUCapsGetDefaultMachine() method doesn't get QEMU's default
machine any more, instead it gets the historical default that libvirt
prefers for each arch. Rename it, so that the old name can be used for
getting QEMU's default.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-08-28 11:49:01 +01:00
Andrea Bolognani
7dd5b0c54b tests: qemucapabilities: Drop mostly duplicated data
When GIC support was introduced (QEMU 2.6 timeframe) we needed
to make sure both GICv2 hardware and GICv3 hardware were handled
correctly, and that was achieved by having separate capabilities
data for each.

Now that we have capabilities data for several QEMU versions we
can stop storing data for GICv2 and GICv3 hardware separately,
and instead have GICv2 data for QEMU <= 2.10 and GICv3 data for
QEMU >= 2.12, without losing any coverage.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-03-23 20:27:52 +01:00
Andrea Bolognani
9be6210f9e tests: domaincaps: Add QEMU 2.12
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-03-23 20:27:51 +01:00
Andrea Bolognani
edf2239bb5 tests: domaincaps: Order by architecture
Test cases in qemucapabilitiestest are ordered by architecture
first, then by QEMU version. Use the same order here.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-03-23 20:27:51 +01:00
Michal Privoznik
fb8c0ea892 fillQemuCaps: Don't leak machine string
==25251== 5 bytes in 1 blocks are definitely lost in loss record 7 of 81
==25251==    at 0x4C2BEDF: malloc (vg_replace_malloc.c:299)
==25251==    by 0x967E379: strdup (in /lib64/libc-2.25.so)
==25251==    by 0x5366F9F: virStrdup (virstring.c:941)
==25251==    by 0x538BF1D: virDomainCapsNew (domain_capabilities.c:121)
==25251==    by 0x10EACE: test_virDomainCapsFormat (domaincapstest.c:295)
==25251==    by 0x10FBD2: virTestRun (testutils.c:180)
==25251==    by 0x10F192: mymain (domaincapstest.c:457)
==25251==    by 0x111C7F: virTestMain (testutils.c:1119)
==25251==    by 0x10FA3C: main (domaincapstest.c:528)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-12-12 16:41:25 +01:00
Andrea Bolognani
61ea70341a tests: Rename ppc64le caps to ppc64
The architecture itself is called ppc64, and it can run both in big
endian and little endian mode - the latter is known as ppc64le.

From the (virtual) hardware point of view, ppc64 is a more accurate
name so it should be used here.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-08 10:47:38 +01:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Jiri Denemark
0861080f0e conf: Add usability blockers to virDomainCapsCPUModel
When a hypervisor marks a CPU model as unusable on the current host, it
may also give us a list of features which prevent the model from being
usable. Storing this list in virDomainCapsCPUModel will help the CPU
driver with creating a host-model CPU configuration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-10-16 09:21:51 +02:00
Pavel Hrdina
13554a9e7f tests: rewrite host CPU mocking
Move all the host CPU data into a separate file and rewrite qemucpumock
to not use passed @caps.  This is preparation for following patch which
will replace virCaps argument with virArch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2017-07-26 15:35:02 +02:00
dann frazier
123880d333 qemu: Add AAVMF32 to the list of known UEFIs
Add a path for UEFI VMs for AArch32 VMs, based on the path Debian is using.
libvirt is the de facto canonical location for defining where distros
should place these firmware images, so let's define this path here to try
and minimize distro fragmentation.
2017-07-21 14:36:54 -04:00
Pavel Hrdina
fa60251b01 tests: domaincapstest: add test for Q35 machine type
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-04-18 13:27:11 +02:00
Pavel Hrdina
9005a64b5c tests: fix some resource leaks
Found by running valgrind for these tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-04-11 13:23:01 +02:00
Andrea Bolognani
4ceac4bf29 tests: Rename VIRT_TEST_* macros to VIR_TEST_*
We use the "vir" prefix pretty consistently in our
APIs, both external and internal, which made these
macros stood out.
2017-04-04 17:30:03 +02:00
Roman Bogorodskiy
74cfb5bb85 domaincapstest: add bhyve caps test
* Extract filling bhyve capabilities from virBhyveDomainCapsBuild()
   into a new function virBhyveDomainCapsFill() to make testing
   easier by not having to mock firmware directory listing and
   hypervisor capabilities probing
 * Also, just presence of the firmware files is not sufficient
   to enable os.loader.supported, hypervisor should support UEFI
   boot too
 * Add tests to domaincapstest for the main caps possible flows:
    - when UEFI bootrom is supported
    - when video (fbus) is supported
    - neither of above is supported
2017-03-26 18:44:46 +04:00
Jiri Denemark
cab2c1af96 tests: Switch to sparse initialization of virCPUDef
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-17 11:50:47 +01:00
Jiri Denemark
e958fb5b15 qemu: Report better host-model CPUs in domain caps
One of the main reasons for introducing host-model CPU definition in a
domain capabilities XML was the inability to express disabled features
in a host capabilities XML. That is, when a host CPU is, e.g., Haswell
without x2apic support, host capabilities XML will have to report it as
Westmere + a bunch of additional features., but we really want to use
Haswell - x2apic when creating a host-model CPU.

Unfortunately, I somehow forgot to do the last step and the code would
just copy the CPU definition found in the host capabilities XML. This
changed recently for new QEMU versions which allow us to query host CPU,
but any slightly older QEMU will not benefit from any change I did. This
patch makes sure the right CPU model is filled in the domain
capabilities even with old QEMU.

The issue was reported in
https://bugzilla.redhat.com/show_bug.cgi?id=1426456

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 23:49:57 +01:00
Jiri Denemark
0bde051f3d domaincapstest: Add test data for QEMU 2.9.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-03 19:57:56 +01:00
Collin L. Walling
9486dbb339 tests: domain capabilities: qemu 2.7 and 2.8 on s390x
Tests domain capabilities on s390x using the Qemu 2.8 capabilities data.

Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
2017-01-06 12:24:57 +01:00