From nobody Thu May 16 01:34:01 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=1671630013; cv=none; d=zohomail.com; s=zohoarc; b=GjqwJ4+YW0l0kbKuWHEwjD1DyXoIsGdzxxRSN9ASSkmzbTAAzRoDELpl6jHsvFZoMqc2TZh5p5zmZITDFor/nKscqIMv2h3XnaV7DOKWCB89f2F1o8lnd6NmdiSdsVQmNcPNetHv6kOyU9oWuhCDp3wU4b8+tXrU5cMdya8Qq/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671630013; h=Content-Type: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=/5C6Nz+Zc1CpqEsEvET28aZqTETA9Nk2g2GEMd/v8cg=; b=ZQ0C/fL4bs2iHKa0ALyZly6UB0zBrsj9v9GrXaIVbN+wFBv11tNvoMMS43g7VXKAMiTiG27hrf3YIDl0qRjBzHemT/K4DhyLgiXSp8xLJ95T0HajuCBSLPecuzR6ThQMbaXA0yBUVCb+kTZiOFn1kVXfKDpHBhLV2O+czO1Cb84= 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 1671630013092997.7477328293139; Wed, 21 Dec 2022 05:40:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7yvq-0004xU-C9; Wed, 21 Dec 2022 08:14:50 -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 1p7yvj-0004rX-S5 for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:43 -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 1p7yvh-0005f2-0x for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:43 -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-424-wshjYYCGPVKy4UnPwt94nQ-1; Wed, 21 Dec 2022 08:14:37 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFA883C0F662 for ; Wed, 21 Dec 2022 13:14:36 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8FF1492B14; Wed, 21 Dec 2022 13:14:36 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9B6F921E691E; Wed, 21 Dec 2022 14:14:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671628480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/5C6Nz+Zc1CpqEsEvET28aZqTETA9Nk2g2GEMd/v8cg=; b=RzcI5OjONpThLTmc2kuiCOtNHVisj2W6ABbTKn+HEAcAKSSw6Z/D5FFFOdUUwG9X2kBAYc I3ynjsdA4RgBZmhyb64euofuS+PimsUvmLsJ15ubWVXcGoxvhEAU6f7emefyDSM9pPtrzs naiy8yneSsHwDcFFI/Btdt5zSHkFn7o= X-MC-Unique: wshjYYCGPVKy4UnPwt94nQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v3 1/5] coroutine: Clean up superfluous inclusion of qemu/coroutine.h Date: Wed, 21 Dec 2022 14:14:31 +0100 Message-Id: <20221221131435.3851212-2-armbru@redhat.com> In-Reply-To: <20221221131435.3851212-1-armbru@redhat.com> References: <20221221131435.3851212-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=armbru@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: 1671630015030100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Tested-by: Philippe Mathieu-Daud=C3=A9 --- crypto/block-luks-priv.h | 1 - include/block/raw-aio.h | 1 - include/scsi/pr-manager.h | 1 - nbd/nbd-internal.h | 1 - blockjob.c | 1 - crypto/block-luks.c | 1 - hw/9pfs/codir.c | 1 - hw/9pfs/cofile.c | 1 - hw/9pfs/cofs.c | 1 - hw/9pfs/coxattr.c | 1 - tests/unit/test-coroutine.c | 1 - tests/unit/test-vmstate.c | 1 - util/qemu-coroutine-lock.c | 1 - util/qemu-coroutine-sleep.c | 1 - util/qemu-coroutine.c | 1 - 15 files changed, 15 deletions(-) diff --git a/crypto/block-luks-priv.h b/crypto/block-luks-priv.h index 90a20d432b..dc2dd14e52 100644 --- a/crypto/block-luks-priv.h +++ b/crypto/block-luks-priv.h @@ -31,7 +31,6 @@ #include "crypto/random.h" #include "qemu/uuid.h" =20 -#include "qemu/coroutine.h" #include "qemu/bitmap.h" =20 /* diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h index 21fc10c4c9..f8cda9df91 100644 --- a/include/block/raw-aio.h +++ b/include/block/raw-aio.h @@ -17,7 +17,6 @@ #define QEMU_RAW_AIO_H =20 #include "block/aio.h" -#include "qemu/coroutine.h" #include "qemu/iov.h" =20 /* AIO request types */ diff --git a/include/scsi/pr-manager.h b/include/scsi/pr-manager.h index e4ecbe00f6..45de28d354 100644 --- a/include/scsi/pr-manager.h +++ b/include/scsi/pr-manager.h @@ -5,7 +5,6 @@ #include "qapi/visitor.h" #include "qom/object_interfaces.h" #include "block/aio.h" -#include "qemu/coroutine.h" =20 #define TYPE_PR_MANAGER "pr-manager" =20 diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h index 1b2141ab4b..df42fef706 100644 --- a/nbd/nbd-internal.h +++ b/nbd/nbd-internal.h @@ -13,7 +13,6 @@ #include "sysemu/block-backend.h" #include "io/channel-tls.h" =20 -#include "qemu/coroutine.h" #include "qemu/iov.h" =20 #ifndef _WIN32 diff --git a/blockjob.c b/blockjob.c index b7daf2a9f6..54b4091a36 100644 --- a/blockjob.c +++ b/blockjob.c @@ -32,7 +32,6 @@ #include "qapi/error.h" #include "qapi/qapi-events-block-core.h" #include "qapi/qmp/qerror.h" -#include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "qemu/timer.h" =20 diff --git a/crypto/block-luks.c b/crypto/block-luks.c index ff9e3945d1..5688783ab1 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -32,7 +32,6 @@ #include "crypto/random.h" #include "qemu/uuid.h" =20 -#include "qemu/coroutine.h" #include "qemu/bitmap.h" =20 /* diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 93ba44fb75..7ba63be489 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -19,7 +19,6 @@ #include "qemu/osdep.h" #include "fsdev/qemu-fsdev.h" #include "qemu/thread.h" -#include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" #include "9p-xattr.h" diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c index 20f93a90e7..9c5344039e 100644 --- a/hw/9pfs/cofile.c +++ b/hw/9pfs/cofile.c @@ -19,7 +19,6 @@ #include "qemu/osdep.h" #include "fsdev/qemu-fsdev.h" #include "qemu/thread.h" -#include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" =20 diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c index 9d0adc2e78..67e3ae5c5c 100644 --- a/hw/9pfs/cofs.c +++ b/hw/9pfs/cofs.c @@ -19,7 +19,6 @@ #include "qemu/osdep.h" #include "fsdev/qemu-fsdev.h" #include "qemu/thread.h" -#include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" =20 diff --git a/hw/9pfs/coxattr.c b/hw/9pfs/coxattr.c index dbcd09e0fd..cd0f8488ac 100644 --- a/hw/9pfs/coxattr.c +++ b/hw/9pfs/coxattr.c @@ -19,7 +19,6 @@ #include "qemu/osdep.h" #include "fsdev/qemu-fsdev.h" #include "qemu/thread.h" -#include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" =20 diff --git a/tests/unit/test-coroutine.c b/tests/unit/test-coroutine.c index e16b80c245..513800d3db 100644 --- a/tests/unit/test-coroutine.c +++ b/tests/unit/test-coroutine.c @@ -12,7 +12,6 @@ */ =20 #include "qemu/osdep.h" -#include "qemu/coroutine.h" #include "qemu/coroutine_int.h" #include "qemu/lockable.h" =20 diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 541bb4f63e..79357b29ca 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -29,7 +29,6 @@ #include "migration/qemu-file-types.h" #include "../migration/qemu-file.h" #include "../migration/savevm.h" -#include "qemu/coroutine.h" #include "qemu/module.h" #include "io/channel-file.h" =20 diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c index 45c6b57374..58f3f77181 100644 --- a/util/qemu-coroutine-lock.c +++ b/util/qemu-coroutine-lock.c @@ -27,7 +27,6 @@ */ =20 #include "qemu/osdep.h" -#include "qemu/coroutine.h" #include "qemu/coroutine_int.h" #include "qemu/processor.h" #include "qemu/queue.h" diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c index 571ab521ff..af59f9af98 100644 --- a/util/qemu-coroutine-sleep.c +++ b/util/qemu-coroutine-sleep.c @@ -12,7 +12,6 @@ */ =20 #include "qemu/osdep.h" -#include "qemu/coroutine.h" #include "qemu/coroutine_int.h" #include "qemu/timer.h" #include "block/aio.h" diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c index 356b746f0b..8494523692 100644 --- a/util/qemu-coroutine.c +++ b/util/qemu-coroutine.c @@ -16,7 +16,6 @@ #include "trace.h" #include "qemu/thread.h" #include "qemu/atomic.h" -#include "qemu/coroutine.h" #include "qemu/coroutine_int.h" #include "qemu/coroutine-tls.h" #include "block/aio.h" --=20 2.38.1 From nobody Thu May 16 01:34:01 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=1671630002; cv=none; d=zohomail.com; s=zohoarc; b=Y4jCQJE7tGr3LJS14Kgtu0I4AAFJJcebROgzxTTOMooMy/NdRqrN/eMtE/vEhGWW620t93PC2CgHraC2gVdGlCCPEGaTpn3dsXdd5QriZsPe2+YKNATQVxPXibMckXWOZbsb5ue1/FUKIneyKIl0qa0RRtcBk+sCp/1Ioo3/3fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671630002; h=Content-Type: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=mumJNKVMVGU89SGM7NKdsxZ1cQb+5Rk3zpYOpnHHvu8=; b=IV4t+9PC3ixxQEbClU+84jSZr85pfW44NGSCbd9uAsKRFzXXW0t561kybe8YOZeu/lVLf3b3vDOmtlI8H7VDy/ptiuQeYxL7ETp/F/SLvbT1KdaV4pxmKmHO2KvDvhLbY/MqGAlOsMZoG9rbg677tRqFFHdnZ25jD3AsGxIZons= 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 16716300023771006.0859807443292; Wed, 21 Dec 2022 05:40:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7yvq-0004xY-Ke; Wed, 21 Dec 2022 08:14:50 -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 1p7yvi-0004rH-Db for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:43 -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 1p7yvf-0005ei-M6 for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:42 -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-464-0NrBjtPmP46x8rBboX7lhg-1; Wed, 21 Dec 2022 08:14:37 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFFDD802C1D for ; Wed, 21 Dec 2022 13:14:36 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A85C2C16027; Wed, 21 Dec 2022 13:14:36 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9F10F21E6928; Wed, 21 Dec 2022 14:14:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671628478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mumJNKVMVGU89SGM7NKdsxZ1cQb+5Rk3zpYOpnHHvu8=; b=C6eDh26KZKP9ss2k5YwSYGQqZ40aEnWT5uWxB3cn8QqGm1mC1Bay58R5wg8+xT5KM/NWIS sxNA7S8Zq7fg3S05UlKed9SHeGNzxo5d7kuzBOTnJPYTxZ8DSX9iMRZ331vcf+rsn8jU60 /b82PaX66mAv/WSmS2A8SA+KbxzESuQ= X-MC-Unique: 0NrBjtPmP46x8rBboX7lhg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v3 2/5] coroutine: Move coroutine_fn to qemu/osdep.h, trim includes Date: Wed, 21 Dec 2022 14:14:32 +0100 Message-Id: <20221221131435.3851212-3-armbru@redhat.com> In-Reply-To: <20221221131435.3851212-1-armbru@redhat.com> References: <20221221131435.3851212-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=armbru@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: 1671630002960100001 Content-Type: text/plain; charset="utf-8" block/block-hmp-cmds.h and qemu/co-shared-resource.h use coroutine_fn without including qemu/coroutine.h. They compile only if it's already included from elsewhere. I could fix that, but pulling in qemu/coroutine.h and everything it includes just for a macro that expands into nothing feels silly. Instead, move the macro to qemu/osdep.h. Inclusions of qemu/coroutine.h just for coroutine_fn become superfluous. Drop them. Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Tested-by: Philippe Mathieu-Daud=C3=A9 --- include/block/aio_task.h | 2 -- include/block/block-common.h | 1 - include/block/graph-lock.h | 2 -- include/monitor/hmp.h | 1 - include/qemu/coroutine.h | 18 +++++++----------- include/qemu/osdep.h | 16 ++++++++++++++++ 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/block/aio_task.h b/include/block/aio_task.h index 50bc1e1817..18a9c41f4e 100644 --- a/include/block/aio_task.h +++ b/include/block/aio_task.h @@ -25,8 +25,6 @@ #ifndef BLOCK_AIO_TASK_H #define BLOCK_AIO_TASK_H =20 -#include "qemu/coroutine.h" - typedef struct AioTaskPool AioTaskPool; typedef struct AioTask AioTask; typedef int coroutine_fn (*AioTaskFunc)(AioTask *task); diff --git a/include/block/block-common.h b/include/block/block-common.h index 4749c46a5e..434ffc5d34 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -27,7 +27,6 @@ #include "block/aio.h" #include "block/aio-wait.h" #include "qemu/iov.h" -#include "qemu/coroutine.h" #include "block/accounting.h" #include "qemu/hbitmap.h" #include "qemu/transactions.h" diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h index 4c92cd8edf..3ab924d5e2 100644 --- a/include/block/graph-lock.h +++ b/include/block/graph-lock.h @@ -23,8 +23,6 @@ #include "qemu/osdep.h" #include "qemu/clang-tsa.h" =20 -#include "qemu/coroutine.h" - /** * Graph Lock API * This API provides a rwlock used to protect block layer diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index dfbc0c9a2f..c92f69da8b 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -15,7 +15,6 @@ #define HMP_H =20 #include "qemu/readline.h" -#include "qemu/coroutine.h" #include "qapi/qapi-types-common.h" =20 bool hmp_handle_error(Monitor *mon, Error *err); diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 89650a2d7f..2496a4f4ef 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -26,23 +26,19 @@ * waiting for events to complete. * * These functions are re-entrant and may be used outside the global mutex. - */ - -/** - * Mark a function that executes in coroutine context * - * Functions that execute in coroutine context cannot be called directly f= rom - * normal functions. In the future it would be nice to enable compiler or - * static checker support for catching such errors. This annotation might= make - * it possible and in the meantime it serves as documentation. - * - * For example: + * Functions that execute in coroutine context cannot be called + * directly from normal functions. Use @coroutine_fn to mark such + * functions. For example: * * static void coroutine_fn foo(void) { * .... * } + * + * In the future it would be nice to have the compiler or a static + * checker catch misuse of such functions. This annotation might make + * it possible and in the meantime it serves as documentation. */ -#define coroutine_fn =20 typedef struct Coroutine Coroutine; =20 diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b9c4307779..8e97e5d79a 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -157,6 +157,22 @@ extern "C" { =20 #include "qemu/typedefs.h" =20 +/** + * Mark a function that executes in coroutine context + * + * Functions that execute in coroutine context cannot be called directly f= rom + * normal functions. In the future it would be nice to enable compiler or + * static checker support for catching such errors. This annotation might= make + * it possible and in the meantime it serves as documentation. + * + * For example: + * + * static void coroutine_fn foo(void) { + * .... + * } + */ +#define coroutine_fn + /* * For mingw, as of v6.0.0, the function implementing the assert macro is * not marked as noreturn, so the compiler cannot delete code following an --=20 2.38.1 From nobody Thu May 16 01:34:01 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=1671629631; cv=none; d=zohomail.com; s=zohoarc; b=bS/LGw+qpLtEsAdohrB8lWL3clAg53jMFb5TpOjSI0Zmm+oU5VqFwfNNaBNGKoszddRZGswoI+rQ6BV1hNebTI38OCqoyJxK136U/Pgg1tO3JyqoG0egmIu91vFesokehTJMk95FPSMafq0I+m8+TIOsUHhMMJMl0sNaCVWjD2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671629631; h=Content-Type: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=lEKOLlqwNgXaAI4cZFQV+6JRlUZBug07TFQp3654L8c=; b=G7rN7A+mS9/D8oB7B6wqDcT5OpAMV2wdnyH54CktX4c3TBx4o8WPYZEjtixIDthCOz2JG38TasKFTOcL87YCR5tUjQZdpdfbcaKQCu6o34yEGohGsJuOUn265deZAG4DPlgyvJ1khGtwsW0SjaKuHLp3nctta6opFG1p5aITLCc= 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 1671629631068124.37193310336284; Wed, 21 Dec 2022 05:33:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7yvo-0004tI-SN; Wed, 21 Dec 2022 08:14:48 -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 1p7yvh-0004qL-83 for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:41 -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 1p7yvf-0005ee-G2 for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:40 -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-408-bKfdYjeZM_uEk7xzRcFKjw-1; Wed, 21 Dec 2022 08:14:37 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D64CF3813F2F for ; Wed, 21 Dec 2022 13:14:36 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB1E82166B26; Wed, 21 Dec 2022 13:14:36 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A035C21E6935; Wed, 21 Dec 2022 14:14:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671628478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lEKOLlqwNgXaAI4cZFQV+6JRlUZBug07TFQp3654L8c=; b=DPQS4s5w05+eWNeDfn80e3LZFgeEKAKhE5AT2PN2e3qXG/kuEZ8r+hFaZUqaE01G7yg22s n2TqV+DLTznVOxhHkJxGybNE1/V6jIj1NCKEMyuF/+nMpM1GEzSfBEF39TQOkYolWUINhD on90gPzJkFB98ONcBgGgo4tEDJXdCyY= X-MC-Unique: bKfdYjeZM_uEk7xzRcFKjw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v3 3/5] coroutine: Clean up superfluous inclusion of qemu/lockable.h Date: Wed, 21 Dec 2022 14:14:33 +0100 Message-Id: <20221221131435.3851212-4-armbru@redhat.com> In-Reply-To: <20221221131435.3851212-1-armbru@redhat.com> References: <20221221131435.3851212-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=armbru@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: 1671629631723100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Tested-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/progress_meter.h | 2 +- block/progress_meter.c | 2 ++ tests/unit/test-coroutine.c | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/qemu/progress_meter.h b/include/qemu/progress_meter.h index dadf822bbf..0f2c0a32d2 100644 --- a/include/qemu/progress_meter.h +++ b/include/qemu/progress_meter.h @@ -27,7 +27,7 @@ #ifndef QEMU_PROGRESS_METER_H #define QEMU_PROGRESS_METER_H =20 -#include "qemu/lockable.h" +#include "qemu/thread.h" =20 typedef struct ProgressMeter { /** diff --git a/block/progress_meter.c b/block/progress_meter.c index aa2e60248c..31a170a2cd 100644 --- a/block/progress_meter.c +++ b/block/progress_meter.c @@ -23,7 +23,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN * THE SOFTWARE. */ + #include "qemu/osdep.h" +#include "qemu/coroutine.h" #include "qemu/progress_meter.h" =20 void progress_init(ProgressMeter *pm) diff --git a/tests/unit/test-coroutine.c b/tests/unit/test-coroutine.c index 513800d3db..b0d21d673a 100644 --- a/tests/unit/test-coroutine.c +++ b/tests/unit/test-coroutine.c @@ -13,7 +13,6 @@ =20 #include "qemu/osdep.h" #include "qemu/coroutine_int.h" -#include "qemu/lockable.h" =20 /* * Check that qemu_in_coroutine() works --=20 2.38.1 From nobody Thu May 16 01:34:01 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=1671630020; cv=none; d=zohomail.com; s=zohoarc; b=YJMfU4ezKJseck2KFRuDJZTc0NIBxcwHO+1pq7cPYPx+vjhFcgl/m7M/1zNPbeyCshZrI0yMG24rZNYxUzvM/Iu4l8i/xSIiGFTCSkaS1VeFzPrItC2TJMI5sQq5BRyle8cYrU5QJRPhVkDRNiCtOgRI4tnBxGmkhivk93wCq24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671630020; h=Content-Type: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=AD4vDPg9CqjUtENsixip/unz5YE5ODh5RPI6R44O6Z0=; b=FJV0zRTEjV6CYPt0mkJ0Xx1sPKwabq7nd4ZYCcMlzk+ZVElJIWq++K9M6zgMfFqyrI7tDrPd/n1IbTy/uIvZ2FwLY3ck+G5V2xFUqw09CqglpW+30mhmNiVjm9F3cerV6GD53m/6ldIlqZPV3T65DiU9AeI07UJ45b2oa83iheQ= 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 167163002096563.01593107296594; Wed, 21 Dec 2022 05:40:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7yvq-0004wa-4o; Wed, 21 Dec 2022 08:14:50 -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 1p7yvj-0004rQ-0H for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:43 -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 1p7yvf-0005ep-MJ for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:42 -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-658-dC7STpN8N8y2qRFWSjEhQA-1; Wed, 21 Dec 2022 08:14:37 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2CC361C05ABB for ; Wed, 21 Dec 2022 13:14:37 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9E3B40C2064; Wed, 21 Dec 2022 13:14:36 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A247921E6931; Wed, 21 Dec 2022 14:14:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671628478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AD4vDPg9CqjUtENsixip/unz5YE5ODh5RPI6R44O6Z0=; b=aoxzMJrxn+QlTeSouYjeFRtrZaN4L0rpY9y2OdJpJU9GcnGQyE8f2kGUxUSJw3p2USOoci AiM8bix2EqegbWrYelGfhQoEqNsuISFzA2bxObEchbW+/d9ywTJiWZ38gwe2ndenTt4qfT E6hz0gqnsm9D06Vz9UfZb/BIluPJDrk= X-MC-Unique: dC7STpN8N8y2qRFWSjEhQA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v3 4/5] coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h Date: Wed, 21 Dec 2022 14:14:34 +0100 Message-Id: <20221221131435.3851212-5-armbru@redhat.com> In-Reply-To: <20221221131435.3851212-1-armbru@redhat.com> References: <20221221131435.3851212-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=armbru@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: 1671630023070100001 Content-Type: text/plain; charset="utf-8" qemu/coroutine.h and qemu/lockable.h include each other. They need each other only in macro expansions, so we could simply drop both inclusions to break the loop, and add suitable includes to files that expand the macros. Instead, move a part of qemu/coroutine.h to new qemu/coroutine-core.h so that qemu/coroutine-core.h doesn't need qemu/lockable.h, and qemu/lockable.h only needs qemu/coroutine-core.h. Result: qemu/coroutine.h includes qemu/lockable.h includes qemu/coroutine-core.h. Signed-off-by: Markus Armbruster Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/9pfs/coth.h | 2 +- include/block/aio.h | 2 +- include/io/channel.h | 2 +- include/qemu/coroutine-core.h | 154 ++++++++++++++++++++++++++++++++++ include/qemu/coroutine.h | 97 +-------------------- include/qemu/lockable.h | 2 +- include/qemu/typedefs.h | 1 - nbd/client-connection.c | 1 + tests/unit/test-aio.c | 2 +- ui/console.c | 1 + 10 files changed, 162 insertions(+), 102 deletions(-) create mode 100644 include/qemu/coroutine-core.h diff --git a/hw/9pfs/coth.h b/hw/9pfs/coth.h index 1a1edbdc2a..2c54249b35 100644 --- a/hw/9pfs/coth.h +++ b/hw/9pfs/coth.h @@ -16,7 +16,7 @@ #define QEMU_9P_COTH_H =20 #include "qemu/thread.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "9p.h" =20 /* diff --git a/include/block/aio.h b/include/block/aio.h index 0f65a3cc9e..3a546e7515 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -17,7 +17,7 @@ #ifdef CONFIG_LINUX_IO_URING #include #endif -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/queue.h" #include "qemu/event_notifier.h" #include "qemu/thread.h" diff --git a/include/io/channel.h b/include/io/channel.h index f1b7e05f81..78b15f7870 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -22,7 +22,7 @@ #define QIO_CHANNEL_H =20 #include "qom/object.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "block/aio.h" =20 #define TYPE_QIO_CHANNEL "qio-channel" diff --git a/include/qemu/coroutine-core.h b/include/qemu/coroutine-core.h new file mode 100644 index 0000000000..230bb56517 --- /dev/null +++ b/include/qemu/coroutine-core.h @@ -0,0 +1,154 @@ +/* + * QEMU coroutine implementation + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Stefan Hajnoczi + * Kevin Wolf + * + * This work is licensed under the terms of the GNU LGPL, version 2 or lat= er. + * See the COPYING.LIB file in the top-level directory. + * + */ + +#ifndef QEMU_COROUTINE_CORE_H +#define QEMU_COROUTINE_CORE_H + +/** + * Coroutines are a mechanism for stack switching and can be used for + * cooperative userspace threading. These functions provide a simple but + * useful flavor of coroutines that is suitable for writing sequential cod= e, + * rather than callbacks, for operations that need to give up control while + * waiting for events to complete. + * + * These functions are re-entrant and may be used outside the global mutex. + * + * Functions that execute in coroutine context cannot be called + * directly from normal functions. Use @coroutine_fn to mark such + * functions. For example: + * + * static void coroutine_fn foo(void) { + * .... + * } + * + * In the future it would be nice to have the compiler or a static + * checker catch misuse of such functions. This annotation might make + * it possible and in the meantime it serves as documentation. + */ + +/** + * Mark a function that executes in coroutine context + * + * + * Functions that execute in coroutine context cannot be called + * directly from normal functions. Use @coroutine_fn to mark such + * functions. For example: + * + * static void coroutine_fn foo(void) { + * .... + * } + * + * In the future it would be nice to have the compiler or a static + * checker catch misuse of such functions. This annotation might make + * it possible and in the meantime it serves as documentation. + */ + +typedef struct Coroutine Coroutine; +typedef struct CoMutex CoMutex; + +/** + * Coroutine entry point + * + * When the coroutine is entered for the first time, opaque is passed in a= s an + * argument. + * + * When this function returns, the coroutine is destroyed automatically and + * execution continues in the caller who last entered the coroutine. + */ +typedef void coroutine_fn CoroutineEntry(void *opaque); + +/** + * Create a new coroutine + * + * Use qemu_coroutine_enter() to actually transfer control to the coroutin= e. + * The opaque argument is passed as the argument to the entry point. + */ +Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque); + +/** + * Transfer control to a coroutine + */ +void qemu_coroutine_enter(Coroutine *coroutine); + +/** + * Transfer control to a coroutine if it's not active (i.e. part of the ca= ll + * stack of the running coroutine). Otherwise, do nothing. + */ +void qemu_coroutine_enter_if_inactive(Coroutine *co); + +/** + * Transfer control to a coroutine and associate it with ctx + */ +void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co); + +/** + * Transfer control back to a coroutine's caller + * + * This function does not return until the coroutine is re-entered using + * qemu_coroutine_enter(). + */ +void coroutine_fn qemu_coroutine_yield(void); + +/** + * Get the AioContext of the given coroutine + */ +AioContext *qemu_coroutine_get_aio_context(Coroutine *co); + +/** + * Get the currently executing coroutine + */ +Coroutine *qemu_coroutine_self(void); + +/** + * Return whether or not currently inside a coroutine + * + * This can be used to write functions that work both when in coroutine co= ntext + * and when not in coroutine context. Note that such functions cannot use= the + * coroutine_fn annotation since they work outside coroutine context. + */ +bool qemu_in_coroutine(void); + +/** + * Return true if the coroutine is currently entered + * + * A coroutine is "entered" if it has not yielded from the current + * qemu_coroutine_enter() call used to run it. This does not mean that the + * coroutine is currently executing code since it may have transferred con= trol + * to another coroutine using qemu_coroutine_enter(). + * + * When several coroutines enter each other there may be no way to know wh= ich + * ones have already been entered. In such situations this function can be + * used to avoid recursively entering coroutines. + */ +bool qemu_coroutine_entered(Coroutine *co); + +/** + * Initialises a CoMutex. This must be called before any other operation i= s used + * on the CoMutex. + */ +void qemu_co_mutex_init(CoMutex *mutex); + +/** + * Locks the mutex. If the lock cannot be taken immediately, control is + * transferred to the caller of the current coroutine. + */ +void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex); + +/** + * Unlocks the mutex and schedules the next coroutine that was waiting for= this + * lock to be run. + */ +void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex); + +#endif diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 2496a4f4ef..a65be6697f 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -15,6 +15,7 @@ #ifndef QEMU_COROUTINE_H #define QEMU_COROUTINE_H =20 +#include "qemu/coroutine-core.h" #include "qemu/queue.h" #include "qemu/timer.h" =20 @@ -40,84 +41,6 @@ * it possible and in the meantime it serves as documentation. */ =20 -typedef struct Coroutine Coroutine; - -/** - * Coroutine entry point - * - * When the coroutine is entered for the first time, opaque is passed in a= s an - * argument. - * - * When this function returns, the coroutine is destroyed automatically and - * execution continues in the caller who last entered the coroutine. - */ -typedef void coroutine_fn CoroutineEntry(void *opaque); - -/** - * Create a new coroutine - * - * Use qemu_coroutine_enter() to actually transfer control to the coroutin= e. - * The opaque argument is passed as the argument to the entry point. - */ -Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque); - -/** - * Transfer control to a coroutine - */ -void qemu_coroutine_enter(Coroutine *coroutine); - -/** - * Transfer control to a coroutine if it's not active (i.e. part of the ca= ll - * stack of the running coroutine). Otherwise, do nothing. - */ -void qemu_coroutine_enter_if_inactive(Coroutine *co); - -/** - * Transfer control to a coroutine and associate it with ctx - */ -void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co); - -/** - * Transfer control back to a coroutine's caller - * - * This function does not return until the coroutine is re-entered using - * qemu_coroutine_enter(). - */ -void coroutine_fn qemu_coroutine_yield(void); - -/** - * Get the AioContext of the given coroutine - */ -AioContext *qemu_coroutine_get_aio_context(Coroutine *co); - -/** - * Get the currently executing coroutine - */ -Coroutine *qemu_coroutine_self(void); - -/** - * Return whether or not currently inside a coroutine - * - * This can be used to write functions that work both when in coroutine co= ntext - * and when not in coroutine context. Note that such functions cannot use= the - * coroutine_fn annotation since they work outside coroutine context. - */ -bool qemu_in_coroutine(void); - -/** - * Return true if the coroutine is currently entered - * - * A coroutine is "entered" if it has not yielded from the current - * qemu_coroutine_enter() call used to run it. This does not mean that the - * coroutine is currently executing code since it may have transferred con= trol - * to another coroutine using qemu_coroutine_enter(). - * - * When several coroutines enter each other there may be no way to know wh= ich - * ones have already been entered. In such situations this function can be - * used to avoid recursively entering coroutines. - */ -bool qemu_coroutine_entered(Coroutine *co); - /** * Provides a mutex that can be used to synchronise coroutines */ @@ -145,24 +68,6 @@ struct CoMutex { Coroutine *holder; }; =20 -/** - * Initialises a CoMutex. This must be called before any other operation i= s used - * on the CoMutex. - */ -void qemu_co_mutex_init(CoMutex *mutex); - -/** - * Locks the mutex. If the lock cannot be taken immediately, control is - * transferred to the caller of the current coroutine. - */ -void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex); - -/** - * Unlocks the mutex and schedules the next coroutine that was waiting for= this - * lock to be run. - */ -void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex); - /** * Assert that the current coroutine holds @mutex. */ diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h index 86db7cb04c..9823220446 100644 --- a/include/qemu/lockable.h +++ b/include/qemu/lockable.h @@ -13,7 +13,7 @@ #ifndef QEMU_LOCKABLE_H #define QEMU_LOCKABLE_H =20 -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/thread.h" =20 typedef void QemuLockUnlockFunc(void *); diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 688408e048..0f7329b70f 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -37,7 +37,6 @@ typedef struct BusState BusState; typedef struct Chardev Chardev; typedef struct Clock Clock; typedef struct CompatProperty CompatProperty; -typedef struct CoMutex CoMutex; typedef struct ConfidentialGuestSupport ConfidentialGuestSupport; typedef struct CPUAddressSpace CPUAddressSpace; typedef struct CPUArchState CPUArchState; diff --git a/nbd/client-connection.c b/nbd/client-connection.c index 0c5f917efa..e5b1046a1c 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -29,6 +29,7 @@ =20 #include "qapi/qapi-visit-sockets.h" #include "qapi/clone-visitor.h" +#include "qemu/coroutine.h" =20 struct NBDClientConnection { /* Initialization constants, never change */ diff --git a/tests/unit/test-aio.c b/tests/unit/test-aio.c index 178048d2f2..321d7ab01a 100644 --- a/tests/unit/test-aio.c +++ b/tests/unit/test-aio.c @@ -16,7 +16,7 @@ #include "qemu/timer.h" #include "qemu/sockets.h" #include "qemu/error-report.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/main-loop.h" =20 static AioContext *ctx; diff --git a/ui/console.c b/ui/console.c index 9ff9217f9b..ab43561fe1 100644 --- a/ui/console.c +++ b/ui/console.c @@ -27,6 +27,7 @@ #include "hw/qdev-core.h" #include "qapi/error.h" #include "qapi/qapi-commands-ui.h" +#include "qemu/coroutine.h" #include "qemu/fifo8.h" #include "qemu/main-loop.h" #include "qemu/module.h" --=20 2.38.1 From nobody Thu May 16 01:34:01 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=1671629297; cv=none; d=zohomail.com; s=zohoarc; b=cL6WB/i8uF9ko0oSLd1Yx4BfkG2HPrakZ9CZZfZbJ9JDyIWEmw79bOVnQX3rRLjYGWkWv9diw1t0xEzgXSA7I5uRkCXsCsMTibc6+6OEleFMWoB4Vvff84JDXe/wyQEIR4BmvkrRqC2xVhl0iwr3QySOeoMl5TXzLhebl2oUIrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671629297; h=Content-Type: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=MmzfLG/LqVAe/JsmFSl4ucPanloDlrjr2xEdy0/zqKA=; b=jCsLTEDbWG1KGodav4AZL9T9gr+AeQ2HwhoywXQKHO37dtYXM+vdmoZ7onScYyoFFlUFOSrHOZeEuvMHGr7pZ0F8RhJyKU+a/tvi2f0A/NDDmGCRWb/TceLOkhThVTUCYTPoS2uBwNX+QsUcCjd5QCQuWNmyljqZExwN+UVjB4Q= 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 1671629297647517.0774044949359; Wed, 21 Dec 2022 05:28:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7yvq-0004zQ-WB; Wed, 21 Dec 2022 08:14:51 -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 1p7yvj-0004rT-FM for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:43 -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 1p7yvg-0005ew-80 for qemu-devel@nongnu.org; Wed, 21 Dec 2022 08:14:43 -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-363-cvxQdcGyM5SizrCE7llGvg-1; Wed, 21 Dec 2022 08:14:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05D928027F8; Wed, 21 Dec 2022 13:14:38 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D139614152F4; Wed, 21 Dec 2022 13:14:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A464521E6939; Wed, 21 Dec 2022 14:14:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671628479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MmzfLG/LqVAe/JsmFSl4ucPanloDlrjr2xEdy0/zqKA=; b=e0JC7QL4kxSeLzF/oOxSG0D6qsf8pFgcVbhfc1mRPbqzs04NqXcO/5Z8O+Ubvd5hVpHPvL kIQGbbER17aCrkOzYpH58Udq9Vqs0tDTCdL+PsqlyCLiTY008hqUIiFFDA36oAnqN/O2RI jYX8AMOKFExJ6EzQHmlc4ZU2TvNdbD0= X-MC-Unique: cvxQdcGyM5SizrCE7llGvg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 5/5] coroutine: Use Coroutine typedef name instead of structure tag Date: Wed, 21 Dec 2022 14:14:35 +0100 Message-Id: <20221221131435.3851212-6-armbru@redhat.com> In-Reply-To: <20221221131435.3851212-1-armbru@redhat.com> References: <20221221131435.3851212-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=armbru@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: 1671629299645100003 Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- include/block/aio.h | 7 +++---- util/async.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/block/aio.h b/include/block/aio.h index 3a546e7515..8fba6a3584 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -52,7 +52,6 @@ typedef void QEMUBHFunc(void *opaque); typedef bool AioPollFn(void *opaque); typedef void IOHandler(void *opaque); =20 -struct Coroutine; struct ThreadPool; struct LinuxAioState; struct LuringState; @@ -694,7 +693,7 @@ static inline bool aio_node_check(AioContext *ctx, bool= is_external) * is the context in which the coroutine is running (i.e. the value of * qemu_get_current_aio_context() from the coroutine itself). */ -void aio_co_schedule(AioContext *ctx, struct Coroutine *co); +void aio_co_schedule(AioContext *ctx, Coroutine *co); =20 /** * aio_co_reschedule_self: @@ -717,7 +716,7 @@ void coroutine_fn aio_co_reschedule_self(AioContext *ne= w_ctx); * context. The coroutine must not be entered by anyone else while * aio_co_wake() is active. */ -void aio_co_wake(struct Coroutine *co); +void aio_co_wake(Coroutine *co); =20 /** * aio_co_enter: @@ -726,7 +725,7 @@ void aio_co_wake(struct Coroutine *co); * * Enter a coroutine in the specified AioContext. */ -void aio_co_enter(AioContext *ctx, struct Coroutine *co); +void aio_co_enter(AioContext *ctx, Coroutine *co); =20 /** * Return the AioContext whose event loop runs in the current thread. diff --git a/util/async.c b/util/async.c index 14d63b3091..0657b75397 100644 --- a/util/async.c +++ b/util/async.c @@ -640,7 +640,7 @@ void coroutine_fn aio_co_reschedule_self(AioContext *ne= w_ctx) } } =20 -void aio_co_wake(struct Coroutine *co) +void aio_co_wake(Coroutine *co) { AioContext *ctx; =20 @@ -653,7 +653,7 @@ void aio_co_wake(struct Coroutine *co) aio_co_enter(ctx, co); } =20 -void aio_co_enter(AioContext *ctx, struct Coroutine *co) +void aio_co_enter(AioContext *ctx, Coroutine *co) { if (ctx !=3D qemu_get_current_aio_context()) { aio_co_schedule(ctx, co); --=20 2.38.1