* [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes
@ 2017-07-13 10:01 Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters Manos Pitsidianakis
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Manos Pitsidianakis @ 2017-07-13 10:01 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Eric Blake, Alberto Garcia, Stefan Hajnoczi,
Max Reitz, Kevin Wolf
This series makes implementing some of the bdrv_* callbacks easier for block
filters by passing requests to bs->file if bs->drv doesn't implement it instead
of failing, and adding default bdrv_co_get_block_status() implementations.
This is based against Kevin Wolf's block branch, commit
da4bd74d2450ab72a7c26bbabb10c6a287dd043e
v5:
rebase against ced1484322 of https://github.com/XanClic/qemu.git block to fix
apply conflicts
add suggested commit message in block: remove unused bdrv_media_changed
add is_filter implication in commit message of block: remove bdrv_truncate
callback in blkdebug
v4:
forward only for block filters
new patch: remove bdrv_media_changed
dropped commit `block: Use defaults of bdrv_* callbacks in raw`, since raw is
not a filter driver and is incompatible with the changes.
v3:
minor changes by Eric Blake's suggestion
new patch: remove bdrv_truncate method from blkdebug
v2:
do not pass to bs->file if bs->drv is NULL
move bs->file check outside of bdrv_inc_in_flight() area in bdrv_co_ioctl()
new patch: remove duplicate code from block/raw-format.c
Manos Pitsidianakis (4):
block: pass bdrv_* methods to bs->file by default in block filters
block: remove unused bdrv_media_changed
block: remove bdrv_truncate callback in blkdebug
block: add default implementations for bdrv_co_get_block_status()
block.c | 35 +++++++++++++++++++----------------
block/blkdebug.c | 20 ++------------------
block/commit.c | 12 +-----------
block/io.c | 26 ++++++++++++++++++++++++++
block/mirror.c | 12 +-----------
block/raw-format.c | 6 ------
include/block/block.h | 1 -
include/block/block_int.h | 25 +++++++++++++++++++++++--
8 files changed, 72 insertions(+), 65 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters
2017-07-13 10:01 [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Manos Pitsidianakis
@ 2017-07-13 10:01 ` Manos Pitsidianakis
2017-07-13 11:23 ` Eric Blake
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 2/4] block: remove unused bdrv_media_changed Manos Pitsidianakis
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Manos Pitsidianakis @ 2017-07-13 10:01 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Eric Blake, Alberto Garcia, Stefan Hajnoczi,
Max Reitz, Kevin Wolf
The following functions fail if bs->drv is a filter and does not
implement them:
bdrv_probe_blocksizes
bdrv_probe_geometry
bdrv_truncate
bdrv_has_zero_init
bdrv_get_info
Instead, the call should be passed to bs->file if it exists, to allow
filter drivers to support those methods without implementing them. This
commit makes `drv->is_filter = true` imply that these callbacks will be
forwarded to bs->file by default, so disabling support for these
functions must be done explicitly.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
---
block.c | 21 +++++++++++++++++++--
include/block/block_int.h | 6 +++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index d24ae85868..892f29d231 100644
--- a/block.c
+++ b/block.c
@@ -494,6 +494,8 @@ int bdrv_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
if (drv && drv->bdrv_probe_blocksizes) {
return drv->bdrv_probe_blocksizes(bs, bsz);
+ } else if (drv && drv->is_filter && bs->file) {
+ return bdrv_probe_blocksizes(bs->file->bs, bsz);
}
return -ENOTSUP;
@@ -511,6 +513,8 @@ int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
if (drv && drv->bdrv_probe_geometry) {
return drv->bdrv_probe_geometry(bs, geo);
+ } else if (drv && drv->is_filter && bs->file) {
+ return bdrv_probe_geometry(bs->file->bs, geo);
}
return -ENOTSUP;
@@ -3420,11 +3424,15 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, PreallocMode prealloc,
assert(child->perm & BLK_PERM_RESIZE);
+ /* if bs->drv == NULL, bs is closed, so there's nothing to do here */
if (!drv) {
error_setg(errp, "No medium inserted");
return -ENOMEDIUM;
}
if (!drv->bdrv_truncate) {
+ if (bs->file && drv->is_filter) {
+ return bdrv_truncate(bs->file, prealloc, offset, errp);
+ }
error_setg(errp, "Image format driver does not support resize");
return -ENOTSUP;
}
@@ -3761,6 +3769,9 @@ int bdrv_has_zero_init(BlockDriverState *bs)
if (bs->drv->bdrv_has_zero_init) {
return bs->drv->bdrv_has_zero_init(bs);
}
+ if (bs->file && bs->drv->is_filter) {
+ return bdrv_has_zero_init(bs->file->bs);
+ }
/* safe default */
return 0;
@@ -3815,10 +3826,16 @@ void bdrv_get_backing_filename(BlockDriverState *bs,
int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BlockDriver *drv = bs->drv;
- if (!drv)
+ /* if bs->drv == NULL, bs is closed, so there's nothing to do here */
+ if (!drv) {
return -ENOMEDIUM;
- if (!drv->bdrv_get_info)
+ }
+ if (!drv->bdrv_get_info) {
+ if (bs->file && drv->is_filter) {
+ return bdrv_get_info(bs->file->bs, bdi);
+ }
return -ENOTSUP;
+ }
memset(bdi, 0, sizeof(*bdi));
return drv->bdrv_get_info(bs, bdi);
}
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 669a2797fd..37388ccb18 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -87,7 +87,11 @@ struct BlockDriver {
const char *format_name;
int instance_size;
- /* set to true if the BlockDriver is a block filter */
+ /* set to true if the BlockDriver is a block filter. Block filters pass
+ * certain callbacks that refer to data (see block.c) to their bs->file if
+ * the driver doesn't implement them. Drivers that do not wish to forward
+ * must implement them and return -ENOTSUP.
+ */
bool is_filter;
/* for snapshots block filter like Quorum can implement the
* following recursive callback.
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v5 2/4] block: remove unused bdrv_media_changed
2017-07-13 10:01 [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters Manos Pitsidianakis
@ 2017-07-13 10:01 ` Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 3/4] block: remove bdrv_truncate callback in blkdebug Manos Pitsidianakis
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Manos Pitsidianakis @ 2017-07-13 10:01 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Eric Blake, Alberto Garcia, Stefan Hajnoczi,
Max Reitz, Kevin Wolf
This function is not used anywhere, so remove it.
Markus Armbruster adds:
The i82078 floppy device model used to call bdrv_media_changed() to
implement its media change bit when backed by a host floppy. This
went away in 21fcf36 "fdc: simplify media change handling".
Probably broke host floppy media change. Host floppy pass-through
was dropped in commit f709623. bdrv_media_changed() has never been
used for anything else. Remove it.
(Source is Message-ID: <87y3ruaypm.fsf@dusky.pond.sub.org>)
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
---
block.c | 14 --------------
block/raw-format.c | 6 ------
include/block/block.h | 1 -
include/block/block_int.h | 1 -
4 files changed, 22 deletions(-)
diff --git a/block.c b/block.c
index 892f29d231..eecec6a016 100644
--- a/block.c
+++ b/block.c
@@ -4200,20 +4200,6 @@ bool bdrv_is_inserted(BlockDriverState *bs)
}
/**
- * Return whether the media changed since the last call to this
- * function, or -ENOTSUP if we don't know. Most drivers don't know.
- */
-int bdrv_media_changed(BlockDriverState *bs)
-{
- BlockDriver *drv = bs->drv;
-
- if (drv && drv->bdrv_media_changed) {
- return drv->bdrv_media_changed(bs);
- }
- return -ENOTSUP;
-}
-
-/**
* If eject_flag is TRUE, eject the media. Otherwise, close the tray
*/
void bdrv_eject(BlockDriverState *bs, bool eject_flag)
diff --git a/block/raw-format.c b/block/raw-format.c
index 142649ed56..ab552c0954 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -372,11 +372,6 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset,
return bdrv_truncate(bs->file, offset, prealloc, 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);
@@ -510,7 +505,6 @@ BlockDriver bdrv_raw = {
.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,
diff --git a/include/block/block.h b/include/block/block.h
index b3e2674845..7e0cec5242 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -441,7 +441,6 @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
bool bdrv_is_sg(BlockDriverState *bs);
bool bdrv_is_inserted(BlockDriverState *bs);
-int bdrv_media_changed(BlockDriverState *bs);
void bdrv_lock_medium(BlockDriverState *bs, bool locked);
void bdrv_eject(BlockDriverState *bs, bool eject_flag);
const char *bdrv_get_format_name(BlockDriverState *bs);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 37388ccb18..afdebe7c52 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -249,7 +249,6 @@ struct BlockDriver {
/* removable device specific */
bool (*bdrv_is_inserted)(BlockDriverState *bs);
- int (*bdrv_media_changed)(BlockDriverState *bs);
void (*bdrv_eject)(BlockDriverState *bs, bool eject_flag);
void (*bdrv_lock_medium)(BlockDriverState *bs, bool locked);
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v5 3/4] block: remove bdrv_truncate callback in blkdebug
2017-07-13 10:01 [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 2/4] block: remove unused bdrv_media_changed Manos Pitsidianakis
@ 2017-07-13 10:01 ` Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 4/4] block: add default implementations for bdrv_co_get_block_status() Manos Pitsidianakis
2017-07-13 11:18 ` [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Eric Blake
4 siblings, 0 replies; 8+ messages in thread
From: Manos Pitsidianakis @ 2017-07-13 10:01 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Eric Blake, Alberto Garcia, Stefan Hajnoczi,
Max Reitz, Kevin Wolf
Now that bdrv_truncate is passed to bs->file by default, remove the
callback from block/blkdebug.c and set is_filter to true.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
---
block/blkdebug.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index c19ab28f07..91ffd1fe12 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -821,12 +821,6 @@ static int64_t blkdebug_getlength(BlockDriverState *bs)
return bdrv_getlength(bs->file->bs);
}
-static int blkdebug_truncate(BlockDriverState *bs, int64_t offset,
- PreallocMode prealloc, Error **errp)
-{
- return bdrv_truncate(bs->file, offset, prealloc, errp);
-}
-
static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
{
BDRVBlkdebugState *s = bs->opaque;
@@ -909,6 +903,7 @@ static BlockDriver bdrv_blkdebug = {
.format_name = "blkdebug",
.protocol_name = "blkdebug",
.instance_size = sizeof(BDRVBlkdebugState),
+ .is_filter = true,
.bdrv_parse_filename = blkdebug_parse_filename,
.bdrv_file_open = blkdebug_open,
@@ -917,7 +912,6 @@ static BlockDriver bdrv_blkdebug = {
.bdrv_child_perm = bdrv_filter_default_perms,
.bdrv_getlength = blkdebug_getlength,
- .bdrv_truncate = blkdebug_truncate,
.bdrv_refresh_filename = blkdebug_refresh_filename,
.bdrv_refresh_limits = blkdebug_refresh_limits,
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v5 4/4] block: add default implementations for bdrv_co_get_block_status()
2017-07-13 10:01 [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Manos Pitsidianakis
` (2 preceding siblings ...)
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 3/4] block: remove bdrv_truncate callback in blkdebug Manos Pitsidianakis
@ 2017-07-13 10:01 ` Manos Pitsidianakis
2017-07-13 11:18 ` [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Eric Blake
4 siblings, 0 replies; 8+ messages in thread
From: Manos Pitsidianakis @ 2017-07-13 10:01 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Eric Blake, Alberto Garcia, Stefan Hajnoczi,
Max Reitz, Kevin Wolf
bdrv_co_get_block_status_from_file() and
bdrv_co_get_block_status_from_backing() set *file to bs->file and
bs->backing respectively, so that bdrv_co_get_block_status() can recurse
to them. Future block drivers won't have to duplicate code to implement
this.
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkdebug.c | 12 +-----------
block/commit.c | 12 +-----------
block/io.c | 26 ++++++++++++++++++++++++++
block/mirror.c | 12 +-----------
include/block/block_int.h | 18 ++++++++++++++++++
5 files changed, 47 insertions(+), 33 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 91ffd1fe12..775c464b4e 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -641,16 +641,6 @@ static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs,
return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
}
-static int64_t coroutine_fn blkdebug_co_get_block_status(
- BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum,
- BlockDriverState **file)
-{
- *pnum = nb_sectors;
- *file = bs->file->bs;
- return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID |
- (sector_num << BDRV_SECTOR_BITS);
-}
-
static void blkdebug_close(BlockDriverState *bs)
{
BDRVBlkdebugState *s = bs->opaque;
@@ -920,7 +910,7 @@ static BlockDriver bdrv_blkdebug = {
.bdrv_co_flush_to_disk = blkdebug_co_flush,
.bdrv_co_pwrite_zeroes = blkdebug_co_pwrite_zeroes,
.bdrv_co_pdiscard = blkdebug_co_pdiscard,
- .bdrv_co_get_block_status = blkdebug_co_get_block_status,
+ .bdrv_co_get_block_status = bdrv_co_get_block_status_from_file,
.bdrv_debug_event = blkdebug_debug_event,
.bdrv_debug_breakpoint = blkdebug_debug_breakpoint,
diff --git a/block/commit.c b/block/commit.c
index 13143608f8..f646c13000 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -242,16 +242,6 @@ static int coroutine_fn bdrv_commit_top_preadv(BlockDriverState *bs,
return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags);
}
-static int64_t coroutine_fn bdrv_commit_top_get_block_status(
- BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum,
- BlockDriverState **file)
-{
- *pnum = nb_sectors;
- *file = bs->backing->bs;
- return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID |
- (sector_num << BDRV_SECTOR_BITS);
-}
-
static void bdrv_commit_top_refresh_filename(BlockDriverState *bs, QDict *opts)
{
bdrv_refresh_filename(bs->backing->bs);
@@ -277,7 +267,7 @@ static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c,
static BlockDriver bdrv_commit_top = {
.format_name = "commit_top",
.bdrv_co_preadv = bdrv_commit_top_preadv,
- .bdrv_co_get_block_status = bdrv_commit_top_get_block_status,
+ .bdrv_co_get_block_status = bdrv_co_get_block_status_from_backing,
.bdrv_refresh_filename = bdrv_commit_top_refresh_filename,
.bdrv_close = bdrv_commit_top_close,
.bdrv_child_perm = bdrv_commit_top_child_perm,
diff --git a/block/io.c b/block/io.c
index b413727524..797109fcfd 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1690,6 +1690,32 @@ typedef struct BdrvCoGetBlockStatusData {
bool done;
} BdrvCoGetBlockStatusData;
+int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs,
+ int64_t sector_num,
+ int nb_sectors,
+ int *pnum,
+ BlockDriverState **file)
+{
+ assert(bs->file && bs->file->bs);
+ *pnum = nb_sectors;
+ *file = bs->file->bs;
+ return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID |
+ (sector_num << BDRV_SECTOR_BITS);
+}
+
+int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs,
+ int64_t sector_num,
+ int nb_sectors,
+ int *pnum,
+ BlockDriverState **file)
+{
+ assert(bs->backing && bs->backing->bs);
+ *pnum = nb_sectors;
+ *file = bs->backing->bs;
+ return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID |
+ (sector_num << BDRV_SECTOR_BITS);
+}
+
/*
* Returns the allocation status of the specified sectors.
* Drivers not implementing the functionality are assumed to not support
diff --git a/block/mirror.c b/block/mirror.c
index 8583b764a0..499fcc3ea3 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1059,16 +1059,6 @@ static int coroutine_fn bdrv_mirror_top_flush(BlockDriverState *bs)
return bdrv_co_flush(bs->backing->bs);
}
-static int64_t coroutine_fn bdrv_mirror_top_get_block_status(
- BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum,
- BlockDriverState **file)
-{
- *pnum = nb_sectors;
- *file = bs->backing->bs;
- return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID |
- (sector_num << BDRV_SECTOR_BITS);
-}
-
static int coroutine_fn bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int bytes, BdrvRequestFlags flags)
{
@@ -1115,7 +1105,7 @@ static BlockDriver bdrv_mirror_top = {
.bdrv_co_pwrite_zeroes = bdrv_mirror_top_pwrite_zeroes,
.bdrv_co_pdiscard = bdrv_mirror_top_pdiscard,
.bdrv_co_flush = bdrv_mirror_top_flush,
- .bdrv_co_get_block_status = bdrv_mirror_top_get_block_status,
+ .bdrv_co_get_block_status = bdrv_co_get_block_status_from_backing,
.bdrv_refresh_filename = bdrv_mirror_top_refresh_filename,
.bdrv_close = bdrv_mirror_top_close,
.bdrv_child_perm = bdrv_mirror_top_child_perm,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index afdebe7c52..3d7b9f3402 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -964,6 +964,24 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
uint64_t perm, uint64_t shared,
uint64_t *nperm, uint64_t *nshared);
+/*
+ * Default implementation for drivers to pass bdrv_co_get_block_status() to
+ * their file.
+ */
+int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs,
+ int64_t sector_num,
+ int nb_sectors,
+ int *pnum,
+ BlockDriverState **file);
+/*
+ * Default implementation for drivers to pass bdrv_co_get_block_status() to
+ * their backing file.
+ */
+int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs,
+ int64_t sector_num,
+ int nb_sectors,
+ int *pnum,
+ BlockDriverState **file);
const char *bdrv_get_parent_name(const BlockDriverState *bs);
void blk_dev_change_media_cb(BlockBackend *blk, bool load, Error **errp);
bool blk_dev_has_removable_media(BlockBackend *blk);
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes
2017-07-13 10:01 [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Manos Pitsidianakis
` (3 preceding siblings ...)
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 4/4] block: add default implementations for bdrv_co_get_block_status() Manos Pitsidianakis
@ 2017-07-13 11:18 ` Eric Blake
4 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2017-07-13 11:18 UTC (permalink / raw)
To: Manos Pitsidianakis, qemu-devel
Cc: qemu-block, Alberto Garcia, Stefan Hajnoczi, Max Reitz,
Kevin Wolf
[-- Attachment #1: Type: text/plain, Size: 745 bytes --]
On 07/13/2017 05:01 AM, Manos Pitsidianakis wrote:
> This series makes implementing some of the bdrv_* callbacks easier for block
> filters by passing requests to bs->file if bs->drv doesn't implement it instead
> of failing, and adding default bdrv_co_get_block_status() implementations.
>
> This is based against Kevin Wolf's block branch, commit
> da4bd74d2450ab72a7c26bbabb10c6a287dd043e
Not quite the case, since...
>
> v5:
> rebase against ced1484322 of https://github.com/XanClic/qemu.git block to fix
> apply conflicts
...you rebased here instead ;) But thanks for doing that!
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters Manos Pitsidianakis
@ 2017-07-13 11:23 ` Eric Blake
2017-07-13 11:39 ` Manos Pitsidianakis
0 siblings, 1 reply; 8+ messages in thread
From: Eric Blake @ 2017-07-13 11:23 UTC (permalink / raw)
To: Manos Pitsidianakis, qemu-devel
Cc: qemu-block, Alberto Garcia, Stefan Hajnoczi, Max Reitz,
Kevin Wolf
[-- Attachment #1: Type: text/plain, Size: 2435 bytes --]
On 07/13/2017 05:01 AM, Manos Pitsidianakis wrote:
> The following functions fail if bs->drv is a filter and does not
> implement them:
>
> bdrv_probe_blocksizes
> bdrv_probe_geometry
> bdrv_truncate
> bdrv_has_zero_init
> bdrv_get_info
>
> Instead, the call should be passed to bs->file if it exists, to allow
> filter drivers to support those methods without implementing them. This
> commit makes `drv->is_filter = true` imply that these callbacks will be
> forwarded to bs->file by default, so disabling support for these
> functions must be done explicitly.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
I would have dropped R-b on the grounds that you added comments to
'is_filter' (good! but non-trivial), to make sure it gets a
grammar/wording review of the new content. Furthermore, your patch had
a semantic change due to the rebase, and looking at that change...
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
> ---
> @@ -3420,11 +3424,15 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, PreallocMode prealloc,
>
> assert(child->perm & BLK_PERM_RESIZE);
>
> + /* if bs->drv == NULL, bs is closed, so there's nothing to do here */
> if (!drv) {
> error_setg(errp, "No medium inserted");
> return -ENOMEDIUM;
> }
> if (!drv->bdrv_truncate) {
> + if (bs->file && drv->is_filter) {
> + return bdrv_truncate(bs->file, prealloc, offset, errp);
...ouch - you got it wrong. s/prealloc, offset/offset, prealloc/
> +++ b/include/block/block_int.h
> @@ -87,7 +87,11 @@ struct BlockDriver {
> const char *format_name;
> int instance_size;
>
> - /* set to true if the BlockDriver is a block filter */
> + /* set to true if the BlockDriver is a block filter. Block filters pass
> + * certain callbacks that refer to data (see block.c) to their bs->file if
> + * the driver doesn't implement them. Drivers that do not wish to forward
> + * must implement them and return -ENOTSUP.
> + */
> bool is_filter;
I'm okay with the new comment.
With the swapped parameter order fixed (the maintainer can probably do
that),
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters
2017-07-13 11:23 ` Eric Blake
@ 2017-07-13 11:39 ` Manos Pitsidianakis
0 siblings, 0 replies; 8+ messages in thread
From: Manos Pitsidianakis @ 2017-07-13 11:39 UTC (permalink / raw)
To: Eric Blake
Cc: qemu-devel, qemu-block, Alberto Garcia, Stefan Hajnoczi,
Max Reitz, Kevin Wolf
[-- Attachment #1: Type: text/plain, Size: 2570 bytes --]
On Thu, Jul 13, 2017 at 06:23:14AM -0500, Eric Blake wrote:
>On 07/13/2017 05:01 AM, Manos Pitsidianakis wrote:
>> The following functions fail if bs->drv is a filter and does not
>> implement them:
>>
>> bdrv_probe_blocksizes
>> bdrv_probe_geometry
>> bdrv_truncate
>> bdrv_has_zero_init
>> bdrv_get_info
>>
>> Instead, the call should be passed to bs->file if it exists, to allow
>> filter drivers to support those methods without implementing them. This
>> commit makes `drv->is_filter = true` imply that these callbacks will be
>> forwarded to bs->file by default, so disabling support for these
>> functions must be done explicitly.
>>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>
>I would have dropped R-b on the grounds that you added comments to
>'is_filter' (good! but non-trivial), to make sure it gets a
>grammar/wording review of the new content. Furthermore, your patch had
>a semantic change due to the rebase, and looking at that change...
>
>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>> Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
>> ---
>
>> @@ -3420,11 +3424,15 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, PreallocMode prealloc,
>>
>> assert(child->perm & BLK_PERM_RESIZE);
>>
>> + /* if bs->drv == NULL, bs is closed, so there's nothing to do here */
>> if (!drv) {
>> error_setg(errp, "No medium inserted");
>> return -ENOMEDIUM;
>> }
>> if (!drv->bdrv_truncate) {
>> + if (bs->file && drv->is_filter) {
>> + return bdrv_truncate(bs->file, prealloc, offset, errp);
>
>...ouch - you got it wrong. s/prealloc, offset/offset, prealloc/
>
>> +++ b/include/block/block_int.h
>> @@ -87,7 +87,11 @@ struct BlockDriver {
>> const char *format_name;
>> int instance_size;
>>
>> - /* set to true if the BlockDriver is a block filter */
>> + /* set to true if the BlockDriver is a block filter. Block filters pass
>> + * certain callbacks that refer to data (see block.c) to their bs->file if
>> + * the driver doesn't implement them. Drivers that do not wish to forward
>> + * must implement them and return -ENOTSUP.
>> + */
>> bool is_filter;
>
>I'm okay with the new comment.
>
>With the swapped parameter order fixed (the maintainer can probably do
>that),
>Reviewed-by: Eric Blake <eblake@redhat.com>
Oh, this compiled correctly because PreallocMode is an enum. Sorry for
the inconvenience, that was rushed. I will send a new version to be
typical.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-07-13 11:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-13 10:01 [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 1/4] block: pass bdrv_* methods to bs->file by default in block filters Manos Pitsidianakis
2017-07-13 11:23 ` Eric Blake
2017-07-13 11:39 ` Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 2/4] block: remove unused bdrv_media_changed Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 3/4] block: remove bdrv_truncate callback in blkdebug Manos Pitsidianakis
2017-07-13 10:01 ` [Qemu-devel] [PATCH v5 4/4] block: add default implementations for bdrv_co_get_block_status() Manos Pitsidianakis
2017-07-13 11:18 ` [Qemu-devel] [PATCH v5 0/4] block: Block driver callbacks fixes Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).