[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/8] block: add missing coroutine_fn annotations


  • To: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>, qemu-devel@xxxxxxxxxx
  • From: "Denis V. Lunev" <den@xxxxxxxxxxxxx>
  • Date: Wed, 22 Jul 2026 19:19:45 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Mfm9NXIWVTQgGbPugzT8H+LawEEKM942vZhuo4NZw4s=; b=UCEOSRNPpazXsWZIYF5/L+GqaWNzPHFFoGb9IqMACmvZ6YlurEvi9eH3J6OrtUaHRNPiSvZJmwzuvMrWDYWVMt7HFWzzC9Bgsq3a5kHx/4J+xCG3kcTuyhnUEvFPpPjXbRcx89MGH7OnrgZQEMf1wSjdV2fXKwONvwa8vx1plsyE12IHfjgXm6IS1vO4I3PJj5yYQlhtWuAV/boMZwthbuuiJZ4EEqfq1OJJgL2vkcyKa2+Wd3ctigz5B6LCD7h90Pwvbt/LK46hrrhVjFuYrMoa5BaHAxyK7rqE2MClaJjkvU2rOX961GhbJdy5JrnfYelerClYAM6SRQI+408i7w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zQUKciMWDIq3xVTB6br1LQX6XVPI9DHk9CBgJndPAoXSdUOKLjvnDpWEaXuTxHOEzBl49Kd+AQvarO3YhuBJmd+XdYAHTEUsN1tZhZln9ufmeMr1fKUdtdhXyKXjqcZx/p/0ilLXwpPG3YiU1Z/sDjzSsMDPfZ43GQJyKJ8hvHhUK8NDduOTJgMMQtz2O3JDD7upDlUproOFKv14/tE9eImMYG/0H9fdss0Qz8E1QXwEXaBPYNFFkpYB07TPWNDLdBT3GNfMIjnHvyvYECnknDjh0PMAklqqYcRhXWNYXahye23jIRFyX4bGz1yFnsHwxgPGmAp54JBA/Q8+EPA2Cw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector2 header.d=virtuozzo.com header.i="@virtuozzo.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com;
  • Cc: Markus Armbruster <armbru@xxxxxxxxxx>, Peter Xu <peterx@xxxxxxxxxx>, Fabiano Rosas <farosas@xxxxxxx>, Daniel P. Berrangé <berrange@xxxxxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxxx>, Kevin Wolf <kwolf@xxxxxxxxxx>, Hanna Reitz <hreitz@xxxxxxxxxx>, qemu-block@xxxxxxxxxx, Stefan Hajnoczi <stefanha@xxxxxxxxxx>, Fam Zheng <fam@xxxxxxxxxx>, "Denis V. Lunev" <den@xxxxxxxxxx>, Christian Schoenebeck <qemu_oss@xxxxxxxxxxxxx>, Greg Kurz <groug@xxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Li Zhijian <lizhijian@xxxxxxxxxxx>
  • Delivery-date: Wed, 22 Jul 2026 17:20:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 7/20/26 09:55, Marc-André Lureau wrote:
> The functions call coroutine functions or are called by coroutine.
>
> Add an assert() in qcow2_do_close() code path which calls a
> no_coroutine_fn bdrv_graph_wrlock_drained().
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> ---
>  include/block/blockjob_int.h |  2 +-
>  block/crypto.c               | 13 +++++++------
>  block/io.c                   |  8 +++++---
>  block/parallels.c            |  5 +++--
>  block/qcow2.c                | 11 +++++++----
>  blockjob.c                   |  3 ++-
>  6 files changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
> index 4c3d2e25a20..34e172874fa 100644
> --- a/include/block/blockjob_int.h
> +++ b/include/block/blockjob_int.h
> @@ -150,7 +150,7 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, 
> uint64_t n);
>   * Put the job to sleep (assuming that it wasn't canceled) to throttle it to 
> the
>   * right speed according to its rate limiting.
>   */
> -void block_job_ratelimit_sleep(BlockJob *job);
> +void coroutine_fn block_job_ratelimit_sleep(BlockJob *job);
>  
>  /**
>   * block_job_error_action:
> diff --git a/block/crypto.c b/block/crypto.c
> index 36abb7af468..8a34d92fded 100644
> --- a/block/crypto.c
> +++ b/block/crypto.c
> @@ -56,12 +56,13 @@ static int block_crypto_probe_generic(QCryptoBlockFormat 
> format,
>  }
>  
>  
> -static int block_crypto_read_func(QCryptoBlock *block,
> -                                  size_t offset,
> -                                  uint8_t *buf,
> -                                  size_t buflen,
> -                                  void *opaque,
> -                                  Error **errp)
> +static int coroutine_mixed_fn
> +block_crypto_read_func(QCryptoBlock *block,
> +                       size_t offset,
> +                       uint8_t *buf,
> +                       size_t buflen,
> +                       void *opaque,
> +                       Error **errp)
>  {
>      BlockDriverState *bs = opaque;
>      BlockCrypto *crypto = bs->opaque;
> diff --git a/block/io.c b/block/io.c
> index a916b236c3c..99dd16864a3 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -346,8 +346,9 @@ static void coroutine_fn 
> bdrv_co_yield_to_drain(BlockDriverState *bs,
>      assert(data.done);
>  }
>  
> -static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
> -                                  bool poll)
> +static void coroutine_mixed_fn
> +bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
> +                      bool poll)
>  {
>      IO_OR_GS_CODE();
>  
> @@ -397,7 +398,8 @@ bdrv_drained_begin(BlockDriverState *bs)
>   * This function does not poll, nor must any of its recursively called
>   * functions.
>   */
> -static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
> +static void coroutine_mixed_fn
> +bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
>  {
>      IO_OR_GS_CODE();
>  
> diff --git a/block/parallels.c b/block/parallels.c
> index 7a90fb5220b..46a6e8f2743 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -142,8 +142,9 @@ static uint32_t host_cluster_index(BDRVParallelsState *s, 
> int64_t off)
>      return off / s->cluster_size;
>  }
>  
> -static int64_t block_status(BDRVParallelsState *s, int64_t sector_num,
> -                            int nb_sectors, int *pnum)
> +static int64_t coroutine_fn
> +block_status(BDRVParallelsState *s, int64_t sector_num,
> +             int nb_sectors, int *pnum)
>  {
>      int64_t start_off = -2, prev_end_off = -2;
>  
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 19271b10a49..161626fa3cb 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1287,9 +1287,10 @@ fail:
>  }
>  
>  /* s_locked specifies whether s->lock is held or not */
> -static void qcow2_update_options_commit(BlockDriverState *bs,
> -                                        Qcow2ReopenState *r,
> -                                        bool s_locked)
> +static void coroutine_fn
> +qcow2_update_options_commit(BlockDriverState *bs,
> +                            Qcow2ReopenState *r,
> +                            bool s_locked)
>  {
>      BDRVQcow2State *s = bs->opaque;
>      int i;
> @@ -2126,7 +2127,8 @@ fail:
>      return ret;
>  }
>  
> -static void qcow2_reopen_commit(BDRVReopenState *state)
> +static void coroutine_fn
> +qcow2_reopen_commit(BDRVReopenState *state)
>  {
>      BDRVQcow2State *s = state->bs->opaque;
>  
> @@ -2905,6 +2907,7 @@ qcow2_do_close(BlockDriverState *bs, bool 
> close_data_file)
>      g_free(s->image_backing_format);
>  
>      if (close_data_file && has_data_file(bs)) {
> +        assert(!qemu_in_coroutine());
>          GLOBAL_STATE_CODE();
>          bdrv_graph_rdunlock_main_loop();
>          bdrv_graph_wrlock_drained();
> diff --git a/blockjob.c b/blockjob.c
> index f3b11cc7a19..f3ad6a93125 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -338,7 +338,8 @@ void block_job_ratelimit_processed_bytes(BlockJob *job, 
> uint64_t n)
>      ratelimit_calculate_delay(&job->limit, n);
>  }
>  
> -void block_job_ratelimit_sleep(BlockJob *job)
> +void coroutine_fn
> +block_job_ratelimit_sleep(BlockJob *job)
>  {
>      uint64_t delay_ns;
>  
>
Reviewed-by: Denis V. Lunev <den@xxxxxxxxxx> (parallels part)



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.