Commit Graph

8402 Commits

Author SHA1 Message Date
Peter Krempa
0da84671ef qemuxml2argvtest: Modernize the rest of 'aarch64' 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
c79f626f21 qemuxml2argvtest: Modernize all 'mach-virt-' aarch64 test 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
4753fdb6f0 qemuxml2argvtest: Don't symlink output files for 'mach-virt-' cases
Make the output changes of upcoming modernization more visible.

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
d66fb85fb5 qemuxml2argvtest: Modernize 'balloon-mmio-deflate'
Use real capabilities and mask-out support for PCIe.

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
b7f0487184 qemuxml2argv: Test default aarch64 cofig without PCIe support
Use real caps and clear out flags for PCIe so that we have a real-ish
example of an aarch64 machine using mmio.

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
8d94853040 qemuxml2argvtest: Drop "aarch64-virt-2.6-virtio-pci-default" case
The test data is effectively identical to the
'aarch64-virtio-pci-default' case.

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
9c26a25f88 qemuxml2argvtest: Add real-caps versions of 'aarch64-virt-virtio'
Add a version for 'latest' caps as well as '4.2.0'. The test
demonstrates that with a real qemu PCIe will be used instead of MMIO.

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
4f33f1325a qemuxml2argvtest: Convert the rest of GIC tests to latest capabilities
Convert the two negative cases to use real capapbilities as well as the
positive case for situations when KVM is not used by stripping the
QEMU_CAPS_KVM flag.

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
dae9c45539 qemuxml2argvtest: Convert DO_TEST_GIC to use real latest 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
b2ca40d2e2 qemuxml2argvtest: Use real capabilities in tests for picking the aarch64 GIC version
Convert 'aarch64-gic-default' and 'aarch64-gic-none' cases to use real
capabilities both latest and locked to 4.2.0 to show what would happen
with a real qemu.

Note that the qemuTestSetHostArch() calls are needed as real caps
override the setting once used. Once we convert all tests to real data
this can be dropped.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:31 +02:00
Peter Krempa
2b3dbf6321 qemuxml2argvdata: Do not symlink output files for aarch64 gic tests
Upcoming patches will be modifying the tests for selecting the GIC
version to use real capabilities. This in certain cases will show that a
different version is picked.

Using symlinks makes it inconvenient to do the modifications and
unobvious what changed.

Remove the symlinks and replace them by real output files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:31 +02:00
Michal Privoznik
fc216db4fb tests: Introduce viracpitest
Introduce a test that checks newly introduced virAcpi module.
There are three IORT tables from a real HW (IORT_ampere,
IORT_gigabyte and IORT_qualcomm), then there's one from a VM
(IORT_virt_aarch64) and one that I handcrafted to be empty
(IORT_empty).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-04-06 12:48:22 +02:00
Andrea Bolognani
641d272573 tests: Don't use GIO_COMPILATION
This flag is intended to be used exclusively in the context of
building GLib itself and should not be passed to the compiler
by a third-party project such as libvirt.

Reverts: 77d1fa5 ("tests: Compile virgdbusmock.c with GIO_COMPILATION enabled")
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-04 10:52:16 +02:00
Andrea Bolognani
84f2399c9e tests: Don't build virgdbusmock on Windows
All of the tests that use this mock (networkxml2firewalltest,
virsystemdtest, virpolkittest) are either no-ops on Windows, or
are not compiled at all on the target.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-04 10:52:16 +02:00
Andrea Bolognani
dc6cdf405d tests: Drop dead code
Left behind by commit 35eb484 ("tests: remove firewalld
backend tests from virfirewalltest.c").

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-04 10:52:15 +02:00
Peter Krempa
f2c20b8260 domaincapstest: Skip unknown variants instead of the default variant
Fix the logic selecting when to run the tests to skip unknown variants
rather than the default variant.

Fixes: 738c5bae88
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2023-04-03 10:51:17 +02:00
Peter Krempa
c674a43f3d testutilsqemu: Drop fake capability testing infrastructure for 's390'
Now that all tests were converted to use real capabilities we don't need
it any more. Remove it so that no new tests are added with it.

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
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
5887466ec6 qemuxml2argvtest: Convert rest of s390 tests to real caps
Convert the rest of the outstanding tests to use real capabilities.

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
2572d991ee qemuxml2argvtest: Modernize s390 cpu tests
Use real capabilities for the CPU test. The negative test case for QEMUs
without QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION is removed as the feature is
now supported by all supported qemu versions.

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
85a30c7570 qemuxml2argvtest: Modernize all s390 'loadparm' tests
Use latest caps for the tests.

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
3429ddf6ec qemuxml2argvtest: Modernize all s390 'keywrap' tests
Use latest caps for the tests.

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
5203380907 qemuxml2argvtest: Remove obsolete negative tests
The 'hostdev-subsys-mdev-vfio-ccw', 'hostdev-vfio-zpci', and
'hostdev-vfio-zpci-autogenerate-fids' test cases have negative versions
which are invoked without capabilities. This does not make sense going
forward as the tests are going to be switched to real capabilities.

Remove them.

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
a0fe48382c testutilsqemu: Drop fake capability testing infrastructure for 'ppc64'
Now that all tests were converted to use real capabilities we don't need
it any more. Remove it so that no new tests are added with it.

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
c523377e19 qemuxml2argvtest: Use real capabilities for negative test cases for ppc64 architecture
Convert the last outstanding test cases for ppc64 to use real
capabilities.

In couple cases this actually fixes the test case to test what it was
intending to do.

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
518d8d1de1 qemu: capabilities: Retire obsolete 'pseries' capabilities
Retire:

    QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE
    QEMU_CAPS_MACHINE_PSERIES_CAP_HTM
    QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV
    QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST
    QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC
    QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC
    QEMU_CAPS_MACHINE_PSERIES_CAP_IBS

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
21b9f65ec0 qemuxml2argvtest: Drop negative test cases for 'pseries' machine features
All of the tested features are always present in the 'pseries' machine
with oldest-supported qemu-4.2, thus the tests don't make sense any
more.

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
8f430f453b qemuxml2argvtest: Add '4.2.0' version of 'pseries-features' test case
Add an example case showing that every feature in the 'pseries-features'
test works also with the oldest supported qemu version.

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
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
dba5bad2a7 qemuxml2argvtest: Modernize all 'ppc64' remaining 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
6eee2de99f qemuhotplugtest: Make the test more useful by validating used commands against QMP schema
qemuhotplugtest validates only that a given command is used but not the
arguments of the command. With this patch we'll validate the arguments
against the QMP schema thus we can catch possible issues with deprecated
commands.

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
706cd47487 qemuhotplugtest: Use real 'latest' capabilities for hotplug testing
Rather than test with synthetic capabilities which might get outdated
reuse testQemuGetRealCaps to fetch latest capabilities and use those.

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
c469b0897c qemuhotplugtest: Refactor calling of testQemuHotplugCpuPrepare
Pass in the whole struct rather than splitting out individual members.

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
cccabdf8be qemuhotplugtest: Assert QEMU_CAPS_SET_ACTION
With modern qemu we use 'set-action' instead of 'watchdog-set-action'.

Switch to it so that later qemuhotplugtest can be switched to use real
capabilities.

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
c84e9a3b82 qemuhotplugtest: Enable 'lsilogic' SCSI controller
All real qemus support the 'lsilogic' controller and thus would pick it
as the default rather than virtio-scsi. Since lsilogic is limited in
some aspects we should test it with the proper default model.

In the future the fake capabilities will be replaced by real
capabilities so this test would break.

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
a58d22250c qemuhotplugtestdomain: Move all i686 test cases to x86_64
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
578c2a0cc7 qemuhotplugtest: Don't fetch capabilities when they are not used
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
d8ea6a391b qemumemlocktest: Use real capabilities
Use testQemuGetRealCaps to fetch real capabilities and use it in place
of the faked 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
83967a9ed2 testQemuGetRealCaps: Integrate fetching of QMP schema
Move the lookup of the corresponding QMP schema used for validation of
QMP commands from 'testCompareXMLToArgvValidateSchema' to
testQemuGetRealCaps as an optional step.

This will simplify using QMP command validation in other tests which
will use testQemuGetRealCaps.

'testutilsqemuschema' module is now linked into 'test_utils_qemu' as it
contains no monitor-specific code itself and after this patch it's
referenced directly from that module.

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
6013561a82 testutilsqemu: Extract fetching of real virQEMUCaps into testQemuGetRealCaps
'testQemuInfoInitArgs' contains the logic to fetch and use the
capabilities for tests using 'struct testQemuInfo'.

As in certain cases use of 'struct testQemuInfo' is an overkill extract
the code to fetch the capabilities into a standalone helper.

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
17d627518c tests: Remove 'vircapstest'
Technically for the LXC capabilities lookup we don't have another test
case, but given that it shares the implementation with qemu and thus the
only thing we are missing out on is testing of filling of the fake
capabilities which doesn't make sense testing.

Remove vircapstest.

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
702620bd6b tests: vircaps: Remove pointless testing of virCapabilitiesHostNUMAGetCpus
The test case doesn't validate the returned map of cpus, just checks
that it didn't fail. We test the returned value indirectly via
qemuxml2argvtest.

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
6ae5d71d38 vircapstest: Remove 'qemu' testing
We have testing based on real capabilities in 'qemucaps2xmltest' for
qemu guest related data and 'vircaps2xmltest' tests the host data
gathering. The testing done here makes no sense.

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
a4c03bdd59 virQEMUCapsInitGuestFromBinary: Remove return value
The function always returns 0.

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
ccee1ee088 virCapabilitiesAllocMachines: Use NULL-terminated list as argument and return count
Simplify use of the function by determining the number of elements
inside the function.

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
6861964704 qemu: capabilities: Drop 'kvmVersion' field
It's never set to any real value. Remove it along with the caching code.

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
252019e087 testutilsqemu: Remove infrastructure for fake-caps testing of OSX
All tests using this were refactored to use real capabilities.

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
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
8704a59e21 qemuxml2argvtest: 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
Peter Krempa
87474f1d1f testutilsqemu: Add support for specifying the variant for qemuxml2(argv|xml)test
Add the possibility to control the variant of the test data for real
caps testing in qemuxml2argvtest and qemuxml2xmltest.

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
12aedb4145 qemucapabilitiesdata: Add (fake) '+hvf' variant of aarch64 data
The data is based on the generic variant of the 7.2.0 data on aarch64.

Only modification to the '.replies' file is that KVM is reported as
unavailable/unsupported.

Ideally this will be replaced by a dump captured from a real system.

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:06 +02:00
Peter Krempa
3fe14604bc qemucapabilitiesdata: Add (fake) '+hvf' variant of x86_64 data
The data is based on the generic variant of the 7.2.0 data on x86_64.

Only modification to the '.replies' file is that KVM is reported as
unavailable/unsupported.

Ideally this will be replaced by a dump captured from a real system.

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:06 +02:00
Peter Krempa
2bde68b6c5 qemucapabilitiestest: Add support for '+hvf' variant
We need to signal to the capabilities code that HVF variant is used so
that it can behave as if it were running on OSX.

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:06 +02:00
Peter Krempa
1f85c31bd8 tests: Mock virQEMUCapsProbeHVF directly in qemucapabilitiestest
It needs to be mocked only for 'qemucapabilitiestest'. Additionally
moving it here will allow to control the return value based on the test
data which will be required for testing dumps from HVF accelerated qemu.

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:06 +02:00
Peter Krempa
6af47df5ac virQEMUCapsProbeHVF: Factor out setting of the capability
Separate the architecture specific code to probe the support for HVF
from the actual setting of the capability.

In upcoming patches 'virQEMUCapsProbeHVF' will be mocked in the
testsuite to provide testing for the HVF hypervisor.

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:06 +02:00
Peter Krempa
111cfc5532 qemu: capabilities: Fix testing of 'TCG' capabilities probing
The logic in 'virQEMUCapsInitQMP' invokes a second probe of qemu in case
when acceleration is used and TCG is supported to specifically probe the
CPU and features of non-accelerated guests.

The same logic must then be used in 'qemucapabilitiestest' when
replaying the data for testing otherwise the test would fail.

Export 'virQEMUCapsHaveAccel' for test usage and use the same logic
in 'testQemuCaps'.

Fix the comment in 'virQEMUCapsInitQMP' to outline what's happening.

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:06 +02:00
Peter Krempa
738c5bae88 domaincapstest: Add testing infrastructure for the '+hvf' variant
Allow testing of capabilities of OSX systems with the hvf accelerator.

'domaincapstest' requires special handling as we need to set
VIR_DOMAIN_VIRT_HVF virt type in such case.

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:06 +02:00
Peter Krempa
bc48522cce domaincapstest: Propagate variant name into doTestQemuInternal
Use it to format test file name as in other cases. Currently
domaincapstest will not run for any unknown variant. This patch is meant
to simplify the review of patches doing actual functional changes.

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:06 +02:00
Peter Krempa
2102a31bc2 tests: Add support for multiple variants of data for the same qemu version+architecture
'qemucapabilitiestest' and other users of the capability data can
benefit from adding a discriminator string to have multiple instances
for the same version+architecture tuple.

This will in the future allow us to have specific capability versions
for test cases which require a specific host feature or are based on a
different operating system.

Add the basic skeleton for parsing the variant string and passing it
around into test cases.

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:06 +02:00
Peter Krempa
36a735c553 tests: qemucapabilitiesdata: Add README file
Explain what the purpose of these files is as well as how they are
named, captured, used and modified.

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:06 +02:00
Peter Krempa
5153a67c19 testQemuGetLatestCapsForArch: Rewrite using testQemuGetLatestCaps
Fetch the full hash of 'latest' files and just return the correct one.

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:06 +02:00
Peter Krempa
a13f37265b testQemuGetLatestCaps: Process capabilities for all architectures in one pass
Rather than finding the newest caps file iteratively for specific
architectures in multiple passes over the directory we can simply load
the latest for everything in one pass by storing the version in the hash
table and filling it progressively.

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:06 +02:00
Peter Krempa
75e606974b qemucapabilitiesdata: Separate version from architecture with a '_'
Parsing a version where components are separated by dots, while other
components are also separated by dots is a bit insane. Separate the
version by an underscore.

To achieve this we rename all the caps files and adjust the appropriate
places formatting the path.

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:06 +02:00
Peter Krempa
e1633a1b27 domaincapstest: Restructure code to avoid disabling of warnings
Construct the capsName/emulator strings as initialization of variable
definition and move definition of 'struct testData' above the code.

This means that 'name' field will be initialized later.

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:06 +02:00
Peter Krempa
a4d222644e domaincapstest: Make construction of filename more extensible
Rather than trying to cram everything into one printf statement format
the type with prefix and machine with prefix separately and then
concatenate everything into the filename.

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:06 +02:00
Peter Krempa
6870e1f141 qemumigrationcookiexmltest: Don't fetch latest caps files without using them
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:06 +02:00
Peter Krempa
5b738195a2 virStringParseVersion: Parse into 'unsigned long long'
Phase out 'unsigned long'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-03 09:19:06 +02:00
Martin Kletzander
3a947eed06 vircryptotest: Fix cipher test typo aes265cbc -> aes256cbc
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-03 08:21:27 +02:00
Jiri Denemark
e349cdc54b util: Update format strings in translated messages (part 1)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Andrea Bolognani
420a7a2550 qemu: Default to raw firmware for existing domains
The changes to the output files are the exact opposite of
those from commit 22207713cf: this is proof that the fix is
working as intended, and that existing domains will keep using
raw firmware images regardless of whether or not qcow2 images
are available on the system and have higher priority.

New domains will keep picking whatever firmware is considered
the preferred one according to the order of descriptors, as
evidenced by the fact that the recently introduced
firmware-auto-efi-abi-update-aarch64 test case is unaffected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-28 14:22:34 +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
Michal Privoznik
77d1fa5e75 tests: Compile virgdbusmock.c with GIO_COMPILATION enabled
There are couple of g_dbus_*() functions we provide an
alternative implementation for in our virgdbusmock.c. However,
these functions are declared in gio/gdbusconnection.h as:

  GIO_AVAILABLE_IN_ALL
  GDBusConnection  *g_bus_get_sync (GBusType            bus_type,
                                    GCancellable       *cancellable,
                                    GError            **error);

where GIO_AVAILABLE_IN_ALL is declared as (in
/gio/gio-visibility.h):

  #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(GIO_STATIC_COMPILATION)
  #  define _GIO_EXPORT __declspec(dllexport)
  #  define _GIO_IMPORT __declspec(dllimport)
  #elif __GNUC__ >= 4
  #  define _GIO_EXPORT __attribute__((visibility("default")))
  #  define _GIO_IMPORT
  #else
  #  define _GIO_EXPORT
  #  define _GIO_IMPORT
  #endif
  #ifdef GIO_COMPILATION
  #  define _GIO_API _GIO_EXPORT
  #else
  #  define _GIO_API _GIO_IMPORT
  #endif

  #define _GIO_EXTERN _GIO_API extern

  #define GIO_AVAILABLE_IN_ALL _GIO_EXTERN

Now, on mingw the functions we mock are declared with dllimport
attribute which makes the compiler unhappy:

  ../tests/virgdbusmock.c:25:24: error: 'g_bus_get_sync'
  redeclared without dllimport attribute: previous dllimport
  ignored [-Werror=attributes]

The solution is to do what glib does when it compiles the gio
module: set GIO_COMPILATION macro which in turn annotates the
function with dllexport attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-28 09:43:40 +02:00
Andrea Bolognani
24ad99d76d qemu: Automatically add firmware type/features information
Even when the user is not taking advantage of firmware
autoselection and instead manually providing all the necessary
information, in most cases they're still going to use firmware
builds that are provided by the OS vendor, are installed in
standard paths and come with a corresponding firmware
descriptor.

Similarly, even when the user is not guiding the autoselection
process by specifying the desired status of certain features
and instead is relying on the system-level descriptor priority
being set up correctly, libvirt will still ultimately decide to
use a specific descriptor, which includes information about the
firmware's features.

In both these cases, take the additional information that were
obtained from the firmware descriptor and reflect them back into
the domain XML, where they can be conveniently inspected by the
user and management applications alike.

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
50d68c1d10 qemu: Don't drop firmware type/features information
Now that we no longer reject configurations that include both
this information and explicit firmware details, as long of
course as everything is internally consistent, and that we've
ensured that we produce maximally compatible XML on migration,
we can stop stripping this information at the end of the
firmware selection process.

There are several advantages to keeping this information around:

  * if the user wants to change the firmware configuration for
    an existing VM, they can simply drop the <loader> and
    <nvram> elements, tweak the firmware autoselection parameters
    and let libvirt pick a firmware that matches on the new
    requirements;

  * management applications can inspect the XML and easily
    figure out firmware-related information without having to
    reverse-engineer them based on some opaque paths.

Overall, this change makes things more transparent and easier to
understand. The improvement is so significant that, in a
follow-up commit, we're going to ensure that this information is
available in even more cases.

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
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
3030010fa9 tests: Fix firmware descriptor masking test
Right now we're checking that firmware descriptor masking works
as intended by creating an empty file matching 60-ovmf-sb.json
in name.

However, that firmware descriptors contains the details for a
perfectly valid and quite common situation: Secure Boot being
supported by the firmware build, but being effectively disabled
by the lack of certificates in the NVRAM template.

Unmask that firmware descriptor, and instead create a dummy one
that has higher priority than all other OVMF builds and points
to paths that are obviously incorrect, which should make it
easy to notice it getting accidentally unmasked 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
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
66e5c43a03 tests: Add firmware-auto-efi-loader-path
This is identical to the existing
firmware-auto-efi-loader-path-nonstandard test case, but uses
a standard firmware path.

Right now the two test cases behave identically, but that's
going to change 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
Andrea Bolognani
d8d06f0a4a tests: Fix firmware-auto-efi-loader-path-nonstandard
This test is intended to simulate the use of an OVMF firmware
image installed under a non-standard path. In order to make
such a configuration work, the user would have to provide
additional information.

Right now it doesn't matter, because the configuration is
rejected anyway, but the behavior is going to change slightly
in the future. Prepare by making the configuration more
complete and realistic.

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
Ján Tomko
246d187a0f tests: qemublocktest: fix memory leak
Set enccount to 1, so the cleanup function knows
there is something to be cleaned up.

Fixes: 1992ae40fa

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2023-03-17 15:36:36 +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
5a42a8c38c qemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LUKS_ANY capability
This capability represents that qemu supports the "luks-any" encryption
format for RBD images.
Both LUKS and LUKS2 formats can be parsed using 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
Or Ozeri
1992ae40fa qemu: add multi-secret support in _qemuDomainStorageSourcePrivate
This commit changes the _qemuDomainStorageSourcePrivate struct
to support multiple secrets (instead of a single one before this commit).
This will useful for storage encryption requiring more than a single secret.

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
6c34f19334 qemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LAYERING capability
This capability represents that qemu supports the layered encryption
of RBD images, where a cloned image is encrypted with a possible
different encryption than its parent image.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:35 +01:00
Tim Wiederhake
62dd68ef18 cpu_map: Add missing feature "fsrc"
Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
4bf853cac2 cpu_map: Add missing feature "fsrs"
Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Tim Wiederhake
43869b9178 cpu_map: Add missing feature "fzrm"
Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-15 14:46:12 +01:00
Michal Privoznik
df2ef2e706 qemuBuildThreadContextProps: Prune .node-affinity wrt <emulatorpin/>
When a thread-context object is specified on the cmd line, then
QEMU spawns a thread and sets its affinity to the list of NUMA
nodes specified in .node-affinity attribute. And this works just
fine, until the main QEMU thread itself is not restricted.

Because of v5.3.0-rc1~18 we restrict the main emulator thread
even before QEMU is executed and thus then it tries to set
affinity of a thread-context thread, it inevitably fails with:

  Setting CPU affinity failed: Invalid argument

Now, we could lift the pinning temporarily, let QEMU spawn all
thread-context threads, and enforce pinning again, but that would
require some form of communication with QEMU (maybe -preconfig?).
But that would still be wrong, because it would circumvent
<emulatorpin/>.

Technically speaking, thread-context is an internal
implementation detail of QEMU, and if it weren't for it, the main
emulator thread would be doing the allocation. Therefore, we
should honor the pinning and prune the list of node so that
inaccessible ones are dropped.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2154750
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:55 +01:00
Michal Privoznik
95ae91fdd4 qemuxml2argvmock: Drop virNuma* mocks
Since qemuxml2argvtest is now using virnumamock, there's no need
for qemuxml2argvmock to offer reimplementation of virNuma*()
functions. Also, the comment about CLang and FreeBSD (introduced
in v4.3.0-40-g77ac204d14) is no longer true. Looks like noinline
attribute was the missing culprit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:36 +01:00
Michal Privoznik
c4c90063a5 qemuxml2argvdata: Extend vCPUs placement in memory-hotplug-dimm-addr.xml
So far, the memory-hotplug-dimm-addr.xml test case pins its vCPUs
onto CPUs 0-1 which correspond to NUMA node #0 (per
tests/vircaps2xmldata/linux-basic/system/node/node0). Place vCPUs
onto nodes #1 and #2 too so that DIMM <memory/> device can
continue using thread-context after future patches. This
configuration, as-is currently, would make QEMU error out anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:33 +01:00
Michal Privoznik
d91ca262fb qemuxml2argvdata: Adjust maximum NUMA node used
We have couple of qemuxml2argvtest cases where up to 8 NUMA nodes
are assumed. These are used to check whether disjoint ranges of
host-nodes= is generated properly. Without prejudice to the
generality, we can rewrite corresponding XML files to use up to 4
NUMA nodes and still have disjoint ranges.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:28 +01:00
Michal Privoznik
28ec9d86b3 qemuxml2argvtest: Use virnuma mock
While no part of cmd line building process currently depends on a
host NUMA configuration, this will change soon. Use freshly
changed virnumamock from qemuxml2argvtest and make the mock read
NUMA data from vircaps2xmldata which seems to have the most rich
NUMA configuration.

