[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/35] accel: Improve selection of the default accele
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 01/35] accel: Improve selection of the default accelerator |
Date: |
Tue, 18 Dec 2018 00:16:26 +0100 |
From: Thomas Huth <address@hidden>
When compiling with "--disable-tcg", we currently still use "tcg"
as default accelerator. "kvm" should be used in this case instead.
Also, some downstream distros provide QEMU binaries which have "kvm"
in their names (e.g. "qemu-kvm" on RHEL or "kvm" on Ubuntu) that use
KVM by default - and some users might want to do something similar
with upstream binaries, too. Accomodate them by using "kvm:tcg" as
default when we detect such a binary name.
Signed-off-by: Thomas Huth <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
accel/accel.c | 18 +++++++++++++++---
include/sysemu/accel.h | 2 +-
vl.c | 2 +-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/accel/accel.c b/accel/accel.c
index 3da26eb90f..1b1214e273 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -69,7 +69,7 @@ static int accel_init_machine(AccelClass *acc, MachineState
*ms)
return ret;
}
-void configure_accelerator(MachineState *ms)
+void configure_accelerator(MachineState *ms, const char *progname)
{
const char *accel;
char **accel_list, **tmp;
@@ -80,8 +80,20 @@ void configure_accelerator(MachineState *ms)
accel = qemu_opt_get(qemu_get_machine_opts(), "accel");
if (accel == NULL) {
- /* Use the default "accelerator", tcg */
- accel = "tcg";
+ /* Select the default accelerator */
+ int pnlen = strlen(progname);
+ if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3], "kvm")) {
+ /* If the program name ends with "kvm", we prefer KVM */
+ accel = "kvm:tcg";
+ } else {
+#if defined(CONFIG_TCG)
+ accel = "tcg";
+#elif defined(CONFIG_KVM)
+ accel = "kvm";
+#else
+#error "No default accelerator available"
+#endif
+ }
}
accel_list = g_strsplit(accel, ":", 0);
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index 637358f430..285899e588 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -66,7 +66,7 @@ typedef struct AccelClass {
extern unsigned long tcg_tb_size;
-void configure_accelerator(MachineState *ms);
+void configure_accelerator(MachineState *ms, const char *progname);
/* Register accelerator specific global properties */
void accel_register_compat_props(AccelState *accel);
/* Called just before os_setup_post (ie just before drop OS privs) */
diff --git a/vl.c b/vl.c
index 2a8b2ee16d..5f6ff43b1b 100644
--- a/vl.c
+++ b/vl.c
@@ -4303,7 +4303,7 @@ int main(int argc, char **argv, char **envp)
qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
&error_fatal);
- configure_accelerator(current_machine);
+ configure_accelerator(current_machine, argv[0]);
if (!qtest_enabled() && machine_class->deprecation_reason) {
error_report("Machine type '%s' is deprecated: %s",
--
2.20.1
- [Qemu-devel] [PULL 00/35] Misc patches for 2018-12-18, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 01/35] accel: Improve selection of the default accelerator,
Paolo Bonzini <=
- [Qemu-devel] [PULL 02/35] vhost-user-bridge: fix "unknown type name" compilation error, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 03/35] checkpatch: fix premature exit when no input or --mailback, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 05/35] checkpatch: improve handling of multiple patches or files, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 04/35] checkpatch: check Signed-off-by in --mailback mode, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 06/35] checkpatch: colorize output to terminal, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 07/35] pam: wrap MemoryRegion initialization in a transaction, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 08/35] memory: extract flat_range_coalesced_io_{del, add}, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 09/35] memory: avoid unnecessary coalesced_io_del operations, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 10/35] memory: update coalesced_range on transaction_commit, Paolo Bonzini, 2018/12/17
- [Qemu-devel] [PULL 11/35] hax: Support for Linux hosts, Paolo Bonzini, 2018/12/17