qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels'
@ 2021-04-15 12:26 Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 1/6] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Philippe Mathieu-Daudé,
	Richard Henderson, Andrew Jones, Markus Armbruster, qemu-arm,
	Claudio Fontana, Igor Mammedov, 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.

As a bonus we remove CONFIG_TCG in config_host, to avoid
building unnecessary objects depending on TCG.

Missing review:
- #4 qtest/qmp-cmd-test: Make test build-independent from accelerator
- #6 tests/meson: Only build softfloat objects if TCG is selected

Since v2:
- Addressed Eric & Paolo review comments

Since v1:
- 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.

Please review,

Phil.

Philippe Mathieu-Daudé (6):
  accel: Introduce 'query-accels' QMP command
  tests/qtest: Add qtest_has_accel() method
  qtest/bios-tables-test: Make test build-independent from accelerator
  qtest/qmp-cmd-test: Make test build-independent from accelerator
  tests/qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
  tests/meson: Only build softfloat objects if TCG is selected

 meson.build                    |  1 -
 qapi/machine.json              | 49 +++++++++++++++++
 tests/qtest/libqos/libqtest.h  |  8 +++
 accel/accel-qmp.c              | 49 +++++++++++++++++
 tests/qtest/bios-tables-test.c | 99 ++++++++++++++++++----------------
 tests/qtest/libqtest.c         | 29 ++++++++++
 tests/qtest/qmp-cmd-test.c     | 18 +++++--
 accel/meson.build              |  2 +-
 tests/qtest/meson.build        |  3 +-
 9 files changed, 203 insertions(+), 55 deletions(-)
 create mode 100644 accel/accel-qmp.c

-- 
2.26.3




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

* [PATCH v3 1/6] accel: Introduce 'query-accels' QMP command
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
@ 2021-04-15 12:26 ` Philippe Mathieu-Daudé
  2021-04-15 15:06   ` Markus Armbruster
  2021-04-15 12:26 ` [PATCH v3 2/6] tests/qtest: Add qtest_has_accel() method Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Philippe Mathieu-Daudé,
	Richard Henderson, Andrew Jones, Markus Armbruster, qemu-arm,
	Claudio Fontana, Igor Mammedov, Paolo Bonzini

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"
            }
        ]
    }

Note that we can't make the enum values or union branches conditional
because of target-specific poisoning of accelerator definitions.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Since v2: @since 6.0 -> 6.1, added note (Eric)
Since v1: 'type' -> 'name' in comments
---
 qapi/machine.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 accel/accel-qmp.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 accel/meson.build |  2 +-
 3 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 accel/accel-qmp.c

diff --git a/qapi/machine.json b/qapi/machine.json
index 6e90d463fc9..4babc06f8b0 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1274,3 +1274,52 @@
 ##
 { 'event': 'MEM_UNPLUG_ERROR',
   'data': { 'device': 'str', 'msg': 'str' } }
+
+##
+# @Accelerator:
+#
+# An enumeration of accelerator names.
+#
+# Since: 6.1
+##
+{ 'enum': 'Accelerator',
+  'data': [ 'qtest', 'tcg', 'kvm', 'hax', 'hvf', 'whpx', 'xen' ] }
+
+##
+# @AcceleratorInfo:
+#
+# Accelerator information.
+#
+# @name: The accelerator name.
+#
+# Since: 6.1
+##
+{ 'union': 'AcceleratorInfo',
+  'base': {'name': 'Accelerator'},
+  'discriminator': 'name',
+  'data': { } }
+
+##
+# @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..426737b3f9a
--- /dev/null
+++ b/accel/accel-qmp.c
@@ -0,0 +1,49 @@
+/*
+ * QEMU accelerators, QMP commands
+ *
+ * Copyright (c) 2021 Red Hat Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/qapi-commands-machine.h"
+
+static const bool accel_builtin_list[ACCELERATOR__MAX] = {
+    [ACCELERATOR_QTEST] = true,
+#ifdef CONFIG_TCG
+    [ACCELERATOR_TCG] = true,
+#endif
+#ifdef CONFIG_KVM
+    [ACCELERATOR_KVM] = true,
+#endif
+#ifdef CONFIG_HAX
+    [ACCELERATOR_HAX] = true,
+#endif
+#ifdef CONFIG_HVF
+    [ACCELERATOR_HVF] = true,
+#endif
+#ifdef CONFIG_WHPX
+    [ACCELERATOR_WHPX] = true,
+#endif
+#ifdef CONFIG_XEN_BACKEND
+    [ACCELERATOR_XEN] = true,
+#endif
+};
+
+AcceleratorInfoList *qmp_query_accels(Error **errp)
+{
+    AcceleratorInfoList *list = NULL, **tail = &list;
+
+    for (Accelerator accel = 0; accel < ACCELERATOR__MAX; accel++) {
+        if (accel_builtin_list[accel]) {
+            AcceleratorInfo *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] 13+ messages in thread

* [PATCH v3 2/6] tests/qtest: Add qtest_has_accel() method
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 1/6] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
@ 2021-04-15 12:26 ` Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 3/6] qtest/bios-tables-test: Make test build-independent from accelerator Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Philippe Mathieu-Daudé,
	Richard Henderson, Andrew Jones, Markus Armbruster, qemu-arm,
	Claudio Fontana, Igor Mammedov, 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>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Since v2:
