Commit Graph

7217 Commits

Author SHA1 Message Date
Peter Krempa
db8ed4fed4 qemuxml2argvtest: Slightly modernize "cpu-host-model" case
Switch to q35 in anticipation of using DO_TEST_CAPS* in further patches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Peter Krempa
d1e48bd3db qemuxml2argvtest: Unify 'cpu-tsc-frequency' and 'cpu-tsc-high-frequency' case
Use the larger number in the original test to avoid having two files.

Additionally this avoids use of 'host-model' with DO_TEST_CAPS_LATEST in
cases when it isn't necessary for the purpose of the test as the CPU
model tends to change.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Peter Krempa
1e5c4d9999 qemuxml2argvdata: Don't use 'host-model' cpu in 'hugepages-memaccess3'
The test case doesn't really test anything about the specific CPU. Using
a host-model cpu with DO_TEST_CAPS_LATEST results in commandline changes
every time qemu updates the cpu definiton.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-25 10:33:38 +02:00
Kristina Hanicova
e70e8e2dd8 lxcxml2xmltest: Substitute 'inactive' variable with 'active'
I removed negation from the name of a variable to make the code
more readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-25 09:52:06 +02:00
Ján Tomko
e431293d74 tests: qemuxml2*test: switch to virTestRunLog
This essentially reverts:
commit ca5c8e1dc7
    qemuxml2argvtest: Avoid conditions in test macro

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
8628cbe6ad tests: cputests: introduce and use virTestRunLog
A helper that resets the log before each test and prints
it on failure.

It also takes the return variable as an argument,
so it can be used to eliminate number of branches
the compiler has to consider in the main function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
0ee2cc3ad8 tests: cputest: remove unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
32f1323cba tests: cputest: use g_autofree
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
849c06596e tests: cputest: use g_auto for virCPUDef
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
12185e5a3a tests: cputest: use g_auto for virCPUData
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
a32c2b2360 tests: cputest: use g_auto for virQEMUCaps
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
e2b5fc9a8b tests: use g_auto in cpuTestMakeQEMUCaps
Refactor to use automatic cleanup and remove the goto's.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
406a6c20a8 tests: virnetdev*: remove unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
0846343861 tests: introduce testVirNetDevBandwidthParse
The 'PARSE' macro does not use '#' or '##' directives,
or anything from outside of the macro other than the
cleanup label.

Turn it into a function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
3e74bb8321 tests: virnetdevbandwidthtest: use g_auto
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
780b5ab62a tests: virnetdevopenvswitch: use g_auto
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
4a0c0d85d2 build: only build virnetdevopenvswitchtest on Linux
Now that it uses virnetdevbandwidthmock which we only
build on Linux.

Fixes: eb55e8a897
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:19 +02:00
Peter Krempa
ca444a2eb2 qemublocktest: Add test for creating a qcow2 on top of an luks-encrypted qcow2
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:43:17 +02:00
Kristina Hanicova
5e71d3ad57 conf: add validation and propagate flags into virInterfaceDefParse()
We need to know if validation flag is present in order to
validate given XML against schema in virXMLParse().

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-20 15:41:21 +02:00
Ján Tomko
0447e6243b tests: use g_auto in qemuTestParseCapabilitiesArch
Refactor qemuTestParseCapabilitiesArch to use g_auto for cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-20 15:19:35 +02:00
Ján Tomko
693831a58d tests: use g_auto in testQemuGetCaps
Refactor testQemuGetCaps to use g_auto for cleanup,
remove the error label and use g_steal_pointer for
the successful return path.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-20 15:19:35 +02:00
Jinsheng Zhang
eb55e8a897 tests: add test on virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos
Test virNetDevOpenvswitchInterfaceSetQos and
virNetDevOpenvswitchInterfaceClearQos with dryrun method.

Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 16:47:40 +02:00
Martin Kletzander
2b6bc910b7 tests: Add missing test cases to vmx2xmltest
Commit 42b2f35d36 was meant to test all four combinations of
serial-pipe-{server,client}-{app,vm} files, but did only add the files and by
mistake duplicated the tests.  Those were later removed as duplicates, so add
them back in.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-19 13:32:10 +02:00
Luke Yue
ba32bf03b2 tests: Test BlkioParameters related functions for test driver
Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-19 13:31:57 +02:00
Michal Privoznik
d080338594 tests: Drop vmx2xml- prefix for vmx2xml test cases
These XMLs live in a separate directory, there's no need for them
to have a special prefix in addition. Dinding proper file based on
vmx2xmltest.c is also needlessly complicated.

The steps used for mass rename are similar to v4.0.0-rc1~186.

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:28:03 +02:00
Michal Privoznik
c0748ac870 vmx2xmltest: Deduplicate DO_TEST*() arguments
In majority of DO_TEST() and DO_TEST_FAIL() calls the input vmx
file name is the same as the output XML file. Therefore, it's not
necessary to provide the same string twice. For the rest, where
the output XML file is different we can use symlinks to the
expected output.

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:59 +02:00
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
Peter Krempa
0b450b0ad1 virNWFilterRuleDefToRuleInst: Remove pointless assignment
'ruleinst' is NULLed by VIR_APPEND_ELEMENT

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 08:53:26 +02:00
Peter Krempa
f90de01763 util: alloc: Completely replace VIR_APPEND_ELEMENT_QUIET by VIR_APPEND_ELEMENT
VIR_APPEND_ELEMENT doesn't report any errors now so we can remove
VIR_APPEND_ELEMENT_QUIET and replace all uses by VIR_APPEND_ELEMENT

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 08:53:25 +02:00
Peter Krempa
98f6f2081d util: alloc: Reimplement VIR_APPEND_ELEMENT using virAppendElement
Use virAppendElement instead of virInsertElementsN to implement
VIR_APPEND_ELEMENT which allows us to remove error handling as the
only relevant errors were removed when switching to aborting memory
allocation functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 08:53:25 +02:00
Peter Krempa
8c22b28dbe util: alloc: Reimplement VIR_APPEND_ELEMENT_QUIET using virAppendElement
For now it was an alias to VIR_APPEND_ELEMENT. Use virAppendElement
directly until VIR_APPEND_ELEMENT is refactored too and we'll be able to
get rid of VIR_APPEND_ELEMENT_QUIET completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 08:53:25 +02:00
Peter Krempa
592517636f util: alloc: Reimplement VIR_APPEND_ELEMENT_COPY using virAppendElement
Use virAppendElement instead of virInsertElementsN to implement
VIR_APPEND_ELEMENT_COPY which allows us to remove error handling as the
only relevant errors were removed when switching to aborting memory
allocation functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 08:53:25 +02:00
Michal Privoznik
73890139bf tests: Don't leak cpu defs
There are cpu definitions that are allocated in
qemuTestDriverInit() but are missing corresponding
virCPUDefFree() call in qemuTestDriverFree(). It's safe to call
the free function because the definitions contain a refcounter
and thus even if they were still in use the refcounter would be
just decreased.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-05 14:53:19 +02:00
Andrea Bolognani
b298fc142f tests: Test pcie-expander-bus for aarch64/virt guests
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-04 09:58:16 +02:00
Andrea Bolognani
f225ef2a04 qemu: Allow pcie-expander-bus for aarch64/virt guests
Starting with QEMU 6.0, this controller is enabled by default
on aarch64.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-04 09:58:14 +02:00
Andrea Bolognani
e9e0876a96 tests: Add capabilities for QEMU 6.0 on aarch64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-04 09:58:09 +02:00
Luke Yue
8d90bf34f5 examples: test: Add a new test xml with more tainted configs for testing
Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-03 14:22:10 +02:00
Luke Yue
7c399a9b0e test_driver: Introduce testDomainObjCheckTaint
In order to test the virDomainGetMessages for test driver, we need to
check some taints or deprecations, so introduce testDomainObjCheckTaint
for checking taints.

As we introduced testDomainObjCheckTaint for test driver, the `dominfo`
command in virshtest will now print tainting messages, so add them for
test.

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-03 14:22:10 +02:00
Michal Privoznik
77f7067059 testutils: Don't leak @testBitmap and @failedTests
In virTestMain() the @failedTests bitmap is allocated and
optionally @testBitmap too. But neither of them is freed.

Fixes: 0cd5a726e3
Fixes: cebb468ef5
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-02 14:14:33 +02:00
Michal Privoznik
7d661d6e20 vmx: Parse vm.genid
The VMware metadata file contains genid but we are not parsing
and thus reporting it in domain XML. However, it's not as
straightforward as one might think. The UUID reported by VMware
is not in its usual string form, but split into two signed long
longs. That means, we have to do a bit of trickery when parsing.
But looking around it's the same magic that libguestfs does:

https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421

It's also explained by Rich on qemu-devel:

https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2021-08-02 12:54:17 +02:00
Peter Krempa
dc0b9c8376 qemu: block: Pass discard requests through the copy-on-read block filter
We need to pass the 'trim' requests through the copy-on-read filter so
if a user configures a discard policy on the disk the requests get
through to the appropriate format layer in the blockdev tree.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1986509
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2021-07-28 15:18:18 +02:00
Peter Krempa
d2ce164ee2 securityselinuxlabeltest: Add debug statements for testUserXattrEnabled return value
I've noticed the test being skipped in my build scenario (tmpfs) and
the output doesn't make it clear why it's happening.

Add debug statements for the various return values of
testUserXattrEnabled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-26 21:08:17 +02:00
Peter Krempa
b04e1fddf7 qemu: capabilities: Enable detection of QEMU_CAPS_BLOCKDEV_REOPEN
Base it on the presence of the "blockdev-reopen" QMP command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-07-26 20:25:23 +02:00
Peter Krempa
4ea9df4dad qemumonitorjsontest: Add test case for 'blockdev-reopen'
Export 'qemuBlockReopenFormatMon' and use it in a new test case wich
will validate the arguments against the QMP schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-07-26 20:25:22 +02:00
Peter Krempa
378f2263ba tests: qemucapabilities: Update capabilities for qemu-6.1.0-rc0 on x86_64
Update to v6.1.0-rc0-48-g7b7ca8ebde

Notable changes are:
 - stabilization of 'blockdev-reopen'
 - addition of the 'vmx-tsc-scaling' cpu flag
 - Supported display types are now in the schema only if they are compiled in.
 - rbd image encryption
 - 'aio-max-batch' iothread property

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-07-26 20:25:22 +02:00
Tim Wiederhake
3ae0c7715e qemusecuritymock: init_hash: virHashNew cannot return NULL
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-07-23 11:30:31 +02:00
Justin Gatzen
e7d579a2dd conf: Add grabToggle to evdev input
Add support for customizable grabToggle key combinations with
<input type='evdev'>.

Signed-off-by: Justin Gatzen <justin.gatzen@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-23 11:20:48 +02:00
Boris Fiuczynski
19b088cfb9 nodedev: fix internal error when no defined mdevs exist
Commit e9b534905f introduced an error when parsing an empty list
returned from mdevctl.

This occurs e.g. if nodedev-undefine is used to undefine the last
defined mdev which causes the following error messages

 libvirtd[33143]: internal error: Unexpected format for mdevctl response
 libvirtd[33143]: internal error: failed to query mdevs from mdevctl:
 libvirtd[33143]: mdevctl failed to updated mediated devices

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-07-22 10:53:44 -05:00
Pavel Hrdina
299174c532 qemuxml2argvmock: drop virQEMUCapsGetKVMSupportsSecureGuest
It is actually not needed because in qemuxml2argvtest we preload
domaincapsmock as well.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-22 15:55:26 +02:00
Pavel Hrdina
e7934a7a6d tests: fix compiling tests with minGW
We need to mock virQEMUCapsGetKVMSupportsSecureGuest only if compiling
with QEMU otherwise compilation will fail with error:

/usr/lib/gcc/i686-w64-mingw32/11.1.1/../../../../i686-w64-mingw32/bin/ld: tests/libdomaincapsmock.dll.p/domaincapsmock.c.obj: in function `virQEMUCapsGetKVMSupportsSecureGuest':
/builds/libvirt/libvirt/build/../tests/domaincapsmock.c:40: undefined reference to `virQEMUCapsGet'
/usr/lib/gcc/i686-w64-mingw32/11.1.1/../../../../i686-w64-mingw32/bin/ld: /builds/libvirt/libvirt/build/../tests/domaincapsmock.c:41: undefined reference to `virQEMUCapsGet'

Fixes: 248a30c0c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-22 15:07:17 +02:00
Kristina Hanicova
bcad39457d genericxml2xmltest: Refactor DO_TEST_FULL() calls
I have added 2 new macros to call tests which are expected to
fail in order to make the code more consistent and readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-21 14:40:50 +02:00