From nobody Thu Nov 13 13:42:06 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580451694196455.94086912637226; Thu, 30 Jan 2020 22:21:34 -0800 (PST) Received: from localhost ([::1]:48884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixPgL-0001qh-3Y for importer@patchew.org; Fri, 31 Jan 2020 01:21:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59419) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixPV0-00070X-GU for qemu-devel@nongnu.org; Fri, 31 Jan 2020 01:09:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixPUz-0000b8-9M for qemu-devel@nongnu.org; Fri, 31 Jan 2020 01:09:50 -0500 Received: from ozlabs.org ([203.11.71.1]:47459) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixPUy-0000ZP-UP; Fri, 31 Jan 2020 01:09:49 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4886Hw1M9Yz9sSp; Fri, 31 Jan 2020 17:09:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1580450972; bh=YIdqK1tRx6Js2Yz0nu83Aa0ByFCx7euikjoqWW8kzKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjsbEjBs9RKhr7PwJ7Hp0B5Y7JXwIl6GjBqBfqc4BJ4u8QPdRIhMSCzVy6IWBvjY4 g7K0/atKdmgPp9tsf0qYoSq578oE0z5Q/pXJGnhUKq/vEmPCp7Ff3eEIHoMjz3sxE3 WW9xlLAMphp1cXzH1WzOYjfh0CnjNfiCKbh/nElY= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 24/34] Wrapper function to wait on condition for the main loop mutex Date: Fri, 31 Jan 2020 17:09:14 +1100 Message-Id: <20200131060924.147449-25-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200131060924.147449-1-david@gibson.dropbear.id.au> References: <20200131060924.147449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Aravinda Prasad , qemu-devel@nongnu.org, groug@kaod.org, Ganesh Goudar , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Aravinda Prasad Introduce a wrapper function to wait on condition for the main loop mutex. This function atomically releases the main loop mutex and causes the calling thread to block on the condition. This wrapper is required because qemu_global_mutex is a static variable. Signed-off-by: Aravinda Prasad Signed-off-by: Ganesh Goudar Reviewed-by: David Gibson Reviewed-by: Greg Kurz Message-Id: <20200130184423.20519-2-ganeshgr@linux.ibm.com> Signed-off-by: David Gibson --- cpus.c | 5 +++++ include/qemu/main-loop.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/cpus.c b/cpus.c index b612116f95..b4f8b84b61 100644 --- a/cpus.c +++ b/cpus.c @@ -1839,6 +1839,11 @@ void qemu_mutex_unlock_iothread(void) qemu_mutex_unlock(&qemu_global_mutex); } =20 +void qemu_cond_wait_iothread(QemuCond *cond) +{ + qemu_cond_wait(cond, &qemu_global_mutex); +} + static bool all_vcpus_paused(void) { CPUState *cpu; diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index f6ba78ea73..a6d20b0719 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -295,6 +295,14 @@ void qemu_mutex_lock_iothread_impl(const char *file, i= nt line); */ void qemu_mutex_unlock_iothread(void); =20 +/* + * qemu_cond_wait_iothread: Wait on condition for the main loop mutex + * + * This function atomically releases the main loop mutex and causes + * the calling thread to block on the condition. + */ +void qemu_cond_wait_iothread(QemuCond *cond); + /* internal interfaces */ =20 void qemu_fd_register(int fd); --=20 2.24.1