[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/22] machine: introduce accel option to allow sele
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 19/22] machine: introduce accel option to allow selection of kvm or tcg |
Date: |
Mon, 7 Jun 2010 18:52:07 -0500 |
Syntax is -machine accel=kvm
-machine accel=tcg
-machine accel=kvm|tcg
kvm|tcg tries kvm and fallbacks on tcg if kvm support isn't available.
Signed-off-by: Anthony Liguori <address@hidden>
diff --git a/hw/boards.h b/hw/boards.h
index 947fa33..1097561 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -81,6 +81,9 @@ void machine_set_default(const char *name);
},{ \
.name = "sockets", \
.type = QEMU_OPT_NUMBER, \
+ },{ \
+ .name = "accel", \
+ .type = QEMU_OPT_STRING, \
}
diff --git a/vl.c b/vl.c
index d84fc65..7cb5865 100644
--- a/vl.c
+++ b/vl.c
@@ -2654,6 +2654,8 @@ int main(int argc, char **argv, char **envp)
int defconfig = 1;
QemuOpts *machine_opts = NULL;
int max_cpus = 0;
+ const char *accel;
+ int tcg_fallback = 0;
error_set_progname(argv[0]);
@@ -3272,7 +3274,10 @@ int main(int argc, char **argv, char **envp)
do_smbios_option(optarg);
break;
case QEMU_OPTION_enable_kvm:
- kvm_allowed = 1;
+ if (!qemu_opts_parsef(&qemu_machine_opts, "accel=kvm")) {
+ printf("failed\n");
+ exit(1);
+ }
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
@@ -3629,15 +3634,36 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ accel = qemu_opt_get(machine_opts, "accel");
+ if (accel) {
+ if (!strcmp(accel, "kvm")) {
+ kvm_allowed = 1;
+ } else if (!strcmp(accel, "tcg")) {
+ kvm_allowed = 0;
+ } else if (!strcmp(accel, "kvm|tcg")) {
+ kvm_allowed = 1;
+ tcg_fallback = 1;
+ } else {
+ fprintf(stderr, "accel: invalid option %s\n", accel);
+ exit(1);
+ }
+ }
+
if (kvm_allowed) {
int ret = kvm_init(smp_cpus);
if (ret < 0) {
if (!kvm_available()) {
printf("KVM not supported for this target\n");
+ exit(1);
} else {
fprintf(stderr, "failed to initialize KVM: %s\n",
strerror(-ret));
+
+ if (tcg_fallback) {
+ kvm_allowed = 0;
+ } else {
+ exit(1);
+ }
}
- exit(1);
}
}
--
1.7.0.4
- [Qemu-devel] [PATCH 12/22] machine: some sugary macros to simplify machine default options, (continued)
- [Qemu-devel] [PATCH 12/22] machine: some sugary macros to simplify machine default options, Anthony Liguori, 2010/06/07
- [Qemu-devel] [PATCH 06/22] Make -acpi-enable a machine specific option, Anthony Liguori, 2010/06/07
- [Qemu-devel] [PATCH 17/22] machine: kill machine->alias, Anthony Liguori, 2010/06/07
- [Qemu-devel] [PATCH 16/22] machine: move default machine out of machine definitions, Anthony Liguori, 2010/06/07
- [Qemu-devel] [PATCH 15/22] machine: make max_cpus a -machine option, Anthony Liguori, 2010/06/07
- Re: [Qemu-devel] [PATCH 15/22] machine: make max_cpus a -machine option, Jes Sorensen, 2010/06/09
- [Qemu-devel] [PATCH 19/22] machine: introduce accel option to allow selection of kvm or tcg,
Anthony Liguori <=
- [Qemu-devel] [PATCH 21/22] machine: convert pc machines to split core vs machine API, Anthony Liguori, 2010/06/07
- [Qemu-devel] [PATCH 14/22] machine: replace QEMUMachine.use_scsi with -machine default_drive, Anthony Liguori, 2010/06/07
- [Qemu-devel] [PATCH 22/22] machine: introduce -machine-def option to define a machine via config, Anthony Liguori, 2010/06/07
[Qemu-devel] [PATCH 20/22] machine: introduce machine core and split qemu_register_machine, Anthony Liguori, 2010/06/07
[Qemu-devel] [PATCH 18/22] machine: final conversion to pure QemuOpts, Anthony Liguori, 2010/06/07
Re: [Qemu-devel] [PATCH 0/22] Refactor machine support, Paul Brook, 2010/06/07