All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels'
@ 2021-05-26 17:04 Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 01/12] MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section Philippe Mathieu-Daudé
                   ` (12 more replies)
  0 siblings, 13 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, qemu-arm, Paolo Bonzini

Hi,

This series aims at having accelerator-independent qtests
by querying a QEMU instance at runtime to check the list
of built-in accelerators.

First we add the 'query-accels' QMP command,
then we add the qtest_has_accel() method to libqtest,
finally we use this new method to allow running
bios-tables-test on KVM-only builds.

This series is expected to be merged via the ARM tree.

Since v7:
- Include Markus code (see patch #2)

Since v6:
- Fixed a typo (Eric)
- Added R-b tags

Since v5:
- Rename bios-tables tests (Igor)
- Do not restrict bios-tables tests to TCG (Igor)
- Reset bios-tables-test R-b tags

Since v4:
- Removed patch 10 (Markus, patch justification not clear)
  'qtest/qmp-cmd-test: Make test build-independent from accelerator'
- Removed patch 12 (Alex, icount / record/replay issue)
  'tests/meson: Only build softfloat objects if TCG is selected (again)'
- Sorted @Accelerator QAPI enum (Eric)
- Added R-b/T-b

Since v3:
- Added Markus review comments
- Added R-b/A-b tags

Since v2:
- Addressed Markus & Drew review comments
- Added qtest/migration-test patch

Since v1:
- Addressed Eric & Paolo review comments

Since v0:
- kept over-engineered union (I don't how to do simple enum)
- dropped arm-cpu-features patches for now
- fixed typos (Eric)
- rename qtest_has_accel (Thomas)
- probe accel with machine none previous qtest (Paolo)
- iterate over QAPI enum (Markus)

Eric's suggestion of conditional QAPI didn't worked out,
as accelerator definitions are poisoned.

Phil.

$ git backport-diff v6
Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respective=
ly

001/12:[----] [--] 'MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs=
 section'
002/12:[0048] [FC] 'accel: Introduce 'query-accels' QMP command'
003/12:[----] [--] 'qtest: Add qtest_has_accel() method'
004/12:[----] [--] 'qtest/arm-cpu-features: Use generic qtest_has_accel() to =
check for KVM'
005/12:[----] [--] 'qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm te=
st to KVM'
006/12:[----] [--] 'qtest/arm-cpu-features: Remove TCG fallback to KVM specif=
ic tests'
007/12:[----] [--] 'qtest/arm-cpu-features: Use generic qtest_has_accel() to =
check for TCG'
008/12:[----] [--] 'qtest/migration-test: Skip tests if KVM not builtin on s3=
90x/ppc64'
009/12:[----] [--] 'qtest/bios-tables-test: Rename tests not TCG specific'
010/12:[----] [--] 'qtest/bios-tables-test: Rename TCG specific tests'
011/12:[----] [--] 'qtest/bios-tables-test: Make test build-independent from =
accelerator'
012/12:[----] [--] 'qtest: Do not restrict bios-tables-test to Aarch64 hosts =
anymore'

Philippe Mathieu-Daud=C3=A9 (12):
  MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section
  accel: Introduce 'query-accels' QMP command
  qtest: Add qtest_has_accel() method
  qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
  qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM
  qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests
  qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG
  qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64
  qtest/bios-tables-test: Rename tests not TCG specific
  qtest/bios-tables-test: Rename TCG specific tests
  qtest/bios-tables-test: Make test build-independent from accelerator
  qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore

 qapi/machine-target.json       |  54 ++++++++++++
 tests/qtest/libqos/libqtest.h  |   8 ++
 accel/accel-qmp.c              |  32 +++++++
 tests/qtest/arm-cpu-features.c |  55 ++++--------
 tests/qtest/bios-tables-test.c | 156 ++++++++++++++++-----------------
 tests/qtest/libqtest.c         |  29 ++++++
 tests/qtest/migration-test.c   |   4 +-
 MAINTAINERS                    |   1 +
 accel/meson.build              |   2 +-
 tests/qtest/meson.build        |   3 +-
 10 files changed, 222 insertions(+), 122 deletions(-)
 create mode 100644 accel/accel-qmp.c

--=20
2.26.3




^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v8 01/12] MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Andrew Jones, Eduardo Habkost,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Thomas Huth, Paolo Bonzini

We want the ARM maintainers and the qemu-arm@ list to be
notified when this file is modified. Add an entry to the
'ARM TCG CPUs' section in the MAINTAINERS file.

Acked-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a77f2465694..52757b08540 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -156,6 +156,7 @@ S: Maintained
 F: target/arm/
 F: tests/tcg/arm/
 F: tests/tcg/aarch64/
+F: tests/qtest/arm-cpu-features.c
 F: hw/arm/
 F: hw/cpu/a*mpcore.c
 F: include/hw/cpu/a*mpcore.h
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 01/12] MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-06-02 23:26   ` John Snow
                     ` (3 more replies)
  2021-05-26 17:04 ` [PATCH v8 03/12] qtest: Add qtest_has_accel() method Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  12 siblings, 4 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Paolo Bonzini, John Snow

Introduce the 'query-accels' QMP command which returns a list
of built-in accelerator names.

- Accelerator is a QAPI enum of all existing accelerators,

- AcceleratorInfo is a QAPI structure providing accelerator
  specific information. Currently the common structure base
  provides the name of the accelerator, while the specific
  part is empty, but each accelerator can expand it.

- 'query-accels' QMP command returns a list of @AcceleratorInfo

For example on a KVM-only build we get:

    { "execute": "query-accels" }
    {
        "return": [
            {
                "name": "qtest"
            },
            {
                "name": "kvm"
            }
        ]
    }

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v8:
- Include code snippet from Markus adding to machine-target.json
  to be able to use enum values or union branches conditional.
- Use accel_find() on enum to be sure the accelerator is enabled
  at runtime (chat with jsnow / eblake).

Cc: Eric Blake <eblake@redhat.com>
Cc: John Snow <jsnow@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
---
 qapi/machine-target.json | 54 ++++++++++++++++++++++++++++++++++++++++
 accel/accel-qmp.c        | 32 ++++++++++++++++++++++++
 accel/meson.build        |  2 +-
 3 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 accel/accel-qmp.c

diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index e7811654b72..586a61b5d99 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -329,3 +329,57 @@
 ##
 { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
   'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
+
+##
+# @Accelerator:
+#
+# An enumeration of accelerator names.
+#
+# Since: 6.1
+##
+{ 'enum': 'Accelerator',
+  'data': [
+      { 'name': 'hax', 'if': 'defined(CONFIG_HAX)' },
+      { 'name': 'hvf', 'if': 'defined(CONFIG_HVF)' },
+      { 'name': 'kvm', 'if': 'defined(CONFIG_KVM)' },
+      { 'name': 'qtest' },
+      { 'name': 'tcg', 'if': 'defined(CONFIG_TCG)' },
+      { 'name': 'whpx', 'if': 'defined(CONFIG_WHPX)' },
+      { 'name': 'xen', 'if': 'defined(CONFIG_XEN_BACKEND)' } ] }
+
+##
+# @AcceleratorInfo:
+#
+# Accelerator information.
+#
+# @name: The accelerator name.
+#
+# Since: 6.1
+##
+{ 'struct': 'AcceleratorInfo',
+  'data': { 'name': 'Accelerator' } }
+
+##
+# @query-accels:
+#
+# Get a list of AcceleratorInfo for all built-in accelerators.
+#
+# Returns: a list of @AcceleratorInfo describing each accelerator.
+#
+# Since: 6.1
+#
+# Example:
+#
+# -> { "execute": "query-accels" }
+# <- { "return": [
+#        {
+#            "name": "qtest"
+#        },
+#        {
+#            "name": "kvm"
+#        }
+#    ] }
+#
+##
+{ 'command': 'query-accels',
+  'returns': ['AcceleratorInfo'] }
diff --git a/accel/accel-qmp.c b/accel/accel-qmp.c
new file mode 100644
index 00000000000..0098297caa5
--- /dev/null
+++ b/accel/accel-qmp.c
@@ -0,0 +1,32 @@
+/*
+ * QEMU accelerators, QMP commands
+ *
+ * Copyright (c) 2021 Red Hat Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/accel.h"
+#include "qapi/qapi-types-machine-target.h"
+#include "qapi/qapi-commands-machine-target.h"
+
+AcceleratorInfoList *qmp_query_accels(Error **errp)
+{
+    AcceleratorInfoList *list = NULL, **tail = &list;
+
+    for (Accelerator accel = 0; accel < ACCELERATOR__MAX; accel++) {
+        AcceleratorInfo *info;
+
+        if (!accel_find(Accelerator_str(accel))) {
+            /* Accelerator available at build time but not at runtime. */
+            continue;
+        }
+
+        info = g_new0(AcceleratorInfo, 1);
+        info->name = accel;
+        QAPI_LIST_APPEND(tail, info);
+    }
+
+    return list;
+}
diff --git a/accel/meson.build b/accel/meson.build
index b44ba30c864..7a48f6d568d 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -1,4 +1,4 @@
-specific_ss.add(files('accel-common.c'))
+specific_ss.add(files('accel-common.c', 'accel-qmp.c'))
 softmmu_ss.add(files('accel-softmmu.c'))
 user_ss.add(files('accel-user.c'))
 
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 03/12] qtest: Add qtest_has_accel() method
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 01/12] MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 04/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Peter Maydell, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Paolo Bonzini

Introduce the qtest_has_accel() method which allows a runtime
query on whether a QEMU instance has an accelerator built-in.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/libqos/libqtest.h |  8 ++++++++
 tests/qtest/libqtest.c        | 29 +++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h
index a68dcd79d44..d80c618c18d 100644
--- a/tests/qtest/libqos/libqtest.h
+++ b/tests/qtest/libqos/libqtest.h
@@ -763,6 +763,14 @@ void qmp_expect_error_and_unref(QDict *rsp, const char *class);
  */
 bool qtest_probe_child(QTestState *s);
 
+/**
+ * qtest_has_accel:
+ * @accel_name: Accelerator name to check for.
+ *
+ * Returns: true if the accelerator is built in.
+ */
+bool qtest_has_accel(const char *accel_name);
+
 /**
  * qtest_set_expected_status:
  * @s: QTestState instance to operate on.
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 825b13a44c7..6bda6e1f331 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -393,6 +393,35 @@ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd)
     return qts;
 }
 
+bool qtest_has_accel(const char *accel_name)
+{
+    bool has_accel = false;
+    QDict *response;
+    QList *accels;
+    QListEntry *accel;
+    QTestState *qts;
+
+    qts = qtest_initf("-accel qtest -machine none");
+    response = qtest_qmp(qts, "{'execute': 'query-accels'}");
+    accels = qdict_get_qlist(response, "return");
+
+    QLIST_FOREACH_ENTRY(accels, accel) {
+        QDict *accel_dict = qobject_to(QDict, qlist_entry_obj(accel));
+        const char *name = qdict_get_str(accel_dict, "name");
+
+        if (g_str_equal(name, accel_name)) {
+            has_accel = true;
+            break;
+        }
+    }
+    qobject_unref(response);
+
+    qtest_quit(qts);
+
+    return has_accel;
+}
+
+
 void qtest_quit(QTestState *s)
 {
     qtest_remove_abrt_handler(s);
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 04/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 03/12] qtest: Add qtest_has_accel() method Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 05/12] qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Peter Maydell, Andrew Jones, Eduardo Habkost,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Claudio Fontana, Thomas Huth, Paolo Bonzini

Use the recently added generic qtest_has_accel() method to
check if KVM is available.

Suggested-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/arm-cpu-features.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index 8252b85bb85..7f4b2521277 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -26,21 +26,6 @@
                     "  'arguments': { 'type': 'full', "
 #define QUERY_TAIL  "}}"
 
-static bool kvm_enabled(QTestState *qts)
-{
-    QDict *resp, *qdict;
-    bool enabled;
-
-    resp = qtest_qmp(qts, "{ 'execute': 'query-kvm' }");
-    g_assert(qdict_haskey(resp, "return"));
-    qdict = qdict_get_qdict(resp, "return");
-    g_assert(qdict_haskey(qdict, "enabled"));
-    enabled = qdict_get_bool(qdict, "enabled");
-    qobject_unref(resp);
-
-    return enabled;
-}
-
 static QDict *do_query_no_props(QTestState *qts, const char *cpu_type)
 {
     return qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s }"
@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
 
     qts = qtest_init(MACHINE_KVM "-cpu max");
 
-    /*
-     * These tests target the 'host' CPU type, so KVM must be enabled.
-     */
-    if (!kvm_enabled(qts)) {
-        qtest_quit(qts);
-        return;
-    }
-
     /* Enabling and disabling kvm-no-adjvtime should always work. */
     assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");
     assert_set_feature(qts, "host", "kvm-no-adjvtime", true);
@@ -624,7 +601,7 @@ int main(int argc, char **argv)
      * order avoid attempting to run an AArch32 QEMU with KVM on
      * AArch64 hosts. That won't work and isn't easy to detect.
      */
-    if (g_str_equal(qtest_get_arch(), "aarch64")) {
+    if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) {
         qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
                             NULL, test_query_cpu_model_expansion_kvm);
     }
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 05/12] qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 04/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 06/12] qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Peter Maydell, Andrew Jones, Eduardo Habkost,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Thomas Huth, Paolo Bonzini

The sve_tests_sve_off_kvm() test is KVM specific.
Only run it if KVM is available.

Suggested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/arm-cpu-features.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index 7f4b2521277..66300c3bc20 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -604,6 +604,8 @@ int main(int argc, char **argv)
     if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) {
         qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
                             NULL, test_query_cpu_model_expansion_kvm);
+        qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
+                            NULL, sve_tests_sve_off_kvm);
     }
 
     if (g_str_equal(qtest_get_arch(), "aarch64")) {
@@ -611,8 +613,6 @@ int main(int argc, char **argv)
                             NULL, sve_tests_sve_max_vq_8);
         qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
                             NULL, sve_tests_sve_off);
-        qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
-                            NULL, sve_tests_sve_off_kvm);
     }
 
     return g_test_run();
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 06/12] qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 05/12] qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 07/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Peter Maydell, Andrew Jones, Eduardo Habkost,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Thomas Huth, Paolo Bonzini

sve_tests_sve_off_kvm() and test_query_cpu_model_expansion_kvm()
tests are now only being run if KVM is available. Drop the TCG
fallback.

Suggested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/arm-cpu-features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index 66300c3bc20..b1d406542f7 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -21,7 +21,7 @@
 #define SVE_MAX_VQ 16
 
 #define MACHINE     "-machine virt,gic-version=max -accel tcg "
-#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg "
+#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "
 #define QUERY_HEAD  "{ 'execute': 'query-cpu-model-expansion', " \
                     "  'arguments': { 'type': 'full', "
 #define QUERY_TAIL  "}}"
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 07/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 06/12] qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 08/12] qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64 Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Peter Maydell, Andrew Jones, Eduardo Habkost,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Thomas Huth, Paolo Bonzini

Now than we can probe if the TCG accelerator is available
at runtime with a QMP command, only run these tests if TCG
is built into the QEMU binary.

Suggested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/arm-cpu-features.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index b1d406542f7..0d9145dd168 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -20,7 +20,7 @@
  */
 #define SVE_MAX_VQ 16
 
-#define MACHINE     "-machine virt,gic-version=max -accel tcg "
+#define MACHINE_TCG "-machine virt,gic-version=max -accel tcg "
 #define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "
 #define QUERY_HEAD  "{ 'execute': 'query-cpu-model-expansion', " \
                     "  'arguments': { 'type': 'full', "
@@ -337,7 +337,7 @@ static void sve_tests_sve_max_vq_8(const void *data)
 {
     QTestState *qts;
 
-    qts = qtest_init(MACHINE "-cpu max,sve-max-vq=8");
+    qts = qtest_init(MACHINE_TCG "-cpu max,sve-max-vq=8");
 
     assert_sve_vls(qts, "max", BIT_ULL(8) - 1, NULL);
 
@@ -372,7 +372,7 @@ static void sve_tests_sve_off(const void *data)
 {
     QTestState *qts;
 
-    qts = qtest_init(MACHINE "-cpu max,sve=off");
+    qts = qtest_init(MACHINE_TCG "-cpu max,sve=off");
 
     /* SVE is off, so the map should be empty. */
     assert_sve_vls(qts, "max", 0, NULL);
@@ -428,7 +428,7 @@ static void test_query_cpu_model_expansion(const void *data)
 {
     QTestState *qts;
 
-    qts = qtest_init(MACHINE "-cpu max");
+    qts = qtest_init(MACHINE_TCG "-cpu max");
 
     /* Test common query-cpu-model-expansion input validation */
     assert_type_full(qts);
@@ -593,8 +593,10 @@ int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
 
-    qtest_add_data_func("/arm/query-cpu-model-expansion",
-                        NULL, test_query_cpu_model_expansion);
+    if (qtest_has_accel("tcg")) {
+        qtest_add_data_func("/arm/query-cpu-model-expansion",
+                            NULL, test_query_cpu_model_expansion);
+    }
 
     /*
      * For now we only run KVM specific tests with AArch64 QEMU in
@@ -608,7 +610,7 @@ int main(int argc, char **argv)
                             NULL, sve_tests_sve_off_kvm);
     }
 
-    if (g_str_equal(qtest_get_arch(), "aarch64")) {
+    if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("tcg")) {
         qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8",
                             NULL, sve_tests_sve_max_vq_8);
         qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 08/12] qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 07/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 09/12] qtest/bios-tables-test: Rename tests not TCG specific Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Peter Maydell, Thomas Huth, Eduardo Habkost,
	Juan Quintela, Philippe Mathieu-Daudé,
	Cornelia Huck, Richard Henderson, Markus Armbruster, Greg Kurz,
	Alex Bennée, qemu-arm, Paolo Bonzini,
	Dr. David Alan Gilbert, David Gibson

We might have a s390x/ppc64 QEMU binary built without the KVM
accelerator (configured with --disable-kvm).
Checking for /dev/kvm accessibility isn't enough, also check for the
accelerator in the binary.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/migration-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 2b028df6875..102bc36b91c 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -1387,7 +1387,7 @@ int main(int argc, char **argv)
      */
     if (g_str_equal(qtest_get_arch(), "ppc64") &&
         (access("/sys/module/kvm_hv", F_OK) ||
-         access("/dev/kvm", R_OK | W_OK))) {
+         access("/dev/kvm", R_OK | W_OK) || !qtest_has_accel("kvm"))) {
         g_test_message("Skipping test: kvm_hv not available");
         return g_test_run();
     }
@@ -1398,7 +1398,7 @@ int main(int argc, char **argv)
      */
     if (g_str_equal(qtest_get_arch(), "s390x")) {
 #if defined(HOST_S390X)
-        if (access("/dev/kvm", R_OK | W_OK)) {
+        if (access("/dev/kvm", R_OK | W_OK) || !qtest_has_accel("kvm")) {
             g_test_message("Skipping test: kvm not available");
             return g_test_run();
         }
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 09/12] qtest/bios-tables-test: Rename tests not TCG specific
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 08/12] qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64 Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:04 ` [PATCH v8 10/12] qtest/bios-tables-test: Rename TCG specific tests Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Michael S. Tsirkin,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, qemu-arm, Igor Mammedov,
	Paolo Bonzini

Various tests don't require TCG, but have '_tcg' in their name.
As this is misleading, remove 'tcg' from their name.

Reported-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/bios-tables-test.c | 142 ++++++++++++++++-----------------
 1 file changed, 71 insertions(+), 71 deletions(-)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index 156d4174aa3..ce498b3ff48 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -753,7 +753,7 @@ static uint8_t base_required_struct_types[] = {
     0, 1, 3, 4, 16, 17, 19, 32, 127
 };
 
-static void test_acpi_piix4_tcg(void)
+static void test_acpi_piix4(void)
 {
     test_data data;
 
@@ -768,7 +768,7 @@ static void test_acpi_piix4_tcg(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_bridge(void)
+static void test_acpi_piix4_bridge(void)
 {
     test_data data;
 
@@ -824,7 +824,7 @@ static void test_acpi_piix4_no_acpi_pci_hotplug(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg(void)
+static void test_acpi_q35(void)
 {
     test_data data;
 
@@ -841,7 +841,7 @@ static void test_acpi_q35_tcg(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_bridge(void)
+static void test_acpi_q35_bridge(void)
 {
     test_data data;
 
@@ -855,7 +855,7 @@ static void test_acpi_q35_tcg_bridge(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_mmio64(void)
+static void test_acpi_q35_mmio64(void)
 {
     test_data data = {
         .machine = MACHINE_Q35,
@@ -872,7 +872,7 @@ static void test_acpi_q35_tcg_mmio64(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_cphp(void)
+static void test_acpi_piix4_cphp(void)
 {
     test_data data;
 
@@ -888,7 +888,7 @@ static void test_acpi_piix4_tcg_cphp(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_cphp(void)
+static void test_acpi_q35_cphp(void)
 {
     test_data data;
 
@@ -908,7 +908,7 @@ static uint8_t ipmi_required_struct_types[] = {
     0, 1, 3, 4, 16, 17, 19, 32, 38, 127
 };
 
-static void test_acpi_q35_tcg_ipmi(void)
+static void test_acpi_q35_ipmi(void)
 {
     test_data data;
 
@@ -923,7 +923,7 @@ static void test_acpi_q35_tcg_ipmi(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_ipmi(void)
+static void test_acpi_piix4_ipmi(void)
 {
     test_data data;
 
@@ -941,7 +941,7 @@ static void test_acpi_piix4_tcg_ipmi(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_memhp(void)
+static void test_acpi_q35_memhp(void)
 {
     test_data data;
 
@@ -957,7 +957,7 @@ static void test_acpi_q35_tcg_memhp(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_memhp(void)
+static void test_acpi_piix4_memhp(void)
 {
     test_data data;
 
@@ -973,7 +973,7 @@ static void test_acpi_piix4_tcg_memhp(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_nosmm(void)
+static void test_acpi_piix4_nosmm(void)
 {
     test_data data;
 
@@ -984,7 +984,7 @@ static void test_acpi_piix4_tcg_nosmm(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_smm_compat(void)
+static void test_acpi_piix4_smm_compat(void)
 {
     test_data data;
 
@@ -995,7 +995,7 @@ static void test_acpi_piix4_tcg_smm_compat(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_smm_compat_nosmm(void)
+static void test_acpi_piix4_smm_compat_nosmm(void)
 {
     test_data data;
 
@@ -1006,7 +1006,7 @@ static void test_acpi_piix4_tcg_smm_compat_nosmm(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_nohpet(void)
+static void test_acpi_piix4_nohpet(void)
 {
     test_data data;
 
@@ -1017,7 +1017,7 @@ static void test_acpi_piix4_tcg_nohpet(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_numamem(void)
+static void test_acpi_q35_numamem(void)
 {
     test_data data;
 
@@ -1029,7 +1029,7 @@ static void test_acpi_q35_tcg_numamem(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_nosmm(void)
+static void test_acpi_q35_nosmm(void)
 {
     test_data data;
 
@@ -1040,7 +1040,7 @@ static void test_acpi_q35_tcg_nosmm(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_smm_compat(void)
+static void test_acpi_q35_smm_compat(void)
 {
     test_data data;
 
@@ -1051,7 +1051,7 @@ static void test_acpi_q35_tcg_smm_compat(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_smm_compat_nosmm(void)
+static void test_acpi_q35_smm_compat_nosmm(void)
 {
     test_data data;
 
@@ -1062,7 +1062,7 @@ static void test_acpi_q35_tcg_smm_compat_nosmm(void)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_nohpet(void)
+static void test_acpi_q35_nohpet(void)
 {
     test_data data;
 
@@ -1073,7 +1073,7 @@ static void test_acpi_q35_tcg_nohpet(void)
     free_test_data(&data);
 }
 
-static void test_acpi_piix4_tcg_numamem(void)
+static void test_acpi_piix4_numamem(void)
 {
     test_data data;
 
@@ -1087,11 +1087,11 @@ static void test_acpi_piix4_tcg_numamem(void)
 
 uint64_t tpm_tis_base_addr;
 
-static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,
+static void test_acpi_tpm(const char *machine, const char *tpm_if,
                               uint64_t base)
 {
 #ifdef CONFIG_TPM
-    gchar *tmp_dir_name = g_strdup_printf("qemu-test_acpi_%s_tcg_%s.XXXXXX",
+    gchar *tmp_dir_name = g_strdup_printf("qemu-test_acpi_%s_%s.XXXXXX",
                                           machine, tpm_if);
     char *tmp_path = g_dir_make_tmp(tmp_dir_name, NULL);
     TestState test;
@@ -1139,12 +1139,12 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,
 #endif
 }
 
-static void test_acpi_q35_tcg_tpm_tis(void)
+static void test_acpi_q35_tpm_tis(void)
 {
-    test_acpi_tcg_tpm("q35", "tis", 0xFED40000);
+    test_acpi_tpm("q35", "tis", 0xFED40000);
 }
 
-static void test_acpi_tcg_dimm_pxm(const char *machine)
+static void test_acpi_dimm_pxm(const char *machine)
 {
     test_data data;
 
@@ -1174,14 +1174,14 @@ static void test_acpi_tcg_dimm_pxm(const char *machine)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_dimm_pxm(void)
+static void test_acpi_q35_dimm_pxm(void)
 {
-    test_acpi_tcg_dimm_pxm(MACHINE_Q35);
+    test_acpi_dimm_pxm(MACHINE_Q35);
 }
 
-static void test_acpi_piix4_tcg_dimm_pxm(void)
+static void test_acpi_piix4_dimm_pxm(void)
 {
-    test_acpi_tcg_dimm_pxm(MACHINE_PC);
+    test_acpi_dimm_pxm(MACHINE_PC);
 }
 
 static void test_acpi_virt_tcg_memhp(void)
@@ -1223,7 +1223,7 @@ static void test_acpi_microvm_prepare(test_data *data)
     data->blkdev = "virtio-blk-device";
 }
 
-static void test_acpi_microvm_tcg(void)
+static void test_acpi_microvm(void)
 {
     test_data data;
 
@@ -1233,7 +1233,7 @@ static void test_acpi_microvm_tcg(void)
     free_test_data(&data);
 }
 
-static void test_acpi_microvm_usb_tcg(void)
+static void test_acpi_microvm_usb(void)
 {
     test_data data;
 
@@ -1244,7 +1244,7 @@ static void test_acpi_microvm_usb_tcg(void)
     free_test_data(&data);
 }
 
-static void test_acpi_microvm_rtc_tcg(void)
+static void test_acpi_microvm_rtc(void)
 {
     test_data data;
 
@@ -1255,7 +1255,7 @@ static void test_acpi_microvm_rtc_tcg(void)
     free_test_data(&data);
 }
 
-static void test_acpi_microvm_pcie_tcg(void)
+static void test_acpi_microvm_pcie(void)
 {
     test_data data;
 
@@ -1267,7 +1267,7 @@ static void test_acpi_microvm_pcie_tcg(void)
     free_test_data(&data);
 }
 
-static void test_acpi_microvm_ioapic2_tcg(void)
+static void test_acpi_microvm_ioapic2(void)
 {
     test_data data;
 
@@ -1332,7 +1332,7 @@ static void test_acpi_virt_tcg_pxb(void)
     free_test_data(&data);
 }
 
-static void test_acpi_tcg_acpi_hmat(const char *machine)
+static void test_acpi_acpi_hmat(const char *machine)
 {
     test_data data;
 
@@ -1364,14 +1364,14 @@ static void test_acpi_tcg_acpi_hmat(const char *machine)
     free_test_data(&data);
 }
 
-static void test_acpi_q35_tcg_acpi_hmat(void)
+static void test_acpi_q35_acpi_hmat(void)
 {
-    test_acpi_tcg_acpi_hmat(MACHINE_Q35);
+    test_acpi_acpi_hmat(MACHINE_Q35);
 }
 
-static void test_acpi_piix4_tcg_acpi_hmat(void)
+static void test_acpi_piix4_acpi_hmat(void)
 {
-    test_acpi_tcg_acpi_hmat(MACHINE_PC);
+    test_acpi_acpi_hmat(MACHINE_PC);
 }
 
 static void test_acpi_virt_tcg(void)
@@ -1512,50 +1512,50 @@ int main(int argc, char *argv[])
             return ret;
         }
         qtest_add_func("acpi/q35/oem-fields", test_acpi_oem_fields_q35);
-        qtest_add_func("acpi/q35/tpm-tis", test_acpi_q35_tcg_tpm_tis);
-        qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
+        qtest_add_func("acpi/q35/tpm-tis", test_acpi_q35_tpm_tis);
+        qtest_add_func("acpi/piix4", test_acpi_piix4);
         qtest_add_func("acpi/oem-fields", test_acpi_oem_fields_pc);
-        qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
+        qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_bridge);
         qtest_add_func("acpi/piix4/pci-hotplug/no_root_hotplug",
                        test_acpi_piix4_no_root_hotplug);
         qtest_add_func("acpi/piix4/pci-hotplug/no_bridge_hotplug",
                        test_acpi_piix4_no_bridge_hotplug);
         qtest_add_func("acpi/piix4/pci-hotplug/off",
                        test_acpi_piix4_no_acpi_pci_hotplug);
-        qtest_add_func("acpi/q35", test_acpi_q35_tcg);
-        qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
-        qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
-        qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
-        qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
-        qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
-        qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
-        qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
-        qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
-        qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_tcg_numamem);
-        qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
-        qtest_add_func("acpi/piix4/nosmm", test_acpi_piix4_tcg_nosmm);
+        qtest_add_func("acpi/q35", test_acpi_q35);
+        qtest_add_func("acpi/q35/bridge", test_acpi_q35_bridge);
+        qtest_add_func("acpi/q35/mmio64", test_acpi_q35_mmio64);
+        qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_ipmi);
+        qtest_add_func("acpi/q35/ipmi", test_acpi_q35_ipmi);
+        qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_cphp);
+        qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_cphp);
+        qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_memhp);
+        qtest_add_func("acpi/q35/memhp", test_acpi_q35_memhp);
+        qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_numamem);
+        qtest_add_func("acpi/q35/numamem", test_acpi_q35_numamem);
+        qtest_add_func("acpi/piix4/nosmm", test_acpi_piix4_nosmm);
         qtest_add_func("acpi/piix4/smm-compat",
-                       test_acpi_piix4_tcg_smm_compat);
+                       test_acpi_piix4_smm_compat);
         qtest_add_func("acpi/piix4/smm-compat-nosmm",
-                       test_acpi_piix4_tcg_smm_compat_nosmm);
-        qtest_add_func("acpi/piix4/nohpet", test_acpi_piix4_tcg_nohpet);
-        qtest_add_func("acpi/q35/nosmm", test_acpi_q35_tcg_nosmm);
+                       test_acpi_piix4_smm_compat_nosmm);
+        qtest_add_func("acpi/piix4/nohpet", test_acpi_piix4_nohpet);
+        qtest_add_func("acpi/q35/nosmm", test_acpi_q35_nosmm);
         qtest_add_func("acpi/q35/smm-compat",
-                       test_acpi_q35_tcg_smm_compat);
+                       test_acpi_q35_smm_compat);
         qtest_add_func("acpi/q35/smm-compat-nosmm",
-                       test_acpi_q35_tcg_smm_compat_nosmm);
-        qtest_add_func("acpi/q35/nohpet", test_acpi_q35_tcg_nohpet);
-        qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
-        qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
-        qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hmat);
-        qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_tcg_acpi_hmat);
-        qtest_add_func("acpi/microvm", test_acpi_microvm_tcg);
-        qtest_add_func("acpi/microvm/usb", test_acpi_microvm_usb_tcg);
-        qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc_tcg);
-        qtest_add_func("acpi/microvm/ioapic2", test_acpi_microvm_ioapic2_tcg);
+                       test_acpi_q35_smm_compat_nosmm);
+        qtest_add_func("acpi/q35/nohpet", test_acpi_q35_nohpet);
+        qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_dimm_pxm);
+        qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_dimm_pxm);
+        qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_acpi_hmat);
+        qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_acpi_hmat);
+        qtest_add_func("acpi/microvm", test_acpi_microvm);
+        qtest_add_func("acpi/microvm/usb", test_acpi_microvm_usb);
+        qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc);
+        qtest_add_func("acpi/microvm/ioapic2", test_acpi_microvm_ioapic2);
         qtest_add_func("acpi/microvm/oem-fields", test_acpi_oem_fields_microvm);
         if (strcmp(arch, "x86_64") == 0) {
-            qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie_tcg);
+            qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie);
         }
     } else if (strcmp(arch, "aarch64") == 0) {
         qtest_add_func("acpi/virt", test_acpi_virt_tcg);
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 10/12] qtest/bios-tables-test: Rename TCG specific tests
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 09/12] qtest/bios-tables-test: Rename tests not TCG specific Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-06-03 16:35   ` Alex Bennée
  2021-05-26 17:04 ` [PATCH v8 11/12] qtest/bios-tables-test: Make test build-independent from accelerator Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Michael S. Tsirkin,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, qemu-arm, Igor Mammedov,
	Paolo Bonzini

Some tests require TCG, but don't have '_tcg' in their name,
while others do. Unify the test names by adding 'tcg' to the
TCG specific tests.

Reported-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/bios-tables-test.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index ce498b3ff48..ad877baeb1b 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -1255,7 +1255,7 @@ static void test_acpi_microvm_rtc(void)
     free_test_data(&data);
 }
 
-static void test_acpi_microvm_pcie(void)
+static void test_acpi_microvm_pcie_tcg(void)
 {
     test_data data;
 
@@ -1475,7 +1475,7 @@ static void test_acpi_oem_fields_microvm(void)
     g_free(args);
 }
 
-static void test_acpi_oem_fields_virt(void)
+static void test_acpi_oem_fields_virt_tcg(void)
 {
     test_data data = {
         .machine = "virt",
@@ -1555,14 +1555,14 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/microvm/ioapic2", test_acpi_microvm_ioapic2);
         qtest_add_func("acpi/microvm/oem-fields", test_acpi_oem_fields_microvm);
         if (strcmp(arch, "x86_64") == 0) {
-            qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie);
+            qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie_tcg);
         }
     } else if (strcmp(arch, "aarch64") == 0) {
         qtest_add_func("acpi/virt", test_acpi_virt_tcg);
         qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
         qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp);
         qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb);
-        qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt);
+        qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt_tcg);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 11/12] qtest/bios-tables-test: Make test build-independent from accelerator
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 10/12] qtest/bios-tables-test: Rename TCG specific tests Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-06-03 16:36   ` Alex Bennée
  2021-05-26 17:04 ` [PATCH v8 12/12] qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore Philippe Mathieu-Daudé
  2021-05-26 17:09 ` [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
  12 siblings, 1 reply; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Michael S. Tsirkin,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, qemu-arm, Igor Mammedov,
	Paolo Bonzini

Now that we can probe if the TCG accelerator is available
at runtime with a QMP command, do it once at the beginning
and only register the tests we can run.
We can then replace the #ifdef'ry by an assertion.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/bios-tables-test.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index ad877baeb1b..762d154b340 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -97,6 +97,7 @@ typedef struct {
     QTestState *qts;
 } test_data;
 
+static bool tcg_accel_available;
 static char disk[] = "tests/acpi-test-disk-XXXXXX";
 static const char *data_dir = "tests/data/acpi";
 #ifdef CONFIG_IASL
@@ -718,12 +719,7 @@ static void test_acpi_one(const char *params, test_data *data)
     char *args;
     bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
 
-#ifndef CONFIG_TCG
-    if (data->tcg_only) {
-        g_test_skip("TCG disabled, skipping ACPI tcg_only test");
-        return;
-    }
-#endif /* CONFIG_TCG */
+    assert(!data->tcg_only || tcg_accel_available);
 
     args = test_acpi_create_args(data, params, use_uefi);
     data->qts = qtest_init(args);
@@ -1506,6 +1502,8 @@ int main(int argc, char *argv[])
 
     g_test_init(&argc, &argv, NULL);
 
+    tcg_accel_available = qtest_has_accel("tcg");
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         ret = boot_sector_init(disk);
         if (ret) {
@@ -1554,10 +1552,10 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc);
         qtest_add_func("acpi/microvm/ioapic2", test_acpi_microvm_ioapic2);
         qtest_add_func("acpi/microvm/oem-fields", test_acpi_oem_fields_microvm);
-        if (strcmp(arch, "x86_64") == 0) {
+        if (strcmp(arch, "x86_64") == 0 && tcg_accel_available) {
             qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie_tcg);
         }
-    } else if (strcmp(arch, "aarch64") == 0) {
+    } else if (strcmp(arch, "aarch64") == 0 && tcg_accel_available) {
         qtest_add_func("acpi/virt", test_acpi_virt_tcg);
         qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
         qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp);
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 12/12] qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 11/12] qtest/bios-tables-test: Make test build-independent from accelerator Philippe Mathieu-Daudé
@ 2021-05-26 17:04 ` Philippe Mathieu-Daudé
  2021-05-26 17:09 ` [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Peter Maydell, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé,
	Richard Henderson, Markus Armbruster, Alex Bennée, qemu-arm,
	Paolo Bonzini

Since commit 82bf7ae84ce ("target/arm: Remove KVM support for
32-bit Arm hosts") we can remove the comment / check added in
commit ab6b6a77774 and directly run the bios-tables-test.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/meson.build | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index c3a223a83d6..2c7415d6166 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -176,14 +176,13 @@
    'boot-serial-test',
    'hexloader-test']
 
-# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
 qtests_aarch64 = \
-  (cpu != 'arm' ? ['bios-tables-test'] : []) +                                                  \
   (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) +        \
   (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) +  \
   ['arm-cpu-features',
    'numa-test',
    'boot-serial-test',
+   'bios-tables-test',
    'xlnx-can-test',
    'migration-test']
 
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels'
  2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2021-05-26 17:04 ` [PATCH v8 12/12] qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore Philippe Mathieu-Daudé
@ 2021-05-26 17:09 ` Philippe Mathieu-Daudé
  12 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-26 17:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Richard Henderson,
	Markus Armbruster, qemu-arm, Paolo Bonzini

On 5/26/21 7:04 PM, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series aims at having accelerator-independent qtests
> by querying a QEMU instance at runtime to check the list
> of built-in accelerators.
> 
> First we add the 'query-accels' QMP command,
> then we add the qtest_has_accel() method to libqtest,
> finally we use this new method to allow running
> bios-tables-test on KVM-only builds.
> 
> This series is expected to be merged via the ARM tree.

I forgot to carry MST R-b tag:
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
https://www.mail-archive.com/qemu-devel@nongnu.org/msg807421.html

> Since v7:
> - Include Markus code (see patch #2)

> $ git backport-diff v6
> Key:
> [----] : patches are identical
> [####] : number of functional differences between upstream/downstream patch
> [down] : patch is downstream-only
> The flags [FC] indicate (F)unctional and (C)ontextual differences, respective=
> ly
> 
> 001/12:[----] [--] 'MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs=
>  section'
> 002/12:[0048] [FC] 'accel: Introduce 'query-accels' QMP command'
> 003/12:[----] [--] 'qtest: Add qtest_has_accel() method'
> 004/12:[----] [--] 'qtest/arm-cpu-features: Use generic qtest_has_accel() to =
> check for KVM'
> 005/12:[----] [--] 'qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm te=
> st to KVM'
> 006/12:[----] [--] 'qtest/arm-cpu-features: Remove TCG fallback to KVM specif=
> ic tests'
> 007/12:[----] [--] 'qtest/arm-cpu-features: Use generic qtest_has_accel() to =
> check for TCG'
> 008/12:[----] [--] 'qtest/migration-test: Skip tests if KVM not builtin on s3=
> 90x/ppc64'
> 009/12:[----] [--] 'qtest/bios-tables-test: Rename tests not TCG specific'
> 010/12:[----] [--] 'qtest/bios-tables-test: Rename TCG specific tests'
> 011/12:[----] [--] 'qtest/bios-tables-test: Make test build-independent from =
> accelerator'
> 012/12:[----] [--] 'qtest: Do not restrict bios-tables-test to Aarch64 hosts =
> anymore'



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-05-26 17:04 ` [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
@ 2021-06-02 23:26   ` John Snow
  2021-06-03  7:31     ` Philippe Mathieu-Daudé
  2021-06-03 17:19   ` Alex Bennée
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 24+ messages in thread
From: John Snow @ 2021-06-02 23:26 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Alex Bennée,
	Richard Henderson, Markus Armbruster, qemu-arm, Paolo Bonzini

On 5/26/21 1:04 PM, Philippe Mathieu-Daudé wrote:
> Introduce the 'query-accels' QMP command which returns a list
> of built-in accelerator names.
>  > - Accelerator is a QAPI enum of all existing accelerators,
> 
> - AcceleratorInfo is a QAPI structure providing accelerator
>    specific information. Currently the common structure base
>    provides the name of the accelerator, while the specific
>    part is empty, but each accelerator can expand it.
> 
> - 'query-accels' QMP command returns a list of @AcceleratorInfo
> 
> For example on a KVM-only build we get:
> 
>      { "execute": "query-accels" }
>      {
>          "return": [
>              {
>                  "name": "qtest"
>              },
>              {
>                  "name": "kvm"
>              }
>          ]
>      }
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Tested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v8:
> - Include code snippet from Markus adding to machine-target.json
>    to be able to use enum values or union branches conditional.
> - Use accel_find() on enum to be sure the accelerator is enabled
>    at runtime (chat with jsnow / eblake).
> 

Hi Phil -- Unfortunately I think I am going to defer on this one until 
Markus is back. I need to chat with him about the right way to design 
this, since I'm also not entirely clear on it myself.

--js

> Cc: Eric Blake <eblake@redhat.com>
> Cc: John Snow <jsnow@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-06-02 23:26   ` John Snow
@ 2021-06-03  7:31     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-03  7:31 UTC (permalink / raw)
  To: John Snow, qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Alex Bennée,
	Richard Henderson, Markus Armbruster, qemu-arm, Paolo Bonzini

On 6/3/21 1:26 AM, John Snow wrote:
> On 5/26/21 1:04 PM, Philippe Mathieu-Daudé wrote:
>> Introduce the 'query-accels' QMP command which returns a list
>> of built-in accelerator names.
>>  > - Accelerator is a QAPI enum of all existing accelerators,
>>
>> - AcceleratorInfo is a QAPI structure providing accelerator
>>    specific information. Currently the common structure base
>>    provides the name of the accelerator, while the specific
>>    part is empty, but each accelerator can expand it.
>>
>> - 'query-accels' QMP command returns a list of @AcceleratorInfo
>>
>> For example on a KVM-only build we get:
>>
>>      { "execute": "query-accels" }
>>      {
>>          "return": [
>>              {
>>                  "name": "qtest"
>>              },
>>              {
>>                  "name": "kvm"
>>              }
>>          ]
>>      }
>>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>> Tested-by: Alex Bennée <alex.bennee@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> v8:
>> - Include code snippet from Markus adding to machine-target.json
>>    to be able to use enum values or union branches conditional.
>> - Use accel_find() on enum to be sure the accelerator is enabled
>>    at runtime (chat with jsnow / eblake).
>>
> 
> Hi Phil -- Unfortunately I think I am going to defer on this one until
> Markus is back. I need to chat with him about the right way to design
> this, since I'm also not entirely clear on it myself.

OK, thanks for the update :)



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 10/12] qtest/bios-tables-test: Rename TCG specific tests
  2021-05-26 17:04 ` [PATCH v8 10/12] qtest/bios-tables-test: Rename TCG specific tests Philippe Mathieu-Daudé
@ 2021-06-03 16:35   ` Alex Bennée
  0 siblings, 0 replies; 24+ messages in thread
From: Alex Bennée @ 2021-06-03 16:35 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Eduardo Habkost, Michael S. Tsirkin,
	Richard Henderson, Markus Armbruster, qemu-devel, qemu-arm,
	Paolo Bonzini, Igor Mammedov


Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> Some tests require TCG, but don't have '_tcg' in their name,
> while others do. Unify the test names by adding 'tcg' to the
> TCG specific tests.
>
> Reported-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 11/12] qtest/bios-tables-test: Make test build-independent from accelerator
  2021-05-26 17:04 ` [PATCH v8 11/12] qtest/bios-tables-test: Make test build-independent from accelerator Philippe Mathieu-Daudé
@ 2021-06-03 16:36   ` Alex Bennée
  0 siblings, 0 replies; 24+ messages in thread
From: Alex Bennée @ 2021-06-03 16:36 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Eduardo Habkost, Michael S. Tsirkin,
	Richard Henderson, qemu-devel, Markus Armbruster, qemu-arm,
	Paolo Bonzini, Igor Mammedov


Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> Now that we can probe if the TCG accelerator is available
> at runtime with a QMP command, do it once at the beginning
> and only register the tests we can run.
> We can then replace the #ifdef'ry by an assertion.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-05-26 17:04 ` [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
  2021-06-02 23:26   ` John Snow
@ 2021-06-03 17:19   ` Alex Bennée
  2021-06-08 10:42     ` Philippe Mathieu-Daudé
  2021-06-08 13:27   ` Thomas Huth
  2021-06-11  9:51   ` Markus Armbruster
  3 siblings, 1 reply; 24+ messages in thread
From: Alex Bennée @ 2021-06-03 17:19 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Eduardo Habkost, John Snow, Richard Henderson,
	qemu-devel, Markus Armbruster, qemu-arm, Paolo Bonzini


Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> Introduce the 'query-accels' QMP command which returns a list
> of built-in accelerator names.
>
> - Accelerator is a QAPI enum of all existing accelerators,
>
> - AcceleratorInfo is a QAPI structure providing accelerator
>   specific information. Currently the common structure base
>   provides the name of the accelerator, while the specific
>   part is empty, but each accelerator can expand it.
>
> - 'query-accels' QMP command returns a list of @AcceleratorInfo
>
> For example on a KVM-only build we get:
>
>     { "execute": "query-accels" }
>     {
>         "return": [
>             {
>                 "name": "qtest"
>             },
>             {
>                 "name": "kvm"
>             }
>         ]
>     }
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Tested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v8:
> - Include code snippet from Markus adding to machine-target.json
>   to be able to use enum values or union branches conditional.
> - Use accel_find() on enum to be sure the accelerator is enabled
>   at runtime (chat with jsnow / eblake).

Hmm something broke because now I get:

 /usr/lib/x86_64-linux-gnu/libpixman-1.so -lgthread-2.0 -lglib-2.0 -lstdc++ -Wl,--end-group
/usr/bin/ld: libqemu-aarch64_be-linux-user.fa.p/accel_accel-qmp.c.o: in function `qmp_query_accels':
/home/alex/lsrc/qemu.git/builds/arm.all/../../accel/accel-qmp.c:15: undefined reference to `Accelerator_lookup'
collect2: error: ld returned 1 exit status
[1327/1413] Linking target qemu-io

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-06-03 17:19   ` Alex Bennée
@ 2021-06-08 10:42     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-08 10:42 UTC (permalink / raw)
  To: Alex Bennée
  Cc: Peter Maydell, Eduardo Habkost, John Snow, Richard Henderson,
	qemu-devel, Markus Armbruster, qemu-arm, Paolo Bonzini,
	Eric Blake

On 6/3/21 7:19 PM, Alex Bennée wrote:
> 
> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> 
>> Introduce the 'query-accels' QMP command which returns a list
>> of built-in accelerator names.
>>
>> - Accelerator is a QAPI enum of all existing accelerators,
>>
>> - AcceleratorInfo is a QAPI structure providing accelerator
>>   specific information. Currently the common structure base
>>   provides the name of the accelerator, while the specific
>>   part is empty, but each accelerator can expand it.
>>
>> - 'query-accels' QMP command returns a list of @AcceleratorInfo
>>
>> For example on a KVM-only build we get:
>>
>>     { "execute": "query-accels" }
>>     {
>>         "return": [
>>             {
>>                 "name": "qtest"
>>             },
>>             {
>>                 "name": "kvm"
>>             }
>>         ]
>>     }
>>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>> Tested-by: Alex Bennée <alex.bennee@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> v8:
>> - Include code snippet from Markus adding to machine-target.json
>>   to be able to use enum values or union branches conditional.
>> - Use accel_find() on enum to be sure the accelerator is enabled
>>   at runtime (chat with jsnow / eblake).
> 
> Hmm something broke because now I get:
> 
>  /usr/lib/x86_64-linux-gnu/libpixman-1.so -lgthread-2.0 -lglib-2.0 -lstdc++ -Wl,--end-group
> /usr/bin/ld: libqemu-aarch64_be-linux-user.fa.p/accel_accel-qmp.c.o: in function `qmp_query_accels':
> /home/alex/lsrc/qemu.git/builds/arm.all/../../accel/accel-qmp.c:15: undefined reference to `Accelerator_lookup'
> collect2: error: ld returned 1 exit status
> [1327/1413] Linking target qemu-io

Sorry I missed that for user-mode, will be fixed in v9.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-05-26 17:04 ` [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
  2021-06-02 23:26   ` John Snow
  2021-06-03 17:19   ` Alex Bennée
@ 2021-06-08 13:27   ` Thomas Huth
  2021-06-08 13:38     ` Philippe Mathieu-Daudé
  2021-06-11  9:51   ` Markus Armbruster
  3 siblings, 1 reply; 24+ messages in thread
From: Thomas Huth @ 2021-06-08 13:27 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, John Snow, Richard Henderson,
	Markus Armbruster, qemu-arm, Paolo Bonzini, Alex Bennée

On 26/05/2021 19.04, Philippe Mathieu-Daudé wrote:
> Introduce the 'query-accels' QMP command which returns a list
> of built-in accelerator names.
> 
> - Accelerator is a QAPI enum of all existing accelerators,
> 
> - AcceleratorInfo is a QAPI structure providing accelerator
>    specific information. Currently the common structure base
>    provides the name of the accelerator, while the specific
>    part is empty, but each accelerator can expand it.
> 
> - 'query-accels' QMP command returns a list of @AcceleratorInfo
> 
> For example on a KVM-only build we get:
> 
>      { "execute": "query-accels" }
>      {
>          "return": [
>              {
>                  "name": "qtest"
>              },
>              {
>                  "name": "kvm"
>              }
>          ]
>      }
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Tested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v8:
> - Include code snippet from Markus adding to machine-target.json
>    to be able to use enum values or union branches conditional.
> - Use accel_find() on enum to be sure the accelerator is enabled
>    at runtime (chat with jsnow / eblake).
> 
> Cc: Eric Blake <eblake@redhat.com>
> Cc: John Snow <jsnow@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> ---
>   qapi/machine-target.json | 54 ++++++++++++++++++++++++++++++++++++++++
>   accel/accel-qmp.c        | 32 ++++++++++++++++++++++++
>   accel/meson.build        |  2 +-
>   3 files changed, 87 insertions(+), 1 deletion(-)
>   create mode 100644 accel/accel-qmp.c
> 
> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
> index e7811654b72..586a61b5d99 100644
> --- a/qapi/machine-target.json
> +++ b/qapi/machine-target.json
> @@ -329,3 +329,57 @@
>   ##
>   { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
>     'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> +
> +##
> +# @Accelerator:
> +#
> +# An enumeration of accelerator names.
> +#
> +# Since: 6.1
> +##
> +{ 'enum': 'Accelerator',
> +  'data': [
> +      { 'name': 'hax', 'if': 'defined(CONFIG_HAX)' },
> +      { 'name': 'hvf', 'if': 'defined(CONFIG_HVF)' },
> +      { 'name': 'kvm', 'if': 'defined(CONFIG_KVM)' },
> +      { 'name': 'qtest' },
> +      { 'name': 'tcg', 'if': 'defined(CONFIG_TCG)' },
> +      { 'name': 'whpx', 'if': 'defined(CONFIG_WHPX)' },
> +      { 'name': 'xen', 'if': 'defined(CONFIG_XEN_BACKEND)' } ] }
> +
> +##
> +# @AcceleratorInfo:
> +#
> +# Accelerator information.
> +#
> +# @name: The accelerator name.
> +#
> +# Since: 6.1
> +##
> +{ 'struct': 'AcceleratorInfo',
> +  'data': { 'name': 'Accelerator' } }
> +
> +##
> +# @query-accels:
> +#
> +# Get a list of AcceleratorInfo for all built-in accelerators.
> +#
> +# Returns: a list of @AcceleratorInfo describing each accelerator.
> +#
> +# Since: 6.1
> +#
> +# Example:
> +#
> +# -> { "execute": "query-accels" }
> +# <- { "return": [
> +#        {
> +#            "name": "qtest"
> +#        },
> +#        {
> +#            "name": "kvm"
> +#        }
> +#    ] }
> +#
> +##
> +{ 'command': 'query-accels',
> +  'returns': ['AcceleratorInfo'] }

What about Markus' comment here:

  https://lore.kernel.org/qemu-devel/87mtsoieyz.fsf@dusky.pond.sub.org/

?

If I've got him right, you don't need the command at all, the Accelerator
enum should be sufficient?

  Thomas
  



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-06-08 13:27   ` Thomas Huth
@ 2021-06-08 13:38     ` Philippe Mathieu-Daudé
  2021-06-09 11:58       ` Markus Armbruster
  0 siblings, 1 reply; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-08 13:38 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Markus Armbruster
  Cc: Peter Maydell, Eduardo Habkost, John Snow, Richard Henderson,
	qemu-arm, Paolo Bonzini, Alex Bennée

On 6/8/21 3:27 PM, Thomas Huth wrote:
> On 26/05/2021 19.04, Philippe Mathieu-Daudé wrote:
>> Introduce the 'query-accels' QMP command which returns a list
>> of built-in accelerator names.
>>
>> - Accelerator is a QAPI enum of all existing accelerators,
>>
>> - AcceleratorInfo is a QAPI structure providing accelerator
>>    specific information. Currently the common structure base
>>    provides the name of the accelerator, while the specific
>>    part is empty, but each accelerator can expand it.
>>
>> - 'query-accels' QMP command returns a list of @AcceleratorInfo
>>
>> For example on a KVM-only build we get:
>>
>>      { "execute": "query-accels" }
>>      {
>>          "return": [
>>              {
>>                  "name": "qtest"
>>              },
>>              {
>>                  "name": "kvm"
>>              }
>>          ]
>>      }
>>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>> Tested-by: Alex Bennée <alex.bennee@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> v8:
>> - Include code snippet from Markus adding to machine-target.json
>>    to be able to use enum values or union branches conditional.
>> - Use accel_find() on enum to be sure the accelerator is enabled
>>    at runtime (chat with jsnow / eblake).
>>
>> Cc: Eric Blake <eblake@redhat.com>
>> Cc: John Snow <jsnow@redhat.com>
>> Cc: Markus Armbruster <armbru@redhat.com>
>> ---
>>   qapi/machine-target.json | 54 ++++++++++++++++++++++++++++++++++++++++
>>   accel/accel-qmp.c        | 32 ++++++++++++++++++++++++
>>   accel/meson.build        |  2 +-
>>   3 files changed, 87 insertions(+), 1 deletion(-)
>>   create mode 100644 accel/accel-qmp.c
>>
>> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
>> index e7811654b72..586a61b5d99 100644
>> --- a/qapi/machine-target.json
>> +++ b/qapi/machine-target.json
>> @@ -329,3 +329,57 @@
>>   ##
>>   { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
>>     'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
>> defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
>> +
>> +##
>> +# @Accelerator:
>> +#
>> +# An enumeration of accelerator names.
>> +#
>> +# Since: 6.1
>> +##
>> +{ 'enum': 'Accelerator',
>> +  'data': [
>> +      { 'name': 'hax', 'if': 'defined(CONFIG_HAX)' },
>> +      { 'name': 'hvf', 'if': 'defined(CONFIG_HVF)' },
>> +      { 'name': 'kvm', 'if': 'defined(CONFIG_KVM)' },
>> +      { 'name': 'qtest' },
>> +      { 'name': 'tcg', 'if': 'defined(CONFIG_TCG)' },
>> +      { 'name': 'whpx', 'if': 'defined(CONFIG_WHPX)' },
>> +      { 'name': 'xen', 'if': 'defined(CONFIG_XEN_BACKEND)' } ] }
>> +
>> +##
>> +# @AcceleratorInfo:
>> +#
>> +# Accelerator information.
>> +#
>> +# @name: The accelerator name.
>> +#
>> +# Since: 6.1
>> +##
>> +{ 'struct': 'AcceleratorInfo',
>> +  'data': { 'name': 'Accelerator' } }
>> +
>> +##
>> +# @query-accels:
>> +#
>> +# Get a list of AcceleratorInfo for all built-in accelerators.
>> +#
>> +# Returns: a list of @AcceleratorInfo describing each accelerator.
>> +#
>> +# Since: 6.1
>> +#
>> +# Example:
>> +#
>> +# -> { "execute": "query-accels" }
>> +# <- { "return": [
>> +#        {
>> +#            "name": "qtest"
>> +#        },
>> +#        {
>> +#            "name": "kvm"
>> +#        }
>> +#    ] }
>> +#
>> +##
>> +{ 'command': 'query-accels',
>> +  'returns': ['AcceleratorInfo'] }
> 
> What about Markus' comment here:
> 
>  https://lore.kernel.org/qemu-devel/87mtsoieyz.fsf@dusky.pond.sub.org/
> 
> ?
> 
> If I've got him right, you don't need the command at all, the Accelerator
> enum should be sufficient?

Yes, this is the part jsnow said "we are waiting for Markus to comment"
on the other thread ;) We'd like to only have enums, but QAPI doesn't
seem to allow a "leaf without branch", we need a command or struct to
use the enum else it is elided. Or maybe we didn't understood Markus
idea.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-06-08 13:38     ` Philippe Mathieu-Daudé
@ 2021-06-09 11:58       ` Markus Armbruster
  0 siblings, 0 replies; 24+ messages in thread
From: Markus Armbruster @ 2021-06-09 11:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Thomas Huth, Eduardo Habkost, Alex Bennée,
	Richard Henderson, qemu-devel, Markus Armbruster, qemu-arm,
	Paolo Bonzini, John Snow

Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 6/8/21 3:27 PM, Thomas Huth wrote:
>> On 26/05/2021 19.04, Philippe Mathieu-Daudé wrote:
>>> Introduce the 'query-accels' QMP command which returns a list
>>> of built-in accelerator names.
>>>
>>> - Accelerator is a QAPI enum of all existing accelerators,
>>>
>>> - AcceleratorInfo is a QAPI structure providing accelerator
>>>    specific information. Currently the common structure base
>>>    provides the name of the accelerator, while the specific
>>>    part is empty, but each accelerator can expand it.
>>>
>>> - 'query-accels' QMP command returns a list of @AcceleratorInfo
>>>
>>> For example on a KVM-only build we get:
>>>
>>>      { "execute": "query-accels" }
>>>      {
>>>          "return": [
>>>              {
>>>                  "name": "qtest"
>>>              },
>>>              {
>>>                  "name": "kvm"
>>>              }
>>>          ]
>>>      }
>>>
>>> Reviewed-by: Eric Blake <eblake@redhat.com>
>>> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>>> Tested-by: Alex Bennée <alex.bennee@linaro.org>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>> v8:
>>> - Include code snippet from Markus adding to machine-target.json
>>>    to be able to use enum values or union branches conditional.
>>> - Use accel_find() on enum to be sure the accelerator is enabled
>>>    at runtime (chat with jsnow / eblake).
>>>
>>> Cc: Eric Blake <eblake@redhat.com>
>>> Cc: John Snow <jsnow@redhat.com>
>>> Cc: Markus Armbruster <armbru@redhat.com>
>>> ---
>>>   qapi/machine-target.json | 54 ++++++++++++++++++++++++++++++++++++++++
>>>   accel/accel-qmp.c        | 32 ++++++++++++++++++++++++
>>>   accel/meson.build        |  2 +-
>>>   3 files changed, 87 insertions(+), 1 deletion(-)
>>>   create mode 100644 accel/accel-qmp.c
>>>
>>> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
>>> index e7811654b72..586a61b5d99 100644
>>> --- a/qapi/machine-target.json
>>> +++ b/qapi/machine-target.json
>>> @@ -329,3 +329,57 @@
>>>   ##
>>>   { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
>>>     'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
>>> defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
>>> +
>>> +##
>>> +# @Accelerator:
>>> +#
>>> +# An enumeration of accelerator names.
>>> +#
>>> +# Since: 6.1
>>> +##
>>> +{ 'enum': 'Accelerator',
>>> +  'data': [
>>> +      { 'name': 'hax', 'if': 'defined(CONFIG_HAX)' },
>>> +      { 'name': 'hvf', 'if': 'defined(CONFIG_HVF)' },
>>> +      { 'name': 'kvm', 'if': 'defined(CONFIG_KVM)' },
>>> +      { 'name': 'qtest' },
>>> +      { 'name': 'tcg', 'if': 'defined(CONFIG_TCG)' },
>>> +      { 'name': 'whpx', 'if': 'defined(CONFIG_WHPX)' },
>>> +      { 'name': 'xen', 'if': 'defined(CONFIG_XEN_BACKEND)' } ] }
>>> +
>>> +##
>>> +# @AcceleratorInfo:
>>> +#
>>> +# Accelerator information.
>>> +#
>>> +# @name: The accelerator name.
>>> +#
>>> +# Since: 6.1
>>> +##
>>> +{ 'struct': 'AcceleratorInfo',
>>> +  'data': { 'name': 'Accelerator' } }
>>> +
>>> +##
>>> +# @query-accels:
>>> +#
>>> +# Get a list of AcceleratorInfo for all built-in accelerators.
>>> +#
>>> +# Returns: a list of @AcceleratorInfo describing each accelerator.
>>> +#
>>> +# Since: 6.1
>>> +#
>>> +# Example:
>>> +#
>>> +# -> { "execute": "query-accels" }
>>> +# <- { "return": [
>>> +#        {
>>> +#            "name": "qtest"
>>> +#        },
>>> +#        {
>>> +#            "name": "kvm"
>>> +#        }
>>> +#    ] }
>>> +#
>>> +##
>>> +{ 'command': 'query-accels',
>>> +  'returns': ['AcceleratorInfo'] }
>> 
>> What about Markus' comment here:
>> 
>>  https://lore.kernel.org/qemu-devel/87mtsoieyz.fsf@dusky.pond.sub.org/
>> 
>> ?
>> 
>> If I've got him right, you don't need the command at all, the Accelerator
>> enum should be sufficient?
>
> Yes, this is the part jsnow said "we are waiting for Markus to comment"
> on the other thread ;) We'd like to only have enums, but QAPI doesn't
> seem to allow a "leaf without branch", we need a command or struct to
> use the enum else it is elided.

Correct; query-qmp-schema shows only the stuff used by commands and
events.

>                                 Or maybe we didn't understood Markus
> idea.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command
  2021-05-26 17:04 ` [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
                     ` (2 preceding siblings ...)
  2021-06-08 13:27   ` Thomas Huth
@ 2021-06-11  9:51   ` Markus Armbruster
  3 siblings, 0 replies; 24+ messages in thread
From: Markus Armbruster @ 2021-06-11  9:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Eduardo Habkost, John Snow, Richard Henderson,
	qemu-devel, qemu-arm, Paolo Bonzini, Alex Bennée

Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> Introduce the 'query-accels' QMP command which returns a list
> of built-in accelerator names.
>
> - Accelerator is a QAPI enum of all existing accelerators,
>
> - AcceleratorInfo is a QAPI structure providing accelerator
>   specific information. Currently the common structure base
>   provides the name of the accelerator, while the specific
>   part is empty, but each accelerator can expand it.

This has become somewhat misleading, I'm afraid.  If memory serves,
earlier versions had union AcceleratorInfo with a common base struct.
This patch has just a struct, which we can grow into a union when we
actually have accelerator-specific information to report.  Perhaps

  - AcceleratorInfo provides information on a specific accelerator.  It
    contains just the accelerator name so far.

>
> - 'query-accels' QMP command returns a list of @AcceleratorInfo
>
> For example on a KVM-only build we get:
>
>     { "execute": "query-accels" }
>     {
>         "return": [
>             {
>                 "name": "qtest"
>             },
>             {
>                 "name": "kvm"
>             }
>         ]
>     }
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Tested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v8:
> - Include code snippet from Markus adding to machine-target.json
>   to be able to use enum values or union branches conditional.
> - Use accel_find() on enum to be sure the accelerator is enabled
>   at runtime (chat with jsnow / eblake).
>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: John Snow <jsnow@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> ---
>  qapi/machine-target.json | 54 ++++++++++++++++++++++++++++++++++++++++
>  accel/accel-qmp.c        | 32 ++++++++++++++++++++++++
>  accel/meson.build        |  2 +-
>  3 files changed, 87 insertions(+), 1 deletion(-)
>  create mode 100644 accel/accel-qmp.c
>
> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
> index e7811654b72..586a61b5d99 100644
> --- a/qapi/machine-target.json
> +++ b/qapi/machine-target.json
> @@ -329,3 +329,57 @@
>  ##
>  { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
>    'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> +
> +##
> +# @Accelerator:
> +#
> +# An enumeration of accelerator names.
> +#
> +# Since: 6.1
> +##
> +{ 'enum': 'Accelerator',
> +  'data': [
> +      { 'name': 'hax', 'if': 'defined(CONFIG_HAX)' },
> +      { 'name': 'hvf', 'if': 'defined(CONFIG_HVF)' },
> +      { 'name': 'kvm', 'if': 'defined(CONFIG_KVM)' },
> +      { 'name': 'qtest' },
> +      { 'name': 'tcg', 'if': 'defined(CONFIG_TCG)' },
> +      { 'name': 'whpx', 'if': 'defined(CONFIG_WHPX)' },
> +      { 'name': 'xen', 'if': 'defined(CONFIG_XEN_BACKEND)' } ] }
> +
> +##
> +# @AcceleratorInfo:
> +#
> +# Accelerator information.
> +#
> +# @name: The accelerator name.
> +#
> +# Since: 6.1
> +##
> +{ 'struct': 'AcceleratorInfo',
> +  'data': { 'name': 'Accelerator' } }
> +
> +##
> +# @query-accels:
> +#
> +# Get a list of AcceleratorInfo for all built-in accelerators.
> +#
> +# Returns: a list of @AcceleratorInfo describing each accelerator.
> +#
> +# Since: 6.1
> +#
> +# Example:
> +#
> +# -> { "execute": "query-accels" }
> +# <- { "return": [
> +#        {
> +#            "name": "qtest"
> +#        },
> +#        {
> +#            "name": "kvm"
> +#        }
> +#    ] }
> +#
> +##
> +{ 'command': 'query-accels',
> +  'returns': ['AcceleratorInfo'] }
> diff --git a/accel/accel-qmp.c b/accel/accel-qmp.c
> new file mode 100644
> index 00000000000..0098297caa5
> --- /dev/null
> +++ b/accel/accel-qmp.c
> @@ -0,0 +1,32 @@
> +/*
> + * QEMU accelerators, QMP commands
> + *
> + * Copyright (c) 2021 Red Hat Inc.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/accel.h"
> +#include "qapi/qapi-types-machine-target.h"
> +#include "qapi/qapi-commands-machine-target.h"
> +
> +AcceleratorInfoList *qmp_query_accels(Error **errp)
> +{
> +    AcceleratorInfoList *list = NULL, **tail = &list;
> +
> +    for (Accelerator accel = 0; accel < ACCELERATOR__MAX; accel++) {
> +        AcceleratorInfo *info;
> +
> +        if (!accel_find(Accelerator_str(accel))) {
> +            /* Accelerator available at build time but not at runtime. */
> +            continue;
> +        }
> +
> +        info = g_new0(AcceleratorInfo, 1);
> +        info->name = accel;
> +        QAPI_LIST_APPEND(tail, info);
> +    }
> +
> +    return list;
> +}

If I read this correctly, there's a subtle difference between the
information returned by query-accels and the information you can get
from introspecting query-accels with query-qmp-schema: the latter gives
you the accelerators compiled into this build of QEMU, the former gives
you the ones that are actually available at run time.  Suggest to
mention that in the commit message.

> diff --git a/accel/meson.build b/accel/meson.build
> index b44ba30c864..7a48f6d568d 100644
> --- a/accel/meson.build
> +++ b/accel/meson.build
> @@ -1,4 +1,4 @@
> -specific_ss.add(files('accel-common.c'))
> +specific_ss.add(files('accel-common.c', 'accel-qmp.c'))
>  softmmu_ss.add(files('accel-softmmu.c'))
>  user_ss.add(files('accel-user.c'))

Preferably with the commit message tweaked to address my remarks:
Acked-by: Markus Armbruster <armbru@redhat.com>



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2021-06-11  9:52 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 17:04 [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 01/12] MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 02/12] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
2021-06-02 23:26   ` John Snow
2021-06-03  7:31     ` Philippe Mathieu-Daudé
2021-06-03 17:19   ` Alex Bennée
2021-06-08 10:42     ` Philippe Mathieu-Daudé
2021-06-08 13:27   ` Thomas Huth
2021-06-08 13:38     ` Philippe Mathieu-Daudé
2021-06-09 11:58       ` Markus Armbruster
2021-06-11  9:51   ` Markus Armbruster
2021-05-26 17:04 ` [PATCH v8 03/12] qtest: Add qtest_has_accel() method Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 04/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 05/12] qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 06/12] qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 07/12] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 08/12] qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64 Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 09/12] qtest/bios-tables-test: Rename tests not TCG specific Philippe Mathieu-Daudé
2021-05-26 17:04 ` [PATCH v8 10/12] qtest/bios-tables-test: Rename TCG specific tests Philippe Mathieu-Daudé
2021-06-03 16:35   ` Alex Bennée
2021-05-26 17:04 ` [PATCH v8 11/12] qtest/bios-tables-test: Make test build-independent from accelerator Philippe Mathieu-Daudé
2021-06-03 16:36   ` Alex Bennée
2021-05-26 17:04 ` [PATCH v8 12/12] qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore Philippe Mathieu-Daudé
2021-05-26 17:09 ` [PATCH v8 00/12] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.