Commit Graph

8402 Commits

Author SHA1 Message Date
Andrea Bolognani
3b6d69237f Revert "conf: Introduce MTE domain feature"
The QEMU interface is still in a state of flux, and KVM support
has been pulled shortly after having been merged. Let's not
commit to a stable interface in libvirt just yet.

Reverts: 720e8f13ff
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
2023-05-22 15:13:19 +02:00
Andrea Bolognani
4fd5f0d660 Revert "qemu:: Introduce QEMU_CAPS_MACHINE_VIRT_MTE capability"
The QEMU interface is still in a state of flux, and KVM support
has been pulled shortly after having been merged. Let's not
commit to a stable interface in libvirt just yet.

Reverts: 1347a19f75
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
2023-05-22 15:13:18 +02:00
Andrea Bolognani
167138a525 Revert "qemu: Generate command line for MTE feature"
The QEMU interface is still in a state of flux, and KVM support
has been pulled shortly after having been merged. Let's not
commit to a stable interface in libvirt just yet.

Reverts: b10bc8f7ab
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
2023-05-22 15:12:51 +02:00
Michal Privoznik
17c8a173b6 numa_conf: Deny other memory modes than 'restrictive' if a memnode is 'restrictive'
We already do check that if there's <memory mode='restrictive'/>
then all <memnode/> have to be of 'restrictive' mode too. But
what we are missing the reverse: if there is <memnode/> with
'restrictive' mode, then the <memory/> has to be of the same mode
too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2208946
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-22 13:58:03 +02:00
Peter Krempa
af621caa6b conf: numa: Allow formatting 'none' values for 'associativity' and 'policy' of cache
The parser makes the values mandatory and also the qemu code implements
actions for those values. The formatter skips them though. Since
format+parse is used to copy the XML at startup a definition with those
values can't be started.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-17 10:02:19 +02:00
Peter Krempa
c051fa874f qemuxml2argvtest: Use real caps instead of fake caps for 'audio-default-*' cases
Convert all of the 'audio-default-*' cases to use capabilities from
qemu-4.2 instead of the fake caps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-17 10:02:19 +02:00
Peter Krempa
36d7d87c87 qemuxml2xmlout: Replace symlinks of all 'audio-' tests by real files
Symlinks are hard to maintain and especially un-cool when attempting to
test against real capapbilities.

Replace symlinks by real files first so that we can switch to real caps
and see the difference.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-17 10:02:19 +02:00
Michal Privoznik
b10bc8f7ab qemu: Generate command line for MTE feature
This is pretty trivial, just append "mte=on/off" to -machine
arguments.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-16 17:43:05 +02:00
Michal Privoznik
1347a19f75 qemu:: Introduce QEMU_CAPS_MACHINE_VIRT_MTE capability
The MTE feature (introduced in QEMU commit of v5.1.0-rc1~8^2~11)
is detectable via 'qom-list-properties' for 'virt' machine type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-16 17:43:00 +02:00
Michal Privoznik
720e8f13ff conf: Introduce MTE domain feature
The Memory Tagging Extensions are hardware acceleration present
in some ARM processors that allow memory error detection [1].
Introduce a domain XML knob that turns them on or off.

1: https://www.arm.com/blogs/blueprint/memory-safety-arm-memory-tagging-extension
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-16 17:42:58 +02:00
Michal Privoznik
37e41b7f16 qemu: Drop @forceVFIO argument of qemuDomainGetMemLockLimitBytes()
After previous cleanup, there's not a single caller that would
call qemuDomainGetMemLockLimitBytes() with @forceVFIO set. All
callers pass false.

Drop the unneeded argument from the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-16 14:43:43 +02:00
Peter Krempa
9884e89236 schemas: backup: Allow missing 'type' attribute for backup disk
One of our examples in the 'formatbackup.rst' page shows following
config:

  <disk name='vda' backup='yes'/>

The schema didn't allow it though. Fix the schema as the internals were
supposed to support it (except for the bug fixed in previous patches).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-16 10:26:33 +02:00
Peter Krempa
1222ada2af conf: backup: Fix logic for generating default backup filenames
If the 'disk->store' property is already allocated which happens e.g.
when the disk is described by the backup XML but the optional filename
is not filled in 'virDomainBackupDefAssignStore' would not fill in the
default location.

Fix the logic to do it also if a 'virStorageSource' categorizes as
empty.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-16 10:26:33 +02:00
Michal Privoznik
a091edf9db virmockstathelpers: Adapt to musl-1.2.4
With musl-1.2.3: I get the following macros defined (from
$builddir/meson-config.h):

  #define WITH_LSTAT 1
  #define WITH_LSTAT64 1
  #define WITH_LSTAT_DECL 1
  #define WITH_STAT 1
  #define WITH_STAT64 1
  #define WITH_STAT_DECL 1
  #define WITH___LXSTAT 1
  #define WITH___LXSTAT64 1
  #define WITH___XSTAT 1
  #define WITH___XSTAT64 1

which in turn means the virmockstathelpers.c ends up defining:

  MOCK_STAT64
  MOCK_LSTAT64

But with  musl-1.2.4 everything changes and the set of defined
macros gets simplified to:

  #define WITH_LSTAT 1
  #define WITH_LSTAT_DECL 1
  #define WITH_STAT 1
  #define WITH_STAT_DECL 1
  #define WITH___LXSTAT 1
  #define WITH___XSTAT 1

which results in no MOCK_* macros defined in
virmockstathelpers.c, i.e. no stat() mocking, nada. The reason
for this simplification are these musl commits [1][2] which
removed all 64 bit aliases. And that's not what our logic for
deciding what flavor of stat() to mock counted with.

Nevertheless, we do build with Alpine Linux in our CI, so how
come we don't see this problem there? Well, simply because Alpine
Linux maintainers decided to revert the commits [3][4]. But on
distributions that use vanilla musl, this problem can be seen
easily.

1: https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
2: https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc
3: https://git.alpinelinux.org/aports/commit/main/musl?id=6a5563fbb45b3d9d60678d7bbf60dbb312a2d481
4: https://git.alpinelinux.org/aports/commit/main/musl?id=a089bd852f8983623fa85e0f5755a3e25bf53c72

Resolves: https://bugs.gentoo.org/906167
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-16 08:48:17 +02:00
Michal Privoznik
9469587314 virfirewallmock: Replace virFindFileInPath() with virFirewallDIsRegistered()
Neither of tests that use virfirewallmock.c
(networkxml2firewalltest, nwfilterebiptablestest,
nwfilterxml2firewalltest, virfirewalltest) really call
virFindFileInPath(). But at least networkxml2firewalltest calls
virFirewallDIsRegistered(), under the hood. Now, the actual
implementation connects to dbus and something, which is
definitely not what we want in our test suite.

Therefore, drop virFindFileInPath() implementation and provide
implementation for virFirewallDIsRegistered() which just returns
-2 to signal that firewalld is not registered.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-05-10 14:44:22 +02:00
Peter Krempa
3d6bc5c611 conf: qemu: Add support for multi-channel mode for 'usb' sound cards
Allow users controlling the multi-channel mode by adding a
'multichannel' property parsed for USB audio devices and wire up the
support in the qemu driver.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/472
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-09 15:12:03 +02:00
Peter Krempa
d6d4cfa5fc qemuxml2(argv|xml)test: Modernize 'sound-device' case
Drop the unnecessary disk definition and use x86_64 emulator.

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

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

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-09 15:12:03 +02:00
Peter Krempa
4b5a9e34ad qemu: Use configured iothread poll parameters on startup
Implement the support for the persisted poll parameters and remove
restrictions on saving config when modifying them during runtime.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-02 14:32:47 +02:00
Peter Krempa
83eee66f81 conf: Store the iothread 'poll' settings in the XML
Currently we allow configuring the 'poll-max-ns', 'poll-grow', and
'poll-shrink' parameters of qemu iothreads only during runtime and they
are not persisted. Add XML machinery to persist them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-05-02 14:32:47 +02:00
Michal Privoznik
fea0d8c40d qemu: Move <hostdev> SCSI path generation into qemuDomainPrepareHostdev()
When preparing a SCSI <hostdev/> with passthrough of a host SCSI
adapter (i.e. no protocol), a virStorageSource structure is
initialized and stored inside virDomainHostdevDef. But the source
structure is filled in many places, with almost the same code.

Firstly, qemuProcessPrepareHostHostdev() and
qemuConnectDomainXMLToNativePrepareHostHostdev() are the same.

Secondly, qemuDomainPrepareHostdev() allocates the src structure,
only to let qemuProcessPrepareHostHostdev() fill src->path later.

Well, src->path can be filled at the same place where the src
structure is allocated (qemuDomainPrepareHostdev()) which renders
the other two functions needless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Michal Privoznik
2020c7e821 qemuxml2argvtest: Drop needless PCI backend setting
The qemuxml2argvtest does a bit of 'fixups' to parsed
virDomainDef just before generating the cmd line. For instance,
it sets PCI backend for hostdevs (to VFIO). The reason for this
is that we want to make the test host independent and thus
letting the code chose backend at runtime might render different
results on different machines. But this is not necessary, as
virpcimock (that the test uses) already creates a fake, but
stable environment (where /dev/vfio/vfio and IOMMU groups exist),
thus qemuHostdevHostSupportsPassthroughVFIO() returns true,
regardless of the actual host support.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 12:36:30 +02:00
Ján Tomko
03ca889b15 qemu: allow forcing emulated maxphysaddr
Treat:
  <maxphysaddr mode="emulate"/>
as a request not to take the maximum address size from the host.
This is useful if QEMU changes the default.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 11:19:37 +02:00
Ján Tomko
e3d95a1eba qemu: add support for setting host-phys-bits-limit
Translate <maxphysaddr limit='39'/> to:
host-phys-bits-limit=39

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

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

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

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-25 11:19:37 +02:00
Michal Privoznik
0eebdce995 qemuhotplugtest: Verify domain XML on UPDATE
Just like we check the resulting domain XML after ATTACH and
DETACH, we should do the same after UPDATE action. This is as
simple as calling testQemuHotplugCheckResult() and providing
missing XMLs. For those test cases where no change is done, we
can just make the expected XML a symlink to the input XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
11793a5311 qemuhotplugtest: use g_autoptr(virDomainDeviceDef)
This brings us one step closer to the caller of
qemuDomainAttachDeviceLive()
(qemuDomainAttachDeviceLiveAndConfig()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
22c082b8a2 qemuhotplugtest: Don't overwrite vm->def->id in testQemuHotplugCheckResult()
This is a leftover from v2.0.0-rc1~300. In v1.2.12-rc1~43 we've
introduced a code that explicitly sets vm->def->id to -1 to force
generation of inactive XML. But this was removed in the later
commit, which forgot to remove the restoration of the original
dom ID.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
dc4ec0e30b qemuhotplugtest: Fix misleading comment on monitor unlock
There's a comment in testQemuHotplug() trying to explain why we
need to unlock the monitor object. Well, while it might have been
correct when being introduced, it's no longer factually correct
as just any function (attach/detach/update) might talk to the
monitor and it expects the monitor to be unlocked (as it calls
qemuDomainObjEnterMonitor() + qemuDomainObjExitMonitor()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
e98f0b99c0 qemuhotplugtest: Call qemuDomainUpdateDeviceLive() directly
There's no reason for qemuhotplugtest to reimplement which device
update function to call (testQemuHotplugUpdate()) when
qemuDomainUpdateDeviceLive() already does that. Thus, drop
testQemuHotplugUpdate() and call qemuDomainUpdateDeviceLive()
directly.

BTW: this also shows why reimplementing
qemuDomainUpdateDeviceLive() is bad idea: The
"disk-cdrom-nochange" test is succeeding only because
testQemuHotplugUpdate() supports graphics and returns an
(expected) error for every other devtype.

NB, there's still missing check that the resulting XML is the
expected one (just like we do for attach and detach), but that's
pre-existing and will be fixed later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
f7b8f740ca qemuhotplugtest: Call qemuDomainAttachDeviceLive() directly
There's no reason for qemuhotplugtest to reimplement which device
attach function to call (testQemuHotplugAttach()) when
qemuDomainAttachDeviceLive() already does that. Thus, drop
testQemuHotplugAttach() and call qemuDomainAttachDeviceLive()
directly.

There's one small catch though, qemuDomainAttachDeviceLive() now
calls one monitor command more (to list all aliases). We don't
care really, because we're not testing that. Therefore, just
provide a dummy reply.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Michal Privoznik
2577ade457 qemuhotplugtest: Call qemuDomainDetachDeviceLive() directly
The testQemuHotplugDetach() already does call
qemuDomainDetachDeviceLive() but only for some device types. For
the rest it reports an error (but only if running test
verbosely). This makes no sense. Just call
qemuDomainDetachDeviceLive() directly and drop
testQemuHotplugDetach().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-04-25 08:46:27 +02:00
Peter Krempa
fb1bfad7ad qemu: hotplug: Update disk private data after hotplug
The disk private data contain information about the tray and
removability of the disk. Until recently we didn't support hotplug of
removable disks thus it wasn't a problem but now when you can hotplug a
CDROM you would not be able to open its tray.

Fix it by updating the hotplugged disk the same way we do at startup.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2160435
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-24 12:57:56 +02:00
Peter Krempa
ca3a12d49a qemucapabilitiestest: Update x86_64 capabilities for qemu-8.0.0 release
Notable changes:
 - 'query-cryptodev' command added
 - 'cxl-inject-uncorrectable-errors', 'cxl-inject-correctable-error'
   commands added
 - 'query-stats' returns data for 'cryptodev'
 - keyboard definions were updated
 - 'igb' device added

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-24 09:36:34 +02:00
Martin Kletzander
865b071ae8 qemu: Validate watchdog action compatibility per-device
This makes it also work during attach.  Also add a test for attaching a
watchdog with incompatible action.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2187278
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Martin Kletzander
2669b442f9 qemu: Forbid ib700 watchdogs for non-i440fx machine types
We can launch qemu with it, but it will not work since it's not even
probed by the kernel at the mapped address with different machine types
since they are expected to be connected to ISA and not even its newer
LPC counterpart found on q35.  And it does not exist on non-x86
architectures.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-20 10:17:35 +02:00
Michal Privoznik
5670c50ffb qemu_domain: Increase memlock limit for NVMe disks
When starting QEMU, or when hotplugging a PCI device QEMU might
lock some memory. How much? Well, that's an undecidable problem.

But despite that, we try to guess. And it more or less works,
until there's a counter example. This time, it's a guest with
both <hostdev/> and an NVMe <disk/>. I've started a simple guest
with 4GiB of memory:

  # virsh dominfo fedora
  Max memory:     4194304 KiB
  Used memory:    4194304 KiB

And here are the amounts of memory that QEMU tried to lock,
obtained via:

  grep VmLck /proc/$(pgrep qemu-kvm)/status

  1) with just one <hostdev/>
     VmLck:   4194308 kB

  2) with just one NVMe <disk/>
     VmLck:   4328544 kB

  3) with one <hostdev/> and one NVMe <disk/>
     VmLck:   8522852 kB

Now, what's surprising is case 2) where the locked memory exceeds
the VM memory. It almost resembles VDPA. Therefore, treat is as
such.

Unfortunately, I don't have a box with two or more spare NVMe-s
so I can't tell for sure. But setting limit too tight means QEMU
refuses to start.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2014030
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-20 08:37:22 +02:00
Jim Fehlig
b9236758c7 qemu: Change default machine type for RISC-V
It's quite difficult, if not impossible, to create a working RISC-V VMs
using the current default machine type of 'spike_v1.10'. Change the
default to the more appropriate and virtualization friendly 'virt'
machine type.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-04-18 08:55:25 -06:00
Jim Fehlig
cb8e3ab3f9 qemu: Change default machine type for ARM
It's quite difficult, if not impossible, to create a usable ARM VMs
using the current default machine type of 'integratorcp'. Change the
default to the more appropriate and virtualization friendly 'virt'
machine type.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-04-18 08:54:49 -06:00
Andrea Bolognani
985f78e804 conf: Restrict use of <portForward> to the passt backend
That's already the case in practice, but it's a better
experience for the user if we reject this configuration
outright instead of silently ignoring part of it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-18 15:52:30 +02:00
Boris Fiuczynski
f1998a63e3 tests: viracpitest only works on little endian
Commit fc216db4fb introduced a mocked test with binary test data
which fails on big endian machines.
Therefore build the viracpitest test only on little endian machines.