This also means, we have to start building virnumamock
unconditionally. But this is not a problem, since nothing inside
of the mock relies on Linux specificity. The whole mock is merely
just reading files and parsing them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:24 +01:00
Michal Privoznik
213b6822a8 virnumamock: Introduce virNumaGetNodeOfCPU() mock
Introduce a mock of virNumaGetNodeOfCPU() because soon we will
need virNumaCPUSetToNodeset() to return predictable results.
Also, fill in missing symlinks in vircaps2xmldata/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-03-15 12:46:21 +01:00
Michal Privoznik
7db8373e08 Use G_N_ELEMENTS() more
In a few places we still use the good old:

  sizeof(var) / sizeof(var[0])
  sizeof(var) / sizeof(int)

The G_N_ELEMENTS() macro is preferred though. In a few places we
don't link with glib, so provide the macro definition.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-03-13 13:29:07 +01:00
Jim Fehlig
705525cbec libxl: Add support for custom firmware path in config converter
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-10 11:02:02 -07:00
Jim Fehlig
bf3be5b76e libxl: Support specifying a custom firmware path
libxl added support for specifying custom firmware paths long ago. The
functionality exists in all Xen version supported by libvirt. This patch
adds support for user-specified efi firmware paths in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-10 11:01:42 -07:00
Christian Nautze
a9a4421ba8 qemu: implement QEMU NBD source reconnect delay attribute
Currently it's only possible to set this parameter during domain
creation via QEMU commandline passthrough feature.
With the new delay attribute it's also possible to set this
parameter if you want to attach a new NBD disk
using "virsh attach-device domain device.xml" e.g.:

  <disk type='network' device='disk'>
    <driver name='qemu' type='raw'/>
    <source protocol='nbd' name='foo'>
      <host name='example.org' port='6000'/>
      <reconnect delay='10'/>
    </source>
    <target dev='vdb' bus='virtio'/>
  </disk>

