Commit Graph

8086 Commits

Author SHA1 Message Date
Ján Tomko
01cf26d41f qemu: retire QEMU_CAPS_VIRTIO_TX_ALG
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-08-11 18:34:47 +02:00
Ján Tomko
c80b10e88f qemu: always assume QEMU_CAPS_VIRTIO_TX_ALG
Introduced back in 2010 by QEMU commit:
  commit a697a334b3c4d3250e6420f5d38550ea10eb5319
      virtio-net: Introduce a new bottom half packet TX

Released in QEMU 0.14.0

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-08-11 18:34:47 +02:00
Ján Tomko
9a23c55b04 tests: qemuxml2xmltest: remove interface from disk test
There is no need to specify an interface for a disk test.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-08-11 18:34:47 +02:00
Peter Krempa
5eb283e294 qemu: Assume and retire QEMU_CAPS_BLOCKDEV_BACKUP
The blockdev-backup QMP command was introduced in qemu-2.3.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:26:32 +02:00
Peter Krempa
66c442f80f qemu: Assume support and retire QEMU_CAPS_BLOCK_WRITE_THRESHOLD
The event was introduced in qemu-2.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:26:17 +02:00
Peter Krempa
3a7955979c qemu: capabilities: Retire QEMU_CAPS_QUERY_NAMED_BLOCK_NODES
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:26:02 +02:00
Peter Krempa
a0b8b54348 qemu: Retire QEMU_CAPS_BLOCKDEV
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:25:36 +02:00
Peter Krempa
1050d80585 qemuDomainValidateStorageSource: Remove 'maskBlockdev' argument
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:25:11 +02:00
Peter Krempa
6695162c76 qemu: domain: Assume QEMU_CAPS_BLOCKDEV for the domain private code
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:24:11 +02:00
Peter Krempa
2ebb44a957 qemuhotplugtest: Switch to -blockdev mode
Enable blockdev mode and convert the expected commands to the modern
equivalents in preparation for removing the old-style hotplug code
paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:22:14 +02:00
Peter Krempa
d2831cd521 qemu: monitor: Remove unused qemuMonitor(Eject|Change)Media
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:21:59 +02:00
Peter Krempa
b573224cf7 qemu: monitor: Remove unused qemuMonitorDrivePivot
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:20:21 +02:00
Peter Krempa
d926d7b4c9 qemu: monitor: Remove unused arguments of qemuMonitorBlockStream
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:19:39 +02:00
Peter Krempa
01f8c55f22 qemu: monitor: Remove unused arguments of qemuMonitorBlockCommit
The 'persistjob' is always true and 'top' and 'base' are always NULL.
Adjust the functions to drop the arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:19:11 +02:00
Peter Krempa
8c67518256 qemu: monitor: Remove unused qemuMonitorDriveMirror
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:18:44 +02:00
Peter Krempa
071a4c8ba7 qemu: alias: Remove check for QEMU_CAPS_BLOCKDEV
The only instance in this file can be simplified to avoid checking the
capability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:14:18 +02:00
Peter Krempa
75a0fbe420 qemu: block: Remove 'qemuBlockNodeNamesDetect' and related infrastructure
With blockdev we are generating the nodenames ourselves so all of this
infrastructure became obsolete. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:13:55 +02:00
Peter Krempa
58e740aa24 qemu: Remove unused code for pre-blockdev disk snapshot monitor interaction
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:07:39 +02:00
Peter Krempa
b27549e631 qemu: capabilities: Retire QEMU_CAPS_BLOCKDEV_DEL
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 15:07:14 +02:00
Peter Krempa
b45f63ecd9 qemu: capabilities: Retire QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
ebfa1fb0f9 qemu: capabilities: Retire capabilities used for -blockdev detection
Retire:
    QEMU_CAPS_BLOCK_FILE_AUTO_READONLY_DYNAMIC
    QEMU_CAPS_SCSI_DISK_DEVICE_ID
    QEMU_CAPS_SAVEVM_MONITOR_NODES

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
b51512f915 qemu: command: Always assume support for QEMU_CAPS_SCSI_DISK_DEVICE_ID
The 'device_id' property of 'scsi_disk' was added in qemu-4.0 and it's
unconditionally present, thus we can now always assume its presence.

Update some fake-caps test which didn't yet assert the capability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
5998381b08 tests: Force QEMU_CAPS_BLOCKDEV(_HOSTDEV_SCSI) in fake caps tests
Until we finish removing the capabilities we need to force them in the
tests so that it's obvious that the code changes have no impact.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
9b54efb7cf qemu: capabilities: Unconditionally set QEMU_CAPS_BLOCKDEV/QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI
The cleanup of the code to always assume support for QEMU_CAPS_BLOCKDEV
will not be simple, so for now we hardcode the support and the code will
be cleaned up gradually.

We also disallow users to clear the flags via the namespace property or
qemu.conf configuration.

The change to the PPC64 test data originates from the fact that the
capability dump is not from the release version but is lacking one of
the necessary flags to enable -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
78ad796a43 qemu: capabilities: Retire QEMU_CAPS_QCOW2_LUKS
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
8eae01ba28 qemuxml2xmltest: Modernize all test cases using QEMU_CAPS_QCOW2_LUKS
Modernize 'disk-nvme', 'encrypted-disk-usage', 'encrypted-disk', and
'user-aliases' cases to use DO_TEST_CAPS_LATEST.

This will remove all uses of QEMU_CAPS_QCOW2_LUKS from the test suite.

Since the output files are done via symlinks to input files, the input
files need to be modernized with few auto-added XML bits.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
cd2d9808db qemuxml2argvtest: Use DO_TEST_CAPS_LATEST for all 'user-aliases' tests
Modernize the tests as they mostly care that the aliases are properly
propagated to qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
f80829dece qemu: capabilities: Retire QEMU_CAPS_DRIVE_DISCARD and QEMU_CAPS_DRIVE_DETECT_ZEROES
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
c250c5a3db qemu: capabilities: Retire QEMU_CAPS_GLUSTER_DEBUG_LEVEL
The debug level of gluster backend became configurable in qemu-2.8.

This also removes the only old-style syntax for the 'blockdev-add'
command prior to stabilization.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
fc0aa62377 qemu: capabilities: Retire QEMU_CAPS_ACTIVE_COMMIT
Active block commit is supported since qemu-2.0

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
3d367a2c93 qemu: capabilities: Retire QEMU_CAPS_CHANGE_BACKING_FILE
The 'change-backing-file' command is unconditionally supported since
qemu-2.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
d1e0eaabb1 qemu: capabilities: Retire QEMU_CAPS_AUDIODEV
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
95215e6b79 qemuxml2(argv|xml)test: Remove use of QEMU_CAPS_AUDIODEV in fake-caps tests
The code no longer uses the capability so the tests don't need to assert
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
31ee59d4e1 qemu: command: Always assume QEMU_CAPS_AUDIODEV
Generate only new version of the '-audiodev' commandline. The leftover
old code and validation will be removed in subsequent patches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
c7ab87b8a6 domaincapstest: Remove test data for qemu-4.1
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
ff4e0b775b qemucapabilitiestest: Remove test data for qemu-4.1
qemu-4.1 will not be supported any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
1228fc69b1 domaincapstest: Remove test data for qemu-4.0
qemu-4.0 will no longer be supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
3397826a68 qemucapabilitiestest: Remove test data for qemu-4.0
qemu-4.0 will no longer be supported, remove the test data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
91c7835cf9 tests: domaincaps: Remove test data for qemu-3.1
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
79cb01304f tests: qemucapabilities: Remove qemu-3.1 test data
Upcoming patches will raise the minimum required qemu version to 4.2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
b1973b883c qemuxml2argvtest: Remove 'qemu-4.0' versions of 'cpu-host-model-cmt' and 'cpu-tsc-frequency'
Minimum qemu version is going to be bumped to qemu-4.2. Upgrading the
version of these tests doesn't make sense as the host cpu in the real
capabilities doesn't support the features the tests are attempting to
test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
081230fcdb qemuxml2argvtest: Remove 'qemu-4.0' version of aarch64-features-sve case
Minimum qemu will be bumped to 4.2 so this test no longer makes sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
a0ce9317fc qemuxml2argvtest: Remove pre-qemu-4.2 versions of 'cpu-host-model' test
Minimum qemu will be bumped to 4.2 so remove the older test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
9248434536 qemuxml2argvtest: Remove 'qemu-3.1' versions of virtio-(non-)transitional tests
Starting from qemu-4.0 a new device model name is used instead of the
'disable_*' props. Since we are going to bump to qemu-4.2 as minimum
this test can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
6a9b336be1 qemuxml2argvtest: Drop 'qemu-4.1' variants of all audio tests
Minimum qemu version will be bumped to qemu-4.2 so we no longer need to
care about configuring audiodevs via the environment variables.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
5838bd98a4 tests: qemuxml2argv: Remove pre-blockdev versions of disk-related tests
Upcoming patches will bump minimum supported qemu version to 4.2 which
will use '-blockdev' with qemu so we can drop all the old test cases for
pre-blockdev configs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Peter Krempa
88dbfabd4e qemuxml2(argv|xml)test: Remove 'qemu-4.1' variant of 'x86-kvm-32-on-64'
Upcoming patches will bump minimum qemu version to 4.2. In this case we
the 'latest' case is sufficient as with qemu-4.2 we already behave as
upstream ('qemu64' cpu is used instead of 'qemu32').

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-11 14:38:31 +02:00
Andrea Bolognani
1f14dbccbc tests: Mock virQEMUCapsProbeHVF()
Successfully returning without doing anything is what the
function already does on non-Apple platforms.

When building on macOS, however, the check for HVF availability
will be performed. When running on bare metal, that will result
in the QEMU_CAPS_HVF flag being added to the virQEMUCaps
instance, and a bunch of error messages along the lines of

  In 'tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml':
  Offset 7557
  Expect [c]
  Actual [hvf'/>
    <flag name=‘c]

showing up.

Up until now we hadn't noticed because our CI jobs run in VMs,
where HVF support is not available.

Reported-by: Christophe de Dinechin <dinechin@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Tested-by: Christophe de Dinechin <dinechin@redhat.com>
2022-08-10 17:49:52 +02:00
Andrea Bolognani
92cc65783e tests: Use domaincapsmock in qemucapabilitiestest
This doesn't change anything at the moment, but is necessary
for the upcoming fix.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Tested-by: Christophe de Dinechin <dinechin@redhat.com>
2022-08-10 17:49:30 +02:00
Kristina Hanicova
203e74ff42 qemu: remove unused driver and all its propagations
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2022-08-10 16:50:07 +02:00
Christophe de Dinechin
ede39c1fc6 tests: Pass the flat_namespace option to the linker
This fixes vircryptotest on macOS 12 (Monterey).

The test relies on library injection (using DYLD_INSERT_LIBRARIES)
to replace the normal random functions with functions giving predictable
results, defined in virrandommock.c. However, using DYLD_INSERT_LIBRARIES
only works when building with flat namespaces.

Adding the -Wl,-flat_namespace option to the linker fixes the problem.
The option was already defined in the top-level meson.build, but had been
forgotten in the test linker arguments.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-08-09 11:42:45 +02:00
Paolo Bonzini
2dd3ec6f57 qemu: deprecate query-cpus-fast capability
All supported versions of QEMU have the command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-08 17:36:49 +02:00
Paolo Bonzini
b1f57ef0fd qemu: remove support for query-cpus
The query-cpus-fast command was introduced in 2.12, therefore
query-cpus is never used on supported versions of QEMU.  Remove
the logic to parse its output, as well as the parameters to
choose between the two commands.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-08 17:36:49 +02:00
Paolo Bonzini
cf1c191155 tests: remove query-cpus tests
All tests now use query-cpus-fast.  Since the QEMU driver will lose
support for query-cpus soon, go ahead and remove support for testing
it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-08 17:36:49 +02:00
Paolo Bonzini
332ea27164 tests: convert x86_64 tests to query-cpus-fast
All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
convert the JSON output for x86 tests to the new format, and drop the
"halted" field from the expected output as it is not available anymore.

The CPU properties were obtained from the query-hotpluggable-cpus output
in tests/qemumonitorjsondata.  CPU, thread_id, and qom_path are renamed
respectively to cpu-index, qom-path and thread-id, while nip and halted
are removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-08 17:36:49 +02:00
Paolo Bonzini
eb98eb0ce8 tests: convert ppc64 tests to query-cpus-fast
All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
convert the JSON output for PPC tests to the new format, and drop the
"halted" field from the expected output as it is not available anymore.

The CPU properties were obtained from the query-hotpluggable-cpus output
in tests/qemumonitorjsondata.  CPU, thread_id, and qom_path are renamed
respectively to cpu-index, qom-path and thread-id, while nip and halted
are removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-08 17:36:49 +02:00
Paolo Bonzini
e398a6aba4 tests: drop "-fast" from query-cpus-fast tests
All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
remove the "-fast" suffix from both x86-full-fast and s390-fast.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-08 17:36:49 +02:00
Paolo Bonzini
3635864fa8 tests: remove duplicate cpuinfo test
All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
remove the query-cpus version of the x86-full test.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-08 17:36:49 +02:00
Martin Kletzander
70768cda97 vmx: Add support for dummy network interface
Also map it to an ethernet without connectionType and networkName.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-05 14:37:54 +02:00
Dario Faggioli
1c1a7cdd40 qemu: Add support for max physical address size
This patch maps /domain/cpu/maxphysaddr into -cpu parameters:

  - <maxphysaddr mode='passthrough'/> becomes host-phys-bits=on
  - <maxphysaddr mode='emualte' bits='42'/> becomes phys-bits=42

Passthrough mode can only be used if the chosen CPU model is
'host-passthrough'. Also validate that an explicitly specified
bits value does not exceed the physical address bits on the host.

The feature is available since QEMU 2.7.0.

Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-08-04 09:04:16 +02:00
Dario Faggioli
e6c29f09e5 conf: Add support for specifying CPU max physical address size
This patch introduces the

    <maxphysaddr mode='passthrough'/>
    <maxphysaddr mode='emulate' bits='42'/>

sub element of /domain/cpu, which allows specifying the guest virtual CPU
address size. This can be useful if the guest needs to have a large amount
of memory.

If mode='passthrough', the virtual CPU will have the same number of address
bits as the host. If mode='emulate', the mandatory bits attribute specifies
the number of address bits.

Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-08-04 09:04:07 +02:00
Michal Privoznik
67b03faaf1 qemuxml2argvtest: Add negative cases for TPM version
Now that we have all the machinery needed, we can introduce two
simple test cases:

1) only TPM 1.2 is supported, but TPM 2.0 was requested in domain XML,
2) only TPM 2.0 is supported, but TPM 1.2 was requested in domain XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2022-08-04 08:14:43 +02:00
Michal Privoznik
1445f62fce testutilsqemu: Fake TPM versions
Because of v8.5.0-rc1~25 we are already faking TPM support for
domaincaps. Might as well fake supported TPM versions.
The swtpm binary supports both TPM versions since its first
release, but pretend it isn't the case. For QEMU-5.2 and older
pretend only TPM-1.2 is available, QEMU-6.* has both TPM-1.2 and
TPM-2.0 and QEMU-7.0 and newer has only TPM-2.0 available.
This way, domaincaps are more dispersed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2022-08-04 08:13:55 +02:00
Peter Krempa
31699d3914 qemuMonitorOpenUnix: Remove 'retry' argument
All callers now pass false for 'retry' we are guaranteed to have a
monitor socket present. This means that the retry code can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-08-03 14:26:56 +02:00
Peter Krempa
7c849ad518 qemuMonitorTestNew: Call qemuMonitorOpen with 'retry' false
The 'retry' argument makes the monitor connection opening re-try the
connection in case the monitor socket doesn't exist or isn't properly
listening. In case of the test code this can't happen because the socket
is created and made listening in 'qemuMonitorCommonTestNew' which is
called prior to calling 'qemuMonitorOpen'.

We can thus avoit the code which attempts retries in monitor connection.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-08-03 14:26:56 +02:00
Peter Krempa
dce9047496 qemu: monitor: Remove 'timeout' argument from qemuMonitorOpen
The 'timeout' argument is used by 'qemuMonitorOpenUnix' only when the
'retry' argument is true. The callers of 'qemuMonitorOpen' only pass '0'
for timeout when they call it with 'retry' true and use other values
when 'retry' is false and thus ignored.

This means we can remove the argument and simply have it set to the
default value of QEMU_DEFAULT_MONITOR_WAIT.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-08-03 14:26:56 +02:00
Michal Privoznik
271d337a56 testutilsqemu: Mock virTPMSwtpmSetupCapsGet()
In a recent commit of v8.5.0-85-g430ab88ab1 I've made domaincaps
XML report supported TPM versions. This was done by calling
virTPMSwtpmSetupCapsGet(). But this function isn't mocked and
thus domaincapstest calls the real implementation, which tries to
execute swtpm_setup binary. This fails, because
virFindFileInPath() is mocked in such way that it returns NULL
for anything else than qemu-*.

Anyway, while the real binary is not executed after all, we
should mock the function which tries to execute it so that
predictable result is returned.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-08-02 09:03:24 +02:00
Michal Privoznik
23d4684640 qemu_command: Separate domain memory building into a helper
The qemuBuildMachineCommandLine() function is needlessly long.
Separate out parts that generate memory related arguments into
qemuAppendDomainMemoryMachineParams(). Unfortunately, expected
outputs for some qemuxml2argvdata cases needed to be updated
because the order in which arguments are generated is changed.
But there's no functional change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-01 10:36:37 +02:00
Michal Privoznik
b185abe9d9 qemu_command: Separate domain features building into a helper
The qemuBuildMachineCommandLine() function is needlessly long.
Separate out parts that generate arguments based on
domainDef->features[] into
qemuAppendDomainFeaturesMachineParam(). Unfortunately, expected
outputs for some qemuxml2argvdata cases needed to be updated
because the order in which features are generated is changed. But
there's no functional change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-01 10:36:27 +02:00
Michal Privoznik
f7baee531a conf: Validate virDomainMemoryDef::targetNode
Almost all of memory models we currently support allow setting
virDomainMemoryDef::targetNode so that the memory module is
associated with given guest NUMA node. And we do have a check
whether the requested node is within bounds, but it's executed
only when building QEMU's cmd line. Move it into validation
phase.

While this commit is moving the validation to a place that does
not validate all the possible code paths, it's okay, because only
the explicit memory device has user-configurable target node
which could break the assumption.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-01 10:36:15 +02:00
Michal Privoznik
303636e7d0 qemuxml2xmltest: Test memory-hotplug-dimm-addr
After previous commit, when memory-hotplug-dimm-addr.xml file was
fixed, we can also introduce the test case to qemuxml2xmltest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-01 10:36:11 +02:00
Michal Privoznik
2be3d3bb76 qemuxml2argvtest: Switch memory-hotplug-dimm-addr to latest caps
So far, we are testing memory-hotplug-dimm-addr against a set of
explicitly listed capabilities. While this works, lets switch it
to DO_TEST_CAPS_LATEST() so that the latest capabilities are
used. This in turn means, we have to update the <emulator/>
because the latest capabilities don't contain caps for
qemu-system-i386.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-01 10:36:07 +02:00
Michal Privoznik
42ca6d6f33 virjson: Change virJSONValueObjectHasKey() signature
Currently, virJSONValueObjectHasKey() can return one of three
values:

  -1 if passed object type is not VIR_JSON_TYPE_OBJECT,
   0 if the key is not present, and finally
   1 if the key is present.

But, neither of callers is interested in the -1 case. In fact,
some callers call this function treating -1 and 1 cases the same.
Therefore, make the function return just true/false and fix few
callers that explicitly checked for == 1 case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-08-01 10:24:34 +02:00
Daniel P. Berrangé
ef53798ab6 qemu: support use of stateless EFI firmware
When the <loader stateless='yes'/> attribute is set, the QEMU driver
needs to do three things

 - Avoid looking for an NVRAM template
 - Avoid auto-populating an <nvram/> path
 - Find firmware descriptors with mode=stateless instead of mode=split

Note, the first thing happens automatically when we solve the second
thing.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-26 15:41:44 +01:00
Daniel P. Berrangé
578ac25c6a conf: support stateless UEFI firmware
Normally when an UEFI firmware is marked as read-only, an associated
NVRAM file will be created. Some builds of UEFI firmware, however, wish
to remain stateless and so will be read-only, but never have any NVRAM
file. To represent this concept a 'stateless' tristate bool attribute
is introduced on the <loader/> element.

There are rather a large number of permutations to consider.

With default firmware selection

  *  <os/>

     => Historic default, no change

  *  <os>
       <loader stateless='yes'/>
     </os>

     => Explicit version of historic default, no change

  *  <os>
       <loader stateless='no'/>
     </os>

      => Invalid, bios is always stateless

With manual legacy BIOS selection

  *  <os>
       <loader>/path/to/seabios</loader>
       ...
     </os>

     => Historic default, no change

  *  <os>
       <loader stateless='yes'>/path/to/seabios</loader>
       ...
     </os>

     => Explicit version of historic default, no change

  *  <os>
       <loader stateless='no'>/path/to/seabios</loader>
       ...
     </os>

      => Invalid, bios is always stateless

With manual UEFI selection

  *  <os>
       <loader type='pflash'>/path/to/edk2</loader>
       ...
     </os>

     => Historic default, no change

  *  <os>
       <loader type='pflash' stateless='yes'>/path/to/edk2</loader>
       ...
     </os>

     => Skip auto-filling NVRAM / template

  *  <os>
       <loader type='pflash' stateless='no'>/path/to/edk2</loader>
       ...
     </os>

     => Explicit version of historic default, no change

With automatic firmware selection

  *  <os firmware='bios'/>

     => Historic default, no change

  *  <os firmware='bios'>
       <loader stateless='yes'/>
     </os>

     => Explicit version of historic default, no change

  *  <os firmware='bios'>
       <loader stateless='no'/>
     </os>

      => Invalid, bios is always stateless

  *  <os firmware='uefi'/>

     => Historic default, no change

  *  <os firmware='uefi'>
       <loader stateless='yes'/>
     </os>

     => Skip auto-filling NVRAM / template

  *  <os firmware='uefi'>
       <loader stateless='no'/>
     </os>

     => Explicit version of historic default, no change

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-26 15:41:44 +01:00
Peter Krempa
f81d26f3b6 tests: qemucapabilities: Update test data for the qemu-7.1 cycle on x86_64
Update to v7.0.0-2780-g5288bee45f

Notable changes:
 - set-vcpu-dirty-limit/cancel-vcpu-dirty-limit/query-vcpu-dirty-limit command added
 - snapshot-save/snapshot-load command added
 - dirty-sync-missed-zero-copy migration statistic added
 - postcopy-preempt migration feature added
 - the 'copy-before-write' block driver gained:
    - 'cbw-timeout' property
    - 'on-cbw-error' property with values:
        - 'break-guest-write'
        - 'break-snapshot'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2022-07-25 10:50:03 +02:00
Andrea Bolognani
5105409614 qemu: Add IOMMU device alias to command line
Note that we can only do this for intel-iommu and virtio-iommu,
which are configured using -device; smmuv3 is configured using
a machine type property, so there's no room on the command line
for an alias in that case.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-22 17:38:09 +02:00
Jonathon Jongsma
1e9d84d9f9 qemu: introduce capability QEMU_CAPS_MIGRATION_BLOCKED_REASONS
since qemu 6.0, if migration is blocked for some reason, 'query-migrate'
will return an array of error strings describing the migration blockers.
This can be used to check whether there are any devices blocking
migration, etc.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2022-07-21 00:58:06 -04:00
minglei.liu
3078799fef qemu: support CDROM hotplug cdrom with USB/SCSI bus
QEMU supports hotplug of a cdrom device with USB or SCSI bus. Just
unblock these devices in qemuDomainAttachDeviceDiskLiveInternal() and
qemuDomainDetachPrepDisk().

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/261

Signed-off-by: minglei.liu <minglei.liu@smartx.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-20 16:53:51 +02:00
Jonathon Jongsma
62ca300530 util: remove virObjectUnref() adapters
These wrapper functions were used to adapt the virObjectUnref() function
signature for different callbacks. But in commit 0d184072, the
virObjectUnref() function was changed to return a void instead of a
bool, so these adapters are no longer necessary.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2022-07-15 16:44:39 -05:00
Peter Krempa
d531b9c724 qemu: monitor: Remove unused migration property getters/setters
The getters/setters for individual properties of migration
speed/downtime/cache size are unused once we switched to setting them
purely via migration parameters. Remove the unused helpers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-15 15:57:10 +02:00
Peter Krempa
e2b86ffa19 qemu: capabilities: Retire QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-15 15:57:10 +02:00
Peter Krempa
af2d983567 qemu: capabilties: Retire QEMU_CAPS_MIGRATION_PARAM_DOWNTIME
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-15 15:57:10 +02:00
Peter Krempa
ce761753d3 qemu: capabilities: Retire QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH
The parameter is supported since qemu-2.8.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-15 15:57:10 +02:00
Michal Privoznik
265d49896d qemu: Generate cmd line for guestReset
QEMU offers two attributes for handling reset requests of an USB
host device: guest-reset and guest-resets-all. When combined they
act as follows:

1) guest-reset=false
   The guest is not allowed to reset the physical USB device.

2) guest-reset=true,guest-resets-all=false
   The guest is allowed to reset the device when it is not yet
   initialized (aka no USB bus address assigned). Usually this results
   in one guest reset being allowed. This is the default behavior.

3) guest-reset=true,guest-resets-all=true
   The guest is allowed to reset the device as it pleases.

Now, there's a clear 1:1 mapping with our representation of
guestReset, so generating cmd line is trivial.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-13 16:01:14 +02:00
Michal Privoznik
0738d339a3 qemu_capabilities: Track usb-host.guest-resets-all capability
We will need two attributes of usb-host device to set:
guest-reset and guest-resets-all. The former was introduced in
QEMU v4.0.0-rc0~56^2 and the other in v4.2.0-rc1~9^2. Hence,
track the latter only as it's only starting from that commit when
QEMU has both attributes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-13 16:00:59 +02:00
Michal Privoznik
85ea114016 conf: Introduce @guestReset to hostdev's <source/>
Some USB devices have a buggy firmware that either crashes on
device reset, or make the device unusable in some other way.
Fortunately, QEMU offers a way to skip device reset either
completely, or if device is not initialized yet. Expose this
ability to users under:

    <hostdev mode='subsystem' type='usb'>
      <source guestReset='off'/>
    </hostdev>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-13 16:00:50 +02:00
Michal Privoznik
dcfbfffd6a tests: Fix qemu replies wrt usb-host properties
My commit of v6.9.0-rc1~457 was a bit too harsh. While it served
its purpose (adding usb-host.hostdevice capability) it has a side
effect: because I copied reply from qemu-5.1.0 to older .replies
files one might now think that say qemu-3.1.0 supports both
.guest-reset and .guest-resets-all properties. But in fact it
doesn't. There are three problematic properties:

1) guest-reset, introduced in v4.0.0-rc0~56^2
2) guest-resets-all introduced in v4.2.0-rc1~9^2
3) suppress-remote-wake introduced in v5.0.0-rc0~148^2~4

Remove these properties from versions that could not have had
them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-13 16:00:41 +02:00
Michal Privoznik
94ae42fd25 tests: Update hostdev-usb-* hostdev-pci-* xml2xml and xml2argv tests
Currently, we have bunch of PCI/USB tests cases for
qemuxml2argvtest and qemuxml2xmltest but all of them run without
any capabilities. This makes is needlessly complicated when
trying to extend them. Switch to DO_TEST_CAPS_LATEST().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-13 15:42:08 +02:00
Peter Krempa
f99808ff25 qemuxml2*test: Add 'startupPolicy' fields to aio-io_uring case
Extend the test for io_uring to also test startup policy.

Since the actual logic for dropping disks is in the host preparation
phase, thus skipped for tests we can use any file path.

Add a case also for 'file' backing to have all cases covered.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-13 09:27:06 +02:00
Peter Krempa
9adeafac81 qemucapabilitiestest: Fake proper version for 'caps_4.2.0.aarch64' case
The capabilities for that version were not updated from the development
version and thus would fail our upcoming minimum version change. Fake
the data to report 4.2.0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
7a3f48247e qemucapabilitiestest: Fake proper version for 'caps_4.2.0.ppc64' case
The capabilities for that version were not updated from the development
version and thus would fail our upcoming minimum version change. Fake
the data to report 4.2.0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
8eb8096556 qemu: Remove qemu-4.0 version of 'cpu-translation' test case
The cpu commandline is identical with the '-latest' version so there's
no need for a separate case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
ed150afb4e qemuxml2argvtest: Move real-caps versions of cpu-host tests out of the block setting fake host cpu
Make it obvious that the fake cpu does not apply to the test cases based
on real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
061224892c qemuxml2argvtest: Make 'qemu-ns' test case more stable
The test was showing that the 'blockdev' capability is properly added
although we didn't detect it yet. Unfortunately this test can't be
carried over once we bump minimum qemu version to qemu-4.2.

Make the test case future-proof by removing the qemu-4.0.0 version which
would become pointless and use only already deprecated capability flags
so that the test output does not change.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
5177143117 qemuxml2argvtest: Convert 'net-user' case to _LATEST
The tested net device has the same syntax with latest qemu so there's no
need to have a version-locked test for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
dc231a1d38 qemuxml2argvtest: Remove qemu-4.0 versions of cpu feature test cases
The cpu feature formatting doesn't change between the versions thus we
can just keep the '-latest' versions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
5579ff564b qemuxml2argvtest: Convert 'cpu-eoi-(disabled|enabled)' cases to VIR_TEST_CAPS_LATEST
The tested feature doesn't change across versions so we can use the
modern testing infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
92f1f61e5b qemuxml2argvtest: Drop 'qemu-4.1' versions of hyperv tests
The version-locked version of the test data is identical to the 'latest'
version so we can remove them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
dcd30a3bf3 qemuxml2(argv|xml)test: Drop qemu-3.1 version of 'cpu-Icelake-Server-pconfig'
Prior to qemu-3.2 we'd have to disable the 'pconfig' feature explicitly
which is no longer needed with new qemu. Remove the version locked to
qemu-3.1 as the 'latest' case sufficiently handles what we want to test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:28 +02:00
Peter Krempa
48e049dca3 test: domaincaps: Remove old test data
Remove the test data for qemu-2.11, qemu-2.12 and qemu-3.0 which are no
longer supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-11 12:48:27 +02:00
Peter Krempa
ebe0e34b64 storagepoolxml2argvtest: Fix output data for 'pool-netfs-protocol-ver'
The storage pool tests have host-specific versions which I neglected to
update in commit c44930d932 thus breaking
the test-suite on non-linux OSes.

Fixes: c44930d932
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2022-07-01 16:53:08 +02:00
Peter Krempa
c44930d932 storage: pool: Allow more intricate nfs protocol versions
Treat the 'protocolVer' field as a string so that e.g. '4.1' can be
used. Forbid only ',' in the string as it's a separator of arguments for
mount options.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-01 16:15:23 +02:00
Andrea Bolognani
262672dbbf qemu_firmware: Enable loader.secure when requires-smm
Currently, a firmware configuration such as

  <os firmware='efi'>
    <firmware>
      <feature enabled='yes' name='enrolled-keys'/>
    </firmware>
  </os>

will correctly pick a firmware that implements the Secure Boot
feature and initialize the NVRAM file so that it contains the
keys necessary to enforce the signing requirements. However, the
lack of a

  <loader secure='yes'/>

element makes it possible for pflash writes to happen outside
of SMM mode. This means that the authenticated UEFI variables
where the keys are stored could potentially be overwritten by
malicious code running in the guest, thus making it possible to
circumvent Secure Boot.

To prevent that from happening, automatically turn on the
loader.secure feature whenever a firmware that implements Secure
Boot is chosen by the firmware autoselection logic. This is
identical to the way we already automatically enable SMM in such
a scenario.

Note that, while this is technically a guest-visible change, it
will not affect migration of existings VMs and will not prevent
legitimate guest code from running.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:39 +02:00
Andrea Bolognani
73c5ae55c7 conf: Reject features when using manual firmware selection
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:37 +02:00
Andrea Bolognani
de2a338dce conf: Validate firmware configuration more thoroughly
Generally speaking, when firmware autoselection is in use we
don't want any information to be provided manually. There are
two exceptions:

  * we still want the path to the NVRAM file to be customizable;

  * using <loader secure='yes'/> was how you would ask for a
    firmware that implements the Secure Boot feature in the
    original approach to firmware autoselection, so we want to
    keep that working.

Anything else should result in a descriptive error.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/327
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:34 +02:00
Andrea Bolognani
161b31f958 conf: Reject enrolled-keys=yes with secure-boot=no
This combination doesn't make sense and so the firmware
autoselection logic will not be able to find a suitable firmware,
but it's more user-friendly to report a detailed error upfront.

Note that this check would ideally happen in the validate phase,
but if we moved it there we would no longer be able to
automatically enable secure-boot when enrolled-keys=yes. Since
the combination never resulted in a working configuration, the
chances of this causing real-world VMs to disappear are
extremely low.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:30 +02:00
Andrea Bolognani
6cacfc751e conf: Enable secure-boot when enrolled-keys is enabled
The latter doesn't make sense without the former, so make that
visible in the XML.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:27 +02:00
Andrea Bolognani
9c7499ce54 conf: Always parse NVRAM path if present
Currently, the lack of a <loader> element results in the <nvram>
element being completely ignored, but this is unnecessarily
limiting: even when firmware autoselection is in use, it should
be possible for the user to specify a custom path for the NVRAM
file.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:26 +02:00
Andrea Bolognani
1afc026c73 tests: Add more firmware tests
Note that some of these new tests are displaying incorrect or
suboptimal behavior. When we address those in upcoming patches,
this will be highlighted by changes in the test data.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:16 +02:00
Andrea Bolognani
29bbd927f8 tests: Don't use loader.secure=no with firmware autoselection
This currently has not effect whatsoever, so it's just cluttering
the input files.

We're going to add specific handling for this scenario, as well
as a test case covering it, in an upcoming commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:14 +02:00
Andrea Bolognani
2ce1dcc6b5 tests: Don't set NVRAM path manually
This does the opposite of

  commit 392292cd99
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Feb 23 12:45:51 2022 +0000

    tests: don't use auto-generated NVRAM path in tests

in order to minimize input files.

We're going to add a test case specifically covering the use of
custom NVRAM paths with firmware autoselection in an upcoming
commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:13 +02:00
Andrea Bolognani
53cdfd7994 tests: Use minimal hardware for firmware tests
When testing firmware selection, we don't really care about any
of the hardware assigned to the VM, and in fact it's better to
keep it as minimal as possible to make sure that the focus
remains on the firmware bits.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:12 +02:00
Andrea Bolognani
f29a8bcef1 tests: Rename and reorganize firmware tests
Group all tests related to firmware selection together and give
them consistent names that leave room for further tests to be
added in an upcoming commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:10 +02:00
Andrea Bolognani
acb8733924 tests: Drop bios-nvram-os-interleave test
This was introduced in

  commit 5882064084
  Author: Martin Kletzander <mkletzan@redhat.com>
  Date:   Wed Feb 25 15:45:26 2015 +0100

    tests: Add test for os interleaving

to ensure a recent change in the schema was behaving correctly.

Seven years later, it no longer seems very useful to keep it
around.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:09 +02:00
Andrea Bolognani
031f379573 tests: Use firmware autoselection on aarch64
This simplifies the test data without negatively impacting test
coverage.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:10:05 +02:00
Andrea Bolognani
c76e595131 tests: Remove firmware bits from unrelated tests
The pci-bridge-many-disks test case is not related to firmware
handling at all, so we can trim it without losing any coverage.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 15:09:50 +02:00
David Michael
9f13f54a63 security_selinux.c: Relabel existing mode="bind" UNIX sockets
This supports sockets created by libvirt and passed by FD using the
same method as in security_dac.c.

Signed-off-by: David Michael <david@bigbadwolfsecurity.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 14:51:19 +02:00
Michal Privoznik
09010f7e76 virnettlscontext: Don't set DH parameters ourselves
According to [1]:

  Prior to GnuTLS 3.6.0 for the ephemeral or anonymous
  Diffie-Hellman (DH) TLS ciphersuites the application was
  required to generate or provide DH parameters. That is no
  longer necessary as GnuTLS utilizes DH parameters and
  negotiation from [RFC7919].

This allows us to:

  a) drop the code that's setting DH params,
  b) drop @dhParams member from _virNetTLSContext struct. and
  c) drop gnutls_dh_params_generate2() mock.

1: https://www.gnutls.org/manual/html_node/Parameter-generation.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-01 13:04:59 +02:00
Michal Privoznik
91e96ab71a virnetdevbandwidthtest: Test QoS for OVS
Ever since v7.6.0-rc1~235 we can use ovs-vsctl to set QoS instead
of tc. However, we don't have a test that's verifying generated
cmd line for ovs-vsctl.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-07-01 13:04:18 +02:00
Michal Privoznik
5f6aa07303 virnetdevbandwidthtest: Reformat TC cmd line
Our coding style expects a long line to be broken into shorter
lines which are then aligned on the first character, for
instance:

  "some string that's broken "
  "into multiple lines"

However, one can argue that there are few cases where shifting
the alignment makes the code more readable. And this is the case
of expected cmd line for DO_TEST_SET() where a long cmd line can
be aligned on the arguments rather than the binary:

  TC " filter ..."
     " police ..."

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-07-01 13:04:18 +02:00
Michal Privoznik
5c5ca1970f virnetdevbandwidthtest: Drop unused testMinimalStruct
The last usage of the testMinimalStruct struct was removed in
v1.2.2-rc1~206 which forgot to remove the struct as well. Remove
it now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-07-01 13:04:17 +02:00
Michal Privoznik
b7ab6a6bd6 virnetdevbandwidthtest: Drop unnecessary brackets
Some cases that call DO_TEST_SET() macro wrap each argument in
curved brackets. This is unnecessary, drop the brackets.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-07-01 13:04:17 +02:00
Jiri Denemark
766abdc291 qemu_migration: Apply max-postcopy-bandwidth on post-copy resume
When resuming post-copy migration users may want to limit the bandwidth
used by the migration and use a value that is different from the one
specified when the migration was originally started.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/333

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 11:28:34 +02:00
Peter Krempa
170eccd03c qemucapabilitiestest: Update capabilities for the 7.1 release cycle on x86_64
Update to v7.0.0-2187-g2a8835cb45

Notable changes:
    - VFU_CLIENT_HANGUP event added
    - query-stats and query-stats-schemas commands added
    - 'vduse-blk' block export export
    - 'loongarch64' arch added
    - added new qom types:
        - cxl-downstream
        - cxl-upstream
        - qio-channel-block
        - qio-channel-null
    - added smi-irq[0], smm-enabled, unnamed-gpio-out[0] properties for PIIX4_PM

    - removed:
        - piix3-ide-xen

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-29 15:37:40 +02:00
Ján Tomko
28337e9485 tests: remove pointless label in testURIParse
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-22 12:28:29 +02:00
Ján Tomko
8d9bd178e2 Use g_auto for virURI almost everywhere
Convert all the cases where we can unconditionally free
the virURI at the end of scope.

In libxlDomainMigrationDstPrepare, uri is only filled
if uri_in was present, so moving the virURIFree out of
the condition is safe.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-22 12:28:29 +02:00
Cole Robinson
8b09303f24 tests: mock swtpm initialization for all qemu tests
Don't restrict this to domcaps testing only, we will soon
need it for qemu command line validation

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-21 08:23:18 -04:00
Cole Robinson
812edc95a3 conf: cpu: Add <signature family=X model=X stepping=X/>
Internally we already collect x86 host family + model + stepping
numeric values. This exposed them in capabilities CPU output.
Example:

$ sudo virsh capabilities | grep -A1 -B1 signature
      <microcode version='240'/>
      <signature family='6' model='94' stepping='3'/>
      <counter name='tsc' frequency='3408010000' scaling='no'/>

Users need to know these values to calculate an expected.
SEV-ES/SEV-SNP launch measurement.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-16 12:12:45 -04:00
Ján Tomko
0df2e7df80 conf: virtiofs: add thread_pool element
Add an element to configure the thread pool size:

...
<binary>
  <thread_pool size='16'/>
</binary>
...

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-16 14:58:25 +02:00
Peng Liang
48e8c36b05 tests: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-16 06:43:58 +02:00
Rohit Kumar
d762abfe3f Add unit tests for new specification of nvram.
This patch adds unit tests for remote NVRAM.

Examples:

<nvram type='network'>
  <source protocol='iscsi' name='iqn.2013-07.com.example:iscsi-nopool/0'>
    <host name='example.com' port='6000'/>
    <auth username='myname'>
      <secret type='iscsi' usage='mycluster_myname'/>
    </auth>
  </source>
</nvram>

and

<nvram type='network'>
  <source protocol='nbd' name='bar'>
    <host name='example.org' port='6000'/>
  </source>
</nvram>

and

<nvram type='file'>
  <source file='/var/lib/libvirt/nvram/guest_VARS.fd'/>
</nvram>

Signed-off-by: Prerna Saxena <prerna.saxena@nutanix.com>
Signed-off-by: Florian Schmidt <flosch@nutanix.com>
Signed-off-by: Rohit Kumar <rohit.kumar3@nutanix.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Rohit Kumar <rohit.kumar3@nutanix.com>
2022-06-14 15:53:11 +02:00
Michal Privoznik
425d3b12a4 qemu: Generate command line for <defaultiothread/> pool size
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2059511
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-10 14:01:08 +02:00
Michal Privoznik
3e4bebb9d1 conf: Introduce <defaultiothread/>
As of v7.0.0-877-g70ac26b9e5 QEMU exposes its default event loop
for devices with no IOThread assigned as an QMP object. In the
very next commit (v7.0.0-878-g71ad4713cc) it was extended for
thread-pool-min and thread-pool-max attributes. Expose them under
new <defaultiothread/> element.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-10 14:01:03 +02:00
Michal Privoznik
86c10f81e5 qemu: Generate command line for IOThread pool size
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-10 14:00:13 +02:00
Michal Privoznik
38a67a9a9e qemu: Introduce QEMU_CAPS_IOTHREAD_THREAD_POOL_MAX
This capability reflects whether QEMU allows setting
thread-pool-min and thread-pool-max attributes on iothread
object. Since both attributes were introduced in the same commit
(v7.0.0-878-g71ad4713cc) and can't exist independently of each
other we can stick with one capability covering both of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-10 14:00:08 +02:00
Michal Privoznik
568503edf1 conf: Introduce thread_pool_min and thread_pool_max attributes to IOThread
At least in case of QEMU an IOThread is actually a pool of
threads (see iothread_set_aio_context_params() in QEMU's code
base). As such, it can have minimal and maximal number of worker
threads. Allow setting them in domain XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-10 13:59:46 +02:00
Jiri Denemark
01d65a1520 qemu: Implement VIR_DOMAIN_ABORT_JOB_POSTCOPY flag
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:21 +02:00
Jiri Denemark
8c4da941c0 qemu: Add support for migrate-recover QMP command
This command tells QEMU to start listening for an incoming post-copy
recovery connection. Just like migrate-incoming is used for starting
fresh migration on the destination host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
7c36e5004c qemu: Restore async job start timestamp on reconnect
Jobs that are supposed to remain active even when libvirt daemon
restarts were reported as started at the time the daemon was restarted.
This is not very helpful, we should restore the original timestamp.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
8cd5edfdfe qemumonitorjsontest: Test more migration capabilities
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:19 +02:00
Peter Krempa
0e3f42b834 qemucapabilitiestest: Update latest caps to 'v7.0.0-1512-gca127b3fc2'
Notable changes:

 - Icelake-Client cpu model family removed:
     "Icelake-Client-noTSX-x86_64-cpu"
     "Icelake-Client-v1-x86_64-cpu"
     "Icelake-Client-v2-x86_64-cpu"
     "Icelake-Client-v3-x86_64-cpu"
     "Icelake-Client-x86_64-cpu"

 - 'zero-copy-send' migration feature added

 - display 'sdl' qapified

 - 'arch-lbr' cpu feature added

 - new HyperV enlightenments:
     'hv-tlbflush-ext'
     'hv-tlbflush-direct'
     'hv-emsr-bitmap'
     'hv-xmm-input'

 - 'none-machine' has two new properties:
     - "boot" described as "Boot configuration"
     - "memory" described as "Memory size configuration"

 - 'igd-passthrough-isa-bridge' is now Xen-only

 - CXL: Compute eXpress Link related devices:
      "CXL"
      "cxl-rp",
      "cxl-type3",
      "pxb-cxl",
      "pxb-cxl-bus",
      "pxb-cxl-host",

 - 'dma-translation' feature of 'intel-iommu'

 - 'vmcb-clean' cpu feature now migratable:
     - possibly due to host kernel upgrade
     - changes commandline generated for the 'cpu-host-model' case of
       qemuxml2argvtest

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-06-07 13:00:56 +02:00
Tim Wiederhake
1b05f2e50b Fix typos
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-01 09:55:48 +02:00
Michal Privoznik
12be42ee7e network: Generate TFTP config regardless of DHCP
We already allow users to provide TFTP root path in network XML
and not specify any DHCP. This makes sense, because dnsmasq is
not only DHCP server but also TFTP server and users might have
a DHCP server configured on their own, outside of libvirt's
control and want just the TFTP part.

By moving TFTP config generator out of DHCP generator and calling
it for every IPv4 range, users can finally enable just TFTP.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2026765
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-01 09:40:40 +02:00
Michal Privoznik
f344005547 lib: Be consistent about vm->pid
The virDomainObj struct has @pid member where the domain's
hypervisor PID is stored (e.g. QEMU/bhyve/libvirt_lxc/... PID).
However, we are not consistent when it comes to shutoff state.
Initially, because virDomainObjNew() uses g_new0() the @pid is
initialized to 0. But when domain is shut off, some functions set
it to -1 (virBhyveProcessStop, virCHProcessStop, qemuProcessStop,
..).

In other places, the @pid is tested to be 0, on some other places
it's tested for being negative and in the rest for being
positive.

To solve this inconsistency we can stick with either value, -1 or
0. I've chosen the latter as it's safer IMO. For instance if by
mistake we'd kill(vm->pid, SIGTERM) we would kill ourselves
instead of init's process group.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-06-01 09:35:26 +02:00
Michal Privoznik
7f463b4c0d nss: Compare hostname case insensitive
There are some tools that convert hostname to lowercase before
resolving it (e.g. ssh). In a way it makes sense because DNS is
case insensitive and in case of ssh the lowercase version is then
used to find matching record in its config file. However, our NSS
module performs case sensitive comparison, which makes it useless
with ssh. Just consider a machine named FooBar.

Therefore, switch to case insensitive string comparison.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1777873
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-05-27 13:43:14 +02:00
Daniel Henrique Barboza
316de7eb12 cpu_ppc64: add support for host-model on POWER10
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2022-05-24 14:25:41 -03:00
Daniel Henrique Barboza
38dba6a02e cpu_map: add POWER10 cpu model
Add POWER10 as a supported cpu model.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2022-05-24 14:25:41 -03:00
Jiri Denemark
76baf935aa qemu: Do not pass unused opaque pointer to monitor callbacks
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-24 16:26:04 +02:00
Andrea Bolognani
7de9b74a84 src: Use archive.org for dead URLs
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-24 12:19:18 +02:00
Daniel Henrique Barboza
a46ff97762 qemuxml2argvtest.c: use CAPS_ARCH_LATEST() with pseries-cpu-compat-power9
Use the newly added ARG_CAPS_HOST_CPU_MODEL to set which host CPU we
expect the test to use - the test should fail when using a POWER8 host
cpu but complete when using a POWER9 host cpu.

Two new macros were added because we will be adding similar tests in the
near future when adding support for the Power10 chip.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2022-05-23 19:25:09 -03:00
Daniel Henrique Barboza
a678430492 testutilsqemu: introduce ARG_CAPS_HOST_CPU_MODEL
When loading a latest caps for an arch for the first time the following
occurs in testQemuInfoInitArgs():

- the caps file is located. It's not in the cache since it's the first time
it's being read;
- the cachecaps are retrieved using qemuTestParseCapabilitiesArch() and
stored in the capscache;
- FLAG_REAL_CAPS is set and regular flow continues.

Loading the same latest caps for the second time the caps are loaded from the
cache, skipping qemuTestParseCapabilitiesArch(). By skipping this function it
means that it also skips virQEMUCapsLoadCache() and, more relevant to
our case, virQEMUCapsInitHostCPUModel(). This function will use the
current arch and cpuModel settings to write the qemuCaps that are being
stored in the cache. And we're also setting FLAG_REAL_CAPS, meaning that
we won't be updating the qemucaps host model via testUpdateQEMUCaps() as
well.

This has side-effects such as:

- the first time the latest caps for an arch is loaded determines the
cpuModel it'll use during the current qemuxml2argvtest run. For
example, when running all tests, the first time the latest ppc64 caps
are read is on "disk-floppy-pseries" test. Since the current host arch
at this point is x86_64, the cpuModel that will be set for this
capability is "core2duo";

- every other latest arch test will use the same hostCPU as the first
one set since we read it from the cache after the first run.
qemuTestSetHostCPU() makes no difference because we won't update the
host model due to FLAG_REAL_CAPS being set. Using the previous example,
every other latest ppc64 test that will be run will be using the
"core2duo" cpuModel.

Using fake capabilities (e.g. using DO_TEST()) prevents FLAG_REAL_CAPS to
be set, meaning that the cpuModel will be updated using the current
settings the test is being ran due to testUpdateQEMUCaps().

Note that not all latest caps arch tests care about the cpuModel being
set to an unexpected default cpuModel. But some tests will care, e.g.
"pseries-cpu-compat-power9", and changing it from DO_TEST() to
DO_TEST_CAPS_ARCH_LATEST() will make it fail every time the
"disk-floppy-pseries" is being ran first.

One way of fixing it is to rethink all the existing logic, for example
not setting FLAG_REAL_CAPS for latest arch tests. Another way is
presented here. ARGS_CAPS_HOST_CPU_MODEL is a new testQemuInfo arg that
allow us to set any specific host CPU model we want when running latest
arch caps tests. This new arg can then be used when converting existing
DO_TEST() testcases to DO_TEST_CAPS_ARCH_LATEST() that requires a
specific host CPU setting to be successful, which we're going to do in
the next patch with "pseries-cpu-compat-power9".

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2022-05-23 19:24:42 -03:00
Daniel Henrique Barboza
eca2a6cc92 qemuxml2xmltests.c: convert pseries tests to DO_TEST_CAPS_ARCH_LATEST
qemuxml2xmltests that have "pseries" in the name now use the
DO_TEST_CAPS_LATEST_ARCH() macro.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2022-05-23 19:19:16 -03:00
Boris Fiuczynski
127fda5e84 nodedev: add tests for optional device address to css device
Add nodedev schema parsing and format tests for the optional new device
address on the css devices.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-23 16:32:44 +02:00
Marc-André Lureau
3fa987cc42 qemu: add usbredir type 'dbus'
The USB device redirection works in a similar way as Spice. The
underlying 'dbus' channel is set to "org.qemu.usbredir" by default for
the client to identify the channel purpose (as specified in -display
dbus documentation).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:40 +02:00
Marc-André Lureau
53905292f9 qemu: add -chardev dbus support
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:37 +02:00
Marc-André Lureau
7648e40da5 conf: add <serial type='dbus'>
Like a Spice port, a dbus serial must specify an associated channel name.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:35 +02:00
Marc-André Lureau
1ce258a570 qemu: add audio type 'dbus'
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:32 +02:00
Marc-André Lureau
a062f5f777 conf: add <audio type='dbus'> support
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:28 +02:00
Marc-André Lureau
bde66322e8 qemu: add -display dbus support
By default, libvirt will start a private bus and tell QEMU to connect to
it. Instead, a D-Bus "address" to connect to can be specified, or the
p2p mode enabled.

D-Bus display works best with GL & a rendernode, which can be specified
with <gl> child element.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:20 +02:00
Marc-André Lureau
88ba34f5a0 conf: add <graphics type='dbus'>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:09 +02:00
Marc-André Lureau
14f45e5d8d qemu: add -display dbus capability check
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:35:26 +02:00
Peter Krempa
15bdced9b3 qemu: Use 'qemuFDPassDirect' for 'unix' chardevs
Unix socket chardevs with FD passing need to use the direct mode so we
need to convert it to use qemuFDPassDirect.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-17 19:31:08 +02:00
Peter Krempa
7869eb9b31 qemu: Convert passing of 'vhostfd' to 'qemuFDPassDirect'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-17 19:31:07 +02:00
Peter Krempa
fcd7741c48 qemuBuildCommandLine: Remove 'flags' argument
The flags are not used for anything.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-05-17 19:31:07 +02:00
Peter Krempa
2afaa6894e qemuBuildCommandLine: Inline qemuCheckFips
Now that we store the state of the host FIPS mode setting in the qemu
driver object, we don't need to outsource the logic into
'qemuCheckFips'.

Additionally since we no longer support very old qemu's which would not
yet have --enable-fips we can drop the part of the comment about very
old qemus.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-05-17 19:31:07 +02:00
Peter Krempa
9b765882cd qemuBuildCommandLine: Remove 'driver' argument
We pass 'vm' which already contains it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-05-17 19:31:07 +02:00
Peter Krempa
b5fd6f2b68 qemu: Store state of FIPS in virQEMUDriver
Rather than re-query all the time we can cache the state of FIPS of the
host as it will not change during the runtime of the guest.

Introduce a 'hostFips' flag to 'virQEMUDriver' and move the code
checking the state from 'qemuCheckFips' to 'qemuStateInitialize' and
also populate 'hostFips' in qemuxml2argvtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-05-17 19:31:07 +02:00
Peter Krempa
552790edf2 qemuBuildCommandLine: Convert 'standalone' flag to use 'flags'
Introduce 'qemuBuildCommandLineFlags' and use it instead of specific
flag booleans.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-05-17 19:31:07 +02:00
Peter Krempa
7bbfabc6b2 qemu: Implement 'absolute' clock offset mode
Add support for the mode and add the corresponding qemuxml2argv test
case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-17 19:30:59 +02:00
Peter Krempa
d53e75aad0 conf: Introduce 'absolute' clock offset
The 'absolute' clock offset type has a 'start' attribute which is an
unix epoch timestamp to which the hardware clock is always set at start
of the VM.

This is useful if some VM needs to be kept set to an arbitrary time for
e.g. testing or working around broken software.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-17 19:30:59 +02:00
Andrea Bolognani
b6705cdefb conf: Fix smm=off handling
We have to always store the state of the feature in the
virDomainDef struct, otherwise

  <smm state='off'/>

will incorrectly be interpreted as if the <smm> element was not
present.

Fixes: eeb94215b0
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 14:29:11 +02:00
Andrea Bolognani
a6ea77e0a5 tests: Introduce smm=off test
This complements the existing smm=on tests. Looking at the output
files, one can immediately see how this case is currently not being
handled correctly. We're going to fix that in the next commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 14:29:09 +02:00
Andrea Bolognani
dd3258da09 tests: Update smm=on test
Use DO_TEST_CAPS_LATEST() instead of hardcoding capabilities and
add the xml2xml part, which was missing; finally, rename it to
accomodate the complementary smm=off test that we're about to
introduce.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 14:29:04 +02:00
Peter Krempa
f59a707d2c qemu: Move opening of vhost file descriptors for net devices into qemuBuildInterfaceConnect
Use the new infrastructure which stores the fds inside 'qemuFDPass'
objects in the private data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 09:15:46 +02:00
Peter Krempa
55485c56a4 qemuBuildHostNetProps: Move all 'tap' code together
Move the block guarded by 'is_tap' boolean to the only place where
'is_tap' is set to true.

This causes few arguments to change places.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 09:15:46 +02:00
Peter Krempa
1e925d1c17 qemu_fd: Don't rely on fdset id allocation by qemu
If we use our own fdset ID when hot-adding a fdset we can vastly
simplify our internals.

As a stop-gap when a fdset would be added behind libvirt's back we'll
validated that the fdset to be added is not yet used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 09:15:45 +02:00
Peter Krempa
278c630d2a qemu: domain: Store and update 'fdsetindex' across libvirtd restarts
While 'add-fd' qmp command gives the possibility to find an unused fdset
ID when hot-adding fdsets, such usage is extremely inconvenient.

This patch allows us to track the used fdset id so that we can avoid the
need to check results and thus employ simpler code flow when hot-adding
devices which use FD passing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 09:15:45 +02:00
Peter Krempa
5077263ecb qemu_fd: Remove error checking from qemuFDPassAddFD
It's effectively replaced by checks in qemuFDPassTransfer. This will
simplify cleanup paths on constructing the qemuFDPass object when FDs
are being handled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 09:15:45 +02:00
Peter Krempa
bcfd23b762 qemu_fd: Add return value handling for qemuFDPassTransfer* APIs
Add possibility to delay checks to the point when the FDs are to be
passed to qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-16 09:15:45 +02:00
Jiri Denemark
b5fd70b367 qemu: Drop QEMU_CAPS_MIGRATION_EVENT
All QEMU versions we care about already support migration events.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-05-12 16:25:57 +02:00
Martin Kletzander
90d36d625e tests: Adjust for invalid qemu command combinations
Everything spice is not supported (and does not make sense) without spice
graphics.  For some tests I also added cirrus VGA capability so that the XML
stays simple and libvirt can guess a default video model rather than adding too
much of an irrelevant XML into the individual tests.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-12 10:20:36 +02:00
Martin Kletzander
d00e51e10c Remove serial-spiceport-nospice test
This old test was added by me to allow people to keep the spicevmc
channel while changing graphics type from spice to something else.
However we do not do this in other places and also now we have all the
Validate functions so it is better to show the user they will not have
the spicevmc channel available rather than simply not formatting it on
the qemu command line.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-12 10:20:36 +02:00
Jonathon Jongsma
2ba73a10fd qemu: add support for qemu-vdagent channel
Implement the qemu-vdagent channel introduced in the previous commit.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-10 11:00:16 -05:00
Jonathon Jongsma
05b09f039e conf: add qemu-vdagent channel
Add the ability to configure a qemu-vdagent in guest domains. This
device is similar to the spice vdagent channel except that qemu handles
the spice-vdagent protocol messages itself rather than routing them over
a spice protocol channel.

The qemu-vdagent device has two notable configuration options which
determine whether qemu will handle particular vdagent features:
'clipboard' and 'mouse'.

The 'clipboard' option allows qemu to synchronize its internal clipboard
manager with the guest clipboard, which enables client<->guest clipboard
synchronization for non-spice guests such as vnc.

The 'mouse' option allows absolute mouse positioning to be sent over the
vdagent channel rather than using a usb or virtio tablet device.

Sample configuration:
  <channel type='qemu-vdagent'>
    <target type='virtio' name='com.redhat.spice.0'/>
    <source>
      <clipboard copypaste='yes'/>
      <mouse mode='client'/>
    </source>
  </channel>

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-10 11:00:15 -05:00
Jonathon Jongsma
b6dfb216c9 qemu: add capability for qemu-vdagent chardev
Detect whether qemu supports the qemu-vdagent character device. This
enables support for copy/paste with VNC graphics.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-10 11:00:13 -05:00
Peter Krempa
dfba8b3645 qemucapabilitiestest: Add test data for the qemu-7.1 dev cycle on x86_64
Notable schema changes:

 - 'cluster-id' is now reported for CPU topology
 - 'display-update' QMP command added
 - 'main-loop' QOM object added with a whole set of properties
 - 'cpu0-id' field reported in SEV data
 - 'blockdev-change-medium' command now has 'force' property
 - 'screendump' QMP command now has a 'format' property
    - supported formats are 'ppm' and 'png'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-10 14:02:31 +02:00
Jonathon Jongsma
728c75b93f conf: ensure only one vgpu has ramfb enabled
Validate the domain configuration to ensure that if there are more than
one vgpu assigned to a domain, only one of them has 'ramfb' enabled.

This was never a supported configuration. QEMU failed confusingly when
attempting to start a domain with this configuration. This change
attempts to provide better information about the error.

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

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-05-09 14:39:43 -05:00
Daniel Henrique Barboza
ae373781a4 tests: qemucapabilities: update ppc64 qemu caps for 7.0.0 release
There are no major changes since 7.0.0-rc2, but a few additional
features are enabled in this build.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-05-09 15:13:37 +02:00
Jiri Denemark
bb6cedd208 cpu_x86: Ignore enabled features for input models in x86DecodeUseCandidate
While we don't want to aim for the shortest list of disabled features in
the baseline result (it would select a very old model), we want to do so
while looking at any of the input models for which we're trying to
compute a baseline CPU model. Given a set of input models, we always
want to take the least capable one of them (i.e., the one with shortest
list of disabled features) or a better model which is not one of the
input models.

So when considering an input model, we just check whether its list of
disabled features is shorter than the currently best one. When looking
at other models we check both enabled and disabled features while
penalizing disabled features as implemented by the previous patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 17:33:47 +02:00
Jiri Denemark
48341b025a cpu_x86: Penalize disabled features when computing CPU model
For finding the best matching CPU model for a given set of features
while we don't know the CPU signature (i.e., when computing a baseline
CPU model) we've been using a "shortest list of features" heuristics.
This works well if new CPU models are supersets of older models, but
that's not always the case. As a result it may actually select a new CPU
model as a baseline while removing some features from it to make it
compatible with older models. This is in general worse than using an old
CPU model with a bunch of added features as a guest OS or apps may crash
when using features that were disabled.

On the other hand we don't want to end up with a very old model which
would guarantee no disabled features as it could stop a guest OS or apps
from using some features provided by the CPU because they would not
expect them on such an old CPU.

This patch changes the heuristics to something in between. Enabled and
disabled features are counted separately so that a CPU model requiring
some features to be disabled looks worse than a model with fewer
disabled features even if its complete list of features is longer. The
penalty given for each additional disabled feature gets bigger to make
longer list of disabled features look even worse.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 17:33:47 +02:00
Jiri Denemark
63d633b9a4 cputest: Add some real world baseline tests
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 17:33:46 +02:00
Jiri Denemark
3daa68e265 cputest: Give better names to baseline tests
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 17:33:46 +02:00
Jiri Denemark
6aff36019b cputest: Drop some old artificial baseline tests
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 17:33:46 +02:00
Jiri Denemark
d2e4d66be3 cpu_map: Disable cpu64-rhel* for host-model and baseline
These ancient RHEL-only CPU models should not really be used by any CPU
definition created by libvirt. We keep them just for backwards
compatibility with domains which might still be using them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 17:33:46 +02:00
Michal Privoznik
776e9a6b26 testutilsqemu: Write getter/setter for CPU def global variables
As of 47503cc859 we are statically linking libtest_utils_qemu.a
into qemuhotplugmock.so (see the original commit for reasoning).
However, this breaks ASAN on older clang because now
qemuhotplugtest has two instances of virCPUDef global variables
(cpuDefault, cpuHaswell, cpuPower8, cpuPower9). One that comes
from the binary itself (which also links with
libtest_utils_qemu.a) and the other from the mock. Resolve this
by making the variables static and introducing getter and setter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-05-06 12:19:34 +02:00
Michal Privoznik
dff4b21585 testutils: Write setter for virTestHostArch global variable
As of 47503cc859 we are statically linking libtest_utils.a into
qemuhotplugmock.so (see the original commit for reasoning).
However, this breaks ASAN on older clang because now
qemuhotplugtest has two instances of virTestHostArch global
variable. One that comes from the binary itself (which also links
with libtest_utils.a) and the other from the mock. Resolve this
by making the variable static and introducing getter and setter.
Well, the former already exists (as virArchFromHost()) so only
the latter is needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-05-06 12:16:15 +02:00
Michal Privoznik
5e5d030b1c tests: Deduplicate some WITH_* checks
When constructing mock_libs array it is firstly initialized to a
static set of mocks followed by couple of WITH_* checks to append
driver specific mocks. These checks are then repeated when
filling some other variables (e.g. supplementary helpers,
libraries, tests, etc.). Dissolve the former in the latter since
we are already doing that, partially, for qemu (qemucapsprobemock
and qemuhotplugmock)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-05 13:26:32 +02:00
Michal Privoznik
47503cc859 test: Link qemuhotplugmock with test_utils_qemu and test_utils
As of ad81aa8ad0 the qemuhotplugmock.c calls
testQemuPrepareHostBackendChardevOne() which is implemented in
testutilsqemu.c. However, the mock is not linked with
testutilsqemu static library which makes some tools (valgrind
particularly) unhappy because the resulting mock library has
unresolved symbol.

The fix is simple, link mock library with test_utils_qemu_lib and
also with test_utils_lib since testutils.c calls some functions
from testutils.c.

Since these two libraries are declared only after mock_libs[], I
had to move the line that declares qemuhotplugmock after those
two.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-05-05 13:26:23 +02:00
Martin Kletzander
97ef63860a tests: Add test for missing network attribute in graphics' listen element
This tests a change done in commit 871a071abb.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2022-05-04 16:11:43 +02:00
Daniel P. Berrangé
a055308668 tests: don't set G_DEBUG=fatal-warnings on macOS
On macOS when BROKEN_POLL is set in GLib, our tests will periodically
trigger a warning:

  (process:50880): GLib-WARNING **: 02:54:15.272: poll(2) failed due to: Bad file descriptor.

Our code is inherantly racy, calling g_source_destroy which
removes the FD from the event thread poll asynchronously but
we close the FD immediately after g_source_destroy returns.

With poll() this results in POLLNVAL which we're ignoring, but
with select() it generates the BADF error on macOS.

We need to ignore the warnings on macOS to avoid abort()ing
our test programs.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/303
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-28 13:45:44 +01:00
Peter Krempa
2d345da361 tests: qemucapabilities: Update qemu caps dump for the qemu-7.0.0 release on x86_64
Few minor changes in qemu since the last update:
    - 'cocoa' display and corresponding props (not present in this build)

Changes in build:
    - dbus display driver re-enabled
    - gtk display support re-disabled
    - xen support re-disabled

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-26 09:23:52 +02:00
Peter Krempa
f0c3398bc4 tests: qemuxml2*: Add testing of authenticated http/ftp disks
Extend the 'disk-cdrom-network' to cover this instance. This also
validates that the parameters of -blockdev conform to the QAPI schema.

Also add the xml2xml variant of this test case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-25 16:34:59 +02:00
Peter Krempa
487f15b26a qemuDomainValidateStorageSource: Add validation of 'encryption' support
Reject encryption requests for unsupported image format types.

Add negative test for the rejected cases as well as modify
'disk-network-rbd-encryption' case to validate that with librbd
encryption the format doesn't matter.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-25 16:34:59 +02:00
Andrea Bolognani
a277dea0a7 qemu: Stop setting QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-04-19 15:43:17 +02:00
Andrea Bolognani
519a2c5577 qemu: Assume QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT
All QEMU versions we support have this feature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-04-19 15:43:17 +02:00
Andrea Bolognani
72427767dd qemu: Stop setting QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-04-19 15:43:17 +02:00
Andrea Bolognani
4b3b14138b tests: Drop pseries-machine-max-cpu-compat
This was supposed to test the behavior when
QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT is present, but these
days that's always the case and pseries-cpu-compat already
provides all the coverage we need.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-04-19 15:43:17 +02:00
Jiri Denemark
74884bef1e qemu: Drop QEMU_CAPS_INCOMING_DEFER
The capability is not used anymore since "-incoming defer" is supported
by all QEMU versions we care about.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-04-08 10:27:02 +02:00
Andrew Melnychenko
4e4def21d3 qemu_command: Generate cmd line for virtio-net.rss hash properties
Also, validate that the requested feature is supported by QEMU.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-05 15:36:30 +02:00
Andrew Melnychenko
7ab013655d qemu_capabilities: Add capability for virtio-net "rss" and "hash".
Introduce QEMU_CAPS_VIRTIO_RSS capability which tracks
virtio-net.rss attribute introduced in qemu-5.2.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-05 15:36:29 +02:00
Andrew Melnychenko
a8b1cbe77e domain_conf: Add configs for virtio net RSS and Hash report.
Added "rss" and "rss_hash_report" configuration that should be
used with qemu virtio RSS. Both options are triswitches. Used as
"driver" options and affects only NIC with model type "virtio".
In other patches - options should turn on virtio-net RSS and hash
properties.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-05 15:36:27 +02:00
Andrea Bolognani
06f5c092b8 conf: Format managed property of hostdev-pci ports correctly
The property is parsed using virTristateBoolTypeFromString() but
formatted as if it was a regular bool, which results in the
following incorrect conversion:

  BOOL_ABSENT -> managed='no'
  BOOL_YES    -> managed='yes'
  BOOL_NO     -> managed='yes'

Use the virTristateBoolTypeToString() helper to ensure the
setting can survive a roundtrip conversion.

Fixes: 4b4a981d60
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-05 13:40:33 +02:00
Boris Fiuczynski
67c77744d7 tests: Fixing compiler warning in cputest
Found when building on Fedora 36 on s390x.

 C compiler for the host machine: gcc (gcc 12.0.1 "gcc (GCC) 12.0.1 20220308 (Red Hat 12.0.1-0)")
 C linker for the host machine: gcc ld.bfd 2.37-24

 In function ‘cpuTestUpdateLiveCompare’,
     inlined from ‘cpuTestUpdateLive’ at ../dist-unpack/libvirt-8.2.5/tests/cputest.c:784:12:
 ../dist-unpack/libvirt-8.2.5/tests/cputest.c:696:21: warning: potential null pointer dereference [-Wnull-dereference]
   696 |              featAct->policy == VIR_CPU_FEATURE_REQUIRE) ||
       |              ~~~~~~~^~~~~~~~

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-05 10:32:41 +02:00
Peter Krempa
5c03346184 qemu: capabilities: Retire QEMU_CAPS_STORAGE_WERROR and QEMU_CAPS_USB_STORAGE_WERROR
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:59 +02:00
Peter Krempa
cb1d044e38 qemu: capabilities: Retire QEMU_CAPS_OVERCOMMIT
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:59 +02:00
Peter Krempa
edfd78d7f6 qemu: command: Always assume QEMU_CAPS_OVERCOMMIT
Starting with qemu-3.1 we always have the '-overcommit' argument and use
it instead of '-realtime'. Remove the capability check and fix all
fake-caps tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:59 +02:00
Peter Krempa
22acc863c7 qemu: capabilities: Retire QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_MIGRATABLE
The flag was based on a version check which no longer made sense. Remove
the flag by replacing it's only use by an arch-check which is equivalent
at this point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:59 +02:00
Peter Krempa
b72318f36d qemu: capabilities: Retire QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:59 +02:00
Peter Krempa
47b6829edc qemu: Always assume QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE
All qemu versions now support FD passing either directly or via FDset.
Assume that we always have this capability so that we can simplify
chardev handling in many cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:59 +02:00
Peter Krempa
931c1de5d3 tests: qemucapabilities: Remove qemu-3.0 test data
Upcoming patches will raise the minimum required qemu version to 3.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:58 +02:00
Peter Krempa
c7e09b7b5f tests: qemucapabilities: Remove qemu-2.12 test data
Upcoming patches will raise the minimum required qemu version to 3.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:58 +02:00
Peter Krempa
04748f0cef tests: qemucapabilities: Remove qemu-2.11 test data
Upcoming patches will raise the minimum required qemu version to 3.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:58 +02:00
Peter Krempa
e6c8705b7f qemuxml2agvtest: Retire tests based on qemu-3.0
Upcoming patches will raise the minimum required qemu version to 3.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:58 +02:00
Peter Krempa
6139ac8b5e qemuxml2agvtest: Retire tests based on qemu-2.12
Upcoming patches will raise the minimum required qemu version to 3.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:58 +02:00
Peter Krempa
7674bafe4f qemuxml2agvtest: Retire tests based on qemu-2.11
Upcoming patches will raise the minimum required qemu version to 3.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 12:26:58 +02:00
Andrea Bolognani
19734c3050 qemu: Generate command line for virtio-iommu
https://bugzilla.redhat.com/show_bug.cgi?id=1653327

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-04 10:36:28 +02:00
Andrea Bolognani
e015606984 tests: Add test for virtio-iommu address
virtio-iommu needs to be an integrated device, and our address
assignment code will make sure that is the case. If the user has
provided an explicit address, however, we should make sure any
addresses pointing to a different bus are rejected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:31:00 +02:00
Andrea Bolognani
fc6cde6cb1 qemu: Validate address type for virtio-iommu
virtio-iommu is a PCI device and attempts to use a different
address type should be rejected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:31:00 +02:00
Andrea Bolognani
f119336162 qemu: Assign PCI address to virtio-iommu
The device is configured to be an integrated endpoint, as is
necessary for it to function correctly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:30:59 +02:00
Andrea Bolognani
7620b1a09a qemu: Validate use of ACPI with virtio-iommu
virtio-iommu doesn't work without ACPI, so we need to make sure
the latter is enabled.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:30:59 +02:00
Andrea Bolognani
28ddd917be qemu: Validate capabilities for virtio-iommu
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:30:59 +02:00
Andrea Bolognani
d8072c0015 qemu: Validate machine type used with virtio-iommu
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:30:59 +02:00
Andrea Bolognani
428ba3608a tests: Add test cases for virtio-iommu
These represent valid uses of the device.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:30:59 +02:00
Andrea Bolognani
672c227037 qemu: Introduce QEMU_CAPS_VIRTIO_IOMMU_BOOT_BYPASS
This capability detects the availability of the boot-bypass
property of the virtio-iommu-pci device.

This property was only introduced in QEMU 7.0 but, since the
device has been around for much longer, we end up querying its
properties for several more releases. As I don't have convenient
access to the 10+ binaries necessary to regenerate the replies,
I just put some fake data in there.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:30:59 +02:00
Andrea Bolognani
fd6442f381 qemu: Introduce QEMU_CAPS_DEVICE_VIRTIO_IOMMU_PCI
This capability detects the availability of the virtio-iommu-pci
device.

Note that, while this device is present even in somewhat old
versions of QEMU, it's only some recent changes that made it
actually usable for our purposes.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-01 19:30:59 +02:00
Andrea Bolognani
b7f5ad4610 tests: Add capabilities for QEMU 7.0.0 on aarch64
The QEMU binary is built from the v7.0.0-rc2 tag.

This causes the argument to -device to be generated in JSON
format, same as what 1a691fe1c8 has done for x86_64.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2022-04-01 19:29:50 +02:00
Andrea Bolognani
c3d0236e67 tests: Update capabilities for QEMU 7.0.0 on ppc64
The QEMU binary is built from the v7.0.0-rc2 tag.

Some of the additional capabilities that show up are a
consequence of more features being enabled in this build than
in the one used to generate the replies initially.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2022-04-01 19:29:23 +02:00
Andrea Bolognani
fd10c72f1c tests: Update capabilities for QEMU 7.0.0 on x86_64
The QEMU binary is built from the v7.0.0-rc2 tag.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2022-04-01 18:35:44 +02:00
Jonathon Jongsma
3832db2108 qemu: fix hotplug for multiqueue vdpa net device
While commit a5e659f0 removed the restriction against multiple queues
for the vdpa net device, there were some missing pieces. Configuring a
device statically and then starting the domain worked as expected, but
hotplugging a device didn't have the expected multiqueue support
enabled. Add the missing bits.

Consider the following device xml:
    <interface type="vdpa">
      <mac address="00:11:22:33:44:03" />
      <source dev="/dev/vhost-vdpa-0" />
      <model type="virtio" />
      <driver queues='2' />
    </interface>

Without this patch, hotplugging the above XML description resulted in
the following:
    {"execute":"netdev_add","arguments":{"type":"vhost-vdpa","vhostdev":"/dev/fdset/0","id":"hostnet1"},"id":"libvirt-392"}
    {"execute":"device_add","arguments":{"driver":"virtio-net-pci","netdev":"hostnet1","id":"net1","mac":"00:11:22:33:44:03","bus":"pci.5","addr":"0x0"},"id":"libvirt-393"}

With the patch, hotplugging results in the following:
    {"execute":"netdev_add","arguments":{"type":"vhost-vdpa","vhostdev":"/dev/fdset/0","queues":2,"id":"hostnet1"},"id":"libvirt-392"}
    {"execute":"device_add","arguments":{"driver":"virtio-net-pci","mq":true,"vectors":6,"netdev":"hostnet1","id":"net1","mac":"00:11:22:33:44:03","bus":"pci.5","addr":"0x0"},"id":"libvirt-393"}

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

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-30 10:14:28 -05:00
Peter Krempa
38ab5c9ead qemu: command: Override device definition according to the namespace config
Apply the user-requested changes to the device definition as requested
by the <qemu:deviceOverride> element from the custom qemu XML namespace.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/287
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-28 13:15:25 +02:00
Peter Krempa
b2d4ae0ec3 qemu: domain: Add XML namespace code for overriding device config
Implement the XML parser and formatter for overriding of device
properties such as:

  <qemu:override>
    <qemu:device alias='ua-disk'>
      <qemu:frontend>
        <qemu:property name='prop1' type='string' value='propval1'/>
        <qemu:property name='prop2' type='signed' value='-321'/>
        <qemu:property name='prop3' type='unsigned' value='123'/>
        <qemu:property name='prop4' type='bool' value='true'/>
        <qemu:property name='prop5' type='bool' value='false'/>
        <qemu:property name='prop6' type='bool' value='false'/>
        <qemu:property name='prop6' type='remove'/>
      </qemu:frontend>
    </qemu:device>
  </qemu:override>

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-28 13:15:25 +02:00
Michal Privoznik
087473a3ef Revert "qemu: add support for tsc.on_reboot element"
This reverts commit 06c960e477.

Turns out, this feature is not needed and QEMU will fix TSC
without any intervention from outside.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>P
2022-03-28 10:00:18 +02:00
Paolo Bonzini
06c960e477 qemu: add support for tsc.on_reboot element
QEMU 7.0.0 adds a new property tsc-clear-on-reset to x86 CPU, corresponding
to Libvirt's <tsc on_reboot="clear"/> element.  Plumb it in the validation,
command line handling and tests.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-25 16:31:02 +01:00
Paolo Bonzini
5cef757875 tests: add dependencies to meson declaration
Make sure that all tests are run after the helpers and mocks are
(re)built.  This enables for example using "meson test" as the
command line passed to "git bisect run".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-25 15:36:25 +01:00
Michal Privoznik
b8d6ecc70c qemu_command: Generate prealloc-threads property
Let's generate prealloc-threads property onto the cmd line if
domain configuration requests so.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-03-24 15:46:00 +01:00
Michal Privoznik
a30dac15dc qemu_capabilities: Detect memory-backend-*.prealloc-threads property
The prealloc-threads is property of memory-backend class which is
parent to the other three classes memory-backend-{ram,file,memfd}.
Therefore the property is present for all, or none if QEMU is
older than v5.0.0-rc0~75^2~1^2~3 which introduced the property.

Anyway, the .reserve property is the same story, and we chose
memory-backend-file to detect it, so stick with our earlier
decision and use the same backend to detect this new property.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-03-24 15:46:00 +01:00
Michal Privoznik
ba7f98126f conf: Introduce memory allocation threads
Since its v5.0.0 release QEMU is capable of specifying number of
threads used to allocate memory. It defaults to 1, which may be
too low for humongous guests with gigantic pages.

In general, on QEMU cmd line level it is possible to use
different number of threads per each memory-backend-* object, in
practical terms it's not useful. Therefore, use <memoryBacking/>
to set guest wide value and let all memory devices 'inherit' it,
silently. IOW, don't introduce per device knob because that would
only complicate things for a little or no benefit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-03-24 15:45:41 +01:00
Claudio Fontana
76ddf2d2e3 schemas: move out of docs, fix no-docs build
schemas are used for more than just documentation,
virsh edit fails if schemas are not available.

Therefore, fix the no-docs build by moving schemas/
to the parsing code inside src/conf/.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-03-22 11:05:09 +01:00
Peter Krempa
e6d1ed4a76 conf: Add support for setting expected TLS hostname for NBD disks
In cases when the hostname of the NBD server doesn't match the hostname
in the TLS certificate the new attribute 'tlsHostname' can be used to
override it.

Add the XML infrastructure and tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-11 15:17:06 +01:00