Blame SOURCES/0009-lib-Autodetect-backing-format-for-qemu-img-create-b.patch

13e635
From 791a16b049ea1ce2c450acd367fce774d9aab5b1 Mon Sep 17 00:00:00 2001
13e635
From: "Richard W.M. Jones" <rjones@redhat.com>
13e635
Date: Tue, 31 Aug 2021 08:27:15 +0100
13e635
Subject: [PATCH] lib: Autodetect backing format for qemu-img create -b
13e635
13e635
qemu 6.1 has decided to change qemu-img create so that a backing
13e635
format (-F) is required if a backing file (-b) is specified.  Since we
13e635
don't want to change the libguestfs API to force callers to specify
13e635
this because that would be an API break, autodetect it.
13e635
13e635
This is similar to commit c8c181e8d9 ("launch: libvirt: Autodetect
13e635
backing format for readonly drive overlays").
13e635
13e635
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1998820
13e635
(cherry picked from commit 45de287447bb18d59749fbfc1ec5072413090109)
13e635
---
13e635
 lib/create.c | 9 +++++++++
13e635
 1 file changed, 9 insertions(+)
13e635
13e635
diff --git a/lib/create.c b/lib/create.c
13e635
index 44a7df25f..75a4d3a28 100644
13e635
--- a/lib/create.c
13e635
+++ b/lib/create.c
13e635
@@ -255,6 +255,7 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
13e635
                    const struct guestfs_disk_create_argv *optargs)
13e635
 {
13e635
   const char *backingformat = NULL;
13e635
+  CLEANUP_FREE char *backingformat_free = NULL;
13e635
   const char *preallocation = NULL;
13e635
   const char *compat = NULL;
13e635
   int clustersize = -1;
13e635
@@ -270,6 +271,14 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
13e635
       return -1;
13e635
     }
13e635
   }
13e635
+  else if (backingfile) {
13e635
+    /* Since qemu 6.1, qemu-img create has requires a backing format (-F)
13e635
+     * parameter if backing file (-b) is used (RHBZ#1998820).
13e635
+     */
13e635
+    backingformat = backingformat_free = guestfs_disk_format (g, backingfile);
13e635
+    if (!backingformat)
13e635
+      return -1;
13e635
+  }
13e635
   if (optargs->bitmask & GUESTFS_DISK_CREATE_PREALLOCATION_BITMASK) {
13e635
     if (STREQ (optargs->preallocation, "off") ||
13e635
         STREQ (optargs->preallocation, "sparse"))
13e635
-- 
e29d66
2.31.1
13e635