qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] vl: Only choose enabled accelerators in configure_accele


From: Alex Bennée
Subject: Re: [PATCH 4/4] vl: Only choose enabled accelerators in configure_accelerators
Date: Thu, 09 Jan 2020 11:35:35 +0000
User-agent: mu4e 1.3.6; emacs 28.0.50

Richard Henderson <address@hidden> writes:

> By choosing "tcg:kvm" when kvm is not enabled, we generate
> an incorrect warning: "invalid accelerator kvm".
>
> Presumably the inverse is also true with --disable-tcg.
>
> Fixes: 28a0961757fc
> Signed-off-by: Richard Henderson <address@hidden>
> ---
>  vl.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 887dbfbb5d..9b7651c80d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2759,11 +2759,10 @@ 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 {
> +            bool have_tcg = accel_find("tcg");
> +            bool have_kvm = accel_find("kvm");
> +
> +            if (have_tcg && have_kvm) {
>                  int pnlen = strlen(progname);
>                  if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3],
>          "kvm")) {

I know you're not touching this bit but:

modified   vl.c
@@ -2763,8 +2763,7 @@ static void configure_accelerators(const char *progname)
             bool have_kvm = accel_find("kvm");
 
             if (have_tcg && have_kvm) {
-                int pnlen = strlen(progname);
-                if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3], "kvm")) {
+                if (g_str_has_suffix(progname, "kvm")) {
                     /* If the program name ends with "kvm", we prefer KVM */
                     accel = "kvm:tcg";
                 } else {


>                      /* If the program name ends with "kvm", we prefer KVM */
> @@ -2771,9 +2770,16 @@ static void configure_accelerators(const char 
> *progname)
>                  } 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++) {

Anyway:

Reviewed-by: Alex Bennée <address@hidden>

-- 
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]