]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virstoragetest: Add test cases for QCOW2 files with a protocol name as backing file...
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2023 19:42:54 +0000 (20:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 27 Nov 2023 09:12:34 +0000 (10:12 +0100)
QEMU allows and in cases where you omit the not-strictly-needed 'raw'
driver on top of raw images automatically uses the protocol name inside
of the 'backing file format' field of the qcow2 image.

Libvirt expects only format names in that field.

Add example images showing this scenario, which will be fixed later.

The qcow2 image files in this commit were formatted as:

  qemu-img create -f qcow2 -F nbd -b  nbd+tcp://example.org:6000/blah -u qcow2-protocol-backing-nbd.qcow2 10M

and

  qemu-img create -f qcow2 -F file -b raw  qcow2-protocol-backing-file.qcow2

thus using 'nbd' and 'file' as backing format respectively.

(note that '-b raw' refers to the file in the example image folder)

To satisfy the test, note that the NBD image is also rejected as we
can't probe it, thus such configuration would not work.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/virstoragetest.c
tests/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2 [new file with mode: 0644]
tests/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2 [new file with mode: 0644]
tests/virstoragetestdata/out/qcow2-protocol-backing-file [new file with mode: 0644]

index c28a23e3328cfb169743b29071d1bddec4749f65..53533d5885e6fd42e0cf14226b3199032aed00a3 100644 (file)
@@ -478,6 +478,14 @@ mymain(void)
                abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-auto.qcow2",
                VIR_STORAGE_FILE_QCOW2, EXP_PASS);
 
+    /* QCOW2 with protocol recorded inside the 'backing file format field */
+    TEST_CHAIN("qcow2-protocol-backing-file",
+               abs_srcdir "/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2",
+               VIR_STORAGE_FILE_QCOW2, EXP_PASS);
+    TEST_CHAIN("qcow2-protocol-backing-nbd",
+               abs_srcdir "/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2",
+               VIR_STORAGE_FILE_QCOW2, EXP_FAIL);
+
     /* Qcow2 file with missing backing file but specified type */
     TEST_CHAIN("qcow2-qcow2_missing",
                abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-missing.qcow2",
diff --git a/tests/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2 b/tests/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2
new file mode 100644 (file)
index 0000000..b3fe320
Binary files /dev/null and b/tests/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2 differ
diff --git a/tests/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2 b/tests/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2
new file mode 100644 (file)
index 0000000..0ae422d
Binary files /dev/null and b/tests/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2 differ
diff --git a/tests/virstoragetestdata/out/qcow2-protocol-backing-file b/tests/virstoragetestdata/out/qcow2-protocol-backing-file
new file mode 100644 (file)
index 0000000..b565bdb
--- /dev/null
@@ -0,0 +1,21 @@
+path:ABS_SRCDIR/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2
+backingStoreRaw: raw
+backingStoreRawFormat: <null>(-1)
+capacity: 1024
+encryption: 0
+relPath:<null>
+type:file
+format:qcow2
+protocol:none
+hostname:<null>
+
+path:ABS_SRCDIR/virstoragetestdata/images/raw
+backingStoreRaw: <null>
+backingStoreRawFormat: none(0)
+capacity: 0
+encryption: 0
+relPath:raw
+type:file
+format:raw
+protocol:none
+hostname:<null>