Signed-off-by: Christian Nautze <christian.nautze@exoscale.ch>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-03-10 09:38:05 +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
Tim Wiederhake
bc77182ea4 Fix some typos
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
2023-03-09 14:09:16 +01:00
Jonathon Jongsma
3138e204b2 test: regenerate virtio-blob expected outputs
Somehow the tests didn't get regenerated after rebasing, which broke the
build.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2023-03-08 17:04:29 -06: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
Jonathon Jongsma
052094b5e4 qemu: Add capability for virtio-gpu.blob
Capability to determine whether this qemu supports the 'blob' option for
virtio-gpu.

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
8f2fb353e4 qemu: capabilities: Retire QEMU_CAPS_LOADPARM
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
0ec1907bac qemu: capabilities: Retire QEMU_CAPS_AES_KEY_WRAP and QEMU_CAPS_DEA_KEY_WRAP
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
1f01ce1e29 qemuxml2argvtest: Remove always asserted s390 capabilities
QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP and QEMU_CAPS_LOADPARM
are always asserted via virQEMUCapsInitQMPBasicArch thus don't need to
be explicitly enabled by tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-07 12:26:32 +01:00
Peter Krempa
f12b0b4a7a qemu: capabilities: Retire QEMU_CAPS_MACH_VIRT_GIC_VERSION
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-07 12:26:32 +01:00
Peter Krempa
f2212f4c2a qemuxml2argvtest: Don't set QEMU_CAPS_MACH_VIRT_GIC_VERSION
testUpdateQEMUCaps calls virQEMUCapsInitQMPBasicArch which already sets
it. Purge the capability from the testing code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-07 12:26:32 +01:00
Peter Krempa
e0b956cd66 qemu: capabilities: Retire QEMU_CAPS_NO_HPET
All uses were replaced by an explicit architecture check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-07 12:26:32 +01:00
Peter Krempa
53a8875f59 qemu: capabilities: Retire QEMU_CAPS_NO_ACPI
The capability is based on a platform check rather than what given qemu
supports.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-07 12:26:32 +01:00
Peter Krempa
4ee4809907 qemu: validate: Fix logic for validating presence of the HPET timer
Commit 24cc9cda82 switched over to use -machine hpet, but one of the
steps it did was to clear the QEMU_CAPS_NO_HPET capability.

The validation check still uses the old capability though which means
that for configs which would explicitly enable HPET we'd report an error.

Since HPET is an x86(_64) platform specific device, convert the
validation check to an architecture check as all supported qemu versions
actually support it.

Modify a test case to request HPET to catch posible future problems.

Fixes: 24cc9cda82
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-07 12:26:32 +01:00
Peter Krempa
9fecdaf1c8 testutilsqemu: Drop support for fake-caps testing of 'arm' architecture
All tests were converted to use real capabilities so there's no need to
support the infrastructure for fake tests.

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
9f805d3757 tests: qemuxml2argvdata: Port 'qemu-system-arm' cases with fake tests to 'qemu-system-aarch64'
'qemu-system-aarch64' is superset of the soon to be deprecated
'qemu-system-arm' binary. We can move over all of our fake-caps tests to
real caps on aarch64.

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
76f441283a qemu: capabilities: Retire QEMU_CAPS_CPU_AARCH64_OFF
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
85644c24c8 qemu: Always assume QEMU_CAPS_CPU_AARCH64_OFF
We always assert the flag for aarch64 qemus and in qemu the 'aarch64'
cpu property doesn't seem to be optional.

Remove checks and remove impossible test case.

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
726efd6aa0 testutilsqemu: Drop support for fake-caps testing of 'ppc' architecture
All tests were converted to use real capabilities so there's no need to
support the infrastructure for fake tests.

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
b8fe04562f qemuxml2argvdata: Convert test cases for 'ppc' architecture to latest caps
Convert the 'ppc-dtb' and 'ppce500-serial' to use real capabilities
albeit captured from a non-native machine. Thus the XML needs to be
converted to use virt type '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
d24e1e6b31 tests: qemu: Add 'ppc' machine caps based on 'qemu-system-ppc' on fedora
The data are obtained from a x86_64 machine thus don't really represent
physical hardware, but it's better than nothing.

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
53909a5a74 testutilsqemu: Drop support for fake-caps testing of 'riscv64' architecture
All tests were converted to use real capabilities so there's no need to
support the infrastructure for fake tests.

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
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
cdf82cdb98 testutilsqemu: Introduce ARG_QEMU_CAPS_DEL, to mask out flags from real caps
In certain cases we want to use as-real capabilities as possible but
that doesn't allow testing certain fallback scenarios of features that
can be complied out of QEMU.

