Re: [Qemu-block] [PATCH v3 2/4] block: Use defaults of bdrv_* callbacks in raw

2017-07-04 Thread Kevin Wolf
Am 04.07.2017 um 10:40 hat Manos Pitsidianakis geschrieben:
> Now that passing the call to bs->file is the default for some bdrv_*
> callbacks, remove the duplicate implementations in block/raw-format.c
> 
> Reviewed-by: Eric Blake 
> Signed-off-by: Manos Pitsidianakis 

If you change patch 1 as suggested there, most of these functions will
have to stay.

The exception is .bdrv_has_zero_init, for which I suggested an
.is_filter check. However, raw isn't declared a filter currently. If we
want to declare it a filter, the definition I proposed in the other mail
doesn't work because raw can apply an offset - this why it needs its own
function for probing geometry, so with that changed definition checking
.is_filter might not be enough any more for all of the functions in
patch 1.

Maybe it turns out in the end that raw just is special enough that
having its own functions is okay.

Kevin



[Qemu-block] [PATCH v3 2/4] block: Use defaults of bdrv_* callbacks in raw

2017-07-04 Thread Manos Pitsidianakis
Now that passing the call to bs->file is the default for some bdrv_*
callbacks, remove the duplicate implementations in block/raw-format.c

Reviewed-by: Eric Blake 
Signed-off-by: Manos Pitsidianakis 
---
 block/raw-format.c | 30 --
 1 file changed, 30 deletions(-)

diff --git a/block/raw-format.c b/block/raw-format.c
index 1ea8c2d7..ccd63411 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -312,11 +312,6 @@ static int64_t raw_getlength(BlockDriverState *bs)
 return s->size;
 }
 
-static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
-{
-return bdrv_get_info(bs->file->bs, bdi);
-}
-
 static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
 {
 if (bs->probed) {
@@ -346,21 +341,6 @@ static int raw_truncate(BlockDriverState *bs, int64_t 
offset, Error **errp)
 return bdrv_truncate(bs->file, offset, errp);
 }
 
-static int raw_media_changed(BlockDriverState *bs)
-{
-return bdrv_media_changed(bs->file->bs);
-}
-
-static void raw_eject(BlockDriverState *bs, bool eject_flag)
-{
-bdrv_eject(bs->file->bs, eject_flag);
-}
-
-static void raw_lock_medium(BlockDriverState *bs, bool locked)
-{
-bdrv_lock_medium(bs->file->bs, locked);
-}
-
 static int raw_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
 {
 BDRVRawState *s = bs->opaque;
@@ -370,11 +350,6 @@ static int raw_co_ioctl(BlockDriverState *bs, unsigned 
long int req, void *buf)
 return bdrv_co_ioctl(bs->file->bs, req, buf);
 }
 
-static int raw_has_zero_init(BlockDriverState *bs)
-{
-return bdrv_has_zero_init(bs->file->bs);
-}
-
 static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
 {
 return bdrv_create_file(filename, opts, errp);
@@ -479,16 +454,11 @@ BlockDriver bdrv_raw = {
 .bdrv_truncate= &raw_truncate,
 .bdrv_getlength   = &raw_getlength,
 .has_variable_length  = true,
-.bdrv_get_info= &raw_get_info,
 .bdrv_refresh_limits  = &raw_refresh_limits,
 .bdrv_probe_blocksizes = &raw_probe_blocksizes,
 .bdrv_probe_geometry  = &raw_probe_geometry,
-.bdrv_media_changed   = &raw_media_changed,
-.bdrv_eject   = &raw_eject,
-.bdrv_lock_medium = &raw_lock_medium,
 .bdrv_co_ioctl= &raw_co_ioctl,
 .create_opts  = &raw_create_opts,
-.bdrv_has_zero_init   = &raw_has_zero_init
 };
 
 static void bdrv_raw_init(void)
-- 
2.11.0