summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel/accel.c18
-rw-r--r--include/sysemu/accel.h2
-rw-r--r--vl.c2
3 files changed, 17 insertions, 5 deletions
diff --git a/accel/accel.c b/accel/accel.c
index 6db5d8f4df..68b6d56323 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 f331d128e9..5565e00a96 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);
/* Called just before os_setup_post (ie just before drop OS privs) */
void accel_setup_post(MachineState *ms);
diff --git a/vl.c b/vl.c
index 064872cc98..a903619d14 100644
--- a/vl.c
+++ b/vl.c
@@ -4329,7 +4329,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",