[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v2 3/9] Require QEMU >= 1.0.



From: "Richard W.M. Jones" <rjones redhat com>

QEMU 1.0 was released at the end of 2011.

Remove all the cruft about detecting broken -machine type which
was only required for QEMU 0.15.

This also reverts commit 30ecbf3ec2ada68f7e125a180553e31b069033b7.
Even on ARM you can pass -machine accel=kvm:tcg and qemu does the
right thing, so I'm not sure why we wanted to disable that.
---
 README       |    2 +-
 configure.ac |   68 ++++++++++++++++++----------------------------------------
 src/launch.c |   27 +++++------------------
 3 files changed, 27 insertions(+), 70 deletions(-)

diff --git a/README b/README
index 2b133c6..4dd2075 100644
--- a/README
+++ b/README
@@ -46,7 +46,7 @@ For basic functionality and the C tools:
 - look at appliance/packagelist.in and install as many of the packages
   that apply to your distro as possible
 
-- recent QEMU >= 0.13 (0.14 or later is better) with virtio-serial support
+- QEMU >= 1.0.
 
 - kernel >= 2.6.34 with virtio-serial support enabled.
 
diff --git a/configure.ac b/configure.ac
index 69da9a5..ca0f9f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -568,55 +568,29 @@ working.
 ])
     fi
 
-    AS_IF([test "x$QEMU_OPTIONS" = "x"],[
-        dnl qemu 0.15 was released with broken support for '-machine',
-        dnl requiring you to add the machine type: '-machine pc,[...]'.
-        dnl The problem is that 'pc' is only applicable for PC-like
-        dnl hardware, so we cannot do this as a general solution.  Since
-        dnl qemu 0.15, this problem has been fixed so now the default
-        dnl machine type is chosen (qemu commit 2645c6dcaf6ea2a51a).
-        dnl
-        dnl We need to work out if this qemu is the broken version, so we
-        dnl can add 'pc' just for this broken version.
-        dnl
-        dnl Note that old qemu didn't support the '-machine' option at all.
-        dnl
-        dnl We use the -kernel option for testing this, because this option
-        dnl is processed very late, after qemu has set up the machine.
-        AC_MSG_CHECKING([for broken '-machine accel=tcg' option in $QEMU])
-        LC_ALL=C $QEMU -nographic -machine accel=tcg -kernel /NO_SUCH_FILE \
-             > config1.tmp 2>&1
-        LC_ALL=C $QEMU -nographic -machine pc,accel=tcg -kernel /NO_SUCH_FILE \
-             > config2.tmp 2>&1
-        if cmp -s config1.tmp config2.tmp; then
-            AC_MSG_RESULT([no])
-        else
-            AC_MSG_RESULT([yes])
-            AC_DEFINE([QEMU_MACHINE_TYPE_IS_BROKEN],[1],[qemu -machine accel=tcg option is broken (in qemu 0.15 only)])
-        fi
-        rm config1.tmp config2.tmp
-
-        dnl See if the '-machine [pc,]accel=tcg' option is required in
-        dnl order to run the virtio-serial test below.  This happens when
-        dnl we run qemu-kvm inside a VM without forcing TCG:
-        dnl
-        dnl   Could not access KVM kernel module: No such file or directory
-        dnl   failed to initialize KVM: No such file or directory
-        dnl   No accelerator found!
-        AC_MSG_CHECKING([if -machine @<:@pc,@:>@accel=tcg option is required to test virtio-serial feature])
-        if $QEMU -nographic -device \? >/dev/null 2>&1; then
-            :
-        elif $QEMU -machine accel=tcg -nographic -device \? >/dev/null 2>&1; then
-            QEMU_OPTIONS_FOR_TEST="-machine accel=tcg"
-        elif $QEMU -machine pc,accel=tcg -nographic -device \? >/dev/null 2>&1; then
-            QEMU_OPTIONS_FOR_TEST="-machine pc,accel=tcg"
-        # else nothing ... it'll fail below.
-        fi
-        AC_MSG_RESULT([$QEMU_OPTIONS_FOR_TEST])
-    ])
+    AC_MSG_CHECKING([that $QEMU -version works])
+    if $QEMU -version >&AS_MESSAGE_LOG_FD 2>&1; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+        AC_MSG_FAILURE(
+[$QEMU -version: command failed.
+
+This could be a very old version of qemu, or qemu might not be
+working.
+])
+    fi
+
+    AC_MSG_CHECKING([for $QEMU version >= 1])
+    if $QEMU -version | grep -sq 'version @<:@1-@:>@'; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_RESULT([no])
+        AC_MSG_FAILURE([$QEMU version must be >= 1.0.])
+    fi
 
     AC_MSG_CHECKING([for virtio-serial support in $QEMU])
-    if $QEMU $QEMU_OPTIONS $QEMU_OPTIONS_FOR_TEST -nographic -device \? 2>&1 | grep -sq virtio-serial; then
+    if $QEMU $QEMU_OPTIONS -machine accel=kvm:tcg -device \? 2>&1 | grep -sq virtio-serial; then
         AC_MSG_RESULT([yes])
     else
         AC_MSG_RESULT([no])
diff --git a/src/launch.c b/src/launch.c
index 7bc913b..e175dd9 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -678,29 +678,13 @@ launch_appliance (guestfs_h *g)
       add_cmdline_shell_unquoted (g, QEMU_OPTIONS);
     }
 
-    /* The #if on the next line should really be "architectures for
-     * which KVM is commonly available.
-     */
-#if defined(__i386__) || defined(__x86_64__)
     /* 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).
      */
     if (qemu_supports (g, "-machine")) {
       add_cmdline (g, "-machine");
-#if QEMU_MACHINE_TYPE_IS_BROKEN
-      /* Workaround for qemu 0.15: We have to add the '[type=]pc'
-       * since there is no default.  This is not a permanent solution
-       * because this only works on PC-like hardware.  Other platforms
-       * like ppc would need a different machine type.
-       *
-       * This bug is fixed in qemu commit 2645c6dcaf6ea2a51a, and was
-       * not a problem in qemu < 0.15.
-       */
-      add_cmdline (g, "pc,accel=kvm:tcg");
-#else
       add_cmdline (g, "accel=kvm:tcg");
-#endif
     } else {
       /* qemu sometimes needs this option to enable hardware
        * virtualization, but some versions of 'qemu-kvm' will use KVM
@@ -718,7 +702,6 @@ launch_appliance (guestfs_h *g)
           is_openable (g, "/dev/kvm", O_RDWR|O_CLOEXEC))
         add_cmdline (g, "-enable-kvm");
     }
-#endif /* i386 or x86-64 */
 
     if (g->smp > 1) {
       snprintf (buf, sizeof buf, "%d", g->smp);
@@ -1339,11 +1322,11 @@ test_qemu (guestfs_h *g)
 
   snprintf (cmd, sizeof cmd, "LC_ALL=C '%s' -nographic -help", g->qemu);
 
-  /* qemu -help should always work (qemu -version OTOH wasn't
-   * supported by qemu 0.9).  If this command doesn't work then it
-   * probably indicates that the qemu binary is missing.
+  /* If this command doesn't work then it probably indicates that the
+   * qemu binary is missing.
    */
   if (test_qemu_cmd (g, cmd, &g->qemu_help) == -1) {
+  qemu_error:
     error (g, _("command failed: %s\n\nIf qemu is located on a non-standard path, try setting the LIBGUESTFS_QEMU\nenvironment variable.  There may also be errors printed above."),
            cmd);
     return -1;
@@ -1352,8 +1335,8 @@ test_qemu (guestfs_h *g)
   snprintf (cmd, sizeof cmd, "LC_ALL=C '%s' -nographic -version 2>/dev/null",
             g->qemu);
 
-  /* Intentionally ignore errors from qemu -version. */
-  ignore_value (test_qemu_cmd (g, cmd, &g->qemu_version));
+  if (test_qemu_cmd (g, cmd, &g->qemu_version) == -1)
+    goto qemu_error;
 
   return 0;
 }
-- 
1.7.10.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]