From nobody Fri May 17 10:13:52 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=adacore.com ARC-Seal: i=1; a=rsa-sha256; t=1696317332; cv=none; d=zohomail.com; s=zohoarc; b=E4rfw6y+/pC4cfy36BY2fiBBk5VEysHQa8mUnowcSA7nQovHhyxFCy3h1K9RZwmUiwS0EHeqVJJFE5QLZ3Cb6mNFqHgj4huw4RyqVhijTJDEW3fEFnS1v0D94Mwm1NDbevdMj/aY027rrphsqzYkbcCQvbGRoyPLou+8DFkBYj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696317332; 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=XCNf+Nj9MkTh/jQhA2UEhUyPLUkNl7IgQhSiMyt4rNI=; b=IPENT8QoYcsUeMhI7Covfu6G635MagR0+PKscZxjqaNWO2Wr0jNwTKe+grq9D0Wn1eIBTnaLQFY8vNR8GYtD/cHg0nFw3V3HG8nEdEBy6R8KfW21jKMLsAUZYZJih7Hl//kx4PCKYNXNsIylrvlX64QmqE7drN3771zoddLx5rA= 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 1696317332677256.7965574038027; Tue, 3 Oct 2023 00:15:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnZcB-0007Sl-8W; Tue, 03 Oct 2023 03:14:43 -0400 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 1qnZc9-0007Qg-Ms for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:41 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnZc7-0001gH-CD for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:41 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3231df68584so598857f8f.1 for ; Tue, 03 Oct 2023 00:14:39 -0700 (PDT) Received: from chigot-Dell.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id y16-20020a5d4710000000b003179d5aee67sm832196wrq.94.2023.10.03.00.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696317278; x=1696922078; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XCNf+Nj9MkTh/jQhA2UEhUyPLUkNl7IgQhSiMyt4rNI=; b=Z99nbxqt4kSKskIFwgtIdei8nssMMplUOsbb1G1xS40vgKKQdpDaxXy6TbZFAD66ql kd+vLFxMp2ACTbDiwhaZ6FBSIiwDbBqXWLxBEszSzj69qt6EGHhCE42DgSUGbJz08St0 9vjgmCruWttoBarOtNLCNk/auSAcH6Vn5ZBNX7rtYd8pvstiIe75jT9YhPSb/1DuSRUg wL4uljPunFhG3FjVmWwe1kV6EAibWkKGM2oOlv6+RJ3tzfeJvppK0m4gRHXljMBirtmy DkPRzUcEu52+6j6oL5EmPJeWtrY4rZjAmW/e00UQU++SvRL0vWzE+49DxKCGWG8EOcsr +YVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696317278; x=1696922078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XCNf+Nj9MkTh/jQhA2UEhUyPLUkNl7IgQhSiMyt4rNI=; b=ZzqzoPEGkpIR1B15iAd2q3pXFL5gijOXongfHOXRxxELlbcus93+p9yUS/IPgkhgXg g27NUurwmA27hwO9pIc1mPH3Z3WlFlxlaSJAUtEzB4MwmGDVcmDf1UH2EAdXhk+qL/jR FRm56C6KpfVso0QL7M6q6F28kMfOcfezC5uajwkhc34slZT8SzmKnA1uhzywuv2KW/0H P9lbeu79yodss/Rn8vhTjqRmXWVdKqutGjODHyc9WdlHhyXs7/1xWm5KNIlfhYzF11vf L4bQcPHbmlpbyCwN4bMH8Dn16tAoVlwA3U2NZaqsLKk5l8f/EOgFOk54phyl0vf3D5gJ TL1w== X-Gm-Message-State: AOJu0Yzq+oNEHxLSUeEBQANRoGNMoguRY3XgXKmzbvCVu9bX6Ke881jn jO4llt4PGmYng4xCTztrn1f8KyCqSuTElmvGHWs= X-Google-Smtp-Source: AGHT+IELoybTylNMZCWzC4yUvlKg2I8FSsHPQuJ6xZA/vw7JvJd5ZUcINC+SYnq9zpSGEG/3Pgf2EA== X-Received: by 2002:adf:ea8f:0:b0:320:1c6:628c with SMTP id s15-20020adfea8f000000b0032001c6628cmr13176077wrm.65.1696317277651; Tue, 03 Oct 2023 00:14:37 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, peter.maydell@linaro.org, alistair23@gmail.com, =?UTF-8?q?Cl=C3=A9ment=20Chigot?= , Alistair Francis Subject: [PATCH v4 1/5] softmmu: add means to pass an exit code when requesting a shutdown Date: Tue, 3 Oct 2023 09:14:23 +0200 Message-Id: <20231003071427.188697-2-chigot@adacore.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231003071427.188697-1-chigot@adacore.com> References: <20231003071427.188697-1-chigot@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::431; envelope-from=chigot@adacore.com; helo=mail-wr1-x431.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @adacore.com) X-ZM-MESSAGEID: 1696317334671100003 As of now, the exit code was either EXIT_FAILURE when a panic shutdown was requested or EXIT_SUCCESS otherwise. However, some hardware could want to pass more complex exit codes. Thus, introduce a new shutdown request function allowing that. Signed-off-by: Cl=C3=A9ment Chigot Reviewed-by: Alistair Francis --- include/sysemu/runstate.h | 2 ++ softmmu/runstate.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 08afb97695..c8c2bd8a61 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -68,6 +68,8 @@ void qemu_system_wakeup_request(WakeupReason reason, Erro= r **errp); void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); void qemu_register_wakeup_notifier(Notifier *notifier); void qemu_register_wakeup_support(void); +void qemu_system_shutdown_request_with_code(ShutdownCause reason, + int exit_code); void qemu_system_shutdown_request(ShutdownCause reason); void qemu_system_powerdown_request(void); void qemu_register_powerdown_notifier(Notifier *notifier); diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 1652ed0439..363a5ea8dd 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -385,6 +385,7 @@ void vm_state_notify(bool running, RunState state) =20 static ShutdownCause reset_requested; static ShutdownCause shutdown_requested; +static int shutdown_exit_code =3D EXIT_SUCCESS; static int shutdown_signal; static pid_t shutdown_pid; static int powerdown_requested; @@ -664,6 +665,13 @@ void qemu_system_killed(int signal, pid_t pid) qemu_notify_event(); } =20 +void qemu_system_shutdown_request_with_code(ShutdownCause reason, + int exit_code) +{ + shutdown_exit_code =3D exit_code; + qemu_system_shutdown_request(reason); +} + void qemu_system_shutdown_request(ShutdownCause reason) { trace_qemu_system_shutdown_request(reason); @@ -725,7 +733,9 @@ static bool main_loop_should_exit(int *status) if (shutdown_action =3D=3D SHUTDOWN_ACTION_PAUSE) { vm_stop(RUN_STATE_SHUTDOWN); } else { - if (request =3D=3D SHUTDOWN_CAUSE_GUEST_PANIC && + if (shutdown_exit_code !=3D EXIT_SUCCESS) { + *status =3D shutdown_exit_code; + } else if (request =3D=3D SHUTDOWN_CAUSE_GUEST_PANIC && panic_action =3D=3D PANIC_ACTION_EXIT_FAILURE) { *status =3D EXIT_FAILURE; } --=20 2.25.1 From nobody Fri May 17 10:13:52 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=adacore.com ARC-Seal: i=1; a=rsa-sha256; t=1696317379; cv=none; d=zohomail.com; s=zohoarc; b=QjmBsRqgVdR9DC6wqPpbeZZzhG9A1BkJfbMzm4MHOVXtikaSE6DaoOZy7XZvj5ctbRHsdORCYd5vwrUlZS6p9AWwM56uaOtjTeTXStiYJMfjkAUtgOsV43St2VKJsw+Wx8TOYH3wuZQE+vv6S+F5nUdxGxcTxZEoPT8o3Vtd14A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696317379; 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=OkiKnEYkM6j4qggxOGznItB/swiKFsiVyTm3GYtzm9w=; b=ndMSDdJdHzvIeJL+ZTilOVlz5m75WxEN9LGDU9aph8bF+ucQ75GnLNq0gWmWYcfhGJ4FtsVlvxTA7Z64UlfaafoFDP2BzmT0/Os9d0ZYgvPXrXmf/qqvUrMd4l9gvEXQkJy8JQVuo2HM+Z0cQP/g+tPe0edd814gR+Co41pVEnE= 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 169631737976094.79050507944396; Tue, 3 Oct 2023 00:16:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnZcC-0007Tn-WD; Tue, 03 Oct 2023 03:14:45 -0400 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 1qnZcA-0007Ry-Si for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:42 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnZc8-0001gY-Cx for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:41 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-9a6190af24aso96047966b.0 for ; Tue, 03 Oct 2023 00:14:40 -0700 (PDT) Received: from chigot-Dell.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id y16-20020a5d4710000000b003179d5aee67sm832196wrq.94.2023.10.03.00.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696317278; x=1696922078; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OkiKnEYkM6j4qggxOGznItB/swiKFsiVyTm3GYtzm9w=; b=aiY7L+8NNUbyzpaJPdDGirdmZzkXKxuuumsWIf8dL38FmkpCuNG/o9dzaFBOcdrWRI B4dQw5bneMraXc/e44dUqarc4Qk/QLBPl9WOkHqPmznR9W0JJ8Vr6q+vMhGRSrJfLHtK vB/oV0ie3fYPIGy5sHjQa439W1sU799LXJWk5Yukzs+zZ6kQH4kN22YFLuWCVCPTDXyt f/Te2XxDByIRH0JOLfEvk7jwOhteIXLoad8pjbLGDq/MDOvu3BzAdWSXOZFW1xeO1L5h ct7s4U1/hVhboGbOD/ptEy4COxD42kIjmO6tZW7We8WGpITpynixFzbM/UUVOrIjnaNg Mbog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696317278; x=1696922078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OkiKnEYkM6j4qggxOGznItB/swiKFsiVyTm3GYtzm9w=; b=iuJLZsy7xTaQS3dq4OrzEGCmF2av7IxDZlbC07SUpvNWLd9XiSFqEH6kbzwdKhJ+xB aCqz8v/jVnsccDF6Gga97I9yNnTTCgvOzbZuf5/XsrpXAAzztgu5j59pMv91UhdiIYv6 10D9vZcd/TJmRqXlSjaQgHgi014UsW6AC+/wTC1Gj/XhgEjb5fCyFoeKgTVNP5stcvx6 WahN6Zdy77PkuCNFP4IxTUymV1KsceaM2hRvcXjYuGYDBbwXoBzTYhwAfobtjLH9hXGG CHYWeSjqJKPXZvpu3UC+JysyK2PG3+aB0PVatJWoCQEtCzpUtI8/KoCzQtYAgsldKCK7 BeHQ== X-Gm-Message-State: AOJu0YzTHAN0V2dupNwkuoKwTQqDOoVfqSXKUzx2WsJguCYfGyOXIYWz 9IaR0QtZxvM2HdNWnIh3D9e0uRMWieIemyj0BA0= X-Google-Smtp-Source: AGHT+IF+hrvXIcNN+MkDWKiHKBP7C2W6OroVn0mUkEsqfSaJVxL4vpsKb+FLy+6ws9Rwq5xm6OrRuA== X-Received: by 2002:a17:906:eb82:b0:9ad:ef31:6ef6 with SMTP id mh2-20020a170906eb8200b009adef316ef6mr13726121ejb.20.1696317278510; Tue, 03 Oct 2023 00:14:38 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, peter.maydell@linaro.org, alistair23@gmail.com, =?UTF-8?q?Cl=C3=A9ment=20Chigot?= , Alistair Francis Subject: [PATCH v4 2/5] softmmu: pass the main loop status to gdb "Wxx" packet Date: Tue, 3 Oct 2023 09:14:24 +0200 Message-Id: <20231003071427.188697-3-chigot@adacore.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231003071427.188697-1-chigot@adacore.com> References: <20231003071427.188697-1-chigot@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::630; envelope-from=chigot@adacore.com; helo=mail-ej1-x630.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @adacore.com) X-ZM-MESSAGEID: 1696317381797100002 gdb_exit function aims to close gdb sessions and sends the exit code of the current execution. It's being called by qemu_cleanup once the main loop is over. Until now, the exit code sent was always 0. Now that hardware can shutdown this main loop with custom exit codes, these codes must be transfered to gdb as well. Signed-off-by: Cl=C3=A9ment Chigot Reviewed-by: Alistair Francis --- include/sysemu/sysemu.h | 2 +- softmmu/main.c | 2 +- softmmu/runstate.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 25be2a692e..73a37949c2 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -101,7 +101,7 @@ bool defaults_enabled(void); =20 void qemu_init(int argc, char **argv); int qemu_main_loop(void); -void qemu_cleanup(void); +void qemu_cleanup(int); =20 extern QemuOptsList qemu_legacy_drive_opts; extern QemuOptsList qemu_common_drive_opts; diff --git a/softmmu/main.c b/softmmu/main.c index 694388bd7f..9b91d21ea8 100644 --- a/softmmu/main.c +++ b/softmmu/main.c @@ -35,7 +35,7 @@ int qemu_default_main(void) int status; =20 status =3D qemu_main_loop(); - qemu_cleanup(); + qemu_cleanup(status); =20 return status; } diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 363a5ea8dd..ea9d6c2a32 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -834,9 +834,9 @@ void qemu_init_subsystems(void) } =20 =20 -void qemu_cleanup(void) +void qemu_cleanup(int status) { - gdb_exit(0); + gdb_exit(status); =20 /* * cleaning up the migration object cancels any existing migration --=20 2.25.1 From nobody Fri May 17 10:13:52 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=adacore.com ARC-Seal: i=1; a=rsa-sha256; t=1696317362; cv=none; d=zohomail.com; s=zohoarc; b=aGxPH5x7BWxLso42s6UcxdIRK+E9QnOC1PFOuYdUm7fpPZUQ/v+GjjSFLfeOHTxIS1G3lIL2FvlDed7avVbDkqjqIhmVIjV5lJCtoWX9ugOaaUTvGlT3vSsxbIIrjxt8Ldr4vk/cga4xZt3kej8mKqxaYm/4MF5njfqHFkUbW/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696317362; 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=5HOWFAUIjoYOvAaPK+iqc8J3TSNnmeBOgrcE2Swe+lQ=; b=H1n9Wh2wYBVZWz4S+KsI7qkhSPH1x/sSAzi1MvuszPDqMx5a0QxyOZxJdCkMEw6LNAnYpyVWTbmL2QkVaDD50C8Y78XpbKKUYGKTR/U/ak6Hnt74xQDwWbuNzVjowXCY22jkA4wQnIlGUn0h/ELLnWcOHunnJq1Fs0cCZjrjfDk= 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 1696317362799450.17257981526666; Tue, 3 Oct 2023 00:16:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnZcC-0007T4-0T; Tue, 03 Oct 2023 03:14:44 -0400 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 1qnZcA-0007Rj-P1 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:42 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnZc9-0001gk-6W for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:42 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-406618d0992so5582435e9.0 for ; Tue, 03 Oct 2023 00:14:40 -0700 (PDT) Received: from chigot-Dell.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id y16-20020a5d4710000000b003179d5aee67sm832196wrq.94.2023.10.03.00.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696317279; x=1696922079; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5HOWFAUIjoYOvAaPK+iqc8J3TSNnmeBOgrcE2Swe+lQ=; b=CwA26jvo7hlAtBHt0wdwQ0AQ/QA7OiariXhgYZy3JMGKQMUQoGO1HbOSP+aR2NhKuY QQCG71b4qW9/G9tvqPczQu26TlacEoyqPu8lK80RqUc1wlMYBEF+xppKdiM490NxrjST f16dxJIm5S7Bo1ZTteNpDC5iz1oiJB3Bkb3Qb2SB5XoDtOdxDHgYGgSXZZlVE67jojHV 9X4BWJATEsZE4MELkbm7bHyi+eFVrvV0IF8wB9kEPAkpjvm8El2do4/n11E71a6WrZ3q O55WyspsO+UxsZgm3zmbepC42sMkJ87lgacoPD8jmHMgfhIBU63cQeDfJ/wpK+BiQJ2i 9l3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696317279; x=1696922079; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5HOWFAUIjoYOvAaPK+iqc8J3TSNnmeBOgrcE2Swe+lQ=; b=BsWvwFWZKhIEfxezCK/hBPYpJwMW8f/h5vh3qr6UVaBRKfzYM2rjtk8PNWK7J9/VC7 UTeztsawe4HqDpx64sdyYFk/0Pyi8FLzKDgUlP9qfUyJH91GyBz7tkksmwUVrCBkZwJF DTnaMROUAeW/HbZVlGsbaFUTTtDZ30njPHVsSMC2+CoDmq3eyLlARR8qk4/dM2jFMA7n Ml0V3Q+2IuxX5y1apLmZZPueTRAnULTk0yEMu3gvAmEjcqBT8XvARFfLtLZaS8vBmzdO TWBGTnoBtPhnBd26sqkUN57BexXez0e8Grm6EuLC/MawxzR9Izqc9OoM6HoJuNOdEDZh Hwew== X-Gm-Message-State: AOJu0YwMjlPZ+gS/UrxiTSCIIAlR0a1YyzNGqVm35sbeTBEHcNGaNcUZ YAuFWHk+KlkhR1evkpkBwTkv2ndPLSrnBhYAdJU= X-Google-Smtp-Source: AGHT+IFWW3YuS9cACNEFJy4rebJE0chXVjrJcnS5IEZCiLXLXDXHiPZj+NUx1gd+TctGbWdl6OlZtQ== X-Received: by 2002:a5d:6a50:0:b0:314:2fdd:28ef with SMTP id t16-20020a5d6a50000000b003142fdd28efmr11141052wrw.18.1696317279299; Tue, 03 Oct 2023 00:14:39 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, peter.maydell@linaro.org, alistair23@gmail.com, =?UTF-8?q?Cl=C3=A9ment=20Chigot?= , Alistair Francis Subject: [PATCH v4 3/5] hw/misc/sifive_test.c: replace exit calls with proper shutdown Date: Tue, 3 Oct 2023 09:14:25 +0200 Message-Id: <20231003071427.188697-4-chigot@adacore.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231003071427.188697-1-chigot@adacore.com> References: <20231003071427.188697-1-chigot@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32d; envelope-from=chigot@adacore.com; helo=mail-wm1-x32d.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @adacore.com) X-ZM-MESSAGEID: 1696317363414100005 This replaces the exit calls by shutdown requests, ensuring a proper cleanup of Qemu. Otherwise, some connections like gdb could be broken before its final packet ("Wxx") is being sent. This part, being done inside qemu_cleanup function, can be reached only when the main loop exits after a shutdown request. Signed-off-by: Cl=C3=A9ment Chigot Reviewed-by: Alistair Francis --- hw/misc/sifive_test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/misc/sifive_test.c b/hw/misc/sifive_test.c index 56df45bfe5..ad688079c4 100644 --- a/hw/misc/sifive_test.c +++ b/hw/misc/sifive_test.c @@ -25,6 +25,7 @@ #include "qemu/module.h" #include "sysemu/runstate.h" #include "hw/misc/sifive_test.h" +#include "sysemu/sysemu.h" =20 static uint64_t sifive_test_read(void *opaque, hwaddr addr, unsigned int s= ize) { @@ -39,9 +40,13 @@ static void sifive_test_write(void *opaque, hwaddr addr, int code =3D (val64 >> 16) & 0xffff; switch (status) { case FINISHER_FAIL: - exit(code); + qemu_system_shutdown_request_with_code( + SHUTDOWN_CAUSE_GUEST_PANIC, code); + return; case FINISHER_PASS: - exit(0); + qemu_system_shutdown_request_with_code( + SHUTDOWN_CAUSE_GUEST_SHUTDOWN, code); + return; case FINISHER_RESET: qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); return; --=20 2.25.1 From nobody Fri May 17 10:13:52 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=adacore.com ARC-Seal: i=1; a=rsa-sha256; t=1696317354; cv=none; d=zohomail.com; s=zohoarc; b=agtu9BA3wUJmLdLmTSHsuvwfOYPbDl6Sv0QOuqsq80iEFrCKwhoG7Xn8CKlJ204sYcZ7EivR0b2G3cQGtWORj3YEIX9U0TQ2+og5rV6d2LIKjtC577dn9IIPHunopkii1KzT2Ua+5U4rZMIrdZVFObGw5IHw4WzIvVoB1Wrl9qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696317354; 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=jWJXBWm1ZYHjW4EfBm3crjEQsee3HSWCWajh4JJ9oZc=; b=BZJt/F48PJimfj+8CrGLUs8ybnm/HK5YboHbjIufCxNXkQIeZ/A3CYaW8T+hLnZ2YalVbC1fdsf2cUwnCRCBISnKgaz98kUVALsn01MdDV7XIQDbXJ0k4uMDN+YidgaCxUFpwCKlQGGo2PPOqrdIRr1Uncy2yNwEM8jyXUzSyco= 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 1696317354257672.3201508573123; Tue, 3 Oct 2023 00:15:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnZcE-0007UB-5g; Tue, 03 Oct 2023 03:14:46 -0400 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 1qnZcB-0007So-GL for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:43 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnZcA-0001h7-0w for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:43 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-327be5fe4beso573720f8f.3 for ; Tue, 03 Oct 2023 00:14:41 -0700 (PDT) Received: from chigot-Dell.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id y16-20020a5d4710000000b003179d5aee67sm832196wrq.94.2023.10.03.00.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696317280; x=1696922080; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jWJXBWm1ZYHjW4EfBm3crjEQsee3HSWCWajh4JJ9oZc=; b=ZlGFTWzP51koOAmxhDWGxWWKriJO28bbPAiE/i/yDfr/klQFlVpPUNgX3KwfkmLVRh 711oadsT8njF7NRmVOo7Bc4h3JIsxDKDATpez5pA4KNC6lelTi6vFi2HBKGpBcO7DCbh qAuEH6o1j4goj24fvYAJSjldjzezuPGzAw1NfVlwjKnHTT46AM7j1Bu6gmq2LZtuFE4Y Y4BP3RpcGznBXztP1itFTSKDuPskxYE9RgOfrEzgleg6fMrSJc0SyYVmI+SxeM+hct73 eJ5951Z4066COx7pu4NpobwojLlwQU6fwA5xvY03awA4B9wkKBLPyXIywIUd7HgnNBZh lIhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696317280; x=1696922080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jWJXBWm1ZYHjW4EfBm3crjEQsee3HSWCWajh4JJ9oZc=; b=UJYygQnvxJpJrcF1QaSxxyVmWd8tm6c114ftaRApqPr1/jD4AdS0CanpwJyT3jjMXg 27OrKpn3EsJOCnnFIwpByNEYXwgF8NLJlEzRgB+rj0WvvIbgFvKQwtiC6oO6JnaN1ThO eWzGkykbUc+5iIOizDS4OeI1hPHqk8GzbLm0TgR61Qt7jy8OrZZzi9QE6sTThaqDeZ/0 ifiZJXMUtZGnV0YZMxXLtpkMAya3nqe4eqAG36tJMi3ydSQ7O5DJR749GU5KZdGSF8ds jxoyr2ViKHbRcS0j6wohiAPp/0Q1ZmcWGxTcl+debPE02v+AGkAKIrO+N+VLT/ONl2p+ 0DAA== X-Gm-Message-State: AOJu0YzTOg1qp79bqsMIF390FOhEzplgb56oGteQDYHhsc9Q8Cmn94cu 8s59KOtOSU9RF28gZqwDGL5Oa7vWo7fykJWHeUY= X-Google-Smtp-Source: AGHT+IHtOSY6DoWRRNrGgpDloH5PKYgXaG6fSiMgh9Wmc9JgOFHAwYKXQes7ZilnQ3LuYi3lQnDsLg== X-Received: by 2002:a5d:5390:0:b0:324:7bdb:873a with SMTP id d16-20020a5d5390000000b003247bdb873amr11996172wrv.58.1696317280120; Tue, 03 Oct 2023 00:14:40 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, peter.maydell@linaro.org, alistair23@gmail.com, =?UTF-8?q?Cl=C3=A9ment=20Chigot?= , Alistair Francis Subject: [PATCH v4 4/5] hw/char: riscv_htif: replace exit calls with proper shutdown Date: Tue, 3 Oct 2023 09:14:26 +0200 Message-Id: <20231003071427.188697-5-chigot@adacore.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231003071427.188697-1-chigot@adacore.com> References: <20231003071427.188697-1-chigot@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::429; envelope-from=chigot@adacore.com; helo=mail-wr1-x429.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @adacore.com) X-ZM-MESSAGEID: 1696317355520100005 This replaces the exit calls by shutdown requests, ensuring a proper cleanup of Qemu. Otherwise, some connections like gdb could be broken before its final packet ("Wxx") is being sent. This part, being done inside qemu_cleanup function, can be reached only when the main loop exits after a shutdown request. Signed-off-by: Cl=C3=A9ment Chigot Reviewed-by: Alistair Francis --- hw/char/riscv_htif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c index 40de6b8b77..9bef60def1 100644 --- a/hw/char/riscv_htif.c +++ b/hw/char/riscv_htif.c @@ -32,6 +32,7 @@ #include "exec/address-spaces.h" #include "exec/tswap.h" #include "sysemu/dma.h" +#include "sysemu/runstate.h" =20 #define RISCV_DEBUG_HTIF 0 #define HTIF_DEBUG(fmt, ...) = \ @@ -206,7 +207,9 @@ static void htif_handle_tohost_write(HTIFState *s, uint= 64_t val_written) g_free(sig_data); } =20 - exit(exit_code); + qemu_system_shutdown_request_with_code( + SHUTDOWN_CAUSE_GUEST_SHUTDOWN, exit_code); + return; } else { uint64_t syscall[8]; cpu_physical_memory_read(payload, syscall, sizeof(syscall)= ); --=20 2.25.1 From nobody Fri May 17 10:13:52 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=adacore.com ARC-Seal: i=1; a=rsa-sha256; t=1696317322; cv=none; d=zohomail.com; s=zohoarc; b=YYf5mNxbUUlAHYxNcc91FogZgCj/W5QSekwuDJivQiLrQ+Ny7DJsO3WEXECg+MPXtJRAImqDDJkRvKpOQDhYhpd1lkhWxT6VjgmteJppi9JyxH+c1CDPoTYyoGFOVRcDIaRfYnte2qf/h+kImVAa5g6LpSD6GuhE0T2C/+f4XE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696317322; 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=yzSpuvNiyZjxVcPUpl33+RuyiyS/VcvR51U6nTfUSj4=; b=nAEa4kQ3KLUvLLGiiikZtFAiO7diQ+Qa+AXk63jkEEOJxz28QhP4e8iqPFBuIC9CYbmG3xBdpQe3GrWTLwoWtEZM+vlE6+n8hbm3jcqxygmIpGpFkuoU9twA7ppIMwkDJAxCAePihkgXYT3U57u3sxnC09ruab1BIp5y6g6A1wU= 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 1696317322232142.9076200451866; Tue, 3 Oct 2023 00:15:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnZcE-0007UD-Ql; Tue, 03 Oct 2023 03:14:46 -0400 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 1qnZcC-0007Tj-Pb for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:44 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnZcA-0001hg-Qz for qemu-devel@nongnu.org; Tue, 03 Oct 2023 03:14:44 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5048156976cso646764e87.2 for ; Tue, 03 Oct 2023 00:14:42 -0700 (PDT) Received: from chigot-Dell.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id y16-20020a5d4710000000b003179d5aee67sm832196wrq.94.2023.10.03.00.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696317281; x=1696922081; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yzSpuvNiyZjxVcPUpl33+RuyiyS/VcvR51U6nTfUSj4=; b=fblKUTDB5YpegakYh0HVAD0RJiJ02oI6c9xluu00jjzRsPjN8DaeOgGBMKVzryPjZR uulj1MGsNUeTepu9Yh6FzsR9MdDsMzr5FDM3xtYjtb91fZCKzIm3H459/WiuF0QpHFar 7qnuVE6smIzK0dlEFUloI1gnuoADFz9i+mt+wmGcjJibNlWubHm7g2AHKDx9ku3C9r+p uyNbuEZ/tC7MCCb0Af/NTsFeM+bnMFTTfFsba/4tInAS1NfMjPo9t7oZjTNMKPVBfPYY uusV/oYdmIB49yt+Kz4cQm/i7BZR7Lq8F6yv1W1yQc6uu0Mat5BE6X2ttkNi4G8JYMdl qACQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696317281; x=1696922081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yzSpuvNiyZjxVcPUpl33+RuyiyS/VcvR51U6nTfUSj4=; b=SOeGux9glJ18ghvxkejnO8Nh5aj2ALVA56szGOGMnMOAcUyBi0WIXnQhDQnFCJlLmt FGT9cWCYW0qftt6ZRj7OA1dgRjzV31xWAQWDFR97myjvJzQLrYOK+rixQqMnrgPM+9FL Tprmz813aen0eTev6nQnxqswmmgnE2zrMr2UbREgHeiv2von45bpEIX4z9pHRy6/Fkwp prehJUNbD9QqSKJPi/SCCHM/yPrnM/Fw3zG871BO+X10PHUz1TebPff2B/Mj+B7DvU39 Ct8tFIRlPvLs3gKVNHBRiwNtjuf4Us7vIU7RRZhlqTRCxsVFle5zfDjXI2r7fpInakh6 Sy6A== X-Gm-Message-State: AOJu0Yxn/u9YViHLLuY6Xk8mdsfv7vRVVmI+mZ30dlfnBoR894KBjJbg edttWx6jbCTLmQcScwPzFJeTXvTz4e7FcCpLgtA= X-Google-Smtp-Source: AGHT+IGGiEx/8kNQrOTdmjbkNj8W3cMX/ZhMjrPGrDJHRZmPHMPbmC+psRBF1qDN8a/HKbsr2zsxow== X-Received: by 2002:a05:6512:4819:b0:505:6ede:20b0 with SMTP id eo25-20020a056512481900b005056ede20b0mr8536401lfb.58.1696317280896; Tue, 03 Oct 2023 00:14:40 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, peter.maydell@linaro.org, alistair23@gmail.com, =?UTF-8?q?Cl=C3=A9ment=20Chigot?= , Alistair Francis Subject: [PATCH v4 5/5] gdbstub: replace exit calls with proper shutdown for softmmu Date: Tue, 3 Oct 2023 09:14:27 +0200 Message-Id: <20231003071427.188697-6-chigot@adacore.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231003071427.188697-1-chigot@adacore.com> References: <20231003071427.188697-1-chigot@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::129; envelope-from=chigot@adacore.com; helo=mail-lf1-x129.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @adacore.com) X-ZM-MESSAGEID: 1696317322757100001 This replaces the exit calls by shutdown requests, ensuring a proper cleanup of Qemu. Features like net/vhost-vdpa.c are expecting qemu_cleanup to be called to remove their last residuals. Signed-off-by: Cl=C3=A9ment Chigot Reviewed-by: Alistair Francis --- gdbstub/gdbstub.c | 5 +++-- gdbstub/softmmu.c | 6 ++++++ gdbstub/user.c | 6 ++++++ include/gdbstub/syscalls.h | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 349d348c7b..1cb6d65306 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1327,7 +1327,7 @@ static void handle_v_kill(GArray *params, void *user_= ctx) gdb_put_packet("OK"); error_report("QEMU: Terminated via GDBstub"); gdb_exit(0); - exit(0); + gdb_qemu_exit(0); } =20 static const GdbCmdParseEntry gdb_v_commands_table[] =3D { @@ -1846,7 +1846,8 @@ static int gdb_handle_packet(const char *line_buf) /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); gdb_exit(0); - exit(0); + gdb_qemu_exit(0); + break; case 'D': { static const GdbCmdParseEntry detach_cmd_desc =3D { diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 9f0b8b5497..a5d6e04c79 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -435,6 +435,12 @@ void gdb_exit(int code) qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); } =20 +void gdb_qemu_exit(int code) +{ + qemu_system_shutdown_request_with_code(SHUTDOWN_CAUSE_GUEST_SHUTDOWN, + code); +} + /* * Memory access */ diff --git a/gdbstub/user.c b/gdbstub/user.c index 7ab6e5d975..dbe1d9b887 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -113,6 +113,12 @@ void gdb_exit(int code) gdb_put_packet(buf); gdbserver_state.allow_stop_reply =3D false; } + +} + +void gdb_qemu_exit(int code) +{ + exit(code); } =20 int gdb_handlesig(CPUState *cpu, int sig) diff --git a/include/gdbstub/syscalls.h b/include/gdbstub/syscalls.h index 243eaf8ce4..54ff7245a1 100644 --- a/include/gdbstub/syscalls.h +++ b/include/gdbstub/syscalls.h @@ -110,4 +110,13 @@ int use_gdb_syscalls(void); */ void gdb_exit(int code); =20 +/** + * gdb_qemu_exit: ask qemu to exit + * @code: exit code reported + * + * This requests qemu to exit. This function is allowed to return as + * the exit request might be processed asynchronously by qemu backend. + */ +void gdb_qemu_exit(int code); + #endif /* _SYSCALLS_H_ */ --=20 2.25.1