From 815eab8a66ba6ae5bea7445abb0fa8b54e01e158 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 6 Feb 2020 15:47:54 +0000
Subject: [PATCH] tests: Use explicit backing format for all backing disks.

Libvirt 6.0 now requires that every disk in the backing chain has an
explicit backing format.  For example this will be rejected by
libvirt:

  qemu-img create -f qcow2 -b backing-disk disk.qcow2

with the error:

  Original error from libvirt: Requested operation is not valid:
  format of backing image 'backing-disk' of image 'disk.qcow2' was not
  specified in the image metadata (See
  https://libvirt.org/kbase/backing_chains.html for troubleshooting)
  [code=55 int1=-1]

Instead you have to use the -F option to specify the format, eg:

  qemu-img create -f qcow2 -b backing-disk -F raw disk.qcow2
---
 customize/test-virt-customize.sh            |  2 +-
 test-data/blank-disks/Makefile.am           |  2 +-
 tests/relative-paths/test-relative-paths.sh | 30 ++++++++++-----------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/customize/test-virt-customize.sh b/customize/test-virt-customize.sh
index 0c5231b4e..7817e67d4 100755
--- a/customize/test-virt-customize.sh
+++ b/customize/test-virt-customize.sh
@@ -27,7 +27,7 @@ f=$top_builddir/test-data/phony-guests/fedora.img
 fq=test-virt-customize-img.qcow
 out=test-virt-customize.out
 rm -f $fq $out
-qemu-img create -f qcow2 -b $f $fq
+qemu-img create -f qcow2 -b $f -F raw $fq
 
 # Add --no-network so UML works.
 $VG virt-customize --format qcow2 -a $fq --no-network \
diff --git a/test-data/blank-disks/Makefile.am b/test-data/blank-disks/Makefile.am
index da5692da3..6dd42bc1f 100644
--- a/test-data/blank-disks/Makefile.am
+++ b/test-data/blank-disks/Makefile.am
@@ -50,4 +50,4 @@ blank-disk-1M.qcow2:
 	qemu-img create -f qcow2 -o preallocation=metadata $@ 1M
 
 blank-disk-with-backing.qcow2: blank-disk-1M.raw
-	qemu-img create -f qcow2 -b $^ $@
+	qemu-img create -f qcow2 -b $^ -F raw $@
diff --git a/tests/relative-paths/test-relative-paths.sh b/tests/relative-paths/test-relative-paths.sh
index 379225903..ed9aa80d8 100755
--- a/tests/relative-paths/test-relative-paths.sh
+++ b/tests/relative-paths/test-relative-paths.sh
@@ -36,63 +36,63 @@ mkdir -p dir1/dir2
 # Regular overlay files.
 
 qemu-img create -f qcow2 backing1 10M
-qemu-img create -f qcow2 -b $(pwd)/backing1 overlay1
+qemu-img create -f qcow2 -b $(pwd)/backing1 -F qcow2 overlay1
 
 qemu-img create -f qcow2 backing2 10M
-qemu-img create -f qcow2 -b backing2 overlay2
+qemu-img create -f qcow2 -b backing2 -F qcow2 overlay2
 
 qemu-img create -f qcow2 backing3 10M
-qemu-img create -f qcow2 -b ./backing3 overlay3
+qemu-img create -f qcow2 -b ./backing3 -F qcow2 overlay3
 
 qemu-img create -f qcow2 backing4 10M
-qemu-img create -f qcow2 -b ../../tests/relative-paths/backing4 overlay4
+qemu-img create -f qcow2 -b ../../tests/relative-paths/backing4 -F qcow2 overlay4
 
 qemu-img create -f qcow2 backing5 10M
 pushd dir1
-qemu-img create -f qcow2 -b ../backing5 overlay5
+qemu-img create -f qcow2 -b ../backing5 -F qcow2 overlay5
 popd
 
 qemu-img create -f qcow2 backing6 10M
 pushd dir1/dir2
-qemu-img create -f qcow2 -b ../../backing6 overlay6
+qemu-img create -f qcow2 -b ../../backing6 -F qcow2 overlay6
 popd
 
 qemu-img create -f qcow2 dir1/backing7 10M
-qemu-img create -f qcow2 -b dir1/backing7 overlay7
+qemu-img create -f qcow2 -b dir1/backing7 -F qcow2 overlay7
 
 qemu-img create -f qcow2 dir1/dir2/backing8 10M
-qemu-img create -f qcow2 -b dir1/dir2/backing8 overlay8
+qemu-img create -f qcow2 -b dir1/dir2/backing8 -F qcow2 overlay8
 
 qemu-img create -f qcow2 dir1/dir2/backing9 10M
 pushd dir1
-qemu-img create -f qcow2 -b dir2/backing9 overlay9
+qemu-img create -f qcow2 -b dir2/backing9 -F qcow2 overlay9
 popd
 
 qemu-img create -f qcow2 dir1/backing10 10M
 pushd dir1/dir2
-qemu-img create -f qcow2 -b ../backing10 overlay10
+qemu-img create -f qcow2 -b ../backing10 -F qcow2 overlay10
 popd
 
 qemu-img create -f qcow2 dir1/backing11 10M
 pushd dir1
-qemu-img create -f qcow2 -b backing11 overlay11
+qemu-img create -f qcow2 -b backing11 -F qcow2 overlay11
 popd
 
 # Symbolic links.
 
 qemu-img create -f qcow2 backing12 10M
-qemu-img create -f qcow2 -b backing12 overlay12
+qemu-img create -f qcow2 -b backing12 -F qcow2 overlay12
 ln -s overlay12 link12
 
 qemu-img create -f qcow2 dir1/backing13 10M
 pushd dir1
-qemu-img create -f qcow2 -b backing13 overlay13
+qemu-img create -f qcow2 -b backing13 -F qcow2 overlay13
 popd
 ln -s dir1/overlay13 link13
 
 qemu-img create -f qcow2 dir1/dir2/backing14 10M
 pushd dir1
-qemu-img create -f qcow2 -b dir2/backing14 overlay14
+qemu-img create -f qcow2 -b dir2/backing14 -F qcow2 overlay14
 popd
 pushd dir1/dir2
 ln -s ../overlay14 link14
@@ -100,7 +100,7 @@ popd
 
 qemu-img create -f qcow2 dir1/backing15 10M
 pushd dir1/dir2
-qemu-img create -f qcow2 -b ../backing15 overlay15
+qemu-img create -f qcow2 -b ../backing15 -F qcow2 overlay15
 popd
 pushd dir1
 ln -s dir2/overlay15 link15
-- 
2.27.0

