[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 1/3] block: resize backing file image during
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 1/3] block: resize backing file image during offline commit, if necessary |
Date: |
Thu, 23 Jan 2014 15:07:44 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
On 01/23/2014 03:00 PM, Benoît Canet wrote:
> Le Thursday 23 Jan 2014 à 16:48:55 (-0500), Jeff Cody a écrit :
>> Currently, if an image file is logically larger than its backing file,
>> commiting it via 'qemu-img commit' will fail.
s/commiting/committing/
>> + uint8_t *buf = NULL;
>
> Why assign NULL to buf ? Is it related to the rest of the patch ?
>
> Reviewed-by: Benoit Canet <address@hidden>
>
>> char filename[PATH_MAX];
>>
>> if (!drv)
>> @@ -1904,7 +1904,24 @@ int bdrv_commit(BlockDriverState *bs)
>> }
>> }
>>
>> - total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
>> + length = bdrv_getlength(bs);
>> + backing_length = bdrv_getlength(bs->backing_hd);
>> +
>> + if (length < 0 || backing_length < 0) {
>> + goto ro_cleanup;
Because this goto now reaches the ro_cleanup label with buf
uninitialized, if we don't assign NULL originally.
>> + total_sectors = length >> BDRV_SECTOR_BITS;
>> buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
The old code only ever reached ro_cleanup after assigning buf, and
ro_cleanup blindly frees buf.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature