!82 fix virt-sparsify fail

From: @yuxiating2021 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
This commit is contained in:
openeuler-ci-bot 2023-12-28 09:40:49 +00:00 committed by Gitee
commit 2627294ea7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,45 @@
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 44a7df25fc..75a4d3a280 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"))

View File

@ -4,7 +4,7 @@
Name: libguestfs
Version: 1.40.2
Release: 19
Release: 20
Epoch: 1
Summary: A set of tools for accessing and modifying virtual machine (VM) disk images
License: LGPLv2+
@ -20,6 +20,7 @@ Patch0004: Fix-defaut-function-compare-error.patch
Patch0005: Fix-verbose-error.patch
Patch0006: 0001-tests-Use-explicit-backing-format-for-all-backing-di.patch
Patch0007: add-some-package-to-fix-run-error.patch
Patch0008: lib-Autodetect-backing-format-for-qemu-img-create-b.patch
BuildRequires: gcc-c++, rpcgen, libtirpc-devel, supermin-devel >= 5.1.18, hivex-devel >= 1.2.7-7, ocaml-hivex-devel, perl(Pod::Simple), perl(Pod::Man)
BuildRequires: /usr/bin/pod2text, po4a, augeas-devel >= 1.7.0, readline-devel, genisoimage, libxml2-devel, createrepo, glibc-static, libselinux-utils
@ -378,6 +379,9 @@ chmod 644 %{buildroot}%{_libdir}/perl5/vendor_perl/auto/Sys/Guestfs/Guestfs.so
%exclude %{_mandir}/man1/virt-tar.1*
%changelog
* Tue Dec 5 2023 yuxiating <yuxiating@xfusion.com> - 1:1.40.2-20
- Autodetect backing format for qemu-img create -b
* Mon Aug 14 2023 suwei <suwei@kylinsec.com.cn> - - 1.40.2-19
- Add loongarch64 and sw_64 support