Upstream patch to work with qemu 6.1 (RHBZ#1998820)

This commit is contained in:
Richard W.M. Jones 2021-08-31 08:38:26 +01:00
parent 941da64078
commit 6c323aeaf2
2 changed files with 56 additions and 1 deletions

View File

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

View File

@ -57,7 +57,7 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs
Epoch: 1
Version: 1.45.6
Release: 11%{?dist}
Release: 12%{?dist}
License: LGPLv2+
# Build only for architectures that have a kernel
@ -91,6 +91,10 @@ Source7: libguestfs.keyring
# Maintainer script which helps with handling patches.
Source8: copy-patches.sh
# Upstream patch to work with qemu 6.1
# https://bugzilla.redhat.com/show_bug.cgi?id=1998820
Patch1: 0001-lib-Autodetect-backing-format-for-qemu-img-create-b.patch
# Downstream (RHEL-only) patches.
%if 0%{?rhel}
Patch9001: 0001-RHEL-Remove-libguestfs-live-RHBZ-798980.patch
@ -1139,6 +1143,9 @@ rm ocaml/html/.gitignore
%changelog
* Tue Aug 31 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.45.6-12
- Upstream patch to work with qemu 6.1 (RHBZ#1998820)
* Fri Aug 06 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.45.6-11
- Fix license files.
- Move appliance to separate subpackage (RHBZ#1989514).