Re: [Qemu-devel] qcow2 corruption observed, fixed by reverting old change

Filip Navara
2009-03-06T22:37:06Z

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

On Wed, Feb 11, 2009 at 5:48 PM, Jamie Lokier <jamie@shareable.org> wrote:
> Kevin Wolf wrote:
>> Besides reviewing the code over and over again, I think the only real
>> chance is that you can get a non-productive copy of your image and add
>> some debug code so that we can see at least which code path is causing
>> problems.
>
> I have a copy of my image to reproduce the bug, so I can test patches
> including diagnostic patches.  That's what I did to narrow it down.

Let's see. I have looked at the change in revision 5006 back and forth
and this is the only bug that I can see...

Does the patch help any?

Best regards,
Filip Navara

[-- Attachment #2: block-qcow2.diff --]
[-- Type: application/octet-stream, Size: 623 bytes --]

Index: block-qcow2.c
===================================================================
--- block-qcow2.c (revision 6729)
+++ block-qcow2.c (working copy)
@@ -621,7 +621,7 @@
if (!offset)
return 0;

- for (i = start; i < start + nb_clusters; i++)
+ for (i = start; i < start + nb_clusters && i < s->l2_size; i++)
if (offset + i * cluster_size != (be64_to_cpu(l2_table[i]) & ~mask))
break;

@@ -632,7 +632,7 @@
{
int i = 0;

- while(nb_clusters-- && l2_table[i] == 0)
+ while(nb_clusters-- && i < s->l2_size && l2_table[i] == 0)
i++;

return i;