qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Re: [PATCH v2 1/2] qcow2: Simplify image creation


From: Kevin Wolf
Subject: Re: [Qemu-devel] Re: [PATCH v2 1/2] qcow2: Simplify image creation
Date: Tue, 15 Jun 2010 13:31:32 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc12 Thunderbird/3.0.4

Am 15.06.2010 13:08, schrieb Stefan Hajnoczi:
> On Tue, Jun 15, 2010 at 11:36 AM, Kevin Wolf <address@hidden> wrote:
>> +    /*
>> +     * And now open the image and make it consistent first (i.e. increase 
>> the
>> +     * refcount of the cluster that is occupied by the header and the 
>> refcount
>> +     * table)
>> +     */
>> +    BlockDriver* drv = bdrv_find_format("qcow2");
>> +    assert(drv != NULL);
>> +    ret = bdrv_open(bs, filename, BDRV_O_RDWR | BDRV_O_NO_FLUSH, drv);
>> +    if (ret < 0) {
>> +        goto out;
>> +    }
> 
> Here I think we should really return directly on error.
> bdrv_delete(bs) doesn't work since bs isn't initialized when
> bdrv_open() fails.

I did consider returning directly here at first, but decided against it
because usually you expect that a function that uses some goto does so
consistently. Also, I noticed later that returning directly we would
leak the BlockDriverState which is malloc'd in bdrv_file_open.

bs should still be initialized at this point and bs->drv = NULL after
the bdrv_close() above, so that bdrv_delete(bs) will just free the
BlockDriverState.

Kevin



reply via email to

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