[PATCH 7/7] storage_file_probe: Treat qcow2 images with protocol drivers in backing store field as raw

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



qemu allows and in some cases uses protocol driver names ('file',
'host_device', 'nbd', ...) in the 'backing file format' field of a qcow
to denote a image where the dummy 'raw' driver was not used on top.

Adapt our backing store parser for such cases. The examples added in
previous patch show the difference in behaviour.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/storage_file/storage_file_probe.c         |  8 ++++++-
 tests/virstoragetest.c                        |  2 +-
 .../out/qcow2-protocol-backing-file           |  2 +-
 .../out/qcow2-protocol-backing-nbd            | 21 +++++++++++++++++++
 4 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 tests/virstoragetestdata/out/qcow2-protocol-backing-nbd

diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/storage_file_probe.c
index 16298f76c7..243927d50a 100644
--- a/src/storage_file/storage_file_probe.c
+++ b/src/storage_file/storage_file_probe.c
@@ -474,9 +474,15 @@ qcow2GetExtensions(const char *buf,
             memcpy(tmp, buf + offset, len);
             tmp[len] = '\0';

+            /* qemu and qemu-img allow using the protocol driver name inside
+             * of the format field in cases when the dummy 'raw' driver should
+             * not be created. Thus libvirt needs to consider anything that
+             * doesn't look like a format driver name to be a protocol driver
+             * directly and thus the image is in fact still considered raw
+             */
             *backingFormat = virStorageFileFormatTypeFromString(tmp);
             if (*backingFormat <= VIR_STORAGE_FILE_NONE)
-                return -1;
+                *backingFormat = VIR_STORAGE_FILE_RAW;
             break;
         }

diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 53533d5885..d07a05d04b 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -484,7 +484,7 @@ mymain(void)
                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);
+               VIR_STORAGE_FILE_QCOW2, EXP_PASS);

     /* Qcow2 file with missing backing file but specified type */
     TEST_CHAIN("qcow2-qcow2_missing",
diff --git a/tests/virstoragetestdata/out/qcow2-protocol-backing-file b/tests/virstoragetestdata/out/qcow2-protocol-backing-file
index b565bdba77..d9d4c1316c 100644
--- a/tests/virstoragetestdata/out/qcow2-protocol-backing-file
+++ b/tests/virstoragetestdata/out/qcow2-protocol-backing-file
@@ -1,6 +1,6 @@
 path:ABS_SRCDIR/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2
 backingStoreRaw: raw
-backingStoreRawFormat: <null>(-1)
+backingStoreRawFormat: raw(1)
 capacity: 1024
 encryption: 0
 relPath:<null>
diff --git a/tests/virstoragetestdata/out/qcow2-protocol-backing-nbd b/tests/virstoragetestdata/out/qcow2-protocol-backing-nbd
new file mode 100644
index 0000000000..360a496ab0
--- /dev/null
+++ b/tests/virstoragetestdata/out/qcow2-protocol-backing-nbd
@@ -0,0 +1,21 @@
+path:ABS_SRCDIR/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2
+backingStoreRaw: nbd+tcp://example.org:6000/blah
+backingStoreRawFormat: raw(1)
+capacity: 10485760
+encryption: 0
+relPath:<null>
+type:file
+format:qcow2
+protocol:none
+hostname:<null>
+
+path:blah
+backingStoreRaw: <null>
+backingStoreRawFormat: none(0)
+capacity: 0
+encryption: 0
+relPath:<null>
+type:network
+format:raw
+protocol:nbd
+hostname:example.org
-- 
2.42.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux