From nobody Tue Feb 10 17:46:15 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=1655816955; cv=none; d=zohomail.com; s=zohoarc; b=ccSeOqKrVInapnsQ8ph75rgnynonYUKVDLGVxtLEXwfkZYbeca+XF3iJ0UuoOCOznfk7t2wTEM+t49ckyAYkMllB6bltH59UQ5ZCmI8pZ7224pNnHJypWWDmep3Pz+t7rJVGw/KOyC5P910Lv5q2MGSkeoAl2uls72OYQTKSEWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655816955; 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=CHdUa5EUCvF0MuxJdZ5rZNLhaXwYjEDCGzXTOWTxyJ0=; b=fACi7AVNNy7mxZNYVmNXyIJRWVYtIWZatd/ymeyYwE8XJLlA3HrKKTttabRYQq8Wy7K1OmYRH7O4EnH3d2cLrCrlvJsNffdxel3aV2NcXlL4NXxmZjcXSTpI7GfbjikoDEdai2h1/rggfFhkUXQsdHcX51cjYwjUWDN0mRJBnC4= 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 16558169550611007.4256785019386; Tue, 21 Jun 2022 06:09:15 -0700 (PDT) Received: from localhost ([::1]:42816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3dd3-0008SX-Tw for importer@patchew.org; Tue, 21 Jun 2022 09:09:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3dTo-0007UY-MN for qemu-devel@nongnu.org; Tue, 21 Jun 2022 08:59:40 -0400 Received: from smtpout30.security-mail.net ([85.31.212.38]:60586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3dTl-0005Fc-Ua for qemu-devel@nongnu.org; Tue, 21 Jun 2022 08:59:40 -0400 Received: from localhost (localhost [127.0.0.1]) by fx308.security-mail.net (Postfix) with ESMTP id 7C5495F46EF for ; Tue, 21 Jun 2022 14:59:36 +0200 (CEST) Received: from fx308 (localhost [127.0.0.1]) by fx308.security-mail.net (Postfix) with ESMTP id BE7845F4624; Tue, 21 Jun 2022 14:59:32 +0200 (CEST) Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx308.security-mail.net (Postfix) with ESMTPS id 3D7DB5F460A; Tue, 21 Jun 2022 14:59:32 +0200 (CEST) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 1C1CD27E04EF; Tue, 21 Jun 2022 14:59:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 004D627E04E7; Tue, 21 Jun 2022 14:59:31 +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 Ck7MY46QggJy; Tue, 21 Jun 2022 14:59:31 +0200 (CEST) Received: from ws2101.lin.mbt.kalray.eu (unknown [192.168.36.68]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id D22D227E04D7; Tue, 21 Jun 2022 14:59:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1655816376; bh=8AoLDKKMDfz7XgrOQZjn193j+3Nd9LcsodtAEQaqICs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eIc49C1r7IZ1gTPKGfM6rX42wRPW7MHuCFyik7ra1AnSn871QbI7CroCIhca62upn 6dMxIMAn8DS31459VpobgSIV2zuOtPq555FhI2pvubLuiG0L3ppp5t+wxNGc7cpQ15 mLM0mjB/aMAoX+ljN8DzJXMGlVoxJcOb9N8MqNYo= X-Virus-Scanned: E-securemail Secumail-id: <83fd.62b1c0b4.3d086.0> DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 004D627E04E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1655816372; bh=CHdUa5EUCvF0MuxJdZ5rZNLhaXwYjEDCGzXTOWTxyJ0=; h=From:To:Date:Message-Id; b=e5VZlIMlViugRB3Uqgg6etitTNXbasH044jOQNarMlAgFSVqg/zJj2/Hb7gv8BMzf yoXv0lfYBjjMqhW+mrfidmkelrvibyEJAG3FFZIirdCbsk7OJ/VgI96fXpMSchA6H/ HSeOH0bxnWmKsQ7ezPJG6R7ck6u8l97ZZ2pVb8mc= 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 v2 1/7] softmmu: add qemu_[set|get]_exit_status functions Date: Tue, 21 Jun 2022 14:59:10 +0200 Message-Id: <20220621125916.25257-2-lmichel@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220621125916.25257-1-lmichel@kalray.eu> References: <20220621125916.25257-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.38; envelope-from=lmichel@kalray.eu; helo=smtpout30.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: 1655816956902100001 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 Reviewed-by: Laurent Vivier --- include/sysemu/sysemu.h | 2 ++ softmmu/main.c | 2 +- softmmu/runstate.c | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) 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..a86ffa91e5 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 @@ -779,11 +790,11 @@ void qemu_init_subsystems(void) } =20 =20 void qemu_cleanup(void) { - gdb_exit(0); + gdb_exit(qemu_get_exit_status()); =20 /* * cleaning up the migration object cancels any existing migration * try to do this early so that it also stops using devices. */ --=20 2.17.1