raw: Fix BlockLimits passthrough
PATCH 1/1 raw: Fix BlockLimits passthrough
raw copies over the BlockLimits of bs->file during bdrv_open(). However, since commit d34682cd it is immediately overwritten during bdrv_refresh_limits(). This caused all fields except for opt_transfer_length and opt_mem_alignment (which happen to be correctly inherited in generic code) to be zeroed.
Move the BlockLimit assignment to a .bdrv_refresh_limits() callback to make it work again for all fields.
--- block/raw_bsd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
block/raw_bsd.c +7 -1
@@ -90,6 +90,12 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)return bdrv_get_info (bs->file, bdi); } +static int raw_refresh_limits (BlockDriverState *bs) +{ + bs->bl = bs->file->bl; +return 0 ; +} +static int raw_truncate (BlockDriverState *bs,int64_t offset) {return bdrv_truncate (bs->file, offset);
@@ -150,7 +156,6 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { bs->sg = bs->file->sg; - bs->bl = bs->file->bl;return 0 ; }
@@ -182,6 +187,7 @@ static BlockDriver bdrv_raw = { .bdrv_getlength = &raw_getlength, .has_variable_length = true, .bdrv_get_info = &raw_get_info, + .bdrv_refresh_limits = &raw_refresh_limits, .bdrv_is_inserted = &raw_is_inserted, .bdrv_media_changed = &raw_media_changed, .bdrv_eject = &raw_eject,
Signature · 1 line
1.8.1.4
Quoted 42 lines · Kevin Wolf
raw copies over the BlockLimits of
bs->fileduringbdrv_open(). However, since commitd34682cdit is immediately overwritten duringbdrv_refresh_limits(). This caused all fields except foropt_transfer_lengthandopt_mem_alignment(which happen to be correctly inherited in generic code) to be zeroed.Move the BlockLimit assignment to a .bdrv_refresh_limits() callback to make it work again for all fields.
Reported-by Laszlo Ersek <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- block/raw_bsd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)block/raw_bsd.c +6
-1@@ -90,6 +90,12 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)return bdrv_get_info (bs->file, bdi); } +static int raw_refresh_limits (BlockDriverState *bs) +{ + bs->bl = bs->file->bl; +return 0 ; +} +static int raw_truncate (BlockDriverState *bs,int64_t offset) {return bdrv_truncate (bs->file, offset);@@ -150,7 +156,6 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { bs->sg = bs->file->sg; - bs->bl = bs->file->bl;return 0 ; }
block/raw_bsd.c static BlockDriver bdrv_raw = { · line 193
Quoted 7 lines
block/raw_bsd.c +1
-0@@ -182,6 +187,7 @@ static BlockDriver bdrv_raw = { .bdrv_getlength = &raw_getlength, .has_variable_length = true, .bdrv_get_info = &raw_get_info, + .bdrv_refresh_limits = &raw_refresh_limits, .bdrv_is_inserted = &raw_is_inserted, .bdrv_media_changed = &raw_media_changed, .bdrv_eject = &raw_eject,