From: Kevin Wolf <kwolf@redhat.com>
Commit a4b15a8b introduced a new function blk_pread_nonzeroes(). Instead
of reading directly from the root node of the BlockBackend, it reads
from its 'file' child node. This can happen to mostly work for raw
images (as long as the 'raw' format driver is in use, but not actually
doing anything), but it breaks everything else.
Fix it to read from the root node instead.
Fixes: a4b15a8b9ef25b44fa92a4825312622600c1f37c
Reported-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230307140230.59158-1-kwolf@redhat.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/block/block.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/block/block.c b/hw/block/block.c
index af0710e477..9f52ee6e72 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -39,8 +39,7 @@ static int blk_pread_nonzeroes(BlockBackend *blk, hwaddr size, void *buf)
return ret;
}
if (!(ret & BDRV_BLOCK_ZERO)) {
- ret = bdrv_pread(bs->file, offset, bytes,
- (uint8_t *) buf + offset, 0);
+ ret = blk_pread(blk, offset, bytes, (uint8_t *) buf + offset, 0);
if (ret < 0) {
return ret;
}
--
2.39.2
On 7/3/23 16:55, Cédric Le Goater wrote:
> From: Kevin Wolf <kwolf@redhat.com>
>
> Commit a4b15a8b introduced a new function blk_pread_nonzeroes(). Instead
> of reading directly from the root node of the BlockBackend, it reads
> from its 'file' child node. This can happen to mostly work for raw
> images (as long as the 'raw' format driver is in use, but not actually
> doing anything), but it breaks everything else.
>
> Fix it to read from the root node instead.
>
> Fixes: a4b15a8b9ef25b44fa92a4825312622600c1f37c
You missed:
Tested-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Fixes: a4b15a8b9e ("pflash: Only read non-zero parts of backend image")
by 3min:
https://lore.kernel.org/qemu-devel/c5c82d88-df2a-e968-4d81-0da1cfa2ab09@maciej.szmigiero.name/
> Reported-by: Cédric Le Goater <clg@kaod.org>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> Message-Id: <20230307140230.59158-1-kwolf@redhat.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> hw/block/block.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/block/block.c b/hw/block/block.c
> index af0710e477..9f52ee6e72 100644
> --- a/hw/block/block.c
> +++ b/hw/block/block.c
> @@ -39,8 +39,7 @@ static int blk_pread_nonzeroes(BlockBackend *blk, hwaddr size, void *buf)
> return ret;
> }
> if (!(ret & BDRV_BLOCK_ZERO)) {
> - ret = bdrv_pread(bs->file, offset, bytes,
> - (uint8_t *) buf + offset, 0);
> + ret = blk_pread(blk, offset, bytes, (uint8_t *) buf + offset, 0);
> if (ret < 0) {
> return ret;
> }
On 3/7/23 17:22, Philippe Mathieu-Daudé wrote:
> On 7/3/23 16:55, Cédric Le Goater wrote:
>> From: Kevin Wolf <kwolf@redhat.com>
>>
>> Commit a4b15a8b introduced a new function blk_pread_nonzeroes(). Instead
>> of reading directly from the root node of the BlockBackend, it reads
>> from its 'file' child node. This can happen to mostly work for raw
>> images (as long as the 'raw' format driver is in use, but not actually
>> doing anything), but it breaks everything else.
>>
>> Fix it to read from the root node instead.
>>
>> Fixes: a4b15a8b9ef25b44fa92a4825312622600c1f37c
>
> You missed:
>
> Tested-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
> Fixes: a4b15a8b9e ("pflash: Only read non-zero parts of backend image")
>
> by 3min:
> https://lore.kernel.org/qemu-devel/c5c82d88-df2a-e968-4d81-0da1cfa2ab09@maciej.szmigiero.name/
yes :) I waited for the CI to complete and didn't check my email before
sending. If I respin, I will fix.
C.
>
>> Reported-by: Cédric Le Goater <clg@kaod.org>
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> Message-Id: <20230307140230.59158-1-kwolf@redhat.com>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>> hw/block/block.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/hw/block/block.c b/hw/block/block.c
>> index af0710e477..9f52ee6e72 100644
>> --- a/hw/block/block.c
>> +++ b/hw/block/block.c
>> @@ -39,8 +39,7 @@ static int blk_pread_nonzeroes(BlockBackend *blk, hwaddr size, void *buf)
>> return ret;
>> }
>> if (!(ret & BDRV_BLOCK_ZERO)) {
>> - ret = bdrv_pread(bs->file, offset, bytes,
>> - (uint8_t *) buf + offset, 0);
>> + ret = blk_pread(blk, offset, bytes, (uint8_t *) buf + offset, 0);
>> if (ret < 0) {
>> return ret;
>> }
>
© 2016 - 2026 Red Hat, Inc.