[PATCH 12/13] block: Fix bdrv_co_create_opts_simple() to open images with no_co_wrapper

Kevin Wolf posted 13 patches 3 years ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, "Denis V. Lunev" <den@openvz.org>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>, Stefan Weil <sw@weilnetz.de>, Jeff Cody <codyprime@gmail.com>, Fam Zheng <fam@euphon.net>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>
[PATCH 12/13] block: Fix bdrv_co_create_opts_simple() to open images with no_co_wrapper
Posted by Kevin Wolf 3 years ago
bdrv_co_create_opts_simpl() runs in a coroutine. Therefore it is not
allowed to open images directly. Fix the call to use the corresponding
no_co_wrapper instead.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index aa9062f2c1..6eac16eac5 100644
--- a/block.c
+++ b/block.c
@@ -657,8 +657,8 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv,
     options = qdict_new();
     qdict_put_str(options, "driver", drv->format_name);
 
-    blk = blk_new_open(filename, NULL, options,
-                       BDRV_O_RDWR | BDRV_O_RESIZE, errp);
+    blk = blk_co_new_open(filename, NULL, options,
+                          BDRV_O_RDWR | BDRV_O_RESIZE, errp);
     if (!blk) {
         error_prepend(errp, "Protocol driver '%s' does not support image "
                       "creation, and opening the image failed: ",
-- 
2.38.1
Re: [PATCH 12/13] block: Fix bdrv_co_create_opts_simple() to open images with no_co_wrapper
Posted by Eric Blake 3 years ago
On Thu, Jan 26, 2023 at 06:24:31PM +0100, Kevin Wolf wrote:
> bdrv_co_create_opts_simpl() runs in a coroutine. Therefore it is not

simple

> allowed to open images directly. Fix the call to use the corresponding
> no_co_wrapper instead.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block.c b/block.c
> index aa9062f2c1..6eac16eac5 100644
> --- a/block.c
> +++ b/block.c
> @@ -657,8 +657,8 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv,
>      options = qdict_new();
>      qdict_put_str(options, "driver", drv->format_name);
>  
> -    blk = blk_new_open(filename, NULL, options,
> -                       BDRV_O_RDWR | BDRV_O_RESIZE, errp);
> +    blk = blk_co_new_open(filename, NULL, options,
> +                          BDRV_O_RDWR | BDRV_O_RESIZE, errp);
>      if (!blk) {
>          error_prepend(errp, "Protocol driver '%s' does not support image "
>                        "creation, and opening the image failed: ",
> -- 
> 2.38.1
> 
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org