On Mon, Jan 13, 2014 at 03:18:45PM -0500, Jeff Cody wrote:
> @@ -1904,7 +1904,19 @@ int bdrv_commit(BlockDriverState *bs)
>          }
>      }
>  
> -    total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
> +    length = bdrv_getlength(bs);
> +
> +    /* If our top snapshot is larger than the backing file image,
> +     * grow the backing file image if possible.  If not possible,
> +     * we must return an error */
> +    if (length > bdrv_getlength(bs->backing_hd)) {
> +        ret = bdrv_truncate(bs->backing_hd, length);

bdrv_getlength() is allowed to return -errno.  It's unlikely here but we
should at least check bdrv_getlength(bs), probably also
bdrv_getlength(bs->backing_hd).

Reply via email to