qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qcow2: preserve free_byte_offset when qcow2_all


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH] qcow2: preserve free_byte_offset when qcow2_alloc_bytes() fails
Date: Mon, 18 Jun 2012 15:29:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

Am 18.06.2012 15:16, schrieb Stefan Hajnoczi:
> On Mon, Jun 18, 2012 at 2:11 PM, Kevin Wolf <address@hidden> wrote:
>> Am 18.06.2012 15:00, schrieb Stefan Hajnoczi:
>>> When qcow2_alloc_clusters() error handling code was introduced in commit
>>> 5d757b563d59142ca81e1073a8e8396750a0ad1a, the value of free_byte_offset
>>> was clobbered in the error case.  This patch keeps free_byte_offset at 0
>>> so we will try to allocate clusters again next time this function is
>>> called.
>>>
>>> Signed-off-by: Stefan Hajnoczi <address@hidden>
>>
>> Thanks, applied to the block branch.
>>
>> And I guess we should get test case 026 fixed up and extended to cover this.
> 
> I'm not sure what to test.  It already returned the error code
> correctly.  The problem was what happened when called again - there
> would be junk in free_byte_offset.

Then this is what needs to be tested. For example:

1. Configure blkdebug to fail on BLKDBG_CLUSTER_ALLOC_BYTES once

2. write_compressed() fails with the configured errno, s->cluster_size
   is corrupted in the old version.

3. write_compressed() is expected to succeed. The buggy version may
   succeed as well, or fail somewhere else because of the negative
   (or wrapped around, huge) offset.

There are different ways to check if we wrote to the right offset,
probably the best way is to combine them:

4a. The obvious one: Read the data back. May or may not reveal a bug,
    depending on what the read code does with negative offsets.

4b. qemu-img info. The image file size is an indicator for this bug.

4c. Repeat the same procedure with a different cluster and a different
    pattern. Read back both. If the second one has overwritten the
    first one, there is a problem.

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]