- reworded (Eric)
Since v1:
- rename qtest_probe_accel() -> qtest_has_accel()
- run with -machine none before creating QTestState
---
 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 71e359efcd3..2156b7e3972 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] 13+ messages in thread

* [PATCH v3 3/6] qtest/bios-tables-test: Make test build-independent from accelerator
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 1/6] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 2/6] tests/qtest: Add qtest_has_accel() method Philippe Mathieu-Daudé
@ 2021-04-15 12:26 ` Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 4/6] qtest/qmp-cmd-test: " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Philippe Mathieu-Daudé,
	Richard Henderson, Andrew Jones, Markus Armbruster, qemu-arm,
	Claudio Fontana, Igor Mammedov, Paolo Bonzini

Now than 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>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Since v1: use global tcg_accel_available, call qtest_has_accel() once
---
 tests/qtest/bios-tables-test.c | 99 ++++++++++++++++++----------------
 1 file changed, 52 insertions(+), 47 deletions(-)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index 156d4174aa3..a4c7bddf6f3 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,15 +719,11 @@ 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);
+
     test_acpi_load_tables(data, use_uefi);
 
     if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
@@ -1504,6 +1501,8 @@ int main(int argc, char *argv[])
     const char *arch = qtest_get_arch();
     int ret;
 
+    tcg_accel_available = qtest_has_accel("tcg");
+
     g_test_init(&argc, &argv, NULL);
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
@@ -1512,56 +1511,62 @@ 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/oem-fields", test_acpi_oem_fields_pc);
-        qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
+        qtest_add_func("acpi/microvm/oem-fields", test_acpi_oem_fields_microvm);
         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/piix4/smm-compat",
-                       test_acpi_piix4_tcg_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);
-        qtest_add_func("acpi/q35/smm-compat",
-                       test_acpi_q35_tcg_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);
-        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);
+        if (tcg_accel_available) {
+            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/piix4/bridge", test_acpi_piix4_tcg_bridge);
+            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/piix4/smm-compat",
+                           test_acpi_piix4_tcg_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);
+            qtest_add_func("acpi/q35/smm-compat",
+                           test_acpi_q35_tcg_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);
+            if (strcmp(arch, "x86_64") == 0) {
+                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);
+        if (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);
+            qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb);
+        }
         qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt);
     }
     ret = g_test_run();
-- 
2.26.3



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

* [PATCH v3 4/6] qtest/qmp-cmd-test: Make test build-independent from accelerator
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-04-15 12:26 ` [PATCH v3 3/6] qtest/bios-tables-test: Make test build-independent from accelerator Philippe Mathieu-Daudé
@ 2021-04-15 12:26 ` Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 5/6] tests/qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Philippe Mathieu-Daudé,
	Richard Henderson, Andrew Jones, Markus Armbruster, qemu-arm,
	Claudio Fontana, Igor Mammedov, Paolo Bonzini

Now than 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 a runtime check.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/qtest/qmp-cmd-test.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index c98b78d0339..8902d2f169f 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -21,19 +21,24 @@ const char common_args[] = "-nodefaults -machine none";
 
 /* Query smoke tests */
 
+static bool tcg_accel_available;
+
 static int query_error_class(const char *cmd)
 {
-    static struct {
+    static const struct {
         const char *cmd;
         int err_class;
+        /*
+         * Pointer to boolean.
+         * If non-NULL and value is %true, the error class is skipped.
+         */
+        bool *skip_err_class;
     } fails[] = {
         /* Success depends on build configuration: */
 #ifndef CONFIG_SPICE
         { "query-spice", ERROR_CLASS_COMMAND_NOT_FOUND },
 #endif
-#ifndef CONFIG_TCG
-        { "query-replay", ERROR_CLASS_COMMAND_NOT_FOUND },
-#endif
+        { "query-replay", ERROR_CLASS_COMMAND_NOT_FOUND, &tcg_accel_available },
 #ifndef CONFIG_VNC
         { "query-vnc", ERROR_CLASS_GENERIC_ERROR },
         { "query-vnc-servers", ERROR_CLASS_GENERIC_ERROR },
@@ -51,6 +56,9 @@ static int query_error_class(const char *cmd)
     int i;
 
     for (i = 0; fails[i].cmd; i++) {
+        if (fails[i].skip_err_class && *fails[i].skip_err_class) {
+            continue;
+        }
         if (!strcmp(cmd, fails[i].cmd)) {
             return fails[i].err_class;
         }
@@ -334,6 +342,8 @@ int main(int argc, char *argv[])
     QmpSchema schema;
     int ret;
 
+    tcg_accel_available = qtest_has_accel("tcg");
+
     g_test_init(&argc, &argv, NULL);
 
     qmp_schema_init(&schema);
-- 
2.26.3



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

* [PATCH v3 5/6] tests/qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2021-04-15 12:26 ` [PATCH v3 4/6] qtest/qmp-cmd-test: " Philippe Mathieu-Daudé
@ 2021-04-15 12:26 ` Philippe Mathieu-Daudé
  2021-04-15 12:26 ` [PATCH v3 6/6] tests/meson: Only build softfloat objects if TCG is selected Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Philippe Mathieu-Daudé,
	Richard Henderson, Andrew Jones, Markus Armbruster, qemu-arm,
	Claudio Fontana, Igor Mammedov, 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>
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 0c767389217..46de073d155 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -175,14 +175,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] 13+ messages in thread

