Commit Graph

8551 Commits

Author SHA1 Message Date
Peter Krempa
a5531a05d2 qemuxml2argvtest: Simplify invocation of GIC tests
Change DO_TEST_GIC so that it accepts the version and switch it to use
DO_TEST_CAPS_ARCH_VER_FULL internally which will ensure that the output
filenames conform to the format we use for real capabilities.

This also allows us to convert a few of versioned tests to use this
improved macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
907a2dfd5c qemuxml2argvtest: Remove old chardev tests
All tests have already a real capability variant.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
78fd84c301 qemuxml2argvtest: Add missing versioned test cases for 'cpu-host-model'
We've forgot to add test invocations with real caps for qemu versions
starting with 6.2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
c9f3f578cd qemu_capabilities: Retire QEMU_CAPS_DEVICE_VFIO_PCI
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
cbb3adde61 qemu: Always assume support for QEMU_CAPS_DEVICE_VFIO_PCI
The 'display' option for the 'vfio-pci' device was added in qemu-2.12
and can't be compiled out. Assume support for the flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
aaec42dbdf qemu: capabilities: Retire QEMU_CAPS_CPU_CACHE
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
917cf3e164 qemu: Always assume support for QEMU_CAPS_CPU_CACHE
All supported qemu versions have this feature and it can't be compiled
out. The logic is a bit more complex in this instance as the flag is
asserted if:

    if (ARCH_IS_X86(qemuCaps->arch) &&
        virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) {
        virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE);
    }

Now QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION is available since qemu-2.8 but
only on certain architectures, thus we need to keep the flag itself, but
x86_64 is one of them.

The flag can be also assumed as qemuValidateDomainDefCpu rejects any
cache config on non-x86 arches.

Remove any use of the capability and drop the impossible test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
3ea514ee30 qemuxml2argvtest: Drop 'monitor-json' case
QMP monitor is the only thing we support at this point, thus all other
tests test the same thing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:43 +02:00
Peter Krempa
35ddb4d78f qemuxml2argvtest: testAddCPUModels: Remove non-x86_64 fake cpu models
At this point only x86_64 is using fake machines, and for real machines
we don't populate the fake cpu models. Thus we can remove everything
non-x86_64.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:42 +02:00
Peter Krempa
e8cd18a8e8 qemuxml2argvtest: Clean up host CPU if overriden
If a test uses ARG_CAPS_HOST_CPU_MODEL feature we override the global
host cpu model to the selected CPU but don't clear it afterwards. This
can trip up fake caps tests following a test which uses this feature.

This does not happen with real caps, because unless overriden, the host
cpu from capabilities is always populated as the host cpu.

Clear the CPU on cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:42 +02:00
Peter Krempa
748dc3b1d3 qemu: capabilities: Preserve location of the default machine type when stripping aliases for tests
Internally the preferred machine which is 'pc' for x86_64 must be kept
in the first place in the array of machines. This was not the case when
stripping the machine aliases for use in tests (so that test output
stays stable) where we've created a new entry for the alias. This means
that the original name (e.g. pc-i440fx-8.1) stayed in the first place.

To fix this we now swap the names around and create a new entry at the
end for the specific type. Additionally the default flag is not
propagated to the copy.

This is also visible now in the output of 'qemuxml2xmltest' as the test
cases which use the default machine type return to 'pc' instead of the
more specific name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:42 +02:00
Peter Krempa
b816b41a65 qemu: capabilities: Retire QEMU_CAPS_ICH9_DISABLE_S* and QEMU_CAPS_ICH9_DISABLE_S* capabilities
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:42 +02:00
Peter Krempa
c225398015 qemu: Always assume support for QEMU_CAPS_PIIX_DISABLE_S* and QEMU_CAPS_ICH9_DISABLE_S*
The support for PIIX power management was added in qemu commit
v1.0-3094-g459ae5ea5a and the suport for ICH9 power management was added
in qemu commit v2.2.0-542-g6ac0d8d44c and both can't be compiled out.

This means we can always assume support for these features. Remove the
validation and impossible tests. Move relevant bits from
'q35-pm-disable' to 'q35' test case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:42 +02:00
Peter Krempa
5e73c89d22 securityselinuxlabeltest: Convert to testQemuInsertRealCaps
Use the modern infrastructure to populate capabilities cache with real
capabilities instead of the faked one which will be soon removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-06 14:09:42 +02:00
Martin Kletzander
e95b81c2fd conf: Generate MAC address instead of keeping all zeroes
When we parse <mac address="00:00:00:00:00:00"/> we keep that in memory
and pass it down to the hypervisor. However, that MAC address is not
strictly valid as it is not marked as locally administered (bit 0x02)
but it is not even globally unique. It is also used for loopback device
on Linux, for example. And QEMU sees such MAC address just as "not
specified" and generates a new one that libvirt does not even know
about. So to make the overall experience better we now generate it if
the supplied one is all clear.

Resolves: https://issues.redhat.com/browse/RHEL-974

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-09-04 16:01:24 +02:00
Peter Krempa
d0601b4267 qemu: capabilities: Retire QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS
All qemu versions have that command and cpu hotplug code now directly
probes the machine type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-09-04 10:31:52 +02:00
Peter Krempa
51daa85d7c qemuhotplugtest: Remove 'modern' field for cpu hotplug tests
Nowadays all tests were considered 'modern' so it makes no longer sense
to have that field.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-09-04 10:31:52 +02:00
Peter Krempa
140ff3c514 tests: qemuhotplugtest: Fix arch-specific parts of 'ppc64' test XMLs
The tests were using a copy of a x86_64 based XML and thus
'qemuhotplugtest' was selecting wrong capabilities to use for that
specific test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-09-04 10:31:52 +02:00
Peter Krempa
a8f3d406e3 qemuxml2argvtest: Modernize 'cpu-hotplug-startup' case
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-09-04 10:31:52 +02:00
Martin Kletzander
1612aa4d4a conf, schema: Switch iothread/poll values to unsignedLong
They represent nanoseconds, and we accept such values already.  Not that
anyone would use such values in the wild, but even one person testing
QEMU could put in a bigger value and will be bothered with validation
errors after every `virsh edit`.  Also add a test for it.

Resolves: https://issues.redhat.com/browse/RHEL-1717

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-09-04 10:07:54 +02:00
Martin Kletzander
8a0319fc7d tests: Remove unused symlink
The test does not use VIR_TEST_DIFFERENT anyway, so it's probably a
leftover.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2023-09-01 17:10:29 +02:00
Pavel Hrdina
0873d63b09 Revert "capabilities: report full external snapshot support"
Reverting external snapshot for running VM doesn't work correctly so we
should not report this capability until it is fixed.

This reverts commit de71573bfe.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-09-01 12:09:04 +02:00
Kristina Hanicova
18705b03c6 qemu: add support for discard_granularity
This commit adds building of `discard_granularity` disk option
for qemu commandline.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-08-25 15:05:22 +02:00
Peter Krempa
08339a34ed qemucapabilitiesdata: Final update of capability test data for qemu-8.1.0 release
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2023-08-25 14:02:01 +02:00
K Shiva Kiran
9fb5234981 Add Test driver and testcase for Network Metadata change APIs
This commit implements the newly defined Network Metadata Get and
Set APIs into the test driver.
It also adds a new testcase "networkmetadatatest" to test the APIs.

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-25 12:36:37 +02:00
Peter Krempa
ab26247f46 qemuxml2xmltest: Merge DO_TEST macro into DO_TEST_CAPS_INTERNAL
Now all tests invoke a real-capability version. Remove DO_TEST.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-25 10:08:12 +02:00
Peter Krempa
42c09b68df qemuxml2xmltest: Modernize rest of 'seclabel-*' tests
Use real capabilities for these last few tests that were not modernized
due to use of 'WHEN_INACTIVE'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-25 10:08:12 +02:00
Peter Krempa
cfb0294344 qemuxml2argvtest: Pass expected state via struct testQemuInfo's 'flags' member
Rather than having a separate argument to DO_TEST pass the state via
newly added flags 'FLAG_SKIP_CONFIG_ACTIVE'. The '_INACTIVE' equivalent
was not added as there's no test which'd use it.

Remove the old 'WHEN_' flags and move the decision logic out of the
DO_TEST macro as any addition to the logic makes the compiler take much
longer to compile qemuxml2xmltest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-25 10:08:12 +02:00
Peter Krempa
c2fd8c2b29 qemuxml2xmltest: Use DO_TEST_CAPS_ARCH_LATEST_FULL for arm GIC tests
Use the new macro instead of open coding it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-25 10:08:12 +02:00
Peter Krempa
1522e7f9b7 qemuxml2xmltest: Rework file name generation in 'testInfoSetPaths'
Pass the state-based suffix directly as string.

Document the logic how the filename is chosen.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-25 10:08:12 +02:00
Peter Krempa
7ef2846f9b virschematest: Validate files in 'chxml2xmlin' and 'chxml2xmlout' directories
The test files for the 'ch' driver were not validated against the schema
and thus also didn't conform to the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-25 10:07:36 +02:00
Peter Krempa
27d1f9e404 tests: chxml2xmlin: Fix path format for fake paths
Our XML schema requires absolute paths for the <kernel> and disk source
values. Fix the 'ch' test to have absolute paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-25 10:07:36 +02:00
Laine Stump
222b66974e util: rename virPCIDeviceGetDriverPathAndName
Instead, call it virPCIDeviceGetCurrentDriverPathAndName() to avoid
confusion with the device name that is stored in the virPCIDevice
object - that one is not necessarily the name of the current driver
for the device, but could instead be the driver that we want to be
bound to the device in the future.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-24 23:36:18 -04:00
Laine Stump
cd2843f546 util: use "stubDriverType" instead of just "stubDriver"
In the past we just kept track of the type of the "stub driver" (the
driver that is bound to a device in order to assign it to a
guest). The next commit will add a stubDriverName to go along with
type, so lets use stubDriverType for the existing enum to make it
easier to keep track of whether we're talking about the name or the
type.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-24 23:36:18 -04:00
Pavel Hrdina
de71573bfe capabilities: report full external snapshot support
Now that deleting and reverting external snapshots is implemented we can
report that in capabilities so management applications can use that
information and start using external snapshots.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-08-24 19:08:20 +02:00
Michal Privoznik
148b7aa7e2 virjsontest: Introduce a test case for an empty array
Previous commits were all about empty strings and empty JSON
arrays. Introduce a test case for "[]" to make sure we pare it
correctly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-08-24 13:47:41 +02:00
Michal Privoznik
a3f0c3852e nodedevmdevctltest: Introduce a test case for empty mdevctl output
As explained earlier, 'mdevctl' can output nothing. Add a test
case to nodedevmdevctltest which covers this situation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-08-24 13:46:22 +02:00
Michal Privoznik
857efc74fe nodedevmdevctltest: Rename mdevctl-list-empty test case
The mdevctl-list-empty test case is there to test whether an
empty JSON array "[]" is handled correctly by mdevctl handling
code. Well, mdevctl can output both, an empty JSON array or no
output at all.

Therefore, rename "mdevctl-list-empty" test case to
"mdevctl-list-empty-array" which is more descriptive and also
frees up slot for actual empty output (handled in next commits).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-08-24 13:45:06 +02:00
Michal Privoznik
520eb3e15b vircommand: Introduce virCommandMassCloseRange()
This is brand new way of closing FDs before exec(). We need to
close all FDs except those we want to explicitly pass to avoid
leaking FDs into the child. Historically, we've done this by
either iterating over all opened FDs and closing them one by one
(or preserving them), or by iterating over an FD interval [2 ...
N] and closing them one by one followed by calling closefrom(N +
1). This is a lot of syscalls.

That's why Linux kernel developers introduced new close_from
syscall. It closes all FDs within given range, in a single
syscall. Since we keep list of FDs we want to preserve and pass
to the child process, we can use this syscall to close all FDs
in between. We don't even need to care about opened FDs.

Of course, we have to check whether the syscall is available and
fall back to the old implementation if it isn't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-08-24 12:45:00 +02:00
Peter Krempa
a3a6f23c09 qemuxml2xmltest: Modernize all remaining fake capability tests
Convert all cases using DO_TEST() to use DO_TEST_CAPS_LATEST() and
remove DO_TEST() to prevent further use.

Most of the changes are related to CPU being present in the output XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
dddff1a01c qemuxml2xmltest: Modernize all 'net-' tests
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
bbb5666d61 qemuxml2argvtest: Modernize 'net-*'
Convert all tests using fake capabilities to use DO_TEST_CAPS_LATEST.

Note that rename detection in git didn't work too well here and the
files may not correspond.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
c5ee3a0a70 qemuxml2xmltest: Modernize all 'video-*' cases
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
0b58c4dbbe qemuxml2argvtest: Moderinze 'video-*' cases
Use latest capabilities for all tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
dc7ca40a13 qemu: Retire 'ivshmem' device
The device was removed in qemu-4.0 and is superseded by 'ivshmem-plain'
and 'ivshmem-doorbell'.

Always report error when the old version is used and drop the irrelevant
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
b76e4d53c6 qemuxml2(argv|xml)test: Modernize 'shmem' test cases
Upgrade the relevant test cases to use latest capabilities. Note that
the 'shmem' (ivshmem) device is no longer supported and will be dropped
later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
3e6b39563b qemuxml2(argv|xml)test: Modernize 'fd-memory*' test cases
Use latest real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
4bc796a82f qemuValidateDomainVCpuTopology: Always validate vcpu count against topology
Historically we've used QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS as witness
that the topology must cover the maximum number ov vcpus. qemu started
to enforce this in qemu-2.5, thus we can now always do the check.

This change also requires aligning the topology in certain test files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
67979c7a63 qemuxml2(argv|xml)test: Sanitize testing of default video type on x86_64
Use real capabilities and remove the redundant test case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
90bb1069c2 qemuxml2(argv|xml)test: Modernize 'graphics-dbus*' tests
Use latest caps for this rather recent graphics protocol.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
7c13b99108 qemuxml2xmltest: Convert rest of 'DO_TEST_NOCAPS' cases to 'DO_TEST_CAPS_LATEST'
Finish the conversion of cases which didn't need any special
capabilities to use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
5789bfae8e qemuxml2xmltest: Use real caps for 'vxhs' disk tests
Version-lock the test to qemu-5.0.0 as it's the latest qemu that
supports 'vxhs' and thus the test can't use 'latest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
c2dfc3b863 virschematest: Improve detection of 'invalid' XMLs
The output files from 'qemuxml2argvtest' may have the real capability
suffix e.g. 'pci-rom-disabled-invalid.x86_64-latest.xml' which would not
be detected as being invalid and thus causing a test failure.

Change the logic to find '-invalid.' so that we can properly use
'virschematest' with test cases using real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:41 +02:00
Peter Krempa
72a6c2ad9f qemuxml2xmloutdata: Workaround wrong detection of 'disk-cdrom-empty-network-invalid' in virschematest
The 'disk-cdrom-empty-network-invalid' is a special case were the input
XML is invalid according to the schema, but after processing a valid XML
is produced.

This corner case doesn't play well with 'virschematest' which uses the
file suffix to determine whether the file is invalid.

Upcoming patch will change the 'virschematest' condition, which would
start detecting this XML as invalid.

Use the '-active'/'-inactive' suffix for the file, which is possible
with qemuxml2xmltest so that an upcoming patch will not cause test
failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Peter Krempa
f83f864230 qemuxml2xmltest: Modernize all 'DO_TEST_NOCAPS' tests
Convert all tests using the 'DO_TEST_NOCAPS' "fake" capability
invocation to use DO_TEST_CAPS_LATEST and remove the DO_TEST_NOCAPS
macro to prevent further use.

