Skip to content

Commit

Permalink
lib: Autodetect backing format for qemu-img create -b
Browse files Browse the repository at this point in the history
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 c8c181e ("launch: libvirt: Autodetect
backing format for readonly drive overlays").

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1998820
  • Loading branch information
rwmjones committed Aug 31, 2021
1 parent 210959c commit 45de287
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/create.c
Expand Up @@ -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;
Expand All @@ -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"))
Expand Down

0 comments on commit 45de287

Please sign in to comment.