ARG_QEMU_CAPS_DEL can be used similarly to ARG_QEMU_CAPS but the flag
arguments are actually masked out of the resulting caps.

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
ce79cf6ab4 testutilsqemu: Rework setting of fake capabilities
Rather that populate a virQEMUCaps object we now populate a bitmap with
the fake capabilities and transfer it into the virQEMUCaps later.

This unifies the code paths between the fully fake caps tests and real
caps + fake flags.

Also the same approach will be used in upcomming patch to add
possibility to mask out flags from real capabilities.

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
f7fa1d4e11 qemuTestCapsCacheInsertImpl: Require that callers always pass capabilities
There's just one case when we're populating the cache with empty caps so
that can allocate a dummy virQEMUCaps object rather than having the
logic inside qemuTestCapsCacheInsertImpl.

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
b048218a8a qemu: Remove return value checks from calls to virQEMUCapsNewCopy
The function now can't fail.

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
f6967e2b77 conf: cpu: Remove NULL check from virCPUDefCopy
Make all callers always pass a valid pointer which in turn allows us to
remove return value check from the callers.

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
e61adbf26b qemu: capabilities: Don't make callers check return of virQEMUCapsNew(Binary)
The allocation of the object itself can't fail. What can fail is the
creation of the class on a programming error. Rather than punting the
error up the stack abort() directly on the first occurence as the error
can't be fixed during runtime.

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
bc52cc2fe4 testutilsqemu: Drop support for fake-caps testing of 'riscv32' architecture
All tests were converted to use real capabilities so there's no need to
support the infrastructure for fake tests.

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
14232f6944 testutilsqemu: Unify array for filling fake machine types
Both 'kvm_machines' and 'qemu_machines' now have the same members so we
can simply drop kvm_machines.

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
e5786922db testutilsqemu: Drop support for fake-caps testing of 'sparc' architecture
All tests were converted to use real capabilities so there's no need to
support the infrastructure for fake tests.

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
27a69cc73c qemuxml2argvtest: Convert 'sparc-minimal' case to DO_TEST_CAPS_ARCH_LATEST
Convert the only outstanding test case for a 'sparc' machine to modern
test infrastructure.

'sparc' machine type also needs to be added to the list of supported
arches in testQemuGetLatestCaps.

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
5810eb97ad qemuTestCapsCacheInsert*: Directly insert real capabilities
Real capabilities populate the binary name, while fake don't. We can
directly insert the capabilities using the real binary name.

This will allow to remove 'qemu_emulators' entries once all tests are
converted to real capabilties.

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
856166a268 qemuxml2argvtest: Fix serial-unix-missing-source case
Use x86_64 emulator and machine and remove the nocaps version of the
test.

Fixes: 80a37e96a9
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
Peter Krempa
12cc08fe72 tests: domainschemadata: Drop redundant tests
The schema tested by removed test cases is tested by other, more useful,
test cases:

 - 'maxMemory'
    - qemuxmlargvdata/memory-hotplug*
 - 'backingChains'
    - qemuxmlargvdata/disk-backing-chains*
 - 'timers'
    - qemuxml2argvdata/kvm-pit-delay.xml
    - qemuxml2argvdata/clock-catchup.xml
 - 'qemu-simple-description-title.xml'
    - 'qemuxml2argvdata/minimal.xml

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
e6c1ca3d11 tests: Undo recent breakages
Turns out that those overrides I recently removed where actually
there for a reason, and there was a motivation behind creating
the driver config as unprivileged too O:-)

