From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601422; cv=none; d=zohomail.com; s=zohoarc; b=H9sZC1NEfB1Jpgv2v7+tGUIPLNneEbW/h96NZ2V5UQ4hFM9nZ1gFychA/wT3fa9ZNNVlhwwOx+HIgmEGmZ6ONqk1IxrSZXUq91j1WbNJrpj/DZjpch7QijbK8miRhEkWb/0nnTCdmTub9NXQCczthnXobUmMEJuIO+zSzRfcy+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601422; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PGysYoRxqY8UMV5t+VFdY13Fiksq/DOO9btd4CD6csk=; b=LCGdy0cD1dMzNrVS6VpXpjZBHK52sUaUjqu0HmqZgjpw8qf6rpXEc6cpS+yOJjj/PlSIhTYKL27yEgmTGHg3FGy26OAshx9Ui3dFH5DhTLHO6/yLvQeNWvrgm6vPz/6fwfzTNbrtLfSUm/c7RFbvPLM/bpj+UeqonZzz/CKQj6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601422605939.2860164009669; Wed, 16 Nov 2022 04:23:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRS-0000gv-Jj; Wed, 16 Nov 2022 07:22:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRK-0000c6-Cd for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRH-0000to-Rh for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:49 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-cy4EhkEjMw2Vl8FQ0TFAqg-1; Wed, 16 Nov 2022 07:22:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 308901C09B6A; Wed, 16 Nov 2022 12:22:44 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8D5F9E70; Wed, 16 Nov 2022 12:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PGysYoRxqY8UMV5t+VFdY13Fiksq/DOO9btd4CD6csk=; b=HiyGqYk/4gMdPoZVUDmyV4NS1Bxe9cbApjKmbNWbBu8gjFgOEOefGa1T4mnCUJgleV1V0q hNJpkfwpROSWyXxt5LrlTbxM34DTL3g2nNqvdouxfHsmubERsvYdBTDefh7jEzXPyIW7RX SnjHO/ND/VNWXK4Fj9nXSh/BDEoNh1Q= X-MC-Unique: cy4EhkEjMw2Vl8FQ0TFAqg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 01/11] block-copy: add missing coroutine_fn annotations Date: Wed, 16 Nov 2022 07:22:31 -0500 Message-Id: <20221116122241.2856527-2-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601423438100004 Content-Type: text/plain; charset="utf-8" These functions end up calling bdrv_common_block_status_above(), a generated_co_wrapper function. In addition, they also happen to be always called in coroutine context, meaning all callers are coroutine_fn. This means that the g_c_w function will enter the qemu_in_coroutine() case and eventually suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-copy.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index bb947afdda..f33ab1d0b6 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -577,8 +577,9 @@ static coroutine_fn int block_copy_task_entry(AioTask *= task) return ret; } =20 -static int block_copy_block_status(BlockCopyState *s, int64_t offset, - int64_t bytes, int64_t *pnum) +static coroutine_fn int block_copy_block_status(BlockCopyState *s, + int64_t offset, + int64_t bytes, int64_t *pn= um) { int64_t num; BlockDriverState *base; @@ -613,8 +614,9 @@ static int block_copy_block_status(BlockCopyState *s, i= nt64_t offset, * Check if the cluster starting at offset is allocated or not. * return via pnum the number of contiguous clusters sharing this allocati= on. */ -static int block_copy_is_cluster_allocated(BlockCopyState *s, int64_t offs= et, - int64_t *pnum) +static int coroutine_fn block_copy_is_cluster_allocated(BlockCopyState *s, + int64_t offset, + int64_t *pnum) { BlockDriverState *bs =3D s->source->bs; int64_t count, total_count =3D 0; @@ -669,8 +671,9 @@ void block_copy_reset(BlockCopyState *s, int64_t offset= , int64_t bytes) * @return 0 when the cluster at @offset was unallocated, * 1 otherwise, and -ret on error. */ -int64_t block_copy_reset_unallocated(BlockCopyState *s, - int64_t offset, int64_t *count) +int64_t coroutine_fn block_copy_reset_unallocated(BlockCopyState *s, + int64_t offset, + int64_t *count) { int ret; int64_t clusters, bytes; --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601416; cv=none; d=zohomail.com; s=zohoarc; b=lmsUcbCmrvhB8/0iP7MlIsi+1H8CcIaWx1m9R397/ZYGCxOICQ7cbfbRRaY07f6CTJl9fKu3twydzxlomGKrVSGU90r+LARWIQwpdSEdwd2uTyUtw1V2BKNnK1PHysX7ZkC9HHjnptr0+LJAteT0Q6CcImVfgDi3m/dLnKGzroQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601416; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3421AU3i61P6bt+m3hZQkZTiF6WrCYIKBa9iKiN7Mis=; b=iqj3BFUn+RVmU5DpdA3PptTLGRXgOS9/rBy5uYyFhuNAWtwhIcTIwd0NQniXZxAS7RhzPP3NIzc/P9eVwOn8LAiR44UG+o4r72LijOwV7D2BxoMNRoT7ubrYN7VMyxK3GjpM9tKzL2Fa3U1M9mjMdhytLoWFHY7EYPp/5XyCXm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601416819567.9420337751233; Wed, 16 Nov 2022 04:23:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRO-0000eW-NH; Wed, 16 Nov 2022 07:22:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRK-0000c8-EQ for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRI-0000tz-HP for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:49 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380-wARBbHEoMTWhFznOHUVb0g-1; Wed, 16 Nov 2022 07:22:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 755CB29ABA0E; Wed, 16 Nov 2022 12:22:44 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 398229E70; Wed, 16 Nov 2022 12:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3421AU3i61P6bt+m3hZQkZTiF6WrCYIKBa9iKiN7Mis=; b=eTpgJxL/foImaG9TnCuR0U9r4g61SYLfwBwJU4WUBq7orDVIslv5edBVd37dnC5cnVv04S N68cMlDJJPo9YK+T0hN3mLH0FCvV1vlpysrbg8yBs4gYj4N0Wuj5mP1CFz6CNzKn4t92jz ERgVOba34S+2o7Wqyw3aZU+nu/kiNoc= X-MC-Unique: wARBbHEoMTWhFznOHUVb0g-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 02/11] nbd/server.c: add missing coroutine_fn annotations Date: Wed, 16 Nov 2022 07:22:32 -0500 Message-Id: <20221116122241.2856527-3-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601417553100001 Content-Type: text/plain; charset="utf-8" These functions end up calling bdrv_*() implemented as generated_co_wrapper functions. In addition, they also happen to be always called in coroutine context, meaning all callers are coroutine_fn. This means that the g_c_w function will enter the qemu_in_coroutine() case and eventually suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- nbd/server.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index ada16089f3..e2eec0cf46 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2141,8 +2141,9 @@ static int nbd_extent_array_add(NBDExtentArray *ea, return 0; } =20 -static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, NBDExtentArray *ea) +static int coroutine_fn blockstatus_to_extents(BlockDriverState *bs, + uint64_t offset, uint64_t b= ytes, + NBDExtentArray *ea) { while (bytes) { uint32_t flags; @@ -2168,8 +2169,9 @@ static int blockstatus_to_extents(BlockDriverState *b= s, uint64_t offset, return 0; } =20 -static int blockalloc_to_extents(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, NBDExtentArray *ea) +static int coroutine_fn blockalloc_to_extents(BlockDriverState *bs, + uint64_t offset, uint64_t by= tes, + NBDExtentArray *ea) { while (bytes) { int64_t num; @@ -2220,11 +2222,12 @@ static int nbd_co_send_extents(NBDClient *client, u= int64_t handle, } =20 /* Get block status from the exported device and send it to the client */ -static int nbd_co_send_block_status(NBDClient *client, uint64_t handle, - BlockDriverState *bs, uint64_t offset, - uint32_t length, bool dont_fragment, - bool last, uint32_t context_id, - Error **errp) +static int +coroutine_fn nbd_co_send_block_status(NBDClient *client, uint64_t handle, + BlockDriverState *bs, uint64_t offse= t, + uint32_t length, bool dont_fragment, + bool last, uint32_t context_id, + Error **errp) { int ret; unsigned int nb_extents =3D dont_fragment ? 1 : NBD_MAX_BLOCK_STATUS_E= XTENTS; --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601739; cv=none; d=zohomail.com; s=zohoarc; b=CUobvCIr/l87WEH1eSU9QRnrYlGPQipGfiHgyD1d0h2t96x7q7YXCJV1IIM2sCDVhVXwq2pzPBPlMD77KYb/WYIbdMY+lQQ6WMp4zO5qc1yGS0xuKW/NMvAMP6H3/l5UhLymkkGbCbEoVpoKFfOl2K243XcWBn5lIVoP5X7DXso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601739; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=usEflojspUSxYZ/sKc23VDOA7vhKiKjbIp0hRmhxNoY=; b=nmDpdUhgbLXZ2sfp6LJKJ/oGkdunz0os+AVeXLYNrhZvu5csUrVgxj2mttVDdCBRSDFXdz/daq+16x/jLaPpRbBelq3nrq59Jqgk8HhvVnO6X5jr6dxfCgL7XXQ5nboi8T7PHAX4kmroHVRC9YJDq6zA6RUwfUasWmONso1cPIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601739192925.656698652634; Wed, 16 Nov 2022 04:28:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRO-0000dq-71; Wed, 16 Nov 2022 07:22:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRK-0000c9-F4 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRH-0000tj-GE for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:49 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-575-GKwmG4zqNNu65GZEpYp9Cw-1; Wed, 16 Nov 2022 07:22:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB146811E67; Wed, 16 Nov 2022 12:22:44 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F7889E70; Wed, 16 Nov 2022 12:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=usEflojspUSxYZ/sKc23VDOA7vhKiKjbIp0hRmhxNoY=; b=IDztvB0/SD0XPRGT8tIqrT16ujtcMPh9LR+w8KYKqqrZ0p3ckc7aU4BMcLNGhCPwqn24Gl bnSBQ5J0F+vlO0ldzj3DhTWnbhfFMV2780HgR2jQ0KQxJekfFC7OBdyaM9+g9VHa3wM5iK HtuAbuhpd4rj9CF9/KUtAHzNBk0v3x0= X-MC-Unique: GKwmG4zqNNu65GZEpYp9Cw-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 03/11] block-backend: replace bdrv_*_above with blk_*_above Date: Wed, 16 Nov 2022 07:22:33 -0500 Message-Id: <20221116122241.2856527-4-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601740267100001 Content-Type: text/plain; charset="utf-8" Avoid mixing bdrv_* functions with blk_*, so create blk_* counterparts for: - bdrv_block_status_above - bdrv_is_allocated_above Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 21 +++++++++++++++++++++ block/commit.c | 4 ++-- include/sysemu/block-backend-io.h | 9 +++++++++ nbd/server.c | 28 ++++++++++++++-------------- qemu-img.c | 4 ++-- 5 files changed, 48 insertions(+), 18 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 742efa7955..333d50fb3f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1424,6 +1424,27 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, i= nt64_t offset, return blk_co_pwritev_part(blk, offset, bytes, qiov, 0, flags); } =20 +int coroutine_fn blk_block_status_above(BlockBackend *blk, + BlockDriverState *base, + int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file) +{ + IO_CODE(); + return bdrv_block_status_above(blk_bs(blk), base, offset, bytes, pnum,= map, + file); +} + +int coroutine_fn blk_is_allocated_above(BlockBackend *blk, + BlockDriverState *base, + bool include_base, int64_t offset, + int64_t bytes, int64_t *pnum) +{ + IO_CODE(); + return bdrv_is_allocated_above(blk_bs(blk), base, include_base, offset, + bytes, pnum); +} + typedef struct BlkRwCo { BlockBackend *blk; int64_t offset; diff --git a/block/commit.c b/block/commit.c index 0029b31944..9d4d908344 100644 --- a/block/commit.c +++ b/block/commit.c @@ -155,8 +155,8 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) break; } /* Copy if allocated above the base */ - ret =3D bdrv_is_allocated_above(blk_bs(s->top), s->base_overlay, t= rue, - offset, COMMIT_BUFFER_SIZE, &n); + ret =3D blk_is_allocated_above(s->top, s->base_overlay, true, + offset, COMMIT_BUFFER_SIZE, &n); copy =3D (ret > 0); trace_commit_one_iteration(s, offset, n, ret); if (copy) { diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 50f5aa2e07..a47cb825e5 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -92,6 +92,15 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in,= int64_t off_in, int64_t bytes, BdrvRequestFlags read_fl= ags, BdrvRequestFlags write_flags); =20 +int coroutine_fn blk_block_status_above(BlockBackend *blk, + BlockDriverState *base, + int64_t offset, int64_t bytes, + int64_t *pnum, int64_t *map, + BlockDriverState **file); +int coroutine_fn blk_is_allocated_above(BlockBackend *blk, + BlockDriverState *base, + bool include_base, int64_t offset, + int64_t bytes, int64_t *pnum); =20 /* * "I/O or GS" API functions. These functions can run without diff --git a/nbd/server.c b/nbd/server.c index e2eec0cf46..6389b46396 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1991,7 +1991,7 @@ static int coroutine_fn nbd_co_send_structured_error(= NBDClient *client, } =20 /* Do a sparse read and send the structured reply to the client. - * Returns -errno if sending fails. bdrv_block_status_above() failure is + * Returns -errno if sending fails. blk_block_status_above() failure is * reported to the client, at which point this function succeeds. */ static int coroutine_fn nbd_co_send_sparse_read(NBDClient *client, @@ -2007,10 +2007,10 @@ static int coroutine_fn nbd_co_send_sparse_read(NBD= Client *client, =20 while (progress < size) { int64_t pnum; - int status =3D bdrv_block_status_above(blk_bs(exp->common.blk), NU= LL, - offset + progress, - size - progress, &pnum, NULL, - NULL); + int status =3D blk_block_status_above(exp->common.blk, NULL, + offset + progress, + size - progress, &pnum, NULL, + NULL); bool final; =20 if (status < 0) { @@ -2141,14 +2141,14 @@ static int nbd_extent_array_add(NBDExtentArray *ea, return 0; } =20 -static int coroutine_fn blockstatus_to_extents(BlockDriverState *bs, +static int coroutine_fn blockstatus_to_extents(BlockBackend *blk, uint64_t offset, uint64_t b= ytes, NBDExtentArray *ea) { while (bytes) { uint32_t flags; int64_t num; - int ret =3D bdrv_block_status_above(bs, NULL, offset, bytes, &num, + int ret =3D blk_block_status_above(blk, NULL, offset, bytes, &num, NULL, NULL); =20 if (ret < 0) { @@ -2169,13 +2169,13 @@ static int coroutine_fn blockstatus_to_extents(Bloc= kDriverState *bs, return 0; } =20 -static int coroutine_fn blockalloc_to_extents(BlockDriverState *bs, +static int coroutine_fn blockalloc_to_extents(BlockBackend *blk, uint64_t offset, uint64_t by= tes, NBDExtentArray *ea) { while (bytes) { int64_t num; - int ret =3D bdrv_is_allocated_above(bs, NULL, false, offset, bytes, + int ret =3D blk_is_allocated_above(blk, NULL, false, offset, bytes, &num); =20 if (ret < 0) { @@ -2224,7 +2224,7 @@ static int nbd_co_send_extents(NBDClient *client, uin= t64_t handle, /* Get block status from the exported device and send it to the client */ static int coroutine_fn nbd_co_send_block_status(NBDClient *client, uint64_t handle, - BlockDriverState *bs, uint64_t offse= t, + BlockBackend *blk, uint64_t offset, uint32_t length, bool dont_fragment, bool last, uint32_t context_id, Error **errp) @@ -2234,9 +2234,9 @@ coroutine_fn nbd_co_send_block_status(NBDClient *clie= nt, uint64_t handle, g_autoptr(NBDExtentArray) ea =3D nbd_extent_array_new(nb_extents); =20 if (context_id =3D=3D NBD_META_ID_BASE_ALLOCATION) { - ret =3D blockstatus_to_extents(bs, offset, length, ea); + ret =3D blockstatus_to_extents(blk, offset, length, ea); } else { - ret =3D blockalloc_to_extents(bs, offset, length, ea); + ret =3D blockalloc_to_extents(blk, offset, length, ea); } if (ret < 0) { return nbd_co_send_structured_error( @@ -2563,7 +2563,7 @@ static coroutine_fn int nbd_handle_request(NBDClient = *client, =20 if (client->export_meta.base_allocation) { ret =3D nbd_co_send_block_status(client, request->handle, - blk_bs(exp->common.blk), + exp->common.blk, request->from, request->len, dont_fragment, !--contexts_remaining, @@ -2576,7 +2576,7 @@ static coroutine_fn int nbd_handle_request(NBDClient = *client, =20 if (client->export_meta.allocation_depth) { ret =3D nbd_co_send_block_status(client, request->handle, - blk_bs(exp->common.blk), + exp->common.blk, request->from, request->len, dont_fragment, !--contexts_remaining, diff --git a/qemu-img.c b/qemu-img.c index a3b64c88af..4282a34bc0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1730,8 +1730,8 @@ static int convert_iteration_sectors(ImgConvertState = *s, int64_t sector_num) do { count =3D n * BDRV_SECTOR_SIZE; =20 - ret =3D bdrv_block_status_above(src_bs, base, offset, count, &= count, - NULL, NULL); + ret =3D bdrv_block_status_above(src_bs, base, offset, count, + &count, NULL, NULL); =20 if (ret < 0) { if (s->salvage) { --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601830; cv=none; d=zohomail.com; s=zohoarc; b=kDv6UQ1bLAXasfaI3EJB0waiK5kWWrzIbO9R2cMTl8xUCVAw3iZqDzYEoKb1ZnXRUzDIjRf9m1+TJIGF2+aHZlth5Mcg37oTug22GD0eDlhhBF6TYAHIOyUrPM8wdZiGAhv+r9tqKotpRXTeu5c05rIY9Jf77NgUazEjzjFdRGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601830; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CqI1u5ra27yhYXgdDyITKa7+J+uNHbpH9ovZo1Jgq+o=; b=I2uxCRoinxudNAAXTKqUtwSNI2sPT+jKNN7ndAIV5h7YLc0nvX1htvWUQ996fWR5ddRXA81HPL4HVdVPvhT8mFvKRy8yC+1FA1j/tDoYraADip05iCBVtdSCsaGSpGgvTBq1mTYxmIpuBLYdZTq/qVuU8s04LoY3b/9jaI32Jvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166860183064528.927986855700055; Wed, 16 Nov 2022 04:30:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRZ-0000iR-2n; Wed, 16 Nov 2022 07:23:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRN-0000dR-4F for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRJ-0000uM-Uk for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:52 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-DkFlK0EAONSN1dCFirIPKQ-1; Wed, 16 Nov 2022 07:22:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C4533C1022F; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4A2F9E70; Wed, 16 Nov 2022 12:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CqI1u5ra27yhYXgdDyITKa7+J+uNHbpH9ovZo1Jgq+o=; b=NM6jLc/wvBJ1ROJFfubWowlzjYkhwN1rnPmypEuv6JG9DoE7zVKnM59RF07R3gUOh+owpa EVOkvPhETqt8DlUKk/KARpUwHI4BqY7R3u1g3fV6QedEIpU70HAmieEmxzjacYhlWD2uP+ W7sRHq96mSr5hLprYzFa4gk48vzW3Qs= X-MC-Unique: DkFlK0EAONSN1dCFirIPKQ-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 04/11] block-coroutine-wrapper.py: introduce generated_co_wrapper_simple Date: Wed, 16 Nov 2022 07:22:34 -0500 Message-Id: <20221116122241.2856527-5-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601832695100003 Content-Type: text/plain; charset="utf-8" This new annotation creates just a function wrapper that creates a new coroutine. It assumes the caller is not a coroutine. This is much better as g_c_w, because it is clear if the caller is a coroutine or not, and provides the advantage of automating the code creation. In the future all g_c_w functions will be substituted on g_c_w_simple. Signed-off-by: Emanuele Giuseppe Esposito --- include/block/block-common.h | 1 + scripts/block-coroutine-wrapper.py | 87 ++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/include/block/block-common.h b/include/block/block-common.h index 297704c1e9..8ae750c7cf 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -43,6 +43,7 @@ * Read more in docs/devel/block-coroutine-wrapper.rst */ #define generated_co_wrapper +#define generated_co_wrapper_simple =20 /* block.c */ typedef struct BlockDriver BlockDriver; diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-w= rapper.py index 08be813407..f88ef53964 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -62,10 +62,15 @@ def __init__(self, param_decl: str) -> None: =20 =20 class FuncDecl: - def __init__(self, return_type: str, name: str, args: str) -> None: + def __init__(self, return_type: str, name: str, args: str, + variant: str) -> None: self.return_type =3D return_type.strip() self.name =3D name.strip() self.args =3D [ParamDecl(arg.strip()) for arg in args.split(',')] + self.create_only_co =3D False + + if variant =3D=3D '_simple': + self.create_only_co =3D True =20 def gen_list(self, format: str) -> str: return ', '.join(format.format_map(arg.__dict__) for arg in self.a= rgs) @@ -75,7 +80,8 @@ def gen_block(self, format: str) -> str: =20 =20 # Match wrappers declared with a generated_co_wrapper mark -func_decl_re =3D re.compile(r'^int\s*generated_co_wrapper\s*' +func_decl_re =3D re.compile(r'^int\s*generated_co_wrapper' + r'(?P(_[a-z][a-z0-9_]*)?)\s*' r'(?P[a-z][a-z0-9_]*)' r'\((?P[^)]*)\);$', re.MULTILINE) =20 @@ -84,7 +90,8 @@ def func_decl_iter(text: str) -> Iterator: for m in func_decl_re.finditer(text): yield FuncDecl(return_type=3D'int', name=3Dm.group('wrapper_name'), - args=3Dm.group('args')) + args=3Dm.group('args'), + variant=3Dm.group('variant')) =20 =20 def snake_to_camel(func_name: str) -> str: @@ -97,6 +104,51 @@ def snake_to_camel(func_name: str) -> str: return ''.join(words) =20 =20 +# Checks if we are already in coroutine +def create_g_c_w(func: FuncDecl) -> str: + name =3D func.co_name + struct_name =3D func.struct_name + return f"""\ +int {func.name}({ func.gen_list('{decl}') }) +{{ + if (qemu_in_coroutine()) {{ + return {name}({ func.gen_list('{name}') }); + }} else {{ + {struct_name} s =3D {{ + .poll_state.bs =3D {func.bs}, + .poll_state.in_progress =3D true, + +{ func.gen_block(' .{name} =3D {name},') } + }}; + + s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); + + return bdrv_poll_co(&s.poll_state); + }} +}}""" + + +# Assumes we are not in coroutine, and creates one +def create_coroutine_only(func: FuncDecl) -> str: + name =3D func.co_name + struct_name =3D func.struct_name + return f"""\ +int {func.name}({ func.gen_list('{decl}') }) +{{ + assert(!qemu_in_coroutine()); + {struct_name} s =3D {{ + .poll_state.bs =3D {func.bs}, + .poll_state.in_progress =3D true, + +{ func.gen_block(' .{name} =3D {name},') } + }}; + + s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); + + return bdrv_poll_co(&s.poll_state); +}}""" + + def gen_wrapper(func: FuncDecl) -> str: assert not '_co_' in func.name assert func.return_type =3D=3D 'int' @@ -105,7 +157,8 @@ def gen_wrapper(func: FuncDecl) -> str: =20 subsystem, subname =3D func.name.split('_', 1) =20 - name =3D f'{subsystem}_co_{subname}' + func.co_name =3D f'{subsystem}_co_{subname}' + name =3D func.co_name =20 t =3D func.args[0].type if t =3D=3D 'BlockDriverState *': @@ -114,7 +167,13 @@ def gen_wrapper(func: FuncDecl) -> str: bs =3D 'child->bs' else: bs =3D 'blk_bs(blk)' - struct_name =3D snake_to_camel(name) + func.bs =3D bs + func.struct_name =3D snake_to_camel(func.name) + struct_name =3D func.struct_name + + creation_function =3D create_g_c_w + if func.create_only_co: + creation_function =3D create_coroutine_only =20 return f"""\ /* @@ -136,23 +195,7 @@ def gen_wrapper(func: FuncDecl) -> str: aio_wait_kick(); }} =20 -int {func.name}({ func.gen_list('{decl}') }) -{{ - if (qemu_in_coroutine()) {{ - return {name}({ func.gen_list('{name}') }); - }} else {{ - {struct_name} s =3D {{ - .poll_state.bs =3D {bs}, - .poll_state.in_progress =3D true, - -{ func.gen_block(' .{name} =3D {name},') } - }}; - - s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); - - return bdrv_poll_co(&s.poll_state); - }} -}}""" +{creation_function(func)}""" =20 =20 def gen_wrappers(input_code: str) -> str: --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601422; cv=none; d=zohomail.com; s=zohoarc; b=NRc/wtQOpzDnSqiFkMOlXeWJQG2uqsFnQ6Fu12nqVlZb7nucGHQzJfOgJWnuIKOMX9FZSKt9o8/eGQQtnfyP1HscDFImul7CnvK8fTgRuvuVLsKaVkDjzyb/nk4MvompqwmDPHqh6MX23yzZRHyC2nDEPwrpiVihlEkegpvMPoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601422; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/tTnM1xa2SDFzEvr4q6j3hZn+n0IfuXdYw6QCt9sgjc=; b=ImtnlqbLc2gp/ulPYu+lQTVitcbSyWKCqKHglu2mnMPrs5dzx844bF4RzM+pceYU2Xt4nPrExIsxJ+d3ftPVPS/pex9mu/sZLk0W7raIAW03bEsPZchGCnFHvDOR5mSfKbZCpUU8GNHvAtpVPZgZUw3dnfJDMeuWEUsy+uOb+q8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601422391293.71851694055886; Wed, 16 Nov 2022 04:23:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRb-0000lM-Ib; Wed, 16 Nov 2022 07:23:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRR-0000gu-TK for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRJ-0000uZ-Na for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:57 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-4sfOFVZ_N36gVxRdEaMluw-1; Wed, 16 Nov 2022 07:22:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 511AC38173CB; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1520D17595; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/tTnM1xa2SDFzEvr4q6j3hZn+n0IfuXdYw6QCt9sgjc=; b=LGIkPRrSOOLRFfTu4Ko3wHEW0DPHqVwJALi3wE9ev9y7hMGBtb2DMC8oTDwrBOv610tUtS hHeOF38Yxro0otXWCABU3h9hCDunxNOpzH/SYyAAvKQWvt6bWjNRUV4MyTa+Yz6i+/OM1d sSp9Qo9cyp5DlBfbQSeMUGuumplO7k4= X-MC-Unique: 4sfOFVZ_N36gVxRdEaMluw-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 05/11] block-coroutine-wrapper.py: default to main loop aiocontext if function does not have a BlockDriverState parameter Date: Wed, 16 Nov 2022 07:22:35 -0500 Message-Id: <20221116122241.2856527-6-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601423436100003 Content-Type: text/plain; charset="utf-8" Basically BdrvPollCo->bs is only used by bdrv_poll_co(), and the functions that it uses are both using bdrv_get_aio_context, that defaults to qemu_get_aio_context() if bs is NULL. Therefore pass NULL to BdrvPollCo to automatically generate a function that create and runs a coroutine in the main loop. Signed-off-by: Emanuele Giuseppe Esposito --- scripts/block-coroutine-wrapper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-w= rapper.py index f88ef53964..0f842386d4 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -152,8 +152,6 @@ def create_coroutine_only(func: FuncDecl) -> str: def gen_wrapper(func: FuncDecl) -> str: assert not '_co_' in func.name assert func.return_type =3D=3D 'int' - assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *', - 'BlockBackend *'] =20 subsystem, subname =3D func.name.split('_', 1) =20 @@ -165,8 +163,10 @@ def gen_wrapper(func: FuncDecl) -> str: bs =3D 'bs' elif t =3D=3D 'BdrvChild *': bs =3D 'child->bs' - else: + elif t =3D=3D 'BlockBackend *': bs =3D 'blk_bs(blk)' + else: + bs =3D 'NULL' func.bs =3D bs func.struct_name =3D snake_to_camel(func.name) struct_name =3D func.struct_name --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601417; cv=none; d=zohomail.com; s=zohoarc; b=M4rWNDr0M0cLFKoJ8zz86qFcjWu4HsoapLPjwYlNoZppr7zdUO0ehYisvE8L2zgd3qvFHRhr5ZCSXLh4ynW9HiUp4u5xLnpZXr9zhBzo2vvrteom75YZs+bnnIITRqIqnzs4VDskYinj9deSMcVm6mc8fhQZbMkOzxBkStNUpmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601417; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OtMeYc3r07Ov/U9gk6yyguEB1DrHpg8GHd8+1KPRhv0=; b=b9AWXwh6lpA3nxx1WUMNZmcS6cCCwAplaxPAqatr5mCt02XsR3bVLC/sRQoSh0ihMVP9RzYnABXMfu8P/5RxeuMZsOkEPs55WEQRsOa+CLJv1RDq2CwIhFXDYU8FB6KdbGYHtETTsFldstAPbWbtB27L+cxnbzc1+0R5DJkAOrc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601417546227.22171357997854; Wed, 16 Nov 2022 04:23:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRU-0000iN-Co; Wed, 16 Nov 2022 07:23:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRO-0000ec-Uw for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRL-0000ui-1W for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:54 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-FAW7tUnQM5Ob_tdiB5HR7A-1; Wed, 16 Nov 2022 07:22:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 981848001B8; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A36B9E70; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtMeYc3r07Ov/U9gk6yyguEB1DrHpg8GHd8+1KPRhv0=; b=dMmN5kPe/r0/IPDKJrsBF3/Yz8/ViVlXIKDK1IXdIxHgIZ6xPw6lpEto4Yf3R3H8otrh0r /vSUd9PN+eXa4GQxa2EpyawmMXCKfqS7s6An9QAJsHnakvJ2Z4hJ1VDhCT6E1rqqXUWyxy dZEgfVoemsxAluLTP7fG4AmWMjFjn+4= X-MC-Unique: FAW7tUnQM5Ob_tdiB5HR7A-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 06/11] block-coroutine-wrapper.py: support also basic return types Date: Wed, 16 Nov 2022 07:22:36 -0500 Message-Id: <20221116122241.2856527-7-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601419117100007 Content-Type: text/plain; charset="utf-8" Extend the regex to cover also return type, pointers included. This implies that the value returned by the function cannot be a simple "int" anymore, but the custom return type. Therefore remove poll_state->ret and instead use a per-function custom "ret" field. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block/block-gen.h | 5 +---- scripts/block-coroutine-wrapper.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/block/block-gen.h b/block/block-gen.h index f80cf4897d..8ac9d5bd4f 100644 --- a/block/block-gen.h +++ b/block/block-gen.h @@ -32,18 +32,15 @@ typedef struct BdrvPollCo { BlockDriverState *bs; bool in_progress; - int ret; Coroutine *co; /* Keep pointer here for debugging */ } BdrvPollCo; =20 -static inline int bdrv_poll_co(BdrvPollCo *s) +static inline void bdrv_poll_co(BdrvPollCo *s) { assert(!qemu_in_coroutine()); =20 bdrv_coroutine_enter(s->bs, s->co); BDRV_POLL_WHILE(s->bs, s->in_progress); - - return s->ret; } =20 #endif /* BLOCK_BLOCK_GEN_H */ diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-w= rapper.py index 0f842386d4..21ecb3e896 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -80,7 +80,8 @@ def gen_block(self, format: str) -> str: =20 =20 # Match wrappers declared with a generated_co_wrapper mark -func_decl_re =3D re.compile(r'^int\s*generated_co_wrapper' +func_decl_re =3D re.compile(r'^(?P[a-zA-Z][a-zA-Z0-9_]* [*]?)' + r'\s*generated_co_wrapper' r'(?P(_[a-z][a-z0-9_]*)?)\s*' r'(?P[a-z][a-z0-9_]*)' r'\((?P[^)]*)\);$', re.MULTILINE) @@ -88,7 +89,7 @@ def gen_block(self, format: str) -> str: =20 def func_decl_iter(text: str) -> Iterator: for m in func_decl_re.finditer(text): - yield FuncDecl(return_type=3D'int', + yield FuncDecl(return_type=3Dm.group('return_type'), name=3Dm.group('wrapper_name'), args=3Dm.group('args'), variant=3Dm.group('variant')) @@ -109,7 +110,7 @@ def create_g_c_w(func: FuncDecl) -> str: name =3D func.co_name struct_name =3D func.struct_name return f"""\ -int {func.name}({ func.gen_list('{decl}') }) +{func.return_type} {func.name}({ func.gen_list('{decl}') }) {{ if (qemu_in_coroutine()) {{ return {name}({ func.gen_list('{name}') }); @@ -123,7 +124,8 @@ def create_g_c_w(func: FuncDecl) -> str: =20 s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); =20 - return bdrv_poll_co(&s.poll_state); + bdrv_poll_co(&s.poll_state); + return s.ret; }} }}""" =20 @@ -133,7 +135,7 @@ def create_coroutine_only(func: FuncDecl) -> str: name =3D func.co_name struct_name =3D func.struct_name return f"""\ -int {func.name}({ func.gen_list('{decl}') }) +{func.return_type} {func.name}({ func.gen_list('{decl}') }) {{ assert(!qemu_in_coroutine()); {struct_name} s =3D {{ @@ -145,13 +147,13 @@ def create_coroutine_only(func: FuncDecl) -> str: =20 s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); =20 - return bdrv_poll_co(&s.poll_state); + bdrv_poll_co(&s.poll_state); + return s.ret; }}""" =20 =20 def gen_wrapper(func: FuncDecl) -> str: assert not '_co_' in func.name - assert func.return_type =3D=3D 'int' =20 subsystem, subname =3D func.name.split('_', 1) =20 @@ -182,6 +184,7 @@ def gen_wrapper(func: FuncDecl) -> str: =20 typedef struct {struct_name} {{ BdrvPollCo poll_state; + {func.return_type} ret; { func.gen_block(' {decl};') } }} {struct_name}; =20 @@ -189,7 +192,7 @@ def gen_wrapper(func: FuncDecl) -> str: {{ {struct_name} *s =3D opaque; =20 - s->poll_state.ret =3D {name}({ func.gen_list('s->{name}') }); + s->ret =3D {name}({ func.gen_list('s->{name}') }); s->poll_state.in_progress =3D false; =20 aio_wait_kick(); --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601513; cv=none; d=zohomail.com; s=zohoarc; b=AX2wJAbceXP/hyJ+ZuWeuTLiIgcG7+bY22MuAB7nIDgaaQYPzq8l4AWveuf2RAeoUjygTrgI1u0qEUqCyoZfQZEEFLFffhIFXhPFDHUyBDk3Q4kU+uz7DteHydPdLxSG8yGes5EH39Z8uGygdWi6+i137GHqW6JGUl2U6ro8Veo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601513; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j9YoMuW7ncHC3ohg3wqBTg/h0labHb8rl1YjdLKA5I4=; b=Cx2s9sEnx1ra6ipOq+fh2I0+erXrftfidmQhIVNAJN0vEJ5l4kwU8fklJSStQkJGHK4b9LlBW243a0OvePMJdcOg1A7QSKsulfpqM3Zy6J8vHHHI+plDnRu7sgczecwmOjI0MXqHjWQSA83N3K4rRjmHEYkVxlLi4HPbrWTht1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601513208695.6047083421248; Wed, 16 Nov 2022 04:25:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRT-0000i9-PZ; Wed, 16 Nov 2022 07:22:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRO-0000eZ-PD for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRL-0000up-1Z for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:54 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-fAEn-k4FM8mmz5v3_UFRkQ-1; Wed, 16 Nov 2022 07:22:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD04A3C10224; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A14199E70; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j9YoMuW7ncHC3ohg3wqBTg/h0labHb8rl1YjdLKA5I4=; b=AqZrZ5ZdKmITZk+nfcnp65gzfnkeGLaLprFdTaZWY/QPhu5EeAzflr/HrFvPbSZhI3d0vC SUhOBDKLHxr0xQYsJeArNERQF/YnB71P2q5+XYetigPlNZ3RpBe2IKWPQgDLnupPmfhGYL PZsFScEEJYciLDv2qBgjfChJ/ImF2R4= X-MC-Unique: fAEn-k4FM8mmz5v3_UFRkQ-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 07/11] block/vmdk: add missing coroutine_fn annotations Date: Wed, 16 Nov 2022 07:22:37 -0500 Message-Id: <20221116122241.2856527-8-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601513672100001 Content-Type: text/plain; charset="utf-8" These functions end up calling bdrv_create() implemented as generated_co_wr= apper functions. In addition, they also happen to be always called in coroutine context, meaning all callers are coroutine_fn. This means that the g_c_w function will enter the qemu_in_coroutine() case and eventually suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block/vmdk.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 26376352b9..0c32bf2e83 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2285,10 +2285,11 @@ exit: return ret; } =20 -static int vmdk_create_extent(const char *filename, int64_t filesize, - bool flat, bool compress, bool zeroed_grain, - BlockBackend **pbb, - QemuOpts *opts, Error **errp) +static int coroutine_fn vmdk_create_extent(const char *filename, + int64_t filesize, bool flat, + bool compress, bool zeroed_grai= n, + BlockBackend **pbb, + QemuOpts *opts, Error **errp) { int ret; BlockBackend *blk =3D NULL; @@ -2366,14 +2367,14 @@ static int filename_decompose(const char *filename,= char *path, char *prefix, * non-split format. * idx >=3D 1: get the n-th extent if in a split subformat */ -typedef BlockBackend *(*vmdk_create_extent_fn)(int64_t size, - int idx, - bool flat, - bool split, - bool compress, - bool zeroed_grain, - void *opaque, - Error **errp); +typedef BlockBackend * coroutine_fn (*vmdk_create_extent_fn)(int64_t size, + int idx, + bool flat, + bool split, + bool compress, + bool zeroed_g= rain, + void *opaque, + Error **errp); =20 static void vmdk_desc_add_extent(GString *desc, const char *extent_line_fmt, @@ -2616,7 +2617,7 @@ typedef struct { QemuOpts *opts; } VMDKCreateOptsData; =20 -static BlockBackend *vmdk_co_create_opts_cb(int64_t size, int idx, +static BlockBackend * coroutine_fn vmdk_co_create_opts_cb(int64_t size, in= t idx, bool flat, bool split, bool co= mpress, bool zeroed_grain, void *opaqu= e, Error **errp) @@ -2768,10 +2769,11 @@ exit: return ret; } =20 -static BlockBackend *vmdk_co_create_cb(int64_t size, int idx, - bool flat, bool split, bool compres= s, - bool zeroed_grain, void *opaque, - Error **errp) +static BlockBackend * coroutine_fn vmdk_co_create_cb(int64_t size, int idx, + bool flat, bool split, + bool compress, + bool zeroed_grain, + void *opaque, Error *= *errp) { int ret; BlockDriverState *bs; --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601464; cv=none; d=zohomail.com; s=zohoarc; b=keochHNuX/wiuTTxFt0NuObfKZ5AW4uvGx0tLFEK6cTq5VXFvSCF1521K9aVnrvYqnelm5FFGCS+Cbu+KV0fnl4TNroC2bckY1LtiawBU91lYllREZRZdUqGkfPUHPx0mFsSYzYL31+AAwqWBqnfd+6QkYnyiT0sjVreHqj4I7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601464; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5NGxTii04B+hdUeAw/OVSdOoNnZ0C0E9Y8mu6Pzt0g4=; b=LWu+zEj4RE7nQ+NYW+4kPgLzyWh987num9RJZQ9VQ/GUFHSDORI/3OdpsPRQXzAlI5LL/TaaEVxw6qXmbfOvZe61f6fF4C3F66q+oiUe+jd+QE+OfyQhIu3ZB2B/HLOoVHsMtrEEmTQVLN785hWUBHBYeCzEr0eR5cuaXes7IEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601464234495.0556932857352; Wed, 16 Nov 2022 04:24:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRc-0000lz-TE; Wed, 16 Nov 2022 07:23:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRQ-0000fe-4T for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRM-0000wK-9h for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:55 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-Mp1vX58oORu-A7xT18T_lg-1; Wed, 16 Nov 2022 07:22:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2E47885A59D; Wed, 16 Nov 2022 12:22:46 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E62F79E70; Wed, 16 Nov 2022 12:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5NGxTii04B+hdUeAw/OVSdOoNnZ0C0E9Y8mu6Pzt0g4=; b=WaBJWMmtW94Ic436g3ugdLTO47avKshKGbgEEjVj75KK+zY8aTPP9/Cn1hhpAmeYk2qhUT SHl8yehQkw9IO9n+OnRSeCwILflBH9YYZDyhLnFjyW1FDG2i4kj2cCLvL/CTCq/+e7R3is 3V/OzkSt5sR0h4jATLLLIgE8wGffKXQ= X-MC-Unique: Mp1vX58oORu-A7xT18T_lg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 08/11] block: distinguish between bdrv_create running in coroutine and not Date: Wed, 16 Nov 2022 07:22:38 -0500 Message-Id: <20221116122241.2856527-9-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601465394100007 Content-Type: text/plain; charset="utf-8" Call two different functions depending on whether bdrv_create is in coroutine or not, following the same pattern as generated_co_wrapper functions. This allows to also call the coroutine function directly, without using CreateCo or relying in bdrv_create(). Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 76 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/block.c b/block.c index 577639c7e0..c610a32e77 100644 --- a/block.c +++ b/block.c @@ -528,66 +528,66 @@ typedef struct CreateCo { Error *err; } CreateCo; =20 -static void coroutine_fn bdrv_create_co_entry(void *opaque) +static int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filen= ame, + QemuOpts *opts, Error **errp) { - Error *local_err =3D NULL; int ret; + char *filename_copy; + GLOBAL_STATE_CODE(); + assert(*errp =3D=3D NULL); + assert(drv); + + if (!drv->bdrv_co_create_opts) { + error_setg(errp, "Driver '%s' does not support image creation", + drv->format_name); + return -ENOTSUP; + } =20 + filename_copy =3D g_strdup(filename); + ret =3D drv->bdrv_co_create_opts(drv, filename_copy, opts, errp); + + if (ret < 0 && !*errp) { + error_setg_errno(errp, -ret, "Could not create image"); + } + + g_free(filename_copy); + return ret; +} + +static void coroutine_fn bdrv_create_co_entry(void *opaque) +{ CreateCo *cco =3D opaque; - assert(cco->drv); GLOBAL_STATE_CODE(); =20 - ret =3D cco->drv->bdrv_co_create_opts(cco->drv, - cco->filename, cco->opts, &local_e= rr); - error_propagate(&cco->err, local_err); - cco->ret =3D ret; + cco->ret =3D bdrv_co_create(cco->drv, cco->filename, cco->opts, &cco->= err); } =20 int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts, Error **errp) { - int ret; - GLOBAL_STATE_CODE(); =20 - Coroutine *co; - CreateCo cco =3D { - .drv =3D drv, - .filename =3D g_strdup(filename), - .opts =3D opts, - .ret =3D NOT_DONE, - .err =3D NULL, - }; - - if (!drv->bdrv_co_create_opts) { - error_setg(errp, "Driver '%s' does not support image creation", dr= v->format_name); - ret =3D -ENOTSUP; - goto out; - } - if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ - bdrv_create_co_entry(&cco); + return bdrv_co_create(drv, filename, opts, errp); } else { + Coroutine *co; + CreateCo cco =3D { + .drv =3D drv, + .filename =3D filename, + .opts =3D opts, + .ret =3D NOT_DONE, + .err =3D NULL, + }; + co =3D qemu_coroutine_create(bdrv_create_co_entry, &cco); qemu_coroutine_enter(co); while (cco.ret =3D=3D NOT_DONE) { aio_poll(qemu_get_aio_context(), true); } + error_propagate(errp, cco.err); + return cco.ret; } - - ret =3D cco.ret; - if (ret < 0) { - if (cco.err) { - error_propagate(errp, cco.err); - } else { - error_setg_errno(errp, -ret, "Could not create image"); - } - } - -out: - g_free(cco.filename); - return ret; } =20 /** --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601462; cv=none; d=zohomail.com; s=zohoarc; b=nNi3af4j9J9ViDHIU7S0hWaA25ydInwWZQZblc4I2lFuqpfuTpz3g6+bVVNClUC29ku9VDlr79kfHoec+iyAq/qMHMb7jb+qnR7G0SxyHW6ZXbVVrR8LHniZmPHCMcYELRBAH/uzm3mF4Da6bKbBYNc3qeWXzgTwW4PntJgmH6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601462; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e/icbMw3vJn19CWAA2NfbCl2FqeUTzb2udfDHum2cnc=; b=bhr/1h6ma5CKfqppdnlcLQsiC1tVxmISaz8qgBZx+K/PHAo2cKkfNWWrVK0z2OLSJ08j2fx1rnATyh7OFRk1BJ65CAGc2dbF9w2VNPh1Nxk6LxlGGkMOR+JcU7UVzc3O12pcOC/fxSzoWKL6ugyYWF3ZkOZ9SYLCGmFr2IJ26G4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166860146221236.84893853273513; Wed, 16 Nov 2022 04:24:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRR-0000fd-8t; Wed, 16 Nov 2022 07:22:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRO-0000du-6A for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRK-0000vb-Vc for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:53 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-BFxCPF49MpmfQdX9hja7HA-1; Wed, 16 Nov 2022 07:22:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7277C882820; Wed, 16 Nov 2022 12:22:46 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36DD89E70; Wed, 16 Nov 2022 12:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e/icbMw3vJn19CWAA2NfbCl2FqeUTzb2udfDHum2cnc=; b=On7e4dBQXlUmMKg2nKJAM+wb9rlK3sNS8clrILlvEF3TELym0QpC/L4Y8I47hJB2QqMPal wDqlUPDYgpJ/2xz+aWLW2cuYTONt9AX/cKTWxdfnR/NzW3c1l4JtdXRBzNNjdc9bE98Rdt ZkQ1veqzXzkCkQF1vMvIyRJGRGD59xw= X-MC-Unique: BFxCPF49MpmfQdX9hja7HA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 09/11] block: bdrv_create_file is a coroutine_fn Date: Wed, 16 Nov 2022 07:22:39 -0500 Message-Id: <20221116122241.2856527-10-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601463523100003 Content-Type: text/plain; charset="utf-8" It is always called in coroutine_fn callbacks, therefore it can directly call bdrv_co_create(). Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 6 ++++-- include/block/block-global-state.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index c610a32e77..7a4c3eb540 100644 --- a/block.c +++ b/block.c @@ -534,6 +534,7 @@ static int coroutine_fn bdrv_co_create(BlockDriver *drv= , const char *filename, int ret; char *filename_copy; GLOBAL_STATE_CODE(); + assert(qemu_in_coroutine()); assert(*errp =3D=3D NULL); assert(drv); =20 @@ -725,7 +726,8 @@ out: return ret; } =20 -int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp) +int coroutine_fn bdrv_create_file(const char *filename, QemuOpts *opts, + Error **errp) { QemuOpts *protocol_opts; BlockDriver *drv; @@ -766,7 +768,7 @@ int bdrv_create_file(const char *filename, QemuOpts *op= ts, Error **errp) goto out; } =20 - ret =3D bdrv_create(drv, filename, protocol_opts, errp); + ret =3D bdrv_co_create(drv, filename, protocol_opts, errp); out: qemu_opts_del(protocol_opts); qobject_unref(qdict); diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index 00e0cf8aea..6f35ed99e3 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -57,7 +57,8 @@ BlockDriver *bdrv_find_protocol(const char *filename, BlockDriver *bdrv_find_format(const char *format_name); int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts, Error **errp); -int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); +int coroutine_fn bdrv_create_file(const char *filename, QemuOpts *opts, + Error **errp); =20 BlockDriverState *bdrv_new(void); int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668601574; cv=none; d=zohomail.com; s=zohoarc; b=mR0XMnyu9Vr6O3Bx9kRTEWtmga2YPqfvc2RIartG9xTJQP5yAkRqqKBuI8bUFJdjVDbfNVKyuH730ghYnDn8BXx9SktGI6CLNG1HBo5NUSC6s2y5JccORYbcOwX7az0FVKnZnvl9j5f3PJtvA4/pj+njAWSNVNdADiDVyiD0zuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668601574; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qw9glPwvAFH4PaG9gpOC8GJVR/OQjC3FLOWikmUfLto=; b=Y7u23u0rncVYvrGCeDI8ERCPKyRkj3e5oibLJA2p7oHOpIejHXGsQCnx7zRZpeM2nSBKZVfE5R6fM9yLTe17RagBASd0rpsSHy+t+ex/6PsR+98SJqKY9jmz0gRO7AAMos4/2V7jQSTTB8fRGt7vTrtOYLOgDlgaBGQypfsiyR4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668601574100360.21822741757944; Wed, 16 Nov 2022 04:26:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRQ-0000fN-J8; Wed, 16 Nov 2022 07:22:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRM-0000dQ-Tl for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRK-0000uE-2D for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:52 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-464-PDliOkPCPwe9BSLblYGHMA-1; Wed, 16 Nov 2022 07:22:47 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B778A3C10222; Wed, 16 Nov 2022 12:22:46 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BC8D9E70; Wed, 16 Nov 2022 12:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qw9glPwvAFH4PaG9gpOC8GJVR/OQjC3FLOWikmUfLto=; b=F3FCL+jUwmim6EQ2u9GPJ02hQt8TNOOxcAywMliCeZEza61G1NnskKzCuFR5s2BYihm4+P xyAenHtVkzfitDtf+tUQ3v7oqkxhyj9Q4LXe/83vHd+P0descPJM3H3Cao+eKPB38S3AIw dtGB47Tux97RhMqSZkCZx2cKO4NzCUg= X-MC-Unique: PDliOkPCPwe9BSLblYGHMA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 10/11] block: convert bdrv_create to generated_co_wrapper_simple Date: Wed, 16 Nov 2022 07:22:40 -0500 Message-Id: <20221116122241.2856527-11-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668601574656100001 Content-Type: text/plain; charset="utf-8" This function is never called in coroutine context, therefore instead of manually creating a new coroutine, delegate it to the block-coroutine-wrapper script, defining it as g_c_w_simple. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block.c | 38 +----------------------------- include/block/block-global-state.h | 10 ++++++-- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/block.c b/block.c index 7a4c3eb540..d3e168408a 100644 --- a/block.c +++ b/block.c @@ -528,7 +528,7 @@ typedef struct CreateCo { Error *err; } CreateCo; =20 -static int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filen= ame, +int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename, QemuOpts *opts, Error **errp) { int ret; @@ -555,42 +555,6 @@ static int coroutine_fn bdrv_co_create(BlockDriver *dr= v, const char *filename, return ret; } =20 -static void coroutine_fn bdrv_create_co_entry(void *opaque) -{ - CreateCo *cco =3D opaque; - GLOBAL_STATE_CODE(); - - cco->ret =3D bdrv_co_create(cco->drv, cco->filename, cco->opts, &cco->= err); -} - -int bdrv_create(BlockDriver *drv, const char* filename, - QemuOpts *opts, Error **errp) -{ - GLOBAL_STATE_CODE(); - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - return bdrv_co_create(drv, filename, opts, errp); - } else { - Coroutine *co; - CreateCo cco =3D { - .drv =3D drv, - .filename =3D filename, - .opts =3D opts, - .ret =3D NOT_DONE, - .err =3D NULL, - }; - - co =3D qemu_coroutine_create(bdrv_create_co_entry, &cco); - qemu_coroutine_enter(co); - while (cco.ret =3D=3D NOT_DONE) { - aio_poll(qemu_get_aio_context(), true); - } - error_propagate(errp, cco.err); - return cco.ret; - } -} - /** * Helper function for bdrv_create_file_fallback(): Resize @blk to at * least the given @minimum_size. diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index 6f35ed99e3..305336bdb9 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -55,8 +55,14 @@ BlockDriver *bdrv_find_protocol(const char *filename, bool allow_protocol_prefix, Error **errp); BlockDriver *bdrv_find_format(const char *format_name); -int bdrv_create(BlockDriver *drv, const char* filename, - QemuOpts *opts, Error **errp); + +int coroutine_fn bdrv_co_create(BlockDriver *drv, const char* filename, + QemuOpts *opts, Error **errp); +int generated_co_wrapper_simple bdrv_create(BlockDriver *drv, + const char* filename, + QemuOpts *opts, + Error **errp); + int coroutine_fn bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); =20 --=20 2.31.1 From nobody Fri May 17 03:54:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668602173; cv=none; d=zohomail.com; s=zohoarc; b=XfbXF0Z4GzRsE6MLYfVcJpg8HbbNEQJqpbiq+0N7pqeOfpYmPpOFYUBYUFh4bl6VMuCNzHPbal/gCMQP14JnmUs+3lOiQOdgjg6eqqctEycZxT/XBKwDWmtpO6raNGPqt6X84Kh3bGp3wHEWwNVVjKOGf/zFZlgc/emfEc75CsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668602173; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4IbsmYf8+FmcN2iCcaVLW9yij0CKmWysIo6HWGho0+Q=; b=TMn1CPPYdGtJYWCsJpQhtIX8jR9R7I+hpt66ZKgWYEEVE69Vkv9bu8QM7Ehl9+XHgxCmDMF/3269ZOBESEwelTPME1J2DdDH7ckLfjE3TES6noxpiAJM2jFkOvuz/TzvgJfRZzi1KP0LqPy46n8meTrk4EXOe/k4oL82jnma5eg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668602173567891.1221017395136; Wed, 16 Nov 2022 04:36:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovHRa-0000jY-54; Wed, 16 Nov 2022 07:23:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRR-0000gL-D0 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovHRN-0000wH-DG for qemu-devel@nongnu.org; Wed, 16 Nov 2022 07:22:56 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-625-yBW7Ulv5NyCL1W-HSw5HhA-1; Wed, 16 Nov 2022 07:22:47 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0EB9A29ABA3F; Wed, 16 Nov 2022 12:22:47 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1A7B9E70; Wed, 16 Nov 2022 12:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668601371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4IbsmYf8+FmcN2iCcaVLW9yij0CKmWysIo6HWGho0+Q=; b=EBKta7gwQo7Gocr1WyABya/wytfUTCbqNoKhzP2fIHYvz6SIyEbaH5qtd90J3MVsxmpWxD DUxpPzIBe1MPTBSJ9iTOElzPjlT36AyJkBGlcaKL3xRGx5Aowf8sz4Ym17rLdt0rgOPrsQ uLtTOAe9UyVOwouPCdMl0aPEd+5VkFs= X-MC-Unique: yBW7Ulv5NyCL1W-HSw5HhA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v4 11/11] block/dirty-bitmap: convert coroutine-only functions to generated_co_wrapper_simple Date: Wed, 16 Nov 2022 07:22:41 -0500 Message-Id: <20221116122241.2856527-12-eesposit@redhat.com> In-Reply-To: <20221116122241.2856527-1-eesposit@redhat.com> References: <20221116122241.2856527-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668602174683100001 Content-Type: text/plain; charset="utf-8" bdrv_can_store_new_dirty_bitmap and bdrv_remove_persistent_dirty_bitmap check if they are running in a coroutine, directly calling the coroutine callback if it's the case. Except that no coroutine calls such functions, therefore that check can be removed, and function creation can be offloaded to g_c_w_simple. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block/dirty-bitmap.c | 88 +----------------------------------- block/meson.build | 1 + include/block/block-common.h | 5 +- include/block/block-io.h | 9 +++- include/block/dirty-bitmap.h | 10 +++- 5 files changed, 21 insertions(+), 92 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index bf3dc0512a..21cf592889 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -388,7 +388,7 @@ void bdrv_release_named_dirty_bitmaps(BlockDriverState = *bs) * not fail. * This function doesn't release corresponding BdrvDirtyBitmap. */ -static int coroutine_fn +int coroutine_fn bdrv_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *n= ame, Error **errp) { @@ -399,45 +399,6 @@ bdrv_co_remove_persistent_dirty_bitmap(BlockDriverStat= e *bs, const char *name, return 0; } =20 -typedef struct BdrvRemovePersistentDirtyBitmapCo { - BlockDriverState *bs; - const char *name; - Error **errp; - int ret; -} BdrvRemovePersistentDirtyBitmapCo; - -static void coroutine_fn -bdrv_co_remove_persistent_dirty_bitmap_entry(void *opaque) -{ - BdrvRemovePersistentDirtyBitmapCo *s =3D opaque; - - s->ret =3D bdrv_co_remove_persistent_dirty_bitmap(s->bs, s->name, s->e= rrp); - aio_wait_kick(); -} - -int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *= name, - Error **errp) -{ - if (qemu_in_coroutine()) { - return bdrv_co_remove_persistent_dirty_bitmap(bs, name, errp); - } else { - Coroutine *co; - BdrvRemovePersistentDirtyBitmapCo s =3D { - .bs =3D bs, - .name =3D name, - .errp =3D errp, - .ret =3D -EINPROGRESS, - }; - - co =3D qemu_coroutine_create(bdrv_co_remove_persistent_dirty_bitma= p_entry, - &s); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, s.ret =3D=3D -EINPROGRESS); - - return s.ret; - } -} - bool bdrv_supports_persistent_dirty_bitmap(BlockDriverState *bs) { @@ -447,7 +408,7 @@ bdrv_supports_persistent_dirty_bitmap(BlockDriverState = *bs) return false; } =20 -static bool coroutine_fn +bool coroutine_fn bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, uint32_t granularity, Error **errp) { @@ -470,51 +431,6 @@ bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *b= s, const char *name, return drv->bdrv_co_can_store_new_dirty_bitmap(bs, name, granularity, = errp); } =20 -typedef struct BdrvCanStoreNewDirtyBitmapCo { - BlockDriverState *bs; - const char *name; - uint32_t granularity; - Error **errp; - bool ret; - - bool in_progress; -} BdrvCanStoreNewDirtyBitmapCo; - -static void coroutine_fn bdrv_co_can_store_new_dirty_bitmap_entry(void *op= aque) -{ - BdrvCanStoreNewDirtyBitmapCo *s =3D opaque; - - s->ret =3D bdrv_co_can_store_new_dirty_bitmap(s->bs, s->name, s->granu= larity, - s->errp); - s->in_progress =3D false; - aio_wait_kick(); -} - -bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *nam= e, - uint32_t granularity, Error **errp) -{ - IO_CODE(); - if (qemu_in_coroutine()) { - return bdrv_co_can_store_new_dirty_bitmap(bs, name, granularity, e= rrp); - } else { - Coroutine *co; - BdrvCanStoreNewDirtyBitmapCo s =3D { - .bs =3D bs, - .name =3D name, - .granularity =3D granularity, - .errp =3D errp, - .in_progress =3D true, - }; - - co =3D qemu_coroutine_create(bdrv_co_can_store_new_dirty_bitmap_en= try, - &s); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, s.in_progress); - - return s.ret; - } -} - void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap) { bdrv_dirty_bitmaps_lock(bitmap->bs); diff --git a/block/meson.build b/block/meson.build index b7c68b83a3..c48a59571e 100644 --- a/block/meson.build +++ b/block/meson.build @@ -137,6 +137,7 @@ block_gen_c =3D custom_target('block-gen.c', output: 'block-gen.c', input: files( '../include/block/block-io.h', + '../include/block/dirty-bitmap.h', '../include/block/block-global-state= .h', '../include/sysemu/block-backend-io.= h', 'coroutines.h' diff --git a/include/block/block-common.h b/include/block/block-common.h index 8ae750c7cf..683e3d1c51 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -29,8 +29,6 @@ #include "qemu/iov.h" #include "qemu/coroutine.h" #include "block/accounting.h" -#include "block/dirty-bitmap.h" -#include "block/blockjob.h" #include "qemu/hbitmap.h" #include "qemu/transactions.h" =20 @@ -45,6 +43,9 @@ #define generated_co_wrapper #define generated_co_wrapper_simple =20 +#include "block/dirty-bitmap.h" +#include "block/blockjob.h" + /* block.c */ typedef struct BlockDriver BlockDriver; typedef struct BdrvChild BdrvChild; diff --git a/include/block/block-io.h b/include/block/block-io.h index 0b49cb33da..f45ef6206f 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -200,8 +200,13 @@ AioContext *child_of_bds_get_parent_aio_context(BdrvCh= ild *c); void bdrv_io_plug(BlockDriverState *bs); void bdrv_io_unplug(BlockDriverState *bs); =20 -bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *nam= e, - uint32_t granularity, Error **errp); +bool coroutine_fn bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, + const char *name, + uint32_t granularity, + Error **errp); +bool generated_co_wrapper_simple +bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, + uint32_t granularity, Error **errp); =20 /** * diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 6528336c4c..2290e7fa28 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -34,8 +34,14 @@ int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap *bitma= p, uint32_t flags, Error **errp); void bdrv_release_dirty_bitmap(BdrvDirtyBitmap *bitmap); void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs); -int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *= name, - Error **errp); + +int coroutine_fn bdrv_co_remove_persistent_dirty_bitmap(BlockDriverState *= bs, + const char *name, + Error **errp); +int generated_co_wrapper_simple +bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name, + Error **errp); + void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap); void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap); void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap); --=20 2.31.1