[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/13] qcow2: Fix open/create to open images with no_co_wrapper
From: |
Kevin Wolf |
Subject: |
[PATCH 06/13] qcow2: Fix open/create to open images with no_co_wrapper |
Date: |
Thu, 26 Jan 2023 18:24:25 +0100 |
.bdrv_co_create implementations run in a coroutine, as does
qcow2_do_open(). Therefore they are not allowed to open images directly.
Fix the calls to use the corresponding no_co_wrappers instead.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2.c | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 21aa4c6b7a..ee0e5b45cc 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1617,9 +1617,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverState
*bs, QDict *options,
if (open_data_file) {
/* Open external data file */
- s->data_file = bdrv_open_child(NULL, options, "data-file", bs,
- &child_of_bds, BDRV_CHILD_DATA,
- true, errp);
+ s->data_file = bdrv_co_open_child(NULL, options, "data-file", bs,
+ &child_of_bds, BDRV_CHILD_DATA,
+ true, errp);
if (*errp) {
ret = -EINVAL;
goto fail;
@@ -1627,9 +1627,10 @@ static int coroutine_fn qcow2_do_open(BlockDriverState
*bs, QDict *options,
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
if (!s->data_file && s->image_data_file) {
- s->data_file = bdrv_open_child(s->image_data_file, options,
- "data-file", bs, &child_of_bds,
- BDRV_CHILD_DATA, false, errp);
+ s->data_file = bdrv_co_open_child(s->image_data_file, options,
+ "data-file", bs,
+ &child_of_bds,
+ BDRV_CHILD_DATA, false,
errp);
if (!s->data_file) {
ret = -EINVAL;
goto fail;
@@ -3454,7 +3455,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options,
Error **errp)
assert(create_options->driver == BLOCKDEV_DRIVER_QCOW2);
qcow2_opts = &create_options->u.qcow2;
- bs = bdrv_open_blockdev_ref(qcow2_opts->file, errp);
+ bs = bdrv_co_open_blockdev_ref(qcow2_opts->file, errp);
if (bs == NULL) {
return -EIO;
}
@@ -3596,7 +3597,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options,
Error **errp)
ret = -EINVAL;
goto out;
}
- data_bs = bdrv_open_blockdev_ref(qcow2_opts->data_file, errp);
+ data_bs = bdrv_co_open_blockdev_ref(qcow2_opts->data_file, errp);
if (data_bs == NULL) {
ret = -EIO;
goto out;
@@ -3629,8 +3630,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options,
Error **errp)
}
/* Create BlockBackend to write to the image */
- blk = blk_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
- errp);
+ blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE,
BLK_PERM_ALL,
+ errp);
if (!blk) {
ret = -EPERM;
goto out;
@@ -3712,9 +3713,9 @@ qcow2_co_create(BlockdevCreateOptions *create_options,
Error **errp)
if (data_bs) {
qdict_put_str(options, "data-file", data_bs->node_name);
}
- blk = blk_new_open(NULL, NULL, options,
- BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
- errp);
+ blk = blk_co_new_open(NULL, NULL, options,
+ BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
+ errp);
if (blk == NULL) {
ret = -EIO;
goto out;
@@ -3793,9 +3794,9 @@ qcow2_co_create(BlockdevCreateOptions *create_options,
Error **errp)
if (data_bs) {
qdict_put_str(options, "data-file", data_bs->node_name);
}
- blk = blk_new_open(NULL, NULL, options,
- BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
- errp);
+ blk = blk_co_new_open(NULL, NULL, options,
+ BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
+ errp);
if (blk == NULL) {
ret = -EIO;
goto out;
@@ -3877,8 +3878,8 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver
*drv,
goto finish;
}
- bs = bdrv_open(filename, NULL, NULL,
- BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
+ bs = bdrv_co_open(filename, NULL, NULL,
+ BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
if (bs == NULL) {
ret = -EIO;
goto finish;
@@ -3892,9 +3893,9 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver
*drv,
goto finish;
}
- data_bs = bdrv_open(val, NULL, NULL,
- BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
- errp);
+ data_bs = bdrv_co_open(val, NULL, NULL,
+ BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
+ errp);
if (data_bs == NULL) {
ret = -EIO;
goto finish;
--
2.38.1
- [PATCH 00/13] block: Fix bdrv_open*() calls from coroutine context, Kevin Wolf, 2023/01/26
- [PATCH 01/13] block-coroutine-wrapper: Introduce no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 02/13] block: Create no_co_wrappers for open functions, Kevin Wolf, 2023/01/26
- [PATCH 03/13] luks: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 06/13] qcow2: Fix open/create to open images with no_co_wrapper,
Kevin Wolf <=
- [PATCH 04/13] parallels: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 07/13] qed: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 08/13] vdi: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 09/13] vhdx: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 05/13] qcow: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 10/13] vmdk: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 12/13] block: Fix bdrv_co_create_opts_simple() to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 11/13] vpc: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper, Kevin Wolf, 2023/01/26
- [PATCH 13/13] block: Assert non-coroutine context for bdrv_open_inherit(), Kevin Wolf, 2023/01/26
- Re: [PATCH 00/13] block: Fix bdrv_open*() calls from coroutine context, Emanuele Giuseppe Esposito, 2023/01/27