On 06.04.22 20:07, Vladimir Sementsov-Ogievskiy wrote:
We are going to add one more option of enum type. Let's refactor option
parsing so that we can simply work with BlockdevOptionsCbw object.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@openvz.org>
---
block/copy-before-write.c | 55 ++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index a8a06fdc09..6877ff893a 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
[...]
@@ -376,6 +365,14 @@ static int cbw_open(BlockDriverState *bs, QDict *options,
int flags,
BDRVCopyBeforeWriteState *s = bs->opaque;
BdrvDirtyBitmap *bitmap = NULL;
int64_t cluster_size;
+ g_autoptr(BlockdevOptions) full_opts = NULL;
+ BlockdevOptionsCbw *opts;
+
+ full_opts = cbw_parse_options(options, errp);
+ if (!full_opts) {
+ return -EINVAL;
+ }
+ opts = &full_opts->u.copy_before_write;
I would prefer an `assert(full_opts->driver ==
BLOCKDEV_DRIVER_COPY_BEFORE_WRITE);` here, but, either way:
Reviewed-by: Hanna Reitz <hre...@redhat.com>