89 lines
3.0 KiB
Diff
89 lines
3.0 KiB
Diff
|
From 2ae7aa73308d911fa9916d6ec03e2a52a16f7737 Mon Sep 17 00:00:00 2001
|
||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||
|
Date: Mon, 25 Jul 2011 10:45:13 +0100
|
||
|
Subject: [PATCH] Fix qemu -machine option for latest qemu (thanks Markus
|
||
|
Armbruster).
|
||
|
|
||
|
---
|
||
|
src/launch.c | 25 +++++++++++++++----------
|
||
|
1 files changed, 15 insertions(+), 10 deletions(-)
|
||
|
|
||
|
diff --git a/src/launch.c b/src/launch.c
|
||
|
index 56aa288..933e3fd 100644
|
||
|
--- a/src/launch.c
|
||
|
+++ b/src/launch.c
|
||
|
@@ -75,10 +75,10 @@ static int launch_appliance (guestfs_h *g);
|
||
|
static int64_t timeval_diff (const struct timeval *x, const struct timeval *y);
|
||
|
static int connect_unix_socket (guestfs_h *g, const char *sock);
|
||
|
static int qemu_supports (guestfs_h *g, const char *option);
|
||
|
-
|
||
|
-#if 0
|
||
|
static int qemu_supports_re (guestfs_h *g, const pcre *option_regex);
|
||
|
|
||
|
+static pcre *re_machine_name;
|
||
|
+
|
||
|
static void compile_regexps (void) __attribute__((constructor));
|
||
|
static void free_regexps (void) __attribute__((destructor));
|
||
|
|
||
|
@@ -96,13 +96,15 @@ compile_regexps (void)
|
||
|
abort (); \
|
||
|
} \
|
||
|
} while (0)
|
||
|
+
|
||
|
+ COMPILE (re_machine_name, "-machine .*\\bname\\b", 0);
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
free_regexps (void)
|
||
|
{
|
||
|
+ pcre_free (re_machine_name);
|
||
|
}
|
||
|
-#endif
|
||
|
|
||
|
/* Add a string to the current command line. */
|
||
|
static void
|
||
|
@@ -516,14 +518,19 @@ launch_appliance (guestfs_h *g)
|
||
|
if (qemu_supports (g, "-nodefconfig"))
|
||
|
add_cmdline (g, "-nodefconfig");
|
||
|
|
||
|
- /* The qemu -machine option (added 2010-12) is a bit more sane
|
||
|
- * since it falls back through various different acceleration
|
||
|
- * modes, so try that first (thanks Markus Armbruster).
|
||
|
+ /* The qemu -machine option (added 2010-12) falls back through
|
||
|
+ * various different acceleration modes, so try that first (thanks
|
||
|
+ * Markus Armbruster). However in qemu commit 9052ea6bf4962b13
|
||
|
+ * the syntax was changed, so we have to detect that.
|
||
|
*/
|
||
|
- if (qemu_supports (g, "-machine")) {
|
||
|
+ if (qemu_supports_re (g, re_machine_name)) { /* after 2011-07-23 */
|
||
|
+ add_cmdline (g, "-machine");
|
||
|
+ add_cmdline (g, "pc,accel=kvm:tcg");
|
||
|
+ }
|
||
|
+ else if (qemu_supports (g, "-machine")) { /* after 2010-12 */
|
||
|
add_cmdline (g, "-machine");
|
||
|
add_cmdline (g, "accel=kvm:tcg");
|
||
|
- } else {
|
||
|
+ } else { /* no -machine option */
|
||
|
/* qemu sometimes needs this option to enable hardware
|
||
|
* virtualization, but some versions of 'qemu-kvm' will use KVM
|
||
|
* regardless (even where this option appears in the help text).
|
||
|
@@ -1159,7 +1166,6 @@ qemu_supports (guestfs_h *g, const char *option)
|
||
|
return strstr (g->qemu_help, option) != NULL;
|
||
|
}
|
||
|
|
||
|
-#if 0
|
||
|
/* As above but using a regex instead of a fixed string. */
|
||
|
static int
|
||
|
qemu_supports_re (guestfs_h *g, const pcre *option_regex)
|
||
|
@@ -1171,7 +1177,6 @@ qemu_supports_re (guestfs_h *g, const pcre *option_regex)
|
||
|
|
||
|
return match (g, g->qemu_help, option_regex);
|
||
|
}
|
||
|
-#endif
|
||
|
|
||
|
/* Check if a file can be opened. */
|
||
|
static int
|
||
|
--
|
||
|
1.7.5.2
|
||
|
|