Until a solution that can both ensure predictable output and
avoid code duplication is developed, go back to the previous
approach.

Fixes: 2f56f69f7f ("tests: Create privileged config for QEMU driver")
Fixes: 0f49b6cc6b ("tests: Drop no longer necessary overrides")
Fixes: 0b464cd84f ("tests: Drop more QEMU driver config overrides")
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2023-03-06 16:40:14 +01:00
Andrea Bolognani
0b464cd84f tests: Drop more QEMU driver config overrides
These are allegedly necessary to keep the output consistent,
but now that we're using a privileged config for the driver we
get the desired behavior out of the box, and as a bonus the
paths match what you would actually see on a regular host.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-06 14:44:13 +01:00
Andrea Bolognani
751693b472 tests: Set SASLdirs to default values
We use standard paths for almost everything else.

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
d4336b4c99 tests: Set TLSx509certdirs to default values
For almost all directories, the value we set matches the one
a standard deployment would use, but in a couple of cases they
deviate from that. Keep things consistent.

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
3278fd0d3b tests: Set more TLSx509certdirs
We were missing a couple.

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
09ac9e6d3c tests: Move more QEMU driver settings to common code
None of these settings is specific to the xml2argv test. Moving
them to the common code ensures the behavior of the QEMU driver
is consistent 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
Andrea Bolognani
98a6618d07 tests: Add convenience variable for QEMU driver config
This makes the code less clunky.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-06 14:35:35 +01:00