Skip to content
Snippets Groups Projects
Commit 12597b06 authored by Kevin Wolf's avatar Kevin Wolf
Browse files

qcow2: Report error for version > 2


The qcow2 driver is now declared responsible for any QCOW image that has
version 2 or greater (before this, version 3 would be detected as raw).

For everything newer than version 2, an error is reported.

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit e8cdcec1)
parent e37dcdfb
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "aes.h" #include "aes.h"
#include "block/qcow2.h" #include "block/qcow2.h"
#include "qemu-error.h" #include "qemu-error.h"
#include "qerror.h"
/* /*
Differences with QCOW: Differences with QCOW:
...@@ -59,7 +60,7 @@ static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename) ...@@ -59,7 +60,7 @@ static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename)
if (buf_size >= sizeof(QCowHeader) && if (buf_size >= sizeof(QCowHeader) &&
be32_to_cpu(cow_header->magic) == QCOW_MAGIC && be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
be32_to_cpu(cow_header->version) == QCOW_VERSION) be32_to_cpu(cow_header->version) >= QCOW_VERSION)
return 100; return 100;
else else
return 0; return 0;
...@@ -163,10 +164,18 @@ static int qcow2_open(BlockDriverState *bs, int flags) ...@@ -163,10 +164,18 @@ static int qcow2_open(BlockDriverState *bs, int flags)
be64_to_cpus(&header.snapshots_offset); be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots); be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION) { if (header.magic != QCOW_MAGIC) {
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} }
if (header.version != QCOW_VERSION) {
char version[64];
snprintf(version, sizeof(version), "QCOW version %d", header.version);
qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bs->device_name, "qcow2", version);
ret = -ENOTSUP;
goto fail;
}
if (header.cluster_bits < MIN_CLUSTER_BITS || if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) { header.cluster_bits > MAX_CLUSTER_BITS) {
ret = -EINVAL; ret = -EINVAL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment