Commit Graph

870 Commits

Author SHA1 Message Date
Boris Fiuczynski
3bf02acdc5 qemu: allow use of async teardown in domain
Asynchronous teardown can be specified if the QEMU binary supports it by
adding in the domain XML

  <features>
    ...
    <async-teardown enabled='yes|no'/>
    ...
  </features>

By default this new feature is disabled.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-10 13:28:17 +02:00
Jean-Louis Dupond
b855f8ea1e Add discard_no_unref option for qcow2 images
Qemu 8.1.0 will add discard_no_unref option for qcow2 images.
When this option is enabled (default=false), then it will no longer
unreference clusters when guest does a discard, but it will just free
the blocks (useful for incremental backups for example) and pass the
discard to the lower layer.

This was implemented to avoid fragmentation within the qcow2 image.

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-06-26 13:06:00 +02:00
Peter Krempa
91856be29b qemuxml2(argv|xml)test: Add case for validating proper DIMM slot validation
Add a config where both DIMM and non-DIMM <memory> devices are used so
that it validates that only DIMMs require memory slots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-06-26 12:58:24 +02:00
Peter Krempa
af621caa6b conf: numa: Allow formatting 'none' values for 'associativity' and 'policy' of cache
The parser makes the values mandatory and also the qemu code implements
actions for those values. The formatter skips them though. Since
format+parse is used to copy the XML at startup a definition with those
values can't be started.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2203709
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-05-17 10:07:18 +02:00
Peter Krempa
a8a63587ff qemuxml2xmltest: Modernize all 'audio-' cases
Use DO_TEST_CAPS_LATEST to run with the latest capapbilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-17 10:02:19 +02:00
Peter Krempa
d6d4cfa5fc qemuxml2(argv|xml)test: Modernize 'sound-device' case
Drop the unnecessary disk definition and use x86_64 emulator.

For 'qemuxml2argvtest' replace the fake-caps invocation by a 4.2.0
version-locked invocation and  add a '_CAPS_LATEST' invocation.

For 'qemuxml2xmltest' convert to use '_CAPS_LATEST' only.

There are no sound-device relevant changes in the output files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-09 15:12:03 +02:00
Peter Krempa
351504744e qemuxml2(argv|xml)test: Remove 'sound' case
The test case is a subset of what the 'sound-device' case tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-09 15:12:03 +02:00
Ján Tomko
03ca889b15 qemu: allow forcing emulated maxphysaddr
Treat:
  <maxphysaddr mode="emulate"/>
as a request not to take the maximum address size from the host.
This is useful if QEMU changes the default.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 11:19:37 +02:00
Ján Tomko
d6fbb21210 conf: cpu: add limit for maxphysaddr
Add a limit attribute to restrict the maximum physical address bits
that would be used for the guest CPU:

   <cpu mode='host-passthrough'>
     <maxphysaddr mode='passthrough' limit='39'/>
   </cpu>

https://gitlab.com/libvirt/libvirt/-/issues/450
https://bugzilla.redhat.com/show_bug.cgi?id=2171860

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 11:19:37 +02:00
Andrea Bolognani
f9ad302335 conf: Fix migration in some firmware autoselection scenarios
Introduce a small kludge in the parser to avoid unnecessarily
blocking incoming migration from a range of recent libvirt
releases.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-12 18:03:21 +02:00
Peter Krempa
962bf7c9a5 qemuxml2xmltest: Convert rest of 'aarch64' cases to real capabilities
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
bd4da926b1 qemuxml2xmltest: Modernize 'mach-virt*' cases
Use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
74d4876d20 qemuxml2xmltest: Modernize 'aarch64-gic*' test cases
Use real capabilities for them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
2449907112 qemuxml2(argv|xml)test: Modernize testing of USB controllers on aarch64
All supported qemu versions at this point support both 'qemu-xhci' and
'nec-xhci' controllers. To allow using real capabilities restructure the
tests so that we test both controllers explicitly as well as the
selection of the default model.

Also add a xml2xml test invocation of the unified test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
c42753524e qemuxml2*test: Drop fake-caps invocation of 'aarch64-virtio-pci-manual-addresses'
The fake-caps version was kept as an example that the code behaves the
same with real capabilities. Now it's not needed any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
f217410a47 qemuxml2argvtest: Update 'aarch64-virtio-pci-manual-addresses' case
With all supported qemu versions we'll pick PCIe to use for the implicit
address busses (those lacking an explicit controller) and thus the
addresses must reflect that.

