diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> | 2022-07-26 23:11:21 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2022-10-27 20:14:11 +0200 |
commit | 83930780325b144a5908c45b3957b9b6457b3831 (patch) | |
tree | 459cb7104d18ea3f5115bea5cbb56b7030176113 /block/copy-before-write.c | |
parent | 046fd84facfc4d326070bf5306dd9cedb7bd9854 (diff) | |
download | qemu-83930780325b144a5908c45b3957b9b6457b3831.zip qemu-83930780325b144a5908c45b3957b9b6457b3831.tar.gz qemu-83930780325b144a5908c45b3957b9b6457b3831.tar.bz2 |
block: introduce bdrv_open_file_child() helper
Almost all drivers call bdrv_open_child() similarly. Let's create a
helper for this.
The only not updated drivers that call bdrv_open_child() to set
bs->file are raw-format and snapshot-access:
raw-format sometimes want to have filtered child but
don't set drv->is_filter to true.
snapshot-access wants only DATA | PRIMARY
Possibly we should implement drv->is_filter_func() handler, to consider
raw-format as filter when it works as filter.. But it's another story.
Note also, that we decrease assignments to bs->file in code: it helps
us restrict modifying this field in further commit.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220726201134.924743-3-vsementsov@yandex-team.ru>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/copy-before-write.c')
-rw-r--r-- | block/copy-before-write.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/block/copy-before-write.c b/block/copy-before-write.c index afbdd04..4abaa73 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -412,6 +412,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, int64_t cluster_size; g_autoptr(BlockdevOptions) full_opts = NULL; BlockdevOptionsCbw *opts; + int ret; full_opts = cbw_parse_options(options, errp); if (!full_opts) { @@ -420,11 +421,9 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, assert(full_opts->driver == BLOCKDEV_DRIVER_COPY_BEFORE_WRITE); opts = &full_opts->u.copy_before_write; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } s->target = bdrv_open_child(NULL, options, "target", bs, &child_of_bds, |