From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53574 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pn7JX-0003lZ-Ta for qemu-devel@nongnu.org; Wed, 09 Feb 2011 05:30:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pn7JW-0006Fn-Rt for qemu-devel@nongnu.org; Wed, 09 Feb 2011 05:30:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pn7JW-0006Fe-JC for qemu-devel@nongnu.org; Wed, 09 Feb 2011 05:30:22 -0500 From: Kevin Wolf Date: Wed, 9 Feb 2011 11:31:59 +0100 Message-Id: <1297247521-11464-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1297247521-11464-1-git-send-email-kwolf@redhat.com> References: <1297247521-11464-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] qcow2: Report error for version > 2 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@gmail.com, lcapitulino@redhat.com 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: Kevin Wolf --- block/qcow2.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 551b3c2..7abd8be 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -28,6 +28,7 @@ #include "aes.h" #include "block/qcow2.h" #include "qemu-error.h" +#include "qerror.h" /* Differences with QCOW: @@ -59,7 +60,7 @@ static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename) if (buf_size >= sizeof(QCowHeader) && 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; else return 0; @@ -163,10 +164,18 @@ static int qcow2_open(BlockDriverState *bs, int flags) be64_to_cpus(&header.snapshots_offset); be32_to_cpus(&header.nb_snapshots); - if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION) { + if (header.magic != QCOW_MAGIC) { ret = -EINVAL; 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, version); + ret = -ENOTSUP; + goto fail; + } if (header.cluster_bits < MIN_CLUSTER_BITS || header.cluster_bits > MAX_CLUSTER_BITS) { ret = -EINVAL; -- 1.7.2.3