mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
storage_file_probe: Treat qcow2 images with protocol drivers in backing store field as raw
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6fe9e35610
commit
156ddb43b1
@ -474,9 +474,15 @@ qcow2GetExtensions(const char *buf,
|
|||||||
memcpy(tmp, buf + offset, len);
|
memcpy(tmp, buf + offset, len);
|
||||||
tmp[len] = '\0';
|
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);
|
*backingFormat = virStorageFileFormatTypeFromString(tmp);
|
||||||
if (*backingFormat <= VIR_STORAGE_FILE_NONE)
|
if (*backingFormat <= VIR_STORAGE_FILE_NONE)
|
||||||
return -1;
|
*backingFormat = VIR_STORAGE_FILE_RAW;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ mymain(void)
|
|||||||
VIR_STORAGE_FILE_QCOW2, EXP_PASS);
|
VIR_STORAGE_FILE_QCOW2, EXP_PASS);
|
||||||
TEST_CHAIN("qcow2-protocol-backing-nbd",
|
TEST_CHAIN("qcow2-protocol-backing-nbd",
|
||||||
abs_srcdir "/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2",
|
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 */
|
/* Qcow2 file with missing backing file but specified type */
|
||||||
TEST_CHAIN("qcow2-qcow2_missing",
|
TEST_CHAIN("qcow2-qcow2_missing",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
path:ABS_SRCDIR/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2
|
path:ABS_SRCDIR/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2
|
||||||
backingStoreRaw: raw
|
backingStoreRaw: raw
|
||||||
backingStoreRawFormat: <null>(-1)
|
backingStoreRawFormat: raw(1)
|
||||||
capacity: 1024
|
capacity: 1024
|
||||||
encryption: 0
|
encryption: 0
|
||||||
relPath:<null>
|
relPath:<null>
|
||||||
|
21
tests/virstoragetestdata/out/qcow2-protocol-backing-nbd
Normal file
21
tests/virstoragetestdata/out/qcow2-protocol-backing-nbd
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user