[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] vl: Only choose enabled accelerators in configure_accelerato
From: |
Richard Henderson |
Subject: |
[PATCH 4/4] vl: Only choose enabled accelerators in configure_accelerators |
Date: |
Thu, 9 Jan 2020 13:17:10 +1100 |
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")) {
/* 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++) {
--
2.20.1
- [PATCH 2/4] vl: Free accel_list in configure_accelerators, (continued)