Update the test to add the new flags, and fix the addresses.
Additionally add a real-caps version of the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
a5bd444cb2 qemuxml2xmltest: Convert all s390 test cases to real capabilities
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:08 +02:00
Peter Krempa
a2c4503021 qemuxml2xmltest: Modernize all remaining 'ppc64' test cases
Switch them to use latest caps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
bfc5955406 qemuxml2xmltest: Remove infrastructure for fake-caps testing on OSX
The last tests using it were refactored to use real capabilities and no
new tests should ever use it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
131493cf68 qemuxml2(argv|xml): Convert "hvf-aarch64-virt-headless" test case to real capabilities
Rather than using fake data and faking the host use the newly introduced
support for test variants to test the OSX HVF qemu version with real
data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
1d1f22f478 qemuxml2(argv|xml): Convert "hvf-x86_64-q35-headless" test case to real capabilities
Rather than using fake data and faking the host use the newly introduced
support for test variants to test the OSX HVF qemu version with real
data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Andrea Bolognani
6bafa74d62 tests: Add firmware-auto-efi-abi-update-aarch64 test case
The input is identical to that of the existing
firmware-auto-efi-aarch64 test, but in this case we want to
cover the scenario in which that input is used to define a new
domain rather than loading the definition of an existing domain
from disk.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-28 12:41:32 +02:00
Andrea Bolognani
d7aaa715bd tests: Introduce DO_TEST_CAPS_ARCH_LATEST_ABI_UPDATE()
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-28 12:41:05 +02:00
Andrea Bolognani
ccf4aa37a0 conf: Remove some firmware validation checks
libvirt 8.6.0 introduced these checks and very clearly delineated
two possible firmware selection scenarios: manual firmware
selection, where the user is responsible for providing all
information, and firmware autoselection, where a list of desired
features is provided and everything else is handled by libvirt.

In the interest of maintaining the clear separation between these
two scenarios, setting most attributes when firmware autoselection
is active will result in the configuration being rejected.

This works fine, but is unnecessarily restrictive: in most cases,
the additional information that the user has provided matches
the information that libvirt would have discovered on its own by
looking at firmware descriptors, and asking the user to scrub it
from the XML only result in pointless friction.

Remove these checks entirely.

Unsurprisingly, this results in a few test cases that were
rejected until now to suddenly start working and producing
sensible results.

The firmware-auto-efi-loader-path-nonstandard test case is
notable: while we can now enable the xml2xml part of the test,
the xml2argv part is still failing, although in a slightly
different way. This is expected: since the firmware binary is a
non-standard one, libvirt is unable to figure out the missing
information from a firmware descriptor, and the configuration
is still ultimately an invalid one. However, if we were to find
such a configuration on disk at daemon startup, we would not
ignore it completely and instead would offer the user a chance
to fix it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
bf6a6f90a9 tests: Add more tests for manual Secure Boot configuration
These cover the same scenarios as the matching test cases for
autoselection.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Andrea Bolognani
bfb507853a tests: Rename a few firmware tests
This unifies the naming between the manual and automatic
selection cases, clarifies the contents of the tests and makes
room for more tests being added in the future.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-22 13:49:53 +01:00
Or Ozeri
5589a3e1f3 qemu: add luks-any encryption support for RBD images
The newly added luks-any rbd encryption format in qemu
allows for opening both LUKS and LUKS2 encryption formats.
This commit enables libvirt uses to use this wildcard format.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:36 +01:00
Or Ozeri
77c9663d72 qemu: add support for librbd layered encryption
This commit enables libvirt users to use layered encryption
of RBD images, using the librbd encryption engine.
This allows opening of an encrypted cloned image
whose parent is encrypted with a possibly different encryption key.
To open such images, multiple encryption secrets are expected
to be defined under the encryption XML tag.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:36 +01:00
Eric Farman
97dddef48c qemuAppendLoadparmMachineParm: add loadparm from hostdev
Commit 54fa1b44af ("conf: Add loadparm boot option for a boot device")
added the ability to specify a loadparm parameter on a <boot/> tag, while
commit 29ba41c2d4 ("qemu: Add loadparm to qemu command line string")
added that value to the QEMU "-machine" command line parameters.

Unfortunately, the latter commit only looked at disks and network
devices for boot information, even though anything with
VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT could potentially have this tag.
In practice, a <hostdev> tag pointing to a passthrough (SCSI or DASD)
disk device can be used in this way, which means the loadparm is
accepted, but not given to QEMU.

Correct this, and add some XML/argv tests.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-10 08:54:05 +01:00
Jonathon Jongsma
168b0ca3fc qemu: Implement 'blob' support for virtio gpu
This can improve performance for some guests since it reduces copying of
display data between host and guest. Requires udmabuf on the host.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-08 13:05:05 -06:00
Peter Krempa
c0e60063c9 qemu: capabilities: Remove unused virQEMUCapsInitQMPBasicArch
The function doesn't set any capability and we don't want to add
arch-dependent always-peresent capabilities in the future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-07 12:26:33 +01:00
Peter Krempa
fe9b95d97d qemuxml2(argv|xml)test: Convert last fake-caps riscv64 tests to real caps
Preserve testing of the MMIO use case in case when GPEX is complied out
of qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 20:55:50 +01:00
Peter Krempa
f0fec72e3f qemuTestCapsCacheInsert*: Drop the file cache rather than poisoning it
Make callers use virFileCacheClear to clear the cache before populating
it rather than trying to overwrite what's in it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 20:55:50 +01:00
Peter Krempa
3c02b1e810 tests: qemu: Move testing of default cache and disk source with space to 'sata-device'
Integrate the two special cases used for schema testing into the more
useful qemuxml2argvtest, whose input data is still tested against the
schema.

Add also a xml output variant.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 20:55:49 +01:00
Andrea Bolognani
0f49b6cc6b tests: Drop no longer necessary overrides
Creating a privileged config ensures these are already set
correctly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-06 14:35:35 +01:00
Andrea Bolognani
d3fe9cc0f0 tests: Set the QEMU driver as privileged in common code
Most test programs were already doing this, and moving it to
the common code ensures we see consistent behavior across all
QEMU tests.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-06 14:35:35 +01:00
Peter Krempa
8442645126 qemuxml2(argv|xmltest): Simplify testing of scheduler settings
Remove the cputune-iothreads, cputune-iothreadsched-zeropriority,
cputune-iothreadsched test files by moving the relevant elements into
the cputune case as we can setup scheduler settings for multiple objects
and thus test everything in one go.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 13:22:36 +01:00
Peter Krempa
d542d72f5c qemuxml2(argv|xml)test: Modernize 'cputune' test cases
Use DO_TEST_CAPS_LATEST for cputune-numatune, cputune-zero-shares,
cputune, and vcpu-placement-static cases. Do the necessary tweaks to
work with actual data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 13:22:36 +01:00
Peter Krempa
17bc74e02d qemuxml2xmltest: Modernize iothread CWW/SCSI test cases
The argv counterparts are already modernized.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 13:22:36 +01:00
Peter Krempa
dcab6ad185 qemuxml2argvtest: Modernize the rest of 'iohtreads-*'
Use DO_TEST_CAPS_LATEST for the basic tests. The emulator needed to be
tweaked to work with the real caps data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 13:22:36 +01:00
Peter Krempa
ebc3323248 qemuxml2(argv|xml)test: Remove 'iothreads' case
'iothreads-disk' covers everything that 'iothreads' did in addition to
actually using the iothread.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 13:22:36 +01:00
Andrea Bolognani
87b30e6965 tests: Move fakerootdir handling to common logic
Instead of having each test manually initialize and cleanup
its own fakerootdir, do that as part of the common test
initialization logic in virTestMain().

In most cases we can simply drop the relevant code from the
test program, but scsihosttest uses the value of fakerootdir
as a starting point to build another path, so we need to do
things slightly differently. In order to keep things working,
we retrieve the value from the LIBVIRT_FAKE_ROOT_DIR
environment variable, same as all the mock libraries are
already doing.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-03 13:52:37 +01:00
Andrea Bolognani
457a0183d6 tests: Adopt fakerootdir helpers
Most replacements are completely straightforward but
vircgrouptest requires slightly different handling because,
instead of initializing a single fakerootdir at the start of
the test program and cleaning it up at the end, it creates
multiple different ones one after the other.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-03 13:52:37 +01:00
Andrea Bolognani
44fb7659cc tests: Add more firmware tests
These cover various scenarios related to firmware formats,
specifically ensuring that all the ways in which the user can
ask for a non-default format to be used work correctly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-03 13:52:37 +01:00
Andrea Bolognani
6f1c6534a8 tests: Add more firmware tests
These cover scenarios such as using the new, more verbose
format of the <nvram> element to point to a local path, mixing
firmware autoselection with non-local NVRAM files, and
explicitly disabling SMM when using firmware autoselection.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-03 13:40:53 +01:00
Andrea Bolognani
54f90a825e tests: Enable qemuxml2xml for more firmware tests
Some of the test cases had only been added to the xml2argv
test program and not to the xml2xml one.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-03 13:40:48 +01:00
Andrea Bolognani
87ab00fdcb tests: Move firmware tests to CAPS_LATEST
This is already the case for the vast majority, but a few are
using explicit capabilities lists.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-03 13:40:38 +01:00
Andrea Bolognani
2adc24fc6a tests: Set nvramDir in qemuxml2xmltest
We already do this in qemuxml2argvtest.

Right now setting this doesn't change anything, but it will
become relevant later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-03 13:40:24 +01:00
Laine Stump
dffc40db69 qemu: add check for QEMU_CAPS_NETDEV_STREAM during validation
In commit 5af6134e I had added a new capability that is true if QEMU
allows "-netdev stream", but somehow neglected to actually check it in
commit a56f0168d when hooking up passt support to qemu. This isn't
catastrophic, since QEMU itself will still report an error, but that
error isn't as easy to understand as a libvirt-generated error.

Fixes: a56f0168d5
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-02-22 07:36:45 -05:00
Kristina Hanicova
78744415fe tests: add case for pvpanic-pci without address
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-02-21 17:51:28 +01:00