Commit Graph

7141 Commits

Author SHA1 Message Date
Michal Privoznik
6234eebbf6 vmx2xmltest: Drop duplicate testcases
There are three test cases are called twice. This is needless.
Drop redundant calls.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-19 13:27:41 +02:00
Peter Krempa
4db8ffeb2e virsh: Add testing for vshStringToArray
Add a '--split' switch for the 'virsh echo' command and add few test
cases to the virshtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 11:07:25 +02:00
Peter Krempa
c67fc3ea82 virshtest: Don't use both '--xml' and '--shell' for 'virsh echo'
Escaping for both shell and XML makes no sense. Use one at time so that
we can forbid use of both.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 11:07:25 +02:00
Peter Krempa
510b951d9c qemuxml2xmltesttest: Avoid conditions in test macro
Pass a pointer to the 'ret' variable to the test executor itself and
update it there to improve compile times of the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
ca5c8e1dc7 qemuxml2argvtest: Avoid conditions in test macro
Pass a pointer to the 'ret' variable to the test executor itself and
update it there to improve compile times of the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
68bb5f9fa6 testutilsqemu: Improve error propagation from 'testQemuInfoSetArgs'
Previously we've ran into problems when 'testQemuInfoSetArgs' failed as
calling the actual test executor could lead to a crash if the data
wasn't prepared but reporting an error doesn't play nicely with our test
output which is handled by 'virTestRun'.

To avoid the issue (and as a side effect improve compilation times of
the test files) split up testQemuInfoSetArgs into two functions.

The first is still called 'testQemuInfoSetArgs' and just blindly
populates arguments into a sub-struct of testQemuInfo. This function no
longer reports errors

A new function 'testQemuInfoInitArgs' which is meant to be called from
the test executor then checks errors and prepares the test data. This
one can fail and the test will be marked as failed appropriately.

A nice side effect is that this vastly improves compile times of
qemuxml2xmltest and qemuxml2argvtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
92e0cd2620 testutilsqemu: Introduce struct to hold data valid for all test runs
We pass multiple caching objects to individual tests which don't change.
To prevent always having to pass them individually to
'testQemuInfoSetArgs' introduce 'struct testQemuConf' which will hold
all of them and just the struct will be passed to the tests.

Additionally this will make the conf available from inside the test run.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
0ceb802ad9 testQemuInfoSetArgs: Move argument fetching to the loop
Since the last patch removed the hack which needed lookahead to see
whether all QEMU_CAPS_ were parsed we can move the fetching of the
arguments into the loop.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
6545a23277 testQemuInfoSetArgs: Remove hack for double QEMU_CAPS_LAST in caps list
The callers don't use it any more. Remove it to avoid fragility of the
test suite.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
725aaf794d testutilsqemu: Ensure that ARG_* macros are out of range of QEMU_CAPS_*
Both are used in the same parser. Using offset values ensures that
errors are caught earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
80340a199b qemuxml2xmltest: Remove 'NONE' macro
There's one last user. Use QEMU_CAPS_LAST explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
786c097b51 qemuxml2xmltest: Add 'DO_TEST_NOCAPS' to replace 'DO_TEST("blah", NONE);'
Add a explicit version of our test invocation macro for tests which use
no capabilities.

This reduces the usage of the somewhat anonymous 'NONE' macro and will
lead to simplification of the code later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
1c2b04c0ac qemuxml2xmltest: Remove hack for qemuCaps allocation
Since qemuCaps are now always allocated we don't need to pass
ARG_QEMU_CAPS, QEMU_CAPS_LAST to force the allocation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
7c63372ebc qemuxml2xmltest: Rename DO_TEST_INTERNAL to DO_TEST_FULL and fix users
'DO_TEST_FULL' isn't a useful wrapper any more. Use the better name for
the main macro and replace all uses.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
d779279e1c qemuxml2xmltest: Add 'ARG_END' from higher level macros
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
ee8db0590a qemuxml2argvtest: Add 'DO_TEST_FAILURE_NOCAPS' to replace 'DO_TEST_FAILURE("blah", NONE);'
Add a explicit version of our test invocation macro for tests which use
no capabilities.

This removes the usage of the somewhat anonymous 'NONE' macro and will
lead to simplification of the code later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
ba8bced3cf qemuxml2argvtest: Add 'DO_TEST_PARSE_ERROR_NOCAPS' to replace 'DO_TEST_PARSE_ERROR("blah", NONE);'
Add a explicit version of our test invocation macro for tests which use
no capabilities.

This reduces the usage of the somewhat anonymous 'NONE' macro and will
lead to simplification of the code later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
5001e2e9e6 qemuxml2argvtest: Add 'DO_TEST_NOCAPS' to replace 'DO_TEST("blah", NONE);'
Add a explicit version of our test invocation macro for tests which use
no capabilities.

This reduces the usage of the somewhat anonymous 'NONE' macro and will
lead to simplification of the code later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
eace429e2d qemuxml2argvtest: Rename DO_TEST_INTERNAL to DO_TEST_FULL and fix users
'DO_TEST_FULL' isn't a useful wrapper any more. Use the better name for
the main macro and replace all uses.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
feb9a8e80c qemuxml2argvtest: Add QEMU_CAPS_LAST in places where ARG_QEMU_CAPS is used
The 'DO_TEST_FULL' macro was ending the argument list which was being
started in other macros. Move it so that 'ARG_QEMU_CAPS' and
'QEMU_CAPS_LAST' are always used in the same macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
7eeb50fd33 qemustatusxml2xmltest: Remove hack for qemuCaps allocation
Since qemuCaps are now always allocated we don't need the hack.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
767f4e5f72 testQemuInfoSetArgs: Always allocate 'info->qemuCaps'
Modify the logic so that 'info->qemuCaps' is populated, but empty even
when ARG_QEMU_CAPS was not used. The function still retains the
interlocking of fake caps with real caps.

A lot of the internal code expects qemuCaps to be populated and many
tests work this around by using ARG_QEMU_CAPS with no caps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
e817d1938a qemuxml2argvtest: Fix broken invocation of "aarch64-tpm-wrong-model"
The string "aarch64" is passed in place of capability flags. We were lucky
that the pointer was always more than QEMU_CAPS_LAST.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
0d00813537 qemuxml2argvtest: Fix broken invocation of "pseries-spaprvio-invalid"
The string "ppc64" is passed in place of capability flags. We were lucky
that the pointer was always more than QEMU_CAPS_LAST.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
36a41cad9d qemuxml2argvtest: Add 'ARG_END' from higher level macros
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Peter Krempa
d3cf0c81d9 qemu: capabilities: Retire QEMU_CAPS_MSG_TIMESTAMP
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:00:34 +02:00
Peter Krempa
c7a85b5b77 qemu: command: Always assume support for '-msg timestamp=on'
All supported QEMU versions have this option so there's no need for us
to base it on the capability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:00:22 +02:00
Peter Krempa
5d87897591 qemu: capabilities: Retire QEMU_CAPS_NAME*
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:59:44 +02:00
Peter Krempa
d5a6145900 qemu: command: Always assume support for '-name guest=' and '-name debug-threads=on'
All QEMU versions we support have these and it's very unlikely that they
will be removed. Remove the capability checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:59:31 +02:00
Peter Krempa
f95dc8286f qemuxml2argvtest: Remove 'minimal-sandbox' case
All modern qemus support sandboxing so this is covered by other tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:59:08 +02:00
Peter Krempa
aa7d6ef97c qemuxml2argvtest: Remove 'minimal-msg-timestamp'
The feature is supported by all supported qemu versions thus covered
thoroughly by other test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:58:46 +02:00
Peter Krempa
05fb347463 qemuxml2argvtest: Remove 'debug-threads' case
The test is now pointless since we always assume that this option is
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:58:23 +02:00
Peter Krempa
88f7511923 qemuMonitorSetBlockIoThrottle: Remove booleans controlling used fields
All supported QEMU versions have all the fields so we can remove the
booleans controlling which fields are used on the monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:57:34 +02:00
Peter Krempa
9c3fdcdfec qemu: capabilties: Retire QEMU_CAPS_DRIVE_IOTUNE_* caps
They are no longer used as we now assume that all tuning caps are
present and in case some will be removed we'll need to use different
probing methods.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:56:33 +02:00
Peter Krempa
2a47d74758 qemu: capabilities: Rename QEMU_CAPS_CHARDEV_FD_PASS to QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE
Make it more obvious that we care about passing FDs on the commandline
before startup of qemu, which is used to avoid startup monitor polling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:54:46 +02:00
Peter Krempa
c678f2d61b qemuxml2argvtest: Remove negative tests for (aes|dea)keywrap (s390) property
Upcoming commit will always add the property so the negative tests would
stop working.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:37:08 +02:00
Ján Tomko
5590fbf8d6 Remove redundant labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
9302e249db Use g_autofree in affected functions
Add g_autofree to functions changed in previous commits doing
g_auto cleanup for libxml2-related variables, where it could
lead to removal of a label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
2c426d2e30 Use g_auto for xmlFreeDoc everywhere
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
5dae71ee8c Use g_auto for xmlXPathContext everywhere
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Pavel Hrdina
38b5f4faab conf: introduce support for Fibre Channel VMID
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 13:50:38 +02:00
Michal Privoznik
32f7db0989 vmx: Support super wide SCSI bus
Since its 6.7 release, vSphere allows up to 64 units on a SCSI
bus [1]. The release version translates to virtualHW_version 13
and thus if we are dealing with sufficiently new version we can
enable the feature.

1: https://configmax.vmware.com/guest?vmwareproduct=vSphere&release=vSphere%206.7&categories=1-0

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1738392
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Michal Privoznik
5c254bb541 conf: Store SCSI bus length in virDomainDef
Libvirt assumes that a SCSI bus can fit up to 8 devices
(including controller itself), except for so called wide bus
which can accommodate up to 16 devices (again, including
controller). This plays important role when computing 'drive'
address in virDomainDiskDefAssignAddress(). So far, the only
driver that enables wide SCSI bus is VMX. But with newer
releases, ESX is capable of "super wide" bus (64 devices).

We can blindly bump the limit in our code because then we would
compute address that's invalid for older ESX versions that we
still want to support.

Unfortunately, I haven't found a better place where to store this
than virDomainDef.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Michal Privoznik
de1829059a vmx2xmltest: Add a test case
This is an attachment from the following bug:

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

Notice that .vmx file has two scsi disks, but only one is
reported in the XML. This will be fixed later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Kristina Hanicova
f43c27960e src: add 'schema' and 'validate' variable to virXMLParseHelper()
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>
2021-08-12 13:12:29 +02:00
Peter Krempa
7f58028c2b testQemuAgentSSHKeys: Refactor cleanup
Use automatic memory freeing for the 'qemuMonitorTest' object and the
list of keys so that the cleanup section can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-09 10:09:00 +02:00
Jonathon Jongsma
3bd8181bc5 nodedev: Handle inactive mdevs with the same UUID
Unfortunately, mdevctl supports defining more than one mdev with the
same UUID as long as they have different parent devices. (Only one of
these devices can be active at any given time).

This means that we can't use the UUID alone as a way to uniquely
identify mdev node devices. Append the parent address to ensure
uniqueness. For example:

    Before: mdev_88a6b868_46bd_4015_8e5b_26107f82da38
    After:  mdev_88a6b868_46bd_4015_8e5b_26107f82da38_0000_00_02_0

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

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 15:02:38 -05:00
Jonathon Jongsma
08d29eb3b1 nodedev: add PostParse callback for nodedev parsing
This can be used similarly to other postparse callbacks in libvirt --
filling in additional information that can be determined by using the
information provided in the XML. In this case, we determine the address
of the parent device and cache it in the mdev caps so that we can use it
for generating a unique name and interacting with mdevctl.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 15:02:36 -05:00
Jonathon Jongsma
d5ae634ba2 nodedev: Add parser validation for node devices
At the moment, this is only for mediated devices. When a new mediated
device is created or defined, the xml is expected specify the nodedev
name of an existing device as its parent. We were not previously
validating this and were simply accepting any string here.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 15:02:32 -05:00
Jonathon Jongsma
a9c1febcf4 nodedev: fix xml output for mdev parents in test suite
Commit 51fbbfdce8 attempted to get the proper nodedev name for the
parent of an defined mdev by traversing the filesystem and looking for a
device that had the appropriate sysfs path.  This works, but it would be
cleaner to to avoid mucking around in the filesystem and instead just
just examine the list of devices we have in memory.

We already had a function nodeDeviceFindAddressByName() which constructs
an address for parent device in a format that can be used with mdevctl.
So if we refactor this function into a a function that simply formats an
address for an arbitrary virNodeDeviceObj*, then we can use this
function as a predicate for our new virNodeDeviceObjListFind() function
from the previous commit. This will search our list of devices for one
whose address matches the address we get from mdevctl.

One nice benefit of this approach is that our test cases will now
display xml output with the proper parent name for mdevs (assuming that
we've added the appropriate mock parent devices to the test driver).
Previously they just displayed 'computer' for the parent because the
alternative would have required specially constructing a mock filesystem
environment with a sysfs that mapped to the appropriate parent.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 15:02:23 -05:00