Skip to contentSkip to conversation

-accel should list enabled accelerators

PATCH Applied Wainer dos Santos Moschetta 2 participants 3 messages May 30, 2019 – May 31, 2019

lore
Share & tools
lore
#0 lore raw

cover -accel should list enabled accelerators

On this series I changed the semantics of -accel help so that it shows only the accelerators enabled in the QEMU target binary. This behavior is now alike -cpu and -machine helps.

Another reason for this proposal is that I am working on an improvement of Avocado QEMU framework which should skip tests tagged with, e.g, "accel:tcg" if tcg is not enabled in the binary. And it seems the best approach to detect the presence (or not) of an accelerator is to query QEMU with -accel help.

Phillipe Mathieu-Daudé proposed a similar fix [1] but it was never merged. My patch is slightly different but it implements some decisions that seemed consensus at that time:

1. Do not display qtest. It's an internal only accelerator.
2. It should display those that have support on the target binary, regardless if they are not present on the host.

Example with this patch on x86_64 host (kvm not installed):
---

$ configure --enable-kvm --enable-xen --target-list="x86_64-softmmu ppc64-softmmu"
$ x86_64-softmmu/qemu-system-x86_64 -accel help
Accelerators supported in QEMU binary:
tcg
xen
kvm
$ ppc64-softmmu/qemu-system-ppc64 -accel help
Accelerators supported in QEMU binary:
tcg
---

Git: https://github.com/wainersm/qemu
Branch: accel_list
Travis: https://travis-ci.org/wainersm/qemu/builds/539366851

[1] https://www.mail-archive.com/[email protected]/msg491542.html

Wainer dos Santos Moschetta (1):
vl: make -accel help to list enabled accelerators only

 vl.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 vl: make -accel help to list enabled accelerators only

Currently, -accel help shows all possible accelerators regardless if they are enabled in the binary or not. That is a different semantic from -cpu and -machine helps, for example. So this change makes it to list only the accelerators which support is compiled in the binary target.

Note that it does not check if the accelerator is enabled in the host, so the help message's header was rewritten to emphasize that. Also qtest is not displayed given that it is used for internal testing purpose only.

---
 vl.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
vl.c +17 -1
index 2e69c9fef2..e5d40c01f8 100644
@@ -3575,7 +3575,23 @@ int main(int argc, char **argv, char **envp)
                                                      optarg, true);
                 optarg = qemu_opt_get(accel_opts, "accel");
                 if (!optarg || is_help_option(optarg)) {
-                    printf("Possible accelerators: kvm, xen, hax, tcg\n");
+                    printf("Accelerators supported in QEMU binary:\n");
+                    GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL,
+                                                                    false);
+                    for (el = accel_list; el; el = el->next) {
+                        gchar *typename = g_strdup(object_class_get_name(
+                                                   OBJECT_CLASS(el->data)));
+                        /* omit qtest which is used for tests only */
+                        if (g_strcmp0(typename, ACCEL_CLASS_NAME("qtest")) &&
+                            g_str_has_suffix(typename, ACCEL_CLASS_SUFFIX)) {
+                            gchar **optname = g_strsplit(typename,
+                                                         ACCEL_CLASS_SUFFIX, 0);
+                            printf("%s\n", optname[0]);
+                            g_free(optname);
+                        }
+                        g_free(typename);
+                    }
+                    g_slist_free(accel_list);
                     exit(0);
                 }
                 opts = qemu_opts_create(qemu_find_opts("machine"), NULL,
Signature · 1 line
2.21.0
#2 lore raw

Re: [Qemu-devel] [PATCH 1/1] vl: make -accel help to list enabled accelerators only

Quoted 36 lines · Wainer dos Santos Moschetta

Currently, -accel help shows all possible accelerators regardless if they are enabled in the binary or not. That is a different semantic from -cpu and -machine helps, for example. So this change makes it to list only the accelerators which support is compiled in the binary target.

Note that it does not check if the accelerator is enabled in the host, so the help message's header was rewritten to emphasize that. Also qtest is not displayed given that it is used for internal testing purpose only.

---
 vl.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
vl.c +10 -1
index 2e69c9fef2..e5d40c01f8 100644
@@ -3575,7 +3575,23 @@ int main(int argc, char **argv, char **envp)
                                                      optarg, true);
                 optarg = qemu_opt_get(accel_opts, "accel");
                 if (!optarg || is_help_option(optarg)) {
-                    printf("Possible accelerators: kvm, xen, hax, tcg\n");
+                    printf("Accelerators supported in QEMU binary:\n");
+                    GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL,
+                                                                    false);
+                    for (el = accel_list; el; el = el->next) {
+                        gchar *typename = g_strdup(object_class_get_name(
+                                                   OBJECT_CLASS(el->data)));
+                        /* omit qtest which is used for tests only */
+                        if (g_strcmp0(typename, ACCEL_CLASS_NAME("qtest")) &&
+                            g_str_has_suffix(typename, ACCEL_CLASS_SUFFIX)) {
+                            gchar **optname = g_strsplit(typename,

vl.c int main(int argc, char **argv, char **envp) · line 3597

Quoted 10 lines
vl.c +7 -0
+                                                         ACCEL_CLASS_SUFFIX, 0);
+                            printf("%s\n", optname[0]);
+                            g_free(optname);
+                        }
+                        g_free(typename);
+                    }
+                    g_slist_free(accel_list);
                     exit(0);
                 }
                 opts = qemu_opts_create(qemu_find_opts("machine"), NULL,

Queued, thanks!

Paolo