Most of the output file changes are related to default USB controller
type and the CPU becoming defined in the XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Peter Krempa
22c8efd32b testutilsqemu: Drop fake data for VIR_ARCH_I686
There are no more tests depending on '/usr/bin/qemu-system-i386' thus we
don't have to carry the data any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Peter Krempa
e1f88be86d qemuxml2argvdata: Convert 'cpu' test cases to use 'x86_64'
Convert the rest of the files using 'qemu-system-i386' to
'qemu-system-x86_64'. The 'cpu*' tests are done separately to emphasise
that there's no change in the output.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Peter Krempa
eb380372dc qemuxml2(argv|xml)test: Convert certain tests to DO_TEST_CAPS_LATEST
Convert tests which use DO_TEST_NOCAPS in both tests and the
qemuxml2xml variant has a symlink back to the qemuxml2argv input file.

This is done to separate the conversion before a patch converts all
DO_TEST_NOCAPS variants in qemuxml2xmltest to use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Peter Krempa
2c17de67d0 qemuxml2argvdata: Replace 'qemu-system-i386' by 'qemu-system-x86_64' in most test files
Replace the emulator and architecture to x86_64, for all non-cpu related
test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Peter Krempa
dbf34acc91 qemuxml2(argv|xml)test: Modernize 'net-many-models' case
Use real latest capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Peter Krempa
7428fe95c4 qemuxml2argvtest: Drop 'master-key' test case
At this point we setup the master key with all VMs, so this specific
test case no longer makes sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-22 14:04:40 +02:00
Andrea Bolognani
7c328b6cf4 tests: Reintroduce firmware-auto-efi-format-mismatch
Since the previous version of this negative test now passes,
create a new version that still triggers the intended failure.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:37 +02:00
Andrea Bolognani
48e5fe7af4 tests: Rename firmware-auto-efi-format-loader-qcow2-nvram-path
Now that, after the recent changes, the test passes, its old
name is no longer accurate.

While at it, enable the xml2xml part for it as well.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:35 +02:00
Andrea Bolognani
10a8997cbb conf: Don't default to raw format for loader/NVRAM
Due to the way the information is stored by the XML parser, we've
had this quirk where specifying any information about the loader
or NVRAM would implicitly set its format to raw. That is,

  <nvram>/path/to/guest_VARS.fd</nvram>

would effectively be interpreted as

  <nvram format='raw'>/path/to/guest_VARS.fd</nvram>

forcing the use of raw format firmware even when qcow2 format
would normally be preferred based on the ordering of firmware
descriptors. This behavior can be worked around in a number of
ways, but it's fairly unintuitive.

In order to remove this quirk, move the selection of the default
firmware format from the parser down to the individual drivers.

Most drivers only support raw firmware images, so they can
unconditionally set the format early and be done with it; the
QEMU driver, however, supports multiple formats and so in that
case we want this default to be applied as late as possible,
when we have already ruled out the possibility of using qcow2
formatted firmware images.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:34 +02:00
Andrea Bolognani
b845e376a4 qemu: Match NVRAM template extension for new domains
Keep things consistent by using the same file extension for the
generated NVRAM path as the NVRAM template.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:32 +02:00
Andrea Bolognani
e96e322725 qemu: Filter firmware based on loader.readonly
If the user included loader.readonly=no in the domain XML, we
should not pick a firmware build that expects to work with
loader.readonly=yes.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:31 +02:00
Andrea Bolognani
ccbb987707 qemu: Generate NVRAM path in more cases
Right now, we only generate it after finding a matching entry
either among firmware descriptors or in the legacy firmware
list.

Even if the domain is configured to use a custom firmware build
that we know nothing about, however, we should still automatically
generate the NVRAM path instead of requiring the user to provide
it manually.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:30 +02:00
Andrea Bolognani
4a49114ff4 qemu: Don't overwrite NVRAM template for legacy firmware
Just because we have found a matching entry, it doesn't mean
that we should discard the information explicitly provided in
the domain XML.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:28 +02:00
Andrea Bolognani
1b3e9c67e3 tests: Include microvm in firmwaretest
libvirt doesn't really support the microvm machine type, but
it can parse the firmware descriptor just fine.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:27 +02:00
Andrea Bolognani
da6b98394b tests: Drop tags from BIOS firmware descriptor
They aren't used for anything.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:26 +02:00
Andrea Bolognani
a97c56888c tests: Update firmware descriptor files
These are imported from Fedora 38's edk2 package.

The files that are being replaced date back to RHEL 7 and no
longer represent what libvirt is likely to encounter on an
actual production system.

Notably, the paths have all changed, with both x86_64 and
aarch64 builds now living under /usr/share/edk2 and the AAVMF
name being having been phased out.

Additionally, the 4MB qcow2 format builds have been introduced
on x86_64 and given high priority, effectively making qcow2
the default format across architectures.

The impact of these changes on the test suite is, predictably,
quite severe.

For the cases where paths to firmware files were explicitly
provided as part of the input, they have been adjusted so that
the modern paths are used instead of the legacy ones. Other
than that, input files have been left untouched.

The following expected changes can be seen in output files:

  * where qcow2 firmware was used on x86_64, Secure Boot
    support is now enabled;

  * all ABI_UPDATE test cases for x86_64 now use qcow2
    formatted firmware;

  * test cases where legacy paths were manually provided
    no longer get additional information about the firmware
    added to the output XML.

Some of the changes described above highlight why, in order
to guarantee a stable guest ABI over time and regardless of
changes to the host's configuration, it was necessary to move
firmware selection from VM startup time to VM creation time.

In a few cases, updating the firmware descriptors changes the
behavior in a way that's undesired and uncovers latent bugs
in libvirt:

  * firmware-manual-efi-secboot-legacy-paths ends up with
    Secure Boot disabled, despite the input XML specifically
    requesting it to be enabled;

  * firmware-manual-efi-rw-modern-paths loses the
    loader.readonly=no part of the configuration and starts
    using an NVRAM file;

  * firmware-manual-efi-nvram-template-nonstandard starts
    failing altogether with a fairly obscure error message.

We're going to address all these issues with upcoming changes.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:24 +02:00
Andrea Bolognani
e930f62a02 tests: Add more tests for firmware selection
Most of these are just additional coverage, but a few demonstrate
bugs in libvirt:

  * firmware-manual-efi-nvram-template-nonstandard sees the NVRAM
    template path, which was explicitly provided in the XML,
    being overridden by the firmware selection machinery;

  * firmware-auto-efi-rw* and firmware-manual-efi-rw-legacy-paths
    lose the loader.readonly=no setting and thus behave
    differently than requested;

  * firmware-manual-efi-loader-path-nonstandard fails because an
    NVRAM path doesn't get generated.

We're going to address all these issues with upcoming changes.

Note that the firmware-auto-efi-nvram-template-nonstandard
failure is expected: firmware autoselection has been enabled, but
the NVRAM template points to a custom path that's not mentioned
in any of the firmware descriptors and so it can't succeed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:23 +02:00
Andrea Bolognani
87d91e9e24 tests: Add some more DO_TEST*ABI_UPDATE* macros
These are going to be useful later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:21 +02:00
Andrea Bolognani
4ba04107d9 tests: Rename firmware-auto-efi-nvram-path
The new name better describes the test scenario and will fit
better with the additional tests that we're about to introduce.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:17 +02:00
Andrea Bolognani
8627ec167c tests: Turn abi-update.xml into a symlink
Since the idea behind introducing the abi-update variant of
a test is showing that libvirt behaves differently based on
whether the configuration is for a newly-defined domain or an
existing one, we don't want the input files to ever go out of
sync.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:16 +02:00
Andrea Bolognani
1773526224 tests: Consistently use /path/to/guest_VARS.fd
That's what we already use in almost all cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:15 +02:00
Andrea Bolognani
5c129c8e7a tests: Use virt-4.0 machine type for aarch64
Using the unversioned machine type means that firmware
descriptors can't be used to discover additional information
about the chosen firmware build.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:13 +02:00
Andrea Bolognani
8c326914d8 tests: Switch to firmware autoselection for hvf
Firmware selection is not relevant to these tests, so adopt
the most convenient approach.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:51:06 +02:00
Andrea Bolognani
751b0e6dbf tests: Use DO_TEST_CAPS_*_ABI_UPDATE() for ppc64
We have a number of tests that can benefit from this macro
instead of open-coding it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-21 13:50:53 +02:00
Peter Krempa
a771d7a5da test: qemu: Update qemu-8.1 test data on x86_64
Update to v8.1.0-rc4

