pflash: Fix blk_pread_nonzeroes()

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: a4b15a8b9e
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>
master
Kevin Wolf 2023-03-07 16:53:18 +01:00 committed by Cédric Le Goater
parent 11aeb4b8c1
commit 3c6f3f65ea
1 changed files with 1 additions and 2 deletions

View File

@ -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;
}