mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
qcow2: Fix open/create to open images with no_co_wrapper
.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> Message-Id: <20230126172432.436111-7-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Hanna Czenczek <hreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
5b9d79b62d
commit
ecbc57caba
1 changed files with 22 additions and 21 deletions
|
@ -1617,7 +1617,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
|
||||||
|
|
||||||
if (open_data_file) {
|
if (open_data_file) {
|
||||||
/* Open external data file */
|
/* Open external data file */
|
||||||
s->data_file = bdrv_open_child(NULL, options, "data-file", bs,
|
s->data_file = bdrv_co_open_child(NULL, options, "data-file", bs,
|
||||||
&child_of_bds, BDRV_CHILD_DATA,
|
&child_of_bds, BDRV_CHILD_DATA,
|
||||||
true, errp);
|
true, errp);
|
||||||
if (*errp) {
|
if (*errp) {
|
||||||
|
@ -1627,8 +1627,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
|
||||||
|
|
||||||
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
|
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
|
||||||
if (!s->data_file && s->image_data_file) {
|
if (!s->data_file && s->image_data_file) {
|
||||||
s->data_file = bdrv_open_child(s->image_data_file, options,
|
s->data_file = bdrv_co_open_child(s->image_data_file, options,
|
||||||
"data-file", bs, &child_of_bds,
|
"data-file", bs,
|
||||||
|
&child_of_bds,
|
||||||
BDRV_CHILD_DATA, false, errp);
|
BDRV_CHILD_DATA, false, errp);
|
||||||
if (!s->data_file) {
|
if (!s->data_file) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -3454,7 +3455,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
assert(create_options->driver == BLOCKDEV_DRIVER_QCOW2);
|
assert(create_options->driver == BLOCKDEV_DRIVER_QCOW2);
|
||||||
qcow2_opts = &create_options->u.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) {
|
if (bs == NULL) {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -3596,7 +3597,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
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) {
|
if (data_bs == NULL) {
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -3629,7 +3630,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create BlockBackend to write to the image */
|
/* Create BlockBackend to write to the image */
|
||||||
blk = blk_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
||||||
errp);
|
errp);
|
||||||
if (!blk) {
|
if (!blk) {
|
||||||
ret = -EPERM;
|
ret = -EPERM;
|
||||||
|
@ -3712,7 +3713,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
if (data_bs) {
|
if (data_bs) {
|
||||||
qdict_put_str(options, "data-file", data_bs->node_name);
|
qdict_put_str(options, "data-file", data_bs->node_name);
|
||||||
}
|
}
|
||||||
blk = blk_new_open(NULL, NULL, options,
|
blk = blk_co_new_open(NULL, NULL, options,
|
||||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
|
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
|
||||||
errp);
|
errp);
|
||||||
if (blk == NULL) {
|
if (blk == NULL) {
|
||||||
|
@ -3793,7 +3794,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
if (data_bs) {
|
if (data_bs) {
|
||||||
qdict_put_str(options, "data-file", data_bs->node_name);
|
qdict_put_str(options, "data-file", data_bs->node_name);
|
||||||
}
|
}
|
||||||
blk = blk_new_open(NULL, NULL, options,
|
blk = blk_co_new_open(NULL, NULL, options,
|
||||||
BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
|
BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
|
||||||
errp);
|
errp);
|
||||||
if (blk == NULL) {
|
if (blk == NULL) {
|
||||||
|
@ -3877,7 +3878,7 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
bs = bdrv_open(filename, NULL, NULL,
|
bs = bdrv_co_open(filename, NULL, NULL,
|
||||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||||
if (bs == NULL) {
|
if (bs == NULL) {
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
@ -3892,7 +3893,7 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
data_bs = bdrv_open(val, NULL, NULL,
|
data_bs = bdrv_co_open(val, NULL, NULL,
|
||||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
|
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
|
||||||
errp);
|
errp);
|
||||||
if (data_bs == NULL) {
|
if (data_bs == NULL) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue