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