From nobody Wed May 15 21:14:48 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=1671551527; cv=none; d=zohomail.com; s=zohoarc; b=cI3aRVNAr/YRHpEdAJ+RJbMoWPHgyFHytnwSKcC/aV+gAlKgPEuX3KJD61ZrRwpVQiKF//3XiVGtWStw20UxyOKYoXqUT1Rxr776fhYB7h5SFp42BOke4LpYWMl0XG9I4UzPzBm10bJHngD0wOUSDrKuQPyJgT8m09YU+dKqQbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671551527; 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=dtDEo2PBNaZIVwTFmVQUFy5wZIBunWdR5uBVLpJ76OgnJbAC991ythhZD2VKfGuo6BqiHHA6iwjQqqvF3qu2n9/QbiPNgXurdszPo9MF3zbiNayXQotSal3hO1uikLPHmHGoh/QE/knejpX45amL1y85uF6T1w1QGihWRug0/jE= 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 1671551527632549.2307635456076; Tue, 20 Dec 2022 07:52:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7esN-00056E-KF; Tue, 20 Dec 2022 10:49:55 -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 1p7esM-00054n-OO for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49: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 1p7esJ-000650-Oy for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49: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-399-TyNdvzGuPWWJtL72IbUYlw-1; Tue, 20 Dec 2022 10:49:46 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 591AE803491 for ; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 015AD112132D; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B50AA21E691E; Tue, 20 Dec 2022 16:49:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671551390; 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=HKRYbI0y7/+aEL6m3AYBfhyd4RYYGvPPRs+cByPTzoH3OLEcUGH9T1PejHjqktBoU63MFz FPhiS84cfx/RwryFDEJ1lSkQWF19yUO7QiQZNgRu6OwHl1w49sF+R1H7DFEpQA3c9qY3sd I1k1uIL4WmsTseyE0w5HrOiz/nhzGeg= X-MC-Unique: TyNdvzGuPWWJtL72IbUYlw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v2 1/5] coroutine: Clean up superfluous inclusion of qemu/coroutine.h Date: Tue, 20 Dec 2022 16:49:40 +0100 Message-Id: <20221220154944.3611845-2-armbru@redhat.com> In-Reply-To: <20221220154944.3611845-1-armbru@redhat.com> References: <20221220154944.3611845-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1671551529189100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi --- 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 Wed May 15 21:14:48 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=1671551505; cv=none; d=zohomail.com; s=zohoarc; b=IH6fYRszApYixY0Wg0S752zBubhHK367hcV9CUztTQlNBPipApTc/GPkrcfKR6lCIs+LdqA6beX9UfG/MqGJbgrxLgMRuOGbCc/lVOoqFDyvGVw1FfgytWaEhvfGklgMT8JcL3mQYgfA4TGg94Hstl5O3DWqpfFtAS447UOIGXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671551505; 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=LyvNkH55tHPUeGEsh5bBKhZnCzprKjInlIqrle9eufxyWJFMvaZBks/7U2ttmGzRAx4gSqn0uS9zb553zzICZfTPU8l7aH1IvVABz3w1G66hZMhBg81fG+/gRWBYcQeX9KUDrn+TFNCy4m1in0KJwQ7nlL9ffIHSv6gEAq/3PK0= 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 1671551505942123.3482335152836; Tue, 20 Dec 2022 07:51:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7esN-00055V-2k; Tue, 20 Dec 2022 10:49:55 -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 1p7esL-00051n-8H for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49: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 1p7esH-00064e-PB for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49: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-618-bBfMtXxsOGOOS_xJRTV0CQ-1; Tue, 20 Dec 2022 10:49:47 -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 DFF243C3C175 for ; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08BE31410DD7; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B738221E6928; Tue, 20 Dec 2022 16:49:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671551388; 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=PyETiIoW6FV/23l+sUtIwx+8gM1e0IBM11nda2y0/2RPvYrXN7LNAWgTtP/Tc2IYJT33Uq RbZ90fTpzO8PMp6zgRQ0fZ9DEBo55XSBL9JaXbUepEu4Tt71KhY/OQ+uZ5ivt6lcnRto9K 9V0R6ShVC/kMgSBEXWY+RKJDbAI4s1c= X-MC-Unique: bBfMtXxsOGOOS_xJRTV0CQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v2 2/5] coroutine: Move coroutine_fn to qemu/osdep.h, trim includes Date: Tue, 20 Dec 2022 16:49:41 +0100 Message-Id: <20221220154944.3611845-3-armbru@redhat.com> In-Reply-To: <20221220154944.3611845-1-armbru@redhat.com> References: <20221220154944.3611845-1-armbru@redhat.com> MIME-Version: 1.0 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.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: 1671551507073100002 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 --- 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 Wed May 15 21:14:48 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=1671551408; cv=none; d=zohomail.com; s=zohoarc; b=D7XVMFV55ZEsDyuoiKvyTRRhGz1hxdj3M0LuJT3x2sGHm29nVSRbwS2FvJp85Qv1sXsWQe8YXY7PQHrBtWxU0VD1PdGN7MEHq5QmDQ6GIWGQ1bFZPCx2uDNDZt7h5obZlEsyShRf3G68Kr5ajxKe07iOsplJWR6OuyaqVYnEoOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671551408; 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=bH6cZ5A1oOTiz+0gW6Hh14Zm39wcFI8q4NqGGPq5z1dN2VM/NEcpzdTV52zJ2eW5egQ4dnFmXN7mnRX9ZY93e/ZbHd0qlxncie1iM00tglVRvIbsb8+Y1BVY59eDgvE6JP0800L415yxM8BwvDST3Jbh7E0mY3fPkpLpYptOdiM= 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 1671551408631370.2914748432713; Tue, 20 Dec 2022 07:50:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7esK-00050h-Tx; Tue, 20 Dec 2022 10:49:52 -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 1p7esJ-0004xC-5I for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49:51 -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 1p7esH-00064a-GJ for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49:50 -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-556-NVEuJuymNiWyuDxOtyS0hA-1; Tue, 20 Dec 2022 10:49:46 -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 46CB4381796C for ; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03930492B00; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BA55021E6931; Tue, 20 Dec 2022 16:49:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671551388; 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=A/yBMQMamLNnCrg0vh8si3iWIIoDO8IrGBukjoi8F8mvnc0dh3SLhW3aop4vFEg1XBwe+h 411Iw62Nq86H7nrue0zZQVcyA2WeHOnPxmItvl7zaJogmsyyzpW9q02ihUcq5C1Pg8knki bMHtz2XUeiZoOZpqU3Ob555iUVZMWNg= X-MC-Unique: NVEuJuymNiWyuDxOtyS0hA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v2 3/5] coroutine: Clean up superfluous inclusion of qemu/lockable.h Date: Tue, 20 Dec 2022 16:49:42 +0100 Message-Id: <20221220154944.3611845-4-armbru@redhat.com> In-Reply-To: <20221220154944.3611845-1-armbru@redhat.com> References: <20221220154944.3611845-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: 1671551409019100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi --- 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 Wed May 15 21:14:48 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=1671551436; cv=none; d=zohomail.com; s=zohoarc; b=LsAUrUEU845L4a9MRY6nuJ3dMzOhp3pbmEvUubwlSN5mATvU2VdJc3kJUJthQbVr6GTBvwPro2q5agX8rOruF7lD3YCau1FtZQ/5ZNbQdpfO6iNxP+adTGEDLojpDrMIX9kNpGAVeUme/Esv9JlxWbcyxFYOdIzfNEoEWrA66Fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671551436; 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=MScXhK2+4RFOnjiAIHvznxHvN2G7ZFH2DpswjbTmdFU=; b=SPVJ2Lf8rYol/kHfSr1uWhy1j9yYgViKFC1nkxIdCRsg4MdZwzGB3Ujx6BAQtvWLPMR2fIXMn/JIQdv9XK3JC9LIWNeAOmjTnAzqyTXN3bw06/QWgw7UhwnjVEgHgkgdTNg7eO8/SJI17xm0IE6a5FFEyw1OA7V1y5Joq5z4m/Q= 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 1671551436598613.7802635270174; Tue, 20 Dec 2022 07:50:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7esP-000588-00; Tue, 20 Dec 2022 10:49: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 1p7esL-00051o-8J for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49: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 1p7esH-00064Z-Gd for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49: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-479-CzDKieuIM1SaZv6JPYt_cg-1; Tue, 20 Dec 2022 10:49:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F90F3817973 for ; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07CA140C1073; Tue, 20 Dec 2022 15:49:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BBC6C21E6935; Tue, 20 Dec 2022 16:49:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671551388; 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=MScXhK2+4RFOnjiAIHvznxHvN2G7ZFH2DpswjbTmdFU=; b=aXP0EiBx0E0EkjQdOb0XMe1RntKbHwtK2tZT8j0jkU68I9JjDeXauRYrhfKvPwmzYoNMIQ 7UklrYt0aSMtr39xhM+pVWLKSN1qlgztEWC0IjTNJfdZZMw+GTuh4MpLtMN4y9iPXd37tv rF2l0wKOhQ5531kcerrQkkY/s81D0hw= X-MC-Unique: CzDKieuIM1SaZv6JPYt_cg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v2 4/5] coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h Date: Tue, 20 Dec 2022 16:49:43 +0100 Message-Id: <20221220154944.3611845-5-armbru@redhat.com> In-Reply-To: <20221220154944.3611845-1-armbru@redhat.com> References: <20221220154944.3611845-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1671551437402100003 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 --- 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 - block.c | 2 +- block/block-copy.c | 2 +- block/io_uring.c | 2 +- block/linux-aio.c | 2 +- block/mirror.c | 2 +- block/vdi.c | 2 +- chardev/char.c | 2 +- hw/9pfs/coth.c | 2 +- hw/block/virtio-blk.c | 2 +- migration/rdma.c | 2 +- nbd/client-connection.c | 1 + net/colo-compare.c | 2 +- qapi/qmp-dispatch.c | 2 +- tests/unit/test-aio.c | 2 +- ui/console.c | 1 + util/thread-pool.c | 2 +- 23 files changed, 175 insertions(+), 115 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/block.c b/block.c index 9c2ac757e4..be78be95f9 100644 --- a/block.c +++ b/block.c @@ -44,7 +44,7 @@ #include "sysemu/block-backend.h" #include "qemu/notify.h" #include "qemu/option.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "block/qapi.h" #include "qemu/timer.h" #include "qemu/cutils.h" diff --git a/block/block-copy.c b/block/block-copy.c index 5e59d6262f..3261a6a0d2 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -20,7 +20,7 @@ #include "block/reqlist.h" #include "sysemu/block-backend.h" #include "qemu/units.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "block/aio_task.h" #include "qemu/error-report.h" #include "qemu/memalign.h" diff --git a/block/io_uring.c b/block/io_uring.c index 973e15d876..1ece7a75c8 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -14,7 +14,7 @@ #include "qemu/queue.h" #include "block/block.h" #include "block/raw-aio.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qapi/error.h" #include "trace.h" =20 diff --git a/block/linux-aio.c b/block/linux-aio.c index d2cfb7f523..9740cae864 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -13,7 +13,7 @@ #include "block/block.h" #include "block/raw-aio.h" #include "qemu/event_notifier.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qapi/error.h" =20 #include diff --git a/block/mirror.c b/block/mirror.c index 251adc5ae0..ef3a111b4e 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -13,7 +13,7 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/range.h" #include "trace.h" #include "block/blockjob_int.h" diff --git a/block/vdi.c b/block/vdi.c index 479bcfe820..fed390a939 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -61,7 +61,7 @@ #include "qemu/option.h" #include "qemu/bswap.h" #include "migration/blocker.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/cutils.h" #include "qemu/uuid.h" #include "qemu/memalign.h" diff --git a/chardev/char.c b/chardev/char.c index 4c5de16402..e98cb0f13b 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -37,7 +37,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/id.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/yank.h" =20 #include "chardev-internal.h" diff --git a/hw/9pfs/coth.c b/hw/9pfs/coth.c index 2802d41cce..706fa2b272 100644 --- a/hw/9pfs/coth.c +++ b/hw/9pfs/coth.c @@ -19,7 +19,7 @@ =20 #include "qemu/osdep.h" #include "block/thread-pool.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/main-loop.h" #include "coth.h" =20 diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f717550fdc..c55f8eb119 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -34,7 +34,7 @@ #include "migration/qemu-file-types.h" #include "hw/virtio/virtio-access.h" #include "hw/virtio/virtio-blk-common.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" =20 static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, VirtIOBlockReq *req) diff --git a/migration/rdma.c b/migration/rdma.c index 94a55dd95b..70dcf51b6e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -27,7 +27,7 @@ #include "qemu/rcu.h" #include "qemu/sockets.h" #include "qemu/bitmap.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "exec/memory.h" #include #include 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/net/colo-compare.c b/net/colo-compare.c index 7f9e6f89ce..d6591aa0ea 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -32,7 +32,7 @@ #include "util.h" =20 #include "block/aio-wait.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" =20 #define TYPE_COLO_COMPARE "colo-compare" typedef struct CompareState CompareState; diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 0990873ec8..2352eeeb23 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -22,7 +22,7 @@ #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include "qapi/qmp/qbool.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "qemu/main-loop.h" =20 Visitor *qobject_input_visitor_new_qmp(QObject *obj) 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" diff --git a/util/thread-pool.c b/util/thread-pool.c index 31113b5860..f98f090287 100644 --- a/util/thread-pool.c +++ b/util/thread-pool.c @@ -17,7 +17,7 @@ #include "qemu/osdep.h" #include "qemu/queue.h" #include "qemu/thread.h" -#include "qemu/coroutine.h" +#include "qemu/coroutine-core.h" #include "trace.h" #include "block/thread-pool.h" #include "qemu/main-loop.h" --=20 2.38.1 From nobody Wed May 15 21:14:48 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=1671551488; cv=none; d=zohomail.com; s=zohoarc; b=MszWCxP8Gnzhu1+N9i+RIhPX/DBQTG5tTngcc7B2U4Jc0Imj9mDb695wzNsKdbnDke5hMTfxqFaqVG8MUGJ76HHu/13tYFgT0VZXc236FnhrBARRwKd4wSONBUu2O/aYyprwfIF5bigNTnRwRlxi5InFMNnEm94YmXfW4RgKBiI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671551488; 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=DevMU3c7BidyH5fB4IsV8CJpzZRo02sEUmoXXzV0Y38=; b=lQ8caKNcQ3zYBnzQpankyiIuXaa5I0hMeDWkJdyvSbsqmcdxGUx/7uUjtjp6daURNxSIQaPATkND+sgsddI0C3w4BR3gCObZpVM2U3OlW7AumIljvG1jsS5wyblx7U9zDW1kuQswBrc2Eo6cseckuhSuCp3a5TgG80Mt87uIWOw= 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 1671551488016756.3380614949729; Tue, 20 Dec 2022 07:51:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7esM-00054Z-Ms; Tue, 20 Dec 2022 10:49: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 1p7esL-00051k-8I for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49: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 1p7esI-00064q-75 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 10:49:52 -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-215-gRrqRV9bNRWuEPORTha-jQ-1; Tue, 20 Dec 2022 10:49:47 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9A7AA802D1B for ; Tue, 20 Dec 2022 15:49:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63EE72026D4B; Tue, 20 Dec 2022 15:49:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BE04621E6939; Tue, 20 Dec 2022 16:49:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671551389; 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=DevMU3c7BidyH5fB4IsV8CJpzZRo02sEUmoXXzV0Y38=; b=e0HvORq6VHUscmepihGk5o+XVGW+im+ejPP94weMcp1PCfZhQ9XQEuIxh0yQkQ8HjbSu5Z TDSveHU3b+nrxShtkF0wRDoe34wvsPtGjJolrJ2G7ZmdRWZa9YPPGX5UDaCZyMiPG93plc /BuOuuWVAryG2y+YWShi5dLth+KiKHs= X-MC-Unique: gRrqRV9bNRWuEPORTha-jQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com Subject: [PATCH v2 5/5] coroutine: Use Coroutine typedef name instead of structure tag Date: Tue, 20 Dec 2022 16:49:44 +0100 Message-Id: <20221220154944.3611845-6-armbru@redhat.com> In-Reply-To: <20221220154944.3611845-1-armbru@redhat.com> References: <20221220154944.3611845-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1671551489084100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-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