Commit Graph

114 Commits

Author SHA1 Message Date
Peter Krempa
2bde68b6c5 qemucapabilitiestest: Add support for '+hvf' variant
We need to signal to the capabilities code that HVF variant is used so
that it can behave as if it were running on OSX.

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:06 +02:00
Peter Krempa
1f85c31bd8 tests: Mock virQEMUCapsProbeHVF directly in qemucapabilitiestest
It needs to be mocked only for 'qemucapabilitiestest'. Additionally
moving it here will allow to control the return value based on the test
data which will be required for testing dumps from HVF accelerated qemu.

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:06 +02:00
Peter Krempa
111cfc5532 qemu: capabilities: Fix testing of 'TCG' capabilities probing
The logic in 'virQEMUCapsInitQMP' invokes a second probe of qemu in case
when acceleration is used and TCG is supported to specifically probe the
CPU and features of non-accelerated guests.

The same logic must then be used in 'qemucapabilitiestest' when
replaying the data for testing otherwise the test would fail.

Export 'virQEMUCapsHaveAccel' for test usage and use the same logic
in 'testQemuCaps'.

Fix the comment in 'virQEMUCapsInitQMP' to outline what's happening.

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:06 +02:00
Peter Krempa
2102a31bc2 tests: Add support for multiple variants of data for the same qemu version+architecture
'qemucapabilitiestest' and other users of the capability data can
benefit from adding a discriminator string to have multiple instances
for the same version+architecture tuple.

This will in the future allow us to have specific capability versions
for test cases which require a specific host feature or are based on a
different operating system.

Add the basic skeleton for parsing the variant string and passing it
around into 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>
2023-04-03 09:19:06 +02:00
Peter Krempa
36a735c553 tests: qemucapabilitiesdata: Add README file
Explain what the purpose of these files is as well as how they are
named, captured, used and modified.

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:06 +02:00
Peter Krempa
75e606974b qemucapabilitiesdata: Separate version from architecture with a '_'
Parsing a version where components are separated by dots, while other
components are also separated by dots is a bit insane. Separate the
version by an underscore.

To achieve this we rename all the caps files and adjust the appropriate
places formatting the path.

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:06 +02:00
Peter Krempa
b048218a8a qemu: Remove return value checks from calls to virQEMUCapsNewCopy
The function now can't fail.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 20:55:50 +01:00
Peter Krempa
e61adbf26b qemu: capabilities: Don't make callers check return of virQEMUCapsNew(Binary)
The allocation of the object itself can't fail. What can fail is the
creation of the class on a programming error. Rather than punting the
error up the stack abort() directly on the first occurence as the error
can't be fixed during runtime.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 20:55:50 +01:00
Andrea Bolognani
92cc65783e tests: Use domaincapsmock in qemucapabilitiestest
This doesn't change anything at the moment, but is necessary
for the upcoming fix.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Tested-by: Christophe de Dinechin <dinechin@redhat.com>
2022-08-10 17:49:30 +02:00
Tim Wiederhake
7cd0e26c81 Fix some typos
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-12 11:43:30 +01:00
Peter Krempa
c574a25932 tests: Remove 'qemucapsfixreplies'
The 'qemucapabilitiesnumbering' tool now replaces the role of this
script and provides way to programmatically modify the replies file on
top.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-03 13:14:43 +01:00
Michal Privoznik
7c79cfe4da tests: Drop cleanup/error labels
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-11 16:16:30 +01:00
Michal Privoznik
b118215703 tests: Use g_autoptr(qemuMonitorTest)
Instead of calling qemuMonitorTestFree() explicitly, we can use
g_autoptr() and let it be called automagically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-11 16:16:26 +01:00
Michal Privoznik
c8238579fb lib: Drop internal virXXXPtr typedefs
Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-13 17:00:38 +02:00
Daniel Henrique Barboza
83a39d3276 tests: get rid of 'make check' references
Update the remaining 'make check' references after the
switch to meson/ninja.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-08-17 08:42:47 +02:00
Ján Tomko
d43f393134 tests: qemu: remove unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
bcbb026993 tests: qemu: use g_autoptr where possible
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
845fee02c1 tests: qemu: use g_autofree where possible
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Daniel P. Berrangé
42b3e5b9e4 qemu: store the emulator name in the capabilities XML
We don't need this for any functional purpose, but when debugging hosts
it is useful to know what binary a given capabilities XML document is
associated with.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-12-23 16:39:38 +00:00
Ján Tomko
20071c9f99 Remove redundant usage of WITH_YAJL
As of commit 2a00ef6e71 which
was released in v5.2.0, we require YAJL to build the QEMU driver.

Remove the checks from code that requires the QEMU driver
or checks that also check for WITH_QEMU.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-12-13 14:57:32 +01:00
Daniel P. Berrangé
adf009b48f qemu: use host CPU object directly
Avoid grabbing the whole virCapsPtr object when we only need the
host CPU information.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-12-09 10:17:27 +00:00
Michal Privoznik
4fa804c0c7 tests: Use g_strdup_printf() instead of virAsprintf()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-11-12 16:15:59 +01:00
Andrea Bolognani
c4d6465aa7 tests: testQemuCapsIterate: Pass prefix and version to callback
Right now we're passing a "base" string that contains both,
separated by an underscore. Some changes that we're going to
introduce later will require us to have the version number on its
own, and instead of delegating the task of splitting the two apart
to the callback it make more sense to perform it upfront.

This change results in quite a bit of churn because we're now
using the version number only, without the prefix, to calculate
the dummy microcodeVersion.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:14 +02:00
Andrea Bolognani
5a45ed9c96 tests: testQemuCapsIterate: Pass suffix to callback
Right now users need to hardcode the suffix, which is not a big
deal since they're the ones who passed it to testQemuCapsIterate()
in the first place; however, since we're already passing most of
the information to the callback and we're going to add more later
on, it makes sense to be consistent and pass the suffix too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:12 +02:00
Andrea Bolognani
51495a4d73 tests: testQemuCapsIterate: Pass inputDir to callback
Right now users need to know input file live inside
TEST_QEMU_CAPS_PATH, which is bad layering.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:21:10 +02:00
Andrea Bolognani
dea6c10946 tests/qemucapabilities: Separate inputDir and outputDir
We'll need this later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-10-24 17:20:49 +02:00
Ján Tomko
1e2ae2e311 Use g_autofree instead of VIR_AUTOFREE
Since commit 44e7f02915
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOFREE is just an alias for g_autofree. Use the GLib macros
directly instead of our custom aliases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-16 12:06:43 +02:00
Daniel P. Berrangé
2c535e50f5 util: remove some no-op thread functions
Neither virThreadInitialize or virThreadOnExit do anything since we
dropped the Win32 threads impl, in favour of win-pthreads with:

  commit 0240d94c36
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Jan 22 16:17:10 2014 +0000

      Remove windows thread implementation in favour of pthreads

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-19 12:50:21 +01:00
Peter Krempa
1a77e0032b tests: Allow QMP schema testing in qemuMonitorTestNewFromFileFull
Pass in the schema data from the caller if QMP schema testing is
desired.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-06-07 16:18:45 +02:00
Andrea Bolognani
c64152b67c tests: Use TEST_QEMU_CAPS_PATH wherever possible
After the recent changes, there are only a few places left
where we use the explicit path instead of taking advantage of
the publicly available define; let's get rid of those too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-17 08:30:59 +02:00
Andrea Bolognani
45dff4bbfa tests: Drop dirname argument from testQemuCapsIterate()
As evidenced by all existing callers, the only directory it makes
sense to use is TEST_QEMU_CAPS_PATH, so let's just bake that into
the function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-17 08:30:57 +02:00
Andrea Bolognani
c2195bee24 tests: Document how to add new replies files
We already document how to generate them, so might as well
go the extra mile and document the remaining steps.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2019-03-18 15:49:47 +01:00
Andrea Bolognani
60943f0eec tests: Use testQemuCapsIterate()
With only a couple minor tweaks, we can make the existing
doCapsTest() functions with testQemuCapsIterate() and finally
remove the need to manually adjust the test programs every time
a new input file is introduced; moreover, this means that the
two lists can't possibly get out of sync anymore.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:12 +01:00
Andrea Bolognani
ad340f225a tests: Move code from DO_TEST() to doCapsTest()
This removes the awkard escaping and will allow us to perform
some more refactoring later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:06 +01:00
Andrea Bolognani
5a8ceba2f3 tests: Use virAsprintf() to build titles
We're using static string concatenation at the moment, but
that will no longer be a possibility in a bit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:04 +01:00
Andrea Bolognani
0c744afe1a tests: Move data directories into testQemuData
This removes a little duplication right away, and will allow
us to avoid introducing more later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:03 +01:00
Andrea Bolognani
c125a6ef2a tests: Move ret into testQemuData
This is not particularly useful right now, but will allow us
to refactor some functionality later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:07:01 +01:00
Andrea Bolognani
31044d6ff2 tests: Introduce testQemuDataInit() and testQemuDataReset()
These functions don't do anything too interesting right now,
but will be extended later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-03-13 11:06:56 +01:00
Chris Venteicher
5b13da5ca2 qemu_process: Enter QMP command mode when starting QEMU Process
qemuProcessQMPStart starts a QEMU process and monitor connection that
can be used by multiple functions possibly for multiple QMP commands.

The QMP exchange to exit capabilities negotiation mode and enter command
mode can only be performed once after the monitor connection is
established.

Move responsibility for entering QMP command mode into the
qemuProcessQMP code so multiple functions can issue QMP commands in
arbitrary orders.

This also simplifies the functions using the connection provided by
qemuProcessQMPStart to issue QMP commands.

Test code now needs to call qemuMonitorSetCapabilities to send the
message to switch to command mode because the test code does not use the
qemuProcessQMP command that internally calls qemuMonitorSetCapabilities.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-02-19 18:44:49 +01:00
Peter Krempa
aedd20386d tests: qemucaps: Make fake 'microcodeVersion' depend on filename instead of length
To avoid changes to the filled in microcode in case we change the caps
replies file for any reason make the number depend on the filename.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-02-08 08:23:26 +01:00
Andrea Bolognani
030f963129 tests: Add capabilities data for QEMU 4.0.0 on RISC-V
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-02-01 11:57:33 +01:00
Cole Robinson
fb0d0d6c54 tests: Add capabilities data for QEMU 4.0.0 x86_64
The next release of QEMU is going to be 4.0.0. A bit early, but
this adds capabilities data for x86_64 from current qemu git
15bede554162dda822cd762c689edb6fa32b6e3b

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-01-21 17:29:10 -05:00
Daniel P. Berrangé
568a417224 Enforce a standard header file guard symbol name
Require that all headers are guarded by a symbol named

  LIBVIRT_$FILENAME

where $FILENAME is the uppercased filename, with all characters
outside a-z changed into '_'.

Note we do not use a leading __ because that is technically a
namespace reserved for the toolchain.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-12-14 10:47:13 +00:00
Erik Skultety
9c4afbda34 test: caps: Add capabilities for QEMU 3.1.0
These are based on QEMU v3.1.0-rc2-41-g4822f1ee9e.

Acked-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-11-29 08:54:01 +01:00
Andrea Bolognani
e95bcd8d18 tests: Add capabilities data for QEMU 3.1.0 on ppc64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-11-27 17:12:15 +01:00
Boris Fiuczynski
d7434ae800 tests: Add capabilities data for QEMU 3.0.0 on s390x
The QEMU binary is compiled from the v3.0.0 tag.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2018-09-20 16:24:58 -04:00
Andrea Bolognani
a3676f3763 tests: Add more tests to qemucaps2xml
More specifically, everything that's tested by qemucapabilities
now goes through qemucaps2xml as well.

Ideally we'll rewrite both so that listing all test cases is
unnecessary and they get picked up automatically by listing the
contents of the input directory instead, but that's a refactor
for another day :)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-09-17 14:52:31 +02:00
Lubomir Rintel
869cb692fa tests: Add RISC-V architectures
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-08-24 13:23:36 +02:00
Ján Tomko
d99a89592d Revert "Switch from yajl to Jansson"
This reverts commit 9cf38263d0.

Jansson cannot parse QEMU's quirky JSON.
Revert back to yajl.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-08-13 15:50:01 +02:00
Ján Tomko
6f99de3148 Revert "m4: Introduce STABLE_ORDERING_JANSSON"
This reverts commit 4dd6054000.

Jansson cannot parse QEMU's quirky JSON.
Revert back to yajl.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-08-13 15:50:00 +02:00