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: (-1) +backingStoreRawFormat: raw(1) capacity: 1024 encryption: 0 relPath: 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: +type:file +format:qcow2 +protocol:none +hostname: + +path:blah +backingStoreRaw: +backingStoreRawFormat: none(0) +capacity: 0 +encryption: 0 +relPath: +type:network +format:raw +protocol:nbd +hostname:example.org