Fixes: fc216db4fb

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-18 12:55:47 +02:00
Andrea Bolognani
f9ad302335 conf: Fix migration in some firmware autoselection scenarios
Introduce a small kludge in the parser to avoid unnecessarily
blocking incoming migration from a range of recent libvirt
releases.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-12 18:03:21 +02:00
Andrea Bolognani
0982103037 tests: Tweak input file
The canonical order for <os> child elements is <firmware>
then <loader>.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-12 18:03:13 +02:00
Peter Krempa
df2373adbb testutilsqemu: Drop fake capability testing infrastructure for 'aarch64'
Now that all tests were converted to use real capabilities we don't need
it any more. Remove it so that no new tests are added with it.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
4d0d31a6fd qemuxml2xmloutdata: Don't symlink output data for 'mach-virt*' cases
Replace them with full files so that potential fallout from conversion
to real capabilities is more obvious and the test is simpler to add.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
0e550e7175 qemuxml2xmlout: Do not symlink output files for 'aarch64-gic' cases
Upcoming patch will be modifying all of them to use real capabilities.
This way it will be more obvious what will change.

Keeping the symlinks around is tedious for humans to do. Waste some
storage instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
0da84671ef qemuxml2argvtest: Modernize the rest of 'aarch64' cases
Use real capabilities for them.

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

Also add a xml2xml test invocation of the unified test.

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

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
c79f626f21 qemuxml2argvtest: Modernize all 'mach-virt-' aarch64 test cases
Use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
4753fdb6f0 qemuxml2argvtest: Don't symlink output files for 'mach-virt-' cases
Make the output changes of upcoming modernization more visible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
d66fb85fb5 qemuxml2argvtest: Modernize 'balloon-mmio-deflate'
Use real capabilities and mask-out support for PCIe.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
b7f0487184 qemuxml2argv: Test default aarch64 cofig without PCIe support
Use real caps and clear out flags for PCIe so that we have a real-ish
example of an aarch64 machine using mmio.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
8d94853040 qemuxml2argvtest: Drop "aarch64-virt-2.6-virtio-pci-default" case
The test data is effectively identical to the
'aarch64-virtio-pci-default' case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
9c26a25f88 qemuxml2argvtest: Add real-caps versions of 'aarch64-virt-virtio'
Add a version for 'latest' caps as well as '4.2.0'. The test
demonstrates that with a real qemu PCIe will be used instead of MMIO.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
4f33f1325a qemuxml2argvtest: Convert the rest of GIC tests to latest capabilities
Convert the two negative cases to use real capapbilities as well as the
positive case for situations when KVM is not used by stripping the
QEMU_CAPS_KVM flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
dae9c45539 qemuxml2argvtest: Convert DO_TEST_GIC to use real latest capabilities
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-11 10:08:32 +02:00
Peter Krempa
b2ca40d2e2 qemuxml2argvtest: Use real capabilities in tests for picking the aarch64 GIC version
Convert 'aarch64-gic-default' and 'aarch64-gic-none' cases to use real
capabilities both latest and locked to 4.2.0 to show what would happen
with a real qemu.

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

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

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

Remove the symlinks and replace them by real output files.

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

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

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

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

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:08 +02:00
Peter Krempa
a5bd444cb2 qemuxml2xmltest: Convert all s390 test cases to real capabilities
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:08 +02:00
Peter Krempa
5887466ec6 qemuxml2argvtest: Convert rest of s390 tests to real caps
Convert the rest of the outstanding tests to use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
2572d991ee qemuxml2argvtest: Modernize s390 cpu tests
Use real capabilities for the CPU test. The negative test case for QEMUs
without QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION is removed as the feature is
now supported by all supported qemu versions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
85a30c7570 qemuxml2argvtest: Modernize all s390 'loadparm' tests
Use latest caps for the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
3429ddf6ec qemuxml2argvtest: Modernize all s390 'keywrap' tests
Use latest caps for the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
5203380907 qemuxml2argvtest: Remove obsolete negative tests
The 'hostdev-subsys-mdev-vfio-ccw', 'hostdev-vfio-zpci', and
'hostdev-vfio-zpci-autogenerate-fids' test cases have negative versions
which are invoked without capabilities. This does not make sense going
forward as the tests are going to be switched to real capabilities.

Remove them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
a0fe48382c testutilsqemu: Drop fake capability testing infrastructure for 'ppc64'
Now that all tests were converted to use real capabilities we don't need
it any more. Remove it so that no new tests are added with it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
c523377e19 qemuxml2argvtest: Use real capabilities for negative test cases for ppc64 architecture
Convert the last outstanding test cases for ppc64 to use real
capabilities.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
518d8d1de1 qemu: capabilities: Retire obsolete 'pseries' capabilities
Retire:

    QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE
    QEMU_CAPS_MACHINE_PSERIES_CAP_HTM
    QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV
    QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST
    QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC
    QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC
    QEMU_CAPS_MACHINE_PSERIES_CAP_IBS

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
21b9f65ec0 qemuxml2argvtest: Drop negative test cases for 'pseries' machine features
All of the tested features are always present in the 'pseries' machine
with oldest-supported qemu-4.2, thus the tests don't make sense any
more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
8f430f453b qemuxml2argvtest: Add '4.2.0' version of 'pseries-features' test case
Add an example case showing that every feature in the 'pseries-features'
test works also with the oldest supported qemu version.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
dba5bad2a7 qemuxml2argvtest: Modernize all 'ppc64' remaining test cases
Switch them to use latest caps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
6eee2de99f qemuhotplugtest: Make the test more useful by validating used commands against QMP schema
qemuhotplugtest validates only that a given command is used but not the
arguments of the command. With this patch we'll validate the arguments
against the QMP schema thus we can catch possible issues with deprecated
commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
706cd47487 qemuhotplugtest: Use real 'latest' capabilities for hotplug testing
Rather than test with synthetic capabilities which might get outdated
reuse testQemuGetRealCaps to fetch latest capabilities and use those.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
c469b0897c qemuhotplugtest: Refactor calling of testQemuHotplugCpuPrepare
Pass in the whole struct rather than splitting out individual members.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
cccabdf8be qemuhotplugtest: Assert QEMU_CAPS_SET_ACTION
With modern qemu we use 'set-action' instead of 'watchdog-set-action'.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
c84e9a3b82 qemuhotplugtest: Enable 'lsilogic' SCSI controller
All real qemus support the 'lsilogic' controller and thus would pick it
as the default rather than virtio-scsi. Since lsilogic is limited in
some aspects we should test it with the proper default model.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
a58d22250c qemuhotplugtestdomain: Move all i686 test cases to x86_64
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
578c2a0cc7 qemuhotplugtest: Don't fetch capabilities when they are not used
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
d8ea6a391b qemumemlocktest: Use real capabilities
Use testQemuGetRealCaps to fetch real capabilities and use it in place
of the faked caps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
83967a9ed2 testQemuGetRealCaps: Integrate fetching of QMP schema
Move the lookup of the corresponding QMP schema used for validation of
QMP commands from 'testCompareXMLToArgvValidateSchema' to
testQemuGetRealCaps as an optional step.

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
6013561a82 testutilsqemu: Extract fetching of real virQEMUCaps into testQemuGetRealCaps
'testQemuInfoInitArgs' contains the logic to fetch and use the
capabilities for tests using 'struct testQemuInfo'.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
17d627518c tests: Remove 'vircapstest'
Technically for the LXC capabilities lookup we don't have another test
case, but given that it shares the implementation with qemu and thus the
only thing we are missing out on is testing of filling of the fake
capabilities which doesn't make sense testing.

Remove vircapstest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
702620bd6b tests: vircaps: Remove pointless testing of virCapabilitiesHostNUMAGetCpus
The test case doesn't validate the returned map of cpus, just checks
that it didn't fail. We test the returned value indirectly via
qemuxml2argvtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
6ae5d71d38 vircapstest: Remove 'qemu' testing
We have testing based on real capabilities in 'qemucaps2xmltest' for
qemu guest related data and 'vircaps2xmltest' tests the host data
gathering. The testing done here makes no sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
a4c03bdd59 virQEMUCapsInitGuestFromBinary: Remove return value
The function always returns 0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
ccee1ee088 virCapabilitiesAllocMachines: Use NULL-terminated list as argument and return count
Simplify use of the function by determining the number of elements
inside the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
6861964704 qemu: capabilities: Drop 'kvmVersion' field
It's never set to any real value. Remove it along with the caching code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00
Peter Krempa
252019e087 testutilsqemu: Remove infrastructure for fake-caps testing of OSX
All tests using this were refactored to use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-03 09:19:07 +02:00