* [PATCH v3 6/6] tests/meson: Only build softfloat objects if TCG is selected
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2021-04-15 12:26 ` [PATCH v3 5/6] tests/qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore Philippe Mathieu-Daudé
@ 2021-04-15 12:26 ` Philippe Mathieu-Daudé
  2021-04-15 12:30 ` [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Claudio Fontana
  2021-04-15 12:57 ` [PATCH v3 7/6] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM Philippe Mathieu-Daudé
  7 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Alex Bennée,
	Richard Henderson, Andrew Jones, Markus Armbruster, qemu-arm,
	Emilio G . Cota, Claudio Fontana, Igor Mammedov, Paolo Bonzini,
	Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

The previous attempt (commit f77147cd4de) doesn't work as
expected, as we still have CONFIG_TCG=1 when using:

  configure --disable-system --disable-user

Now than we have removed the use of CONFIG_TCG from target-dependent
files in tests/qtest/, we can remove the unconditional definition of
CONFIG_TCG in config_host.

This avoid to build a bunch of unrequired objects when building with
--disable-tcg (in particular the softfloat tests):

Before:

  $ make
  [1/812] Generating trace-qom.h with a custom command
  ...

After:

  $ make
  [1/349] Generating trace-qom.h with a custom command
  ...

A difference of 463 objects...

Reported-by: Claudio Fontana <cfontana@suse.de>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v3: Include Paolo's feedback:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg793872.html
therefore o not include Alex's R-b tag.

Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Alex Bennée <alex.bennee@linaro.org>
Cc: Emilio G. Cota <cota@braap.org>
---
 meson.build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/meson.build b/meson.build
index c6f4b0cf5e8..623cbe50685 100644
--- a/meson.build
+++ b/meson.build
@@ -262,7 +262,6 @@
                         language: ['c', 'cpp', 'objc'])
 
   accelerators += 'CONFIG_TCG'
-  config_host += { 'CONFIG_TCG': 'y' }
 endif
 
 if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
-- 
2.26.3



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

* Re: [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels'
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2021-04-15 12:26 ` [PATCH v3 6/6] tests/meson: Only build softfloat objects if TCG is selected Philippe Mathieu-Daudé
@ 2021-04-15 12:30 ` Claudio Fontana
  2021-04-15 12:50   ` Philippe Mathieu-Daudé
  2021-04-15 12:57 ` [PATCH v3 7/6] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM Philippe Mathieu-Daudé
  7 siblings, 1 reply; 13+ messages in thread
From: Claudio Fontana @ 2021-04-15 12:30 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Richard Henderson,
	Andrew Jones, Markus Armbruster, qemu-arm, Igor Mammedov,
	Paolo Bonzini

Hi Philippe,

does the tests/qtest/arm-cpu-features.c kvm_enabled() function need to be replaced by the use of this new command?

Maybe something to add to the series?

The use of "kvm_enabled()" in this function is particularly confused, because it matches the sysemu/kvm.h function name with completely different meaning.

Ciao,

CLaudio

On 4/15/21 2:26 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.
> 
> As a bonus we remove CONFIG_TCG in config_host, to avoid
> building unnecessary objects depending on TCG.
> 
> Missing review:
> - #4 qtest/qmp-cmd-test: Make test build-independent from accelerator
> - #6 tests/meson: Only build softfloat objects if TCG is selected
> 
> Since v2:
> - Addressed Eric & Paolo review comments
> 
> Since v1:
> - 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.
> 
> Please review,
> 
> Phil.
> 
> Philippe Mathieu-Daudé (6):
>   accel: Introduce 'query-accels' QMP command
>   tests/qtest: Add qtest_has_accel() method
>   qtest/bios-tables-test: Make test build-independent from accelerator
>   qtest/qmp-cmd-test: Make test build-independent from accelerator
>   tests/qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
>   tests/meson: Only build softfloat objects if TCG is selected
> 
>  meson.build                    |  1 -
>  qapi/machine.json              | 49 +++++++++++++++++
>  tests/qtest/libqos/libqtest.h  |  8 +++
>  accel/accel-qmp.c              | 49 +++++++++++++++++
>  tests/qtest/bios-tables-test.c | 99 ++++++++++++++++++----------------
>  tests/qtest/libqtest.c         | 29 ++++++++++
>  tests/qtest/qmp-cmd-test.c     | 18 +++++--
>  accel/meson.build              |  2 +-
>  tests/qtest/meson.build        |  3 +-
>  9 files changed, 203 insertions(+), 55 deletions(-)
>  create mode 100644 accel/accel-qmp.c
> 



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

* Re: [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels'
  2021-04-15 12:30 ` [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Claudio Fontana
@ 2021-04-15 12:50   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:50 UTC (permalink / raw)
  To: Claudio Fontana, qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Richard Henderson,
	Andrew Jones, Markus Armbruster, qemu-arm, Igor Mammedov,
	Paolo Bonzini

On 4/15/21 2:30 PM, Claudio Fontana wrote:
> Hi Philippe,
> 
> does the tests/qtest/arm-cpu-features.c kvm_enabled() function need to be replaced by the use of this new command?
> 
> Maybe something to add to the series?
> 
> The use of "kvm_enabled()" in this function is particularly confused, because it matches the sysemu/kvm.h function name with completely different meaning.

Great idea, thanks!

> 
> Ciao,
> 
> CLaudio



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

* [PATCH v3 7/6] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
  2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2021-04-15 12:30 ` [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Claudio Fontana
@ 2021-04-15 12:57 ` Philippe Mathieu-Daudé
  2021-04-15 13:23   ` Andrew Jones
  7 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 12:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Andrew Jones, Thomas Huth, Eric Auger, qemu-arm,
	Claudio Fontana, Paolo Bonzini, Philippe Mathieu-Daudé

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

Suggested-by: Claudio Fontana <cfontana@suse.de>
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] 13+ messages in thread

* Re: [PATCH v3 7/6] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
  2021-04-15 12:57 ` [PATCH v3 7/6] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM Philippe Mathieu-Daudé
@ 2021-04-15 13:23   ` Andrew Jones
  2021-04-15 16:01     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Jones @ 2021-04-15 13:23 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Laurent Vivier, Thomas Huth, qemu-devel, Eric Auger, qemu-arm,
	Claudio Fontana, Paolo Bonzini

On Thu, Apr 15, 2021 at 02:57:37PM +0200, Philippe Mathieu-Daudé wrote:
> Use the recently added generic qtest_has_accel() method to
> check if KVM is available.
> 
> Suggested-by: Claudio Fontana <cfontana@suse.de>
> 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")) {

With this new guard in main(), we should be able to drop the tcg fallback
in MACHINE_KVM. But, to do that, we also need to guard the call to
sve_tests_sve_off_kvm().

>          qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
>                              NULL, test_query_cpu_model_expansion_kvm);
>      }
> -- 
> 2.26.3
> 

And, shouldn't we also guard all the other tests, which require tcg, with
qtest_has_accel("tcg")?

Thanks,
drew



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

* Re: [PATCH v3 1/6] accel: Introduce 'query-accels' QMP command
  2021-04-15 12:26 ` [PATCH v3 1/6] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
@ 2021-04-15 15:06   ` Markus Armbruster
  0 siblings, 0 replies; 13+ messages in thread
From: Markus Armbruster @ 2021-04-15 15:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Laurent Vivier, Thomas Huth, Daniel P . Berrangé,
	Eduardo Habkost, Michael S. Tsirkin, Richard Henderson,
	qemu-devel, Andrew Jones, qemu-arm, Claudio Fontana,
	Paolo Bonzini, Igor Mammedov

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"
>             }
>         ]
>     }
>
> Note that we can't make the enum values or union branches conditional
> because of target-specific poisoning of accelerator definitions.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Since v2: @since 6.0 -> 6.1, added note (Eric)
> Since v1: 'type' -> 'name' in comments
> ---
>  qapi/machine.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++
>  accel/accel-qmp.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
>  accel/meson.build |  2 +-
>  3 files changed, 99 insertions(+), 1 deletion(-)
>  create mode 100644 accel/accel-qmp.c
>
> diff --git a/qapi/machine.json b/qapi/machine.json
> index 6e90d463fc9..4babc06f8b0 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -1274,3 +1274,52 @@
>  ##
>  { 'event': 'MEM_UNPLUG_ERROR',
>    'data': { 'device': 'str', 'msg': 'str' } }
> +
> +##
> +# @Accelerator:
> +#
> +# An enumeration of accelerator names.
> +#
> +# Since: 6.1
> +##
> +{ 'enum': 'Accelerator',
> +  'data': [ 'qtest', 'tcg', 'kvm', 'hax', 'hvf', 'whpx', 'xen' ] }
> +
> +##
> +# @AcceleratorInfo:
> +#
> +# Accelerator information.
> +#
> +# @name: The accelerator name.
> +#
> +# Since: 6.1
> +##
> +{ 'union': 'AcceleratorInfo',
> +  'base': {'name': 'Accelerator'},
> +  'discriminator': 'name',
> +  'data': { } }

Not wrong, but feels overengineered unless you have concrete plans to
add variant members in the near future.  Simpler:

   { 'struct': 'AcceleratorInfo',
     'data': { 'name': 'Accelerator' } }

Changing this to flat union when we actually need it won't break
compatibility.

> +
> +##
> +# @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'] }
[...]



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

* Re: [PATCH v3 7/6] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
  2021-04-15 13:23   ` Andrew Jones
@ 2021-04-15 16:01     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-15 16:01 UTC (permalink / raw)
  To: Andrew Jones
  Cc: Laurent Vivier, Thomas Huth, qemu-devel, Eric Auger, qemu-arm,
	Claudio Fontana, Paolo Bonzini

Hi Drew,

On 4/15/21 3:23 PM, Andrew Jones wrote:
> On Thu, Apr 15, 2021 at 02:57:37PM +0200, Philippe Mathieu-Daudé wrote:
>> Use the recently added generic qtest_has_accel() method to
>> check if KVM is available.
>>
>> Suggested-by: Claudio Fontana <cfontana@suse.de>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  tests/qtest/arm-cpu-features.c | 25 +------------------------
>>  1 file changed, 1 insertion(+), 24 deletions(-)

>>  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")) {
> 
> With this new guard in main(), we should be able to drop the tcg fallback
> in MACHINE_KVM. But, to do that, we also need to guard the call to
> sve_tests_sve_off_kvm().

OK, I'll have a look.

>>          qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
>>                              NULL, test_query_cpu_model_expansion_kvm);
>>      }
>> -- 
>> 2.26.3
>>
> 
> And, shouldn't we also guard all the other tests, which require tcg, with
> qtest_has_accel("tcg")?

Now that we have this qtest_has_accel() method, there is certainly room
for improvements / simplifications. This doesn't have to block this
patch set and could be done on top. (Beside helping Claudio's effort,
my main selfish motivation was to stop compile pointless objects and
reduce minutes wasted on CI).

Thanks,

Phil.



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

end of thread, other threads:[~2021-04-15 16:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 12:26 [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Philippe Mathieu-Daudé
2021-04-15 12:26 ` [PATCH v3 1/6] accel: Introduce 'query-accels' QMP command Philippe Mathieu-Daudé
2021-04-15 15:06   ` Markus Armbruster
2021-04-15 12:26 ` [PATCH v3 2/6] tests/qtest: Add qtest_has_accel() method Philippe Mathieu-Daudé
2021-04-15 12:26 ` [PATCH v3 3/6] qtest/bios-tables-test: Make test build-independent from accelerator Philippe Mathieu-Daudé
2021-04-15 12:26 ` [PATCH v3 4/6] qtest/qmp-cmd-test: " Philippe Mathieu-Daudé
2021-04-15 12:26 ` [PATCH v3 5/6] tests/qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore Philippe Mathieu-Daudé
2021-04-15 12:26 ` [PATCH v3 6/6] tests/meson: Only build softfloat objects if TCG is selected Philippe Mathieu-Daudé
2021-04-15 12:30 ` [PATCH v3 0/6] qtests: Check accelerator available at runtime via QMP 'query-accels' Claudio Fontana
2021-04-15 12:50   ` Philippe Mathieu-Daudé
2021-04-15 12:57 ` [PATCH v3 7/6] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM Philippe Mathieu-Daudé
2021-04-15 13:23   ` Andrew Jones
2021-04-15 16:01     ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).