Notable changes:
 - 'dirty-limit' migration feature added
    - 'vcpu-dirty-limit', 'x-vcpu-dirty-limit-period' parameters added
    - 'dirty-limit-ring-full-time', 'dirty-limit-throttle-time-per-round' statistics added
 - migration statistic of number of skipped zero pages is now deprecated

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-08-21 13:02:40 +02:00
Michal Privoznik
8abc979bb0 qemu: Move channelTargetDir into stateDir
For historical reasons (i.e. unknown reason) we put channel
sockets into a path derived from cfg->libDir which is a path that
survives host reboots (e.g. /var/lib/libvirt/...). This is not
necessary and in fact for session daemon creates a longer prefix:

  XDG_CONFIG_HOME -> /home/user/.config
  XDG_RUNTIME_DIR -> /run/user/1000

Worse, if host is rebooted suddenly (e.g. due to power loss) then
we leave files behind and nobody will ever remove them.

Therefore, place the channel target dir into state dir.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2173980
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-08-17 17:22:09 +02:00
Michal Privoznik
d3759d3674 qemu: Generate shorter channel target paths
A <channel/> device is basically an UNIX socket into guest.
Whatever is sent from the host, appears in the guest and vice
versa. But because of that, the length of the path to the socket
is important (underscored by fact that we derive the path from
domain short name). But there are still cases where we might not
fit into UNIX_PATH_MAX limit (usually 108 characters), because
the path is derived also from other variables, e.g.
XDG_CONFIG_HOME for session domains.

There are two components though, that are needless: "/target/"
and "domain-" prefix. Drop them. This is safe to do, because
running domains have their path saved in status XML and even
though paths are dropped on migration, they are not part of guest
ABI and thus we are free to change them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-08-17 17:19:01 +02:00
Michal Privoznik
4f159d4269 lib: Finish using struct zero initializer manually
There are some cases left after previous commit which were not
picked up by coccinelle. Mostly, becuase the spatch was not
generic enough. We are left with cases like: two variables
declared on one line, a variable declared in #ifdef-s (there are
notoriously difficult for coccinelle), arrays, macro definitions,
etc.

Finish what coccinelle started, by hand.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
2023-08-03 16:41:19 +02:00
Michal Privoznik
b20a5e9a4d lib: use struct zero initializer instead of memset
This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.

Generated using the following semantic patch:

  @@
  type T;
  identifier X;
  @@
  -  T X;
  +  T X = { 0 };
     ... when exists
  (
  -  memset(&X, 0, sizeof(X));
  |
  -  memset(&X, 0, sizeof(T));
  )

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
2023-08-03 16:41:19 +02:00
Michal Privoznik
039b16e41e Decrease scope of some variables
There are couple of variables that are declared at function
beginning but then used solely within a block (either for() loop
or if() statement). And just before their use they are zeroed
explicitly using memset(). Decrease their scope, use struct zero
initializer and drop explicit memset().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
2023-08-03 16:35:11 +02:00
Peter Krempa
033c4fcddf qemu_monitor: Remove helpers for 'query-commands'
Now that we don't use it for probing at all we can remove all the
corresponding monitor code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-07-20 17:28:21 +02:00
Peter Krempa
0af5a514ee qemu: capabilities: Don't probe 'query-commands'
The capability code now probes the presence of commands from the QMP
schema instead of using 'query-commands'. Don't call the command and
adjust the '.replies' files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-07-20 17:27:19 +02:00
Peter Krempa
294cf405d5 qemu: capabilities: Retire QEMU_CAPS_(IDE|SCSI)_DRIVE_WWN
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-07-20 15:24:43 +02:00
Peter Krempa
5eed97e313 qemu: Always assume support for QEMU_CAPS_SCSI_DISK_WWN
The support for configuring the 'wwn' of a SCSI disk was added in qemu
commit 27395add759ff4caeb0 (v1.0-3326-g27395add75) and can't be compiled
out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-07-20 15:24:21 +02:00
Peter Krempa
f276dbeefe qemu: capabilities: Update capabilities test data for qemu-8.1 dev cycle
Update the test data on x86_64 to v8.0.0-2835-g361d539735

Notable changes:

 - added new commands:
    - cxl-inject-dram-event
    - cxl-inject-general-media-event
    - cxl-inject-memory-module-event
    - cxl-inject-poison
    - switchover-ack
 - q35-8.1 machine type now supports 1024 cpus
 - new cpu models:
    - 'SapphireRapids-v2'
    - 'GraniteRapids-v1'
 - removed commands:
    - x-query-profile
 - cpu features which can be emulated now:
    - rdseed, rdpid, 3dnowprefetch, xsaveerptr, wbnoinvd
 - applicable CPU bug mitigation flags are now exposed to TCG guests to
   allow using more named models

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-07-20 15:24:12 +02:00
Peter Krempa
a7f7bfa347 qemuTestDriverInit: Don't autopopulate qemu capabilities when initializing driver
In an effort to use strictly real capability testing all tests were
converted to do insertion of their own capabilities when required, thus
we don't need to popluate the capabilities. This will also promote using
proper capabilities based on what the test is trying to achieve.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:23:52 +02:00
Peter Krempa
b1126c46eb qemudomaincheckpointxml2xmltest: Use real 'x86_64' capabilities in all test data
Use the platform which is getting most development for the checkpoint XML
examples so that it's tested against latest capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:23:43 +02:00
Peter Krempa
f45aff1635 qemuagenttest: Use real x86_64 capabilities for parsing domain definitions
Some test cases require a real definition and thus parse a XML with the
definition to obtain it. Convert the code to use real capabilities and
switch to x86_64.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:23:34 +02:00
Peter Krempa
86edcfac4d tests: qemudomainsnapshotxml2xmlout: Use real 'x86_64' capabilities in all test data
Use the platform which is getting most development for the snapshot XML
examples so that it's tested against latest capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:23:24 +02:00
Peter Krempa
faa4d488e5 qemumemlocktest: Use 'testQemuInsertRealCaps'
Rewrite the capability fetching to use the new helper, thus simplifying
the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:23:16 +02:00
Peter Krempa
bb142b6db1 testutilsqemu: Introduce 'testQemuInsertRealCaps' helper
'testQemuInsertRealCaps' looks up and inserts real capabilities into the
capability 'file cache' for testing purposes. Effectively this helper
replaces following steps:

1) testQemuGetRealCaps
2) virFileCacheClear
3) qemuTestCapsCacheInsert

This helper doesn't copy the capabilities that are borrowed from it's
internal cache thus they must not be modified afterwards in contrast to
the above steps.

The use of this helper is in simple tests which require some form of
capabilities to parse a definition but don't care about doctoring them
in any way.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:23:00 +02:00
Peter Krempa
4cac4867ad testQemuGetRealCaps: Extract caching of the caps into a new helper
Introduce testQemuGetRealCapsInternal that loads and caches the
capabilities. testQemuGetRealCaps just copies the cache entry and
returns it to the user.

The new helper will be used in a helper that doesn't modify the
capabilities and thus we don't need to copy it before use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:22:50 +02:00
Peter Krempa
b5ddd072bc testQemuGetRealCaps: Strip the default machine alias before insertion into cache
Expand the default machine type alias of the 'latest' capabilities for
an architecture before caching it rather than after copying it, so that
we don't duplicate the work all the time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:22:40 +02:00
Peter Krempa
64dcb59756 domaincapstest: Use obviously fake firmware name in capabilities
The domain capabilities data feature a firmware section which is filled
by few entries. The entries used until now looked real and it was
suspicious that a x86_64 host was listing aarch64 firmware images which
should not happen.

Fill it by an obviously fake path as it's not actually interpreted in a
meaningful way.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 15:22:20 +02:00
Peter Krempa
0cbe448977 testutils: Print number of failed tests
We can easily report how many tests failed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-07-20 14:59:57 +02:00