* [Qemu-devel] [PATCH] qcow2: fix autoclear image header update
@ 2012-06-14 10:42 Stefan Hajnoczi
2012-06-14 11:06 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-06-14 10:42 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel, 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 <stefanha@linux.vnet.ibm.com>
---
block/qcow2.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index c2e49cd..79201fc 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: fix autoclear image header update
2012-06-14 10:42 [Qemu-devel] [PATCH] qcow2: fix autoclear image header update Stefan Hajnoczi
@ 2012-06-14 11:06 ` Kevin Wolf
2012-06-14 11:16 ` Stefan Hajnoczi
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2012-06-14 11:06 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel
Am 14.06.2012 12:42, schrieb 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 <stefanha@linux.vnet.ibm.com>
Ouch...
You don't have a qemu-iotests case to offer for the feature bit
handling, by any chance?
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: fix autoclear image header update
2012-06-14 11:06 ` Kevin Wolf
@ 2012-06-14 11:16 ` Stefan Hajnoczi
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-06-14 11:16 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Stefan Hajnoczi, qemu-devel
On Thu, Jun 14, 2012 at 12:06 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 14.06.2012 12:42, schrieb 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 <stefanha@linux.vnet.ibm.com>
>
> Ouch...
>
> You don't have a qemu-iotests case to offer for the feature bit
> handling, by any chance?
Nope. I'll cook one up, should be easy with your qcow2.py module.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-14 11:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-14 10:42 [Qemu-devel] [PATCH] qcow2: fix autoclear image header update Stefan Hajnoczi
2012-06-14 11:06 ` Kevin Wolf
2012-06-14 11:16 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).