From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf9dG-0007IP-KB for qemu-devel@nongnu.org; Thu, 14 Jun 2012 08:58:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sf9dB-0003YA-7w for qemu-devel@nongnu.org; Thu, 14 Jun 2012 08:58:38 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:44650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf9dA-0003XI-VU for qemu-devel@nongnu.org; Thu, 14 Jun 2012 08:58:33 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Jun 2012 13:58:27 +0100 Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5ECwO792854956 for ; Thu, 14 Jun 2012 13:58:24 +0100 Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5ECwNiU005270 for ; Thu, 14 Jun 2012 06:58:24 -0600 From: Stefan Hajnoczi Date: Thu, 14 Jun 2012 13:58:16 +0100 Message-Id: <1339678698-17726-2-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1339678698-17726-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1339678698-17726-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 1/3] qcow2: fix autoclear image header update List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, Stefan Hajnoczi The autoclear feature bits can be used for qcow2 file format features that are safe to "drop" by old programs that do not understand the feature. Upon opening the image file unknown autoclear feature bits are cleared and the image file header is rewritten, but this was happening too early in the code when critical header fields were not yet loaded. Process autoclear feature bits after all necessary header information has been loaded. Signed-off-by: Stefan Hajnoczi --- block/qcow2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index d66de58..aa3f176 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -298,14 +298,6 @@ static int qcow2_open(BlockDriverState *bs, int flags) goto fail; } - if (!bs->read_only && s->autoclear_features != 0) { - s->autoclear_features = 0; - ret = qcow2_update_header(bs); - if (ret < 0) { - goto fail; - } - } - /* Check support for various header values */ if (header.refcount_order != 4) { report_unsupported(bs, "%d bit reference counts", @@ -411,6 +403,15 @@ static int qcow2_open(BlockDriverState *bs, int flags) goto fail; } + /* Clear unknown autoclear feature bits */ + if (!bs->read_only && s->autoclear_features != 0) { + s->autoclear_features = 0; + ret = qcow2_update_header(bs); + if (ret < 0) { + goto fail; + } + } + /* Initialise locks */ qemu_co_mutex_init(&s->lock); -- 1.7.10