From: anthony.perard@citrix.com
To: qemu-devel@nongnu.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
xen-devel@lists.xensource.com, Stefano.Stabellini@eu.citrix.com
Subject: [Qemu-devel] [PATCH RFC V4 04/14] Introduce -accel command option.
Date: Tue, 28 Sep 2010 16:01:27 +0100 [thread overview]
Message-ID: <1285686097-13036-5-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1285686097-13036-1-git-send-email-anthony.perard@citrix.com>
From: Anthony PERARD <anthony.perard@citrix.com>
This option gives the ability to switch one "accelerator" like kvm, xen
or the default one tcg. We can specify more than one accelerator by
separate them by a comma. QEMU will try each one and use the first whose
works.
So,
-accel xen,kvm,tcg
which would try Xen support first, then KVM and finaly tcg if none of
the other works.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
qemu-options.hx | 10 ++++++
vl.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 85 insertions(+), 11 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index a0b5ae9..53c4d35 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1904,6 +1904,16 @@ Enable KVM full virtualization support. This option is only available
if KVM support is enabled when compiling.
ETEXI
+DEF("accel", HAS_ARG, QEMU_OPTION_accel, \
+ "-accel accel use an accelerator (kvm,xen,tcg), default is tcg\n", QEMU_ARCH_ALL)
+STEXI
+@item -accel @var{accel}[,@var{accel}[,...]]
+@findex -accel
+This is use to enable an accelerator, in kvm,xen,tcg.
+By default, it use only tcg. If there a more than one accelerator
+specified, the next one is used if the first don't work.
+ETEXI
+
DEF("xen-domid", HAS_ARG, QEMU_OPTION_xen_domid,
"-xen-domid id specify xen guest domain id\n", QEMU_ARCH_ALL)
DEF("xen-create", 0, QEMU_OPTION_xen_create,
diff --git a/vl.c b/vl.c
index 3f45aa9..797f04d 100644
--- a/vl.c
+++ b/vl.c
@@ -1747,6 +1747,74 @@ static int debugcon_parse(const char *devname)
return 0;
}
+static struct {
+ const char *opt_name;
+ const char *name;
+ int (*available)(void);
+ int (*init)(int smp_cpus);
+ int *allowed;
+} accel_list[] = {
+ { "tcg", "tcg", NULL, NULL, NULL },
+ { "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed },
+};
+
+static int accel_parse_init(const char *opts)
+{
+ const char *p = opts;
+ char buf[10];
+ int i, ret;
+ bool accel_initalised = 0;
+ bool init_failed = 0;
+
+ while (!accel_initalised && *p != '\0') {
+ if (*p == ',') {
+ p++;
+ }
+ p = get_opt_name(buf, sizeof (buf), p, ',');
+ for (i = 0; i < ARRAY_SIZE(accel_list); i++) {
+ if (strcmp(accel_list[i].opt_name, buf) == 0) {
+ if (accel_list[i].init) {
+ ret = accel_list[i].init(smp_cpus);
+ } else {
+ ret = 0;
+ }
+ if (ret < 0) {
+ init_failed = 1;
+ if (!accel_list[i].available()) {
+ printf("%s not supported for this target\n",
+ accel_list[i].name);
+ } else {
+ fprintf(stderr, "failed to initialize %s: %s\n",
+ accel_list[i].name,
+ strerror(-ret));
+ }
+ } else {
+ accel_initalised = 1;
+ if (accel_list[i].allowed) {
+ *(accel_list[i].allowed) = 1;
+ }
+ }
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(accel_list) + 1) {
+ fprintf(stderr, "\"%s\" accelerator does not exist.\n", buf);
+ exit(1);
+ }
+ }
+
+ if (!accel_initalised) {
+ fprintf(stderr, "No accelerator found!\n");
+ exit(1);
+ }
+
+ if (init_failed) {
+ fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name);
+ }
+
+ return !accel_initalised;
+}
+
void qemu_add_exit_notifier(Notifier *notify)
{
notifier_list_add(&exit_notifiers, notify);
@@ -1826,6 +1894,7 @@ int main(int argc, char **argv, char **envp)
const char *incoming = NULL;
int show_vnc_port = 0;
int defconfig = 1;
+ const char *accel_list_opts = "tcg";
#ifdef CONFIG_SIMPLE_TRACE
const char *trace_file = NULL;
@@ -2446,7 +2515,10 @@ int main(int argc, char **argv, char **envp)
do_smbios_option(optarg);
break;
case QEMU_OPTION_enable_kvm:
- kvm_allowed = 1;
+ accel_list_opts = "kvm";
+ break;
+ case QEMU_OPTION_accel:
+ accel_list_opts = optarg;
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
@@ -2744,16 +2816,8 @@ int main(int argc, char **argv, char **envp)
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");
- } else {
- fprintf(stderr, "failed to initialize KVM: %s\n", strerror(-ret));
- }
- exit(1);
- }
+ if (accel_list_opts) {
+ accel_parse_init(accel_list_opts);
}
if (qemu_init_main_loop()) {
--
1.6.5
next prev parent reply other threads:[~2010-09-28 15:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-28 15:01 [Qemu-devel] [PATCH RFC V4 00/14] xen device model support anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 01/14] xen: Replace some tab-indents with spaces (clean-up) anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 02/14] xen: Support new libxc calls from xen unstable anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 03/14] xen: Add xen_machine_fv anthony.perard
2010-09-28 15:01 ` anthony.perard [this message]
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 05/14] xen: Add xen in -accel option anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 06/14] xen: Add the Xen platform pci device anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 07/14] piix_pci: Introduces Xen specific call for irq anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 08/14] xen: add a 8259 Interrupt Controller anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 09/14] xen: Introduce the Xen mapcache anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 10/14] Introduce qemu_ram_ptr_unlock anthony.perard
2010-09-28 15:14 ` [Qemu-devel] " Anthony Liguori
2010-09-28 15:25 ` Stefano Stabellini
2010-09-28 16:01 ` Anthony Liguori
2010-09-28 18:04 ` Stefano Stabellini
2010-09-29 7:38 ` Gerd Hoffmann
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 11/14] vl.c: Introduce getter for shutdown_requested and reset_requested anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 12/14] xen: Initialize event channels and io rings anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 13/14] xen: Set running state in xenstore anthony.perard
2010-09-28 15:01 ` [Qemu-devel] [PATCH RFC V4 14/14] xen: Add a Xen specific ACPI Implementation to target-xen anthony.perard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1285686097-13036-5-git-send-email-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=Stefano.Stabellini@eu.citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).