ms->accelerator = NULL;
*(acc->allowed) = false;
object_unref(OBJECT(accel));
+ } else {
+ object_set_accelerator_compat_props(acc->compat_props);
}
return ret;
}
-void configure_accelerator(MachineState *ms)
+void configure_accelerator(MachineState *ms, const char *progname)
{
const char *accel;
char **accel_list, **tmp;
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_report("No accelerator selected and"
+ " no default accelerator available");
+ exit(1);
+#endif
+ }
}
accel_list = g_strsplit(accel, ":", 0);
if (!acc) {
continue;
}
- if (acc->available && !acc->available()) {
- printf("%s not supported for this target\n",
- acc->name);
- continue;
- }
ret = accel_init_machine(acc, ms);
if (ret < 0) {
init_failed = true;
}
}
-void accel_register_compat_props(AccelState *accel)
-{
- AccelClass *class = ACCEL_GET_CLASS(accel);
- GlobalProperty *prop = class->global_props;
-
- for (; prop && prop->driver; prop++) {
- /* Any compat_props must never cause error */
- prop->errp = &error_abort;
- qdev_prop_register_global(prop);
- }
-}
-
void accel_setup_post(MachineState *ms)
{
AccelState *accel = ms->accelerator;