All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] vl: Fixes for cleanups to -accel
@ 2020-01-16 21:05 Richard Henderson
  2020-01-16 21:05 ` [PATCH v2 1/4] vl: Remove unused variable in configure_accelerators Richard Henderson
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Richard Henderson @ 2020-01-16 21:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, alex.bennee, aleksandar.m.mail, philmd

Running qemu-system-foo with no options should not generate
a warning for "invalid accelerator bar".

Changes in v2:
  * Rebase on master, getting the free accel_list fix from upstream.
    Re-word the resulting patch 2 to merely reduce the scope of the
    local variables.
  * Use g_str_has_suffix (ajb)


r~


Richard Henderson (4):
  vl: Remove unused variable in configure_accelerators
  vl: Reduce scope of variables in configure_accelerators
  vl: Remove useless test in configure_accelerators
  vl: Only choose enabled accelerators in configure_accelerators

 vl.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

-- 
2.20.1



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

* [PATCH v2 1/4] vl: Remove unused variable in configure_accelerators
  2020-01-16 21:05 [PATCH v2 0/4] vl: Fixes for cleanups to -accel Richard Henderson
@ 2020-01-16 21:05 ` Richard Henderson
  2020-01-16 21:05 ` [PATCH v2 2/4] vl: Reduce scope of variables " Richard Henderson
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2020-01-16 21:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, alex.bennee, aleksandar.m.mail, philmd

The accel_initialised variable no longer has any setters.

Fixes: 6f6e1698a68c
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 vl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index 751401214c..6a5abf2f54 100644
--- a/vl.c
+++ b/vl.c
@@ -2754,7 +2754,6 @@ static void configure_accelerators(const char *progname)
 {
     const char *accel;
     char **accel_list, **tmp;
-    bool accel_initialised = false;
     bool init_failed = false;
 
     qemu_opts_foreach(qemu_find_opts("icount"),
@@ -2781,7 +2780,7 @@ static void configure_accelerators(const char *progname)
 
         accel_list = g_strsplit(accel, ":", 0);
 
-        for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) {
+        for (tmp = accel_list; tmp && *tmp; tmp++) {
             /*
              * Filter invalid accelerators here, to prevent obscenities
              * such as "-machine accel=tcg,,thread=single".
-- 
2.20.1



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

* [PATCH v2 2/4] vl: Reduce scope of variables in configure_accelerators
  2020-01-16 21:05 [PATCH v2 0/4] vl: Fixes for cleanups to -accel Richard Henderson
  2020-01-16 21:05 ` [PATCH v2 1/4] vl: Remove unused variable in configure_accelerators Richard Henderson
@ 2020-01-16 21:05 ` Richard Henderson
  2020-01-16 21:05 ` [PATCH v2 3/4] vl: Remove useless test " Richard Henderson
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2020-01-16 21:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, alex.bennee, aleksandar.m.mail, philmd

The accel_list and tmp variables are only used when manufacturing
-machine accel, options based on -accel.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
v2: The freeing of accel_list was fixed in adb464ff671d.
---
 vl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index 6a5abf2f54..3e2b77a4e8 100644
--- a/vl.c
+++ b/vl.c
@@ -2753,7 +2753,6 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
 static void configure_accelerators(const char *progname)
 {
     const char *accel;
-    char **accel_list, **tmp;
     bool init_failed = false;
 
     qemu_opts_foreach(qemu_find_opts("icount"),
@@ -2761,6 +2760,8 @@ static void configure_accelerators(const char *progname)
 
     accel = qemu_opt_get(qemu_get_machine_opts(), "accel");
     if (QTAILQ_EMPTY(&qemu_accel_opts.head)) {
+        char **accel_list, **tmp;
+
         if (accel == NULL) {
             /* Select the default accelerator */
             if (!accel_find("tcg") && !accel_find("kvm")) {
-- 
2.20.1



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

* [PATCH v2 3/4] vl: Remove useless test in configure_accelerators
  2020-01-16 21:05 [PATCH v2 0/4] vl: Fixes for cleanups to -accel Richard Henderson
  2020-01-16 21:05 ` [PATCH v2 1/4] vl: Remove unused variable in configure_accelerators Richard Henderson
  2020-01-16 21:05 ` [PATCH v2 2/4] vl: Reduce scope of variables " Richard Henderson
@ 2020-01-16 21:05 ` Richard Henderson
  2020-01-16 21:05 ` [PATCH v2 4/4] vl: Only choose enabled accelerators " Richard Henderson
  2020-01-17 11:58 ` [PATCH v2 0/4] vl: Fixes for cleanups to -accel Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2020-01-16 21:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, alex.bennee, aleksandar.m.mail, philmd

The result of g_strsplit is never NULL.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 vl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index 3e2b77a4e8..8ae8a5d241 100644
--- a/vl.c
+++ b/vl.c
@@ -2781,7 +2781,7 @@ static void configure_accelerators(const char *progname)
 
         accel_list = g_strsplit(accel, ":", 0);
 
-        for (tmp = accel_list; tmp && *tmp; tmp++) {
+        for (tmp = accel_list; *tmp; tmp++) {
             /*
              * Filter invalid accelerators here, to prevent obscenities
              * such as "-machine accel=tcg,,thread=single".
-- 
2.20.1



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

* [PATCH v2 4/4] vl: Only choose enabled accelerators in configure_accelerators
  2020-01-16 21:05 [PATCH v2 0/4] vl: Fixes for cleanups to -accel Richard Henderson
                   ` (2 preceding siblings ...)
  2020-01-16 21:05 ` [PATCH v2 3/4] vl: Remove useless test " Richard Henderson
@ 2020-01-16 21:05 ` Richard Henderson
  2020-01-17 11:58 ` [PATCH v2 0/4] vl: Fixes for cleanups to -accel Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2020-01-16 21:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, alex.bennee, aleksandar.m.mail, philmd

By choosing "tcg:kvm" when kvm is not enabled, we generate
an incorrect warning: "invalid accelerator kvm".

At the same time, use g_str_has_suffix rather than open-coding
the same operation.

Presumably the inverse is also true with --disable-tcg.

Fixes: 28a0961757fc
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
v2: Use g_str_has_suffix (ajb)
---
 vl.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/vl.c b/vl.c
index 8ae8a5d241..40ac9c5544 100644
--- a/vl.c
+++ b/vl.c
@@ -2764,21 +2764,26 @@ static void configure_accelerators(const char *progname)
 
         if (accel == NULL) {
             /* Select the default accelerator */
-            if (!accel_find("tcg") && !accel_find("kvm")) {
-                error_report("No accelerator selected and"
-                             " no default accelerator available");
-                exit(1);
-            } else {
-                int pnlen = strlen(progname);
-                if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3], "kvm")) {
+            bool have_tcg = accel_find("tcg");
+            bool have_kvm = accel_find("kvm");
+
+            if (have_tcg && have_kvm) {
+                if (g_str_has_suffix(progname, "kvm")) {
                     /* If the program name ends with "kvm", we prefer KVM */
                     accel = "kvm:tcg";
                 } else {
                     accel = "tcg:kvm";
                 }
+            } else if (have_kvm) {
+                accel = "kvm";
+            } else if (have_tcg) {
+                accel = "tcg";
+            } else {
+                error_report("No accelerator selected and"
+                             " no default accelerator available");
+                exit(1);
             }
         }
-
         accel_list = g_strsplit(accel, ":", 0);
 
         for (tmp = accel_list; *tmp; tmp++) {
-- 
2.20.1



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

* Re: [PATCH v2 0/4] vl: Fixes for cleanups to -accel
  2020-01-16 21:05 [PATCH v2 0/4] vl: Fixes for cleanups to -accel Richard Henderson
                   ` (3 preceding siblings ...)
  2020-01-16 21:05 ` [PATCH v2 4/4] vl: Only choose enabled accelerators " Richard Henderson
@ 2020-01-17 11:58 ` Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2020-01-17 11:58 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: philmd, alex.bennee, aleksandar.m.mail

On 16/01/20 22:05, Richard Henderson wrote:
> Running qemu-system-foo with no options should not generate
> a warning for "invalid accelerator bar".
> 
> Changes in v2:
>   * Rebase on master, getting the free accel_list fix from upstream.
>     Re-word the resulting patch 2 to merely reduce the scope of the
>     local variables.
>   * Use g_str_has_suffix (ajb)
> 
> 
> r~
> 
> 
> Richard Henderson (4):
>   vl: Remove unused variable in configure_accelerators
>   vl: Reduce scope of variables in configure_accelerators
>   vl: Remove useless test in configure_accelerators
>   vl: Only choose enabled accelerators in configure_accelerators
> 
>  vl.c | 27 ++++++++++++++++-----------
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>



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

end of thread, other threads:[~2020-01-17 11:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 21:05 [PATCH v2 0/4] vl: Fixes for cleanups to -accel Richard Henderson
2020-01-16 21:05 ` [PATCH v2 1/4] vl: Remove unused variable in configure_accelerators Richard Henderson
2020-01-16 21:05 ` [PATCH v2 2/4] vl: Reduce scope of variables " Richard Henderson
2020-01-16 21:05 ` [PATCH v2 3/4] vl: Remove useless test " Richard Henderson
2020-01-16 21:05 ` [PATCH v2 4/4] vl: Only choose enabled accelerators " Richard Henderson
2020-01-17 11:58 ` [PATCH v2 0/4] vl: Fixes for cleanups to -accel Paolo Bonzini

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.