From: Stefan Hajnoczi Date: Thu, 14 Jun 2012 10:42:23 +0000 (+0100) Subject: qcow2: fix autoclear image header update X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~3993^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af7b708db2d03eb47f7ba44a050439ad9ee65e7a;p=sdk%2Femulator%2Fqemu.git qcow2: fix autoclear image header update 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 Signed-off-by: Kevin Wolf --- diff --git a/block/qcow2.c b/block/qcow2.c index 57fd43d..2c1cd0a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -297,14 +297,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", @@ -408,6 +400,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);