[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [Qemu-devel] [PATCH 2/4] block: Guarantee that *file i
From: |
Eric Blake |
Subject: |
Re: [Qemu-stable] [Qemu-devel] [PATCH 2/4] block: Guarantee that *file is set on bdrv_get_block_status() |
Date: |
Wed, 24 May 2017 10:03:17 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 |
On 05/18/2017 09:32 PM, Eric Blake wrote:
> We document that *file is valid if the return is not an error and
> includes BDRV_BLOCK_OFFSET_VALID, but forgot to obey this contract
> when a driver (such as blkdebug) lacks a callback. Broken in
> commit 67a0fd2 (v2.6), when we added the file parameter.
>
> +++ b/block/io.c
> @@ -1749,6 +1749,7 @@ static int64_t coroutine_fn
> bdrv_co_get_block_status(BlockDriverState *bs,
> int64_t n;
> int64_t ret, ret2;
>
> + *file = NULL;
> total_sectors = bdrv_nb_sectors(bs);
> if (total_sectors < 0) {
> return total_sectors;
> @@ -1769,6 +1770,7 @@ static int64_t coroutine_fn
> bdrv_co_get_block_status(BlockDriverState *bs,
> ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
> if (bs->drv->protocol_name) {
> ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
> + *file = bs;
> }
> return ret;
> }
Continuing context:
*file = NULL;
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors,
pnum,
file);
Guess I need a v2, to remove the now-redundant second initialization of
*file.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature