Blame SOURCES/0081-launch-direct-Use-old-style-file-and-format-paramete.patch

a30de4
From 6db3412d15981d7624817d06999cb2ef4a03eed7 Mon Sep 17 00:00:00 2001
a30de4
From: "Richard W.M. Jones" <rjones@redhat.com>
a30de4
Date: Wed, 17 Jan 2018 10:11:53 +0000
a30de4
Subject: [PATCH] launch: direct: Use old-style file= and format= parameters
a30de4
 when not disabling locking (RHBZ#1503497).
a30de4
MIME-Version: 1.0
a30de4
Content-Type: text/plain; charset=UTF-8
a30de4
Content-Transfer-Encoding: 8bit
a30de4
a30de4
Ancient qemu 1.5 (in RHEL 7) does not understand the
a30de4
file.file.filename= and file.driver= parameters.  Go back to using the
a30de4
old-style file= and format= parameters when we're not trying to set
a30de4
the file.backing.file.locking=off parameter.
a30de4
a30de4
Fixes commit 9fe592808ccfd9ed184b88ca9c6cad2e1798dee3.
a30de4
a30de4
Thanks: Yongkui Guo, Václav Kadlčík.
a30de4
(cherry picked from commit a30b51747fc6605f50a9d5d8095fd2b6d1473b1c)
a30de4
---
a30de4
 lib/launch-direct.c | 32 +++++++++++++++++++++++++-------
a30de4
 1 file changed, 25 insertions(+), 7 deletions(-)
a30de4
a30de4
diff --git a/lib/launch-direct.c b/lib/launch-direct.c
a30de4
index 4f31ac231..3d6e72e78 100644
a30de4
--- a/lib/launch-direct.c
a30de4
+++ b/lib/launch-direct.c
a30de4
@@ -529,13 +529,31 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
a30de4
     else {
a30de4
       /* Writable qcow2 overlay on top of read-only drive. */
a30de4
       escaped_file = guestfs_int_qemu_escape_param (g, drv->overlay);
a30de4
-      param = safe_asprintf
a30de4
-        (g, "file.file.filename=%s,cache=unsafe,file.driver=qcow2%s%s%s,id=hd%zu",
a30de4
-         escaped_file,
a30de4
-         drv->disk_label ? ",serial=" : "",
a30de4
-         drv->disk_label ? drv->disk_label : "",
a30de4
-         data->qemu_mandatory_locking && drv->src.protocol == drive_protocol_file ? ",file.backing.file.locking=off" : "",
a30de4
-         i);
a30de4
+      if (data->qemu_mandatory_locking &&
a30de4
+	/* Add the file-specific locking option only for files, as
a30de4
+	 * qemu won't accept options unknown to the block driver in
a30de4
+	 * use.
a30de4
+	 */
a30de4
+	drv->src.protocol == drive_protocol_file) {
a30de4
+        param = safe_asprintf
a30de4
+          (g, "file.file.filename=%s,file.driver=qcow2,file.backing.file.locking=off,cache=unsafe%s%s,id=hd%zu",
a30de4
+           escaped_file,
a30de4
+           drv->disk_label ? ",serial=" : "",
a30de4
+           drv->disk_label ? drv->disk_label : "",
a30de4
+           i);
a30de4
+      } else {
a30de4
+        /* Ancient qemu (esp. qemu 1.5 in RHEL 7) didn't understand the
a30de4
+         * file.file.filename= parameter, so use the safer old-style
a30de4
+         * form of parameters unless we actually want to specify the
a30de4
+         * locking flag above.
a30de4
+         */
a30de4
+        param = safe_asprintf
a30de4
+          (g, "file=%s,format=qcow2,cache=unsafe%s%s,id=hd%zu",
a30de4
+           escaped_file,
a30de4
+           drv->disk_label ? ",serial=" : "",
a30de4
+           drv->disk_label ? drv->disk_label : "",
a30de4
+           i);
a30de4
+      }
a30de4
     }
a30de4
 
a30de4
     /* If there's an explicit 'iface', use it.  Otherwise default to
a30de4
-- 
a30de4
2.14.3
a30de4