From nobody Tue Feb 10 07:42:02 2026 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=quarantine dis=none) header.from=kalray.eu ARC-Seal: i=1; a=rsa-sha256; t=1655735620; cv=none; d=zohomail.com; s=zohoarc; b=K7W5HDJJnahHWyo3AK5PPbaWYSVjPRzdyS+zqXUrDUIUZIEhfg7nS2tXSXzXb2ozVmeIpbfMA8RhzcBR/UO+YDLNexPm+4Rhk8sDmeqngSHv8M9CPUnJq2whxDvzzN5gEtxGJY0xYVjIdUhdqC3chE3Nr7vfaImY5dKY8zU9DKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655735620; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=QgH8wZqo2/2TxGhCDC/6naM/dZWNtRHlDBEDvIF5y6w=; b=A2YQrS+yzV9z0MKAC8kwVisEAGpPf3i8Jy+5X9LFjUzsqNSIK/dOe0YU2JslFZAXwhuiAw2GMWaeR7I7qDnQ+tF3s1eAkWZAD43p8AdXw26WnP7d4MWwdPtB3FqQI28BAg0m3j5QRZFNeZ0TVA+YldSOoZpCVktOrBTBjpQ8PEA= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16557356209071009.561773233131; Mon, 20 Jun 2022 07:33:40 -0700 (PDT) Received: from localhost ([::1]:52928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3ITD-0008U8-Sk for importer@patchew.org; Mon, 20 Jun 2022 10:33:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3IL8-0005iN-Rg for qemu-devel@nongnu.org; Mon, 20 Jun 2022 10:25:18 -0400 Received: from mxout.security-mail.net ([85.31.212.42]:33892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3IL5-0001SA-Ot for qemu-devel@nongnu.org; Mon, 20 Jun 2022 10:25:18 -0400 Received: from localhost (localhost [127.0.0.1]) by fx302.security-mail.net (Postfix) with ESMTP id 2D7363D3B139 for ; Mon, 20 Jun 2022 16:25:12 +0200 (CEST) Received: from fx302 (localhost [127.0.0.1]) by fx302.security-mail.net (Postfix) with ESMTP id 409193D3B11A; Mon, 20 Jun 2022 16:25:10 +0200 (CEST) Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx302.security-mail.net (Postfix) with ESMTPS id ACB0C3D3B11B; Mon, 20 Jun 2022 16:25:09 +0200 (CEST) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 7B75D27E04E7; Mon, 20 Jun 2022 16:25:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 556CD27E04EC; Mon, 20 Jun 2022 16:25:09 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0y3QulsaVkGf; Mon, 20 Jun 2022 16:25:09 +0200 (CEST) Received: from ws2101.lin.mbt.kalray.eu (unknown [192.168.36.68]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 272D027E04D7; Mon, 20 Jun 2022 16:25:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1655735112; bh=CpDmm89i98qrl33cB4lpGWbeQuoLpTjJMK52jQ1/8e8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=55cHmQv6WJINO+McaW+ZPZg2WmY2pp3kBWhbO4sGwVOwC+OT/J2LTbaMN96uXHJAW iORfiImr476DrR1B7XiiY70di1dg5FQfnSgnhkM7oQIkgzpkmPcu9Yf5aHua45saMV VJYOqVR/gxH1ZhlXCo5ZtzsFad+1Nj6crKw8QYo4= X-Virus-Scanned: E-securemail Secumail-id: <2be4.62b08345.ac348.0> DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 556CD27E04EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1655735109; bh=QgH8wZqo2/2TxGhCDC/6naM/dZWNtRHlDBEDvIF5y6w=; h=From:To:Date:Message-Id; b=ba3UHBY2rhhQo35ox7cSOl6YTm26Gf70dgl+SgVx720LowwjZzSOoX9iHEYj0ZOPR N3rrQFLYxLvibgys+lbO/YP+MCFFhRfPHjg5+BbhOUb9AaNEsFmgjx+hF0D2Bzd39F GicohCDg0ozt/6NpoNiuOlV5GfFd4lzpidTtj23k= From: Luc Michel To: qemu-devel@nongnu.org Cc: Luc Michel , Richard Henderson , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eric Blake , Markus Armbruster , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Max Filippov Subject: [PATCH 1/7] softmmu: add qemu_[set|get]_exit_status functions Date: Mon, 20 Jun 2022 16:24:20 +0200 Message-Id: <20220620142426.15040-3-lmichel@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220620142426.15040-1-lmichel@kalray.eu> References: <20220620142426.15040-1-lmichel@kalray.eu> X-Virus-Scanned: by Secumail 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=85.31.212.42; envelope-from=lmichel@kalray.eu; helo=mxout.security-mail.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @kalray.eu) X-ZM-MESSAGEID: 1655735621841100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the two function qemu_set_exit_status() and qemu_get_exit_status(). Use qemu_get_exit_status() in main instead of 0 as the return value. This is in preparation for the semihosting exit request implementation. Signed-off-by: Luc Michel --- include/sysemu/sysemu.h | 2 ++ softmmu/main.c | 2 +- softmmu/runstate.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 812f66a31a..49b6970d0e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -103,10 +103,12 @@ void qemu_boot_set(const char *boot_order, Error **er= rp); bool defaults_enabled(void); =20 void qemu_init(int argc, char **argv, char **envp); void qemu_main_loop(void); void qemu_cleanup(void); +void qemu_set_exit_status(int status); +int qemu_get_exit_status(void); =20 extern QemuOptsList qemu_legacy_drive_opts; extern QemuOptsList qemu_common_drive_opts; extern QemuOptsList qemu_drive_opts; extern QemuOptsList bdrv_runtime_opts; diff --git a/softmmu/main.c b/softmmu/main.c index c00432ff09..67b4bb111e 100644 --- a/softmmu/main.c +++ b/softmmu/main.c @@ -34,11 +34,11 @@ int qemu_main(int argc, char **argv, char **envp) { qemu_init(argc, argv, envp); qemu_main_loop(); qemu_cleanup(); =20 - return 0; + return qemu_get_exit_status(); } =20 #ifndef CONFIG_COCOA int main(int argc, char **argv) { diff --git a/softmmu/runstate.c b/softmmu/runstate.c index fac7b63259..d2491b8a59 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -336,10 +336,11 @@ void vm_state_notify(bool running, RunState state) } =20 static ShutdownCause reset_requested; static ShutdownCause shutdown_requested; static int shutdown_signal; +static int exit_status; static pid_t shutdown_pid; static int powerdown_requested; static int debug_requested; static int suspend_requested; static WakeupReason wakeup_reason; @@ -351,10 +352,20 @@ static NotifierList wakeup_notifiers =3D NOTIFIER_LIST_INITIALIZER(wakeup_notifiers); static NotifierList shutdown_notifiers =3D NOTIFIER_LIST_INITIALIZER(shutdown_notifiers); static uint32_t wakeup_reason_mask =3D ~(1 << QEMU_WAKEUP_REASON_NONE); =20 +void qemu_set_exit_status(int status) +{ + exit_status =3D status; +} + +int qemu_get_exit_status(void) +{ + return exit_status; +} + ShutdownCause qemu_shutdown_requested_get(void) { return shutdown_requested; } =20 --=20 2.17.1