[libguestfs] Add non-upstream patch to deal with broken qemu -machine option.

Richard W.M. Jones rjones at fedoraproject.org
Tue Jul 26 17:56:51 UTC 2011


commit 56dd0556bb7b1bd2041b9e1e467e62c394544ce9
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Jul 26 18:56:16 2011 +0100

    Add non-upstream patch to deal with broken qemu -machine option.

 ...chine-option-for-latest-qemu-thanks-Marku.patch |   88 ++++++++++++++++++++
 libguestfs.spec                                    |   11 ++-
 2 files changed, 97 insertions(+), 2 deletions(-)
---
diff --git a/0001-Fix-qemu-machine-option-for-latest-qemu-thanks-Marku.patch b/0001-Fix-qemu-machine-option-for-latest-qemu-thanks-Marku.patch
new file mode 100644
index 0000000..b14bb86
--- /dev/null
+++ b/0001-Fix-qemu-machine-option-for-latest-qemu-thanks-Marku.patch
@@ -0,0 +1,88 @@
+From 2ae7aa73308d911fa9916d6ec03e2a52a16f7737 Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones at 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
+
diff --git a/libguestfs.spec b/libguestfs.spec
index 5d64757..3eb8917 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -30,7 +30,7 @@ Summary:       Access and modify virtual machine disk images
 Name:          libguestfs
 Epoch:         1
 Version:       1.12.1
-Release:       2%{?dist}
+Release:       3%{?dist}
 License:       LGPLv2+
 Group:         Development/Libraries
 URL:           http://libguestfs.org/
@@ -43,6 +43,11 @@ Patch0:        libguestfs-1.7.13-no-fuse-test.patch
 # Force qemu-kvm test to run with -machine accel=tcg flag.
 Patch2:        libguestfs-1.12.0-configure-force-machine-accel-tcg.patch
 
+# Non-upstream patch to fix -machine option.  This is not upstream
+# because qemu look like they might revert (ie. fix) the -machine
+# option so that this patch would not be needed.
+Patch3:        0001-Fix-qemu-machine-option-for-latest-qemu-thanks-Marku.patch
+
 # Basic build requirements:
 BuildRequires: /usr/bin/pod2man
 BuildRequires: /usr/bin/pod2text
@@ -495,6 +500,7 @@ for %{name}.
 
 %patch0 -p1
 %patch2 -p1
+%patch3 -p1
 
 mkdir -p daemon/m4
 
@@ -860,9 +866,10 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
-* Tue Jul 26 2011 Richard W.M. Jones <rjones at redhat.com> - 1:1.12.1-2
+* Tue Jul 26 2011 Richard W.M. Jones <rjones at redhat.com> - 1:1.12.1-3
 - New upstream stable branch version 1.12.1.
 - Remove 5 x upstream patches.
+- Add non-upstream patch to deal with broken qemu -machine option.
 
 * Tue Jul 26 2011 Richard W.M. Jones <rjones at redhat.com> - 1:1.12.0-11
 - Bump and rebuild.


More information about the scm-commits mailing list