From nobody Sat Sep 26 20:02:58 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1788555517; cv=none; d=zohomail.com; s=zohoarc; b=CejGu7cUN0cacbw4jMDHxB3r20KXHf46CjSofILtJpKHOTP5eHWfLBxkinBNQ3RHOJ1zjy80WfY9NSGOxHIMoKm24qKIZRdHVuiNYnA5hE8Kmt9aaHSy7/qQVIc6iELNJ2HXRfmpmn8ce9gCn9SJlrfqKbI5X6KXDx0VitzcYO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788555517; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bedHR9LEwKO84C89vQwYCYbjLl7t6GtzAgZ2vPETCyQ=; b=hzpU0tIByxM5GsXMB9DXpoTTHtg81s2XO21rog/QkqcGr9ygS8cAtXvLQ9n+4cuDA3q70NkF3Jv5wCqgJ2J//BT+K/fDcS8oZLHyCoPiUvTiI4kKU/scSk02aim9ddIVze324YHFv0y+L9nmrWqzC7d5cNyIGzMpR7h9V1jPxN4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788555517396253.98045081697762; Fri, 4 Sep 2026 13:58:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2az4-00038L-Hh; Fri, 04 Sep 2026 16:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az3-000380-9b for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:01 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az1-0007w7-7t for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:01 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c11:43a8:0:640:574d:0]) by forwardcorp1b.mail.yandex.net (postfix) with ESMTPS id 59F32807B0; Fri, 04 Sep 2026 23:57:54 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:4d::1:17]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp) with ESMTPSA id rvQjs41YPqM0-ei1dEAG6; Fri, 04 Sep 2026 23:57:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1788555474; bh=bedHR9LEwKO84C89vQwYCYbjLl7t6GtzAgZ2vPETCyQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=E86LoHp/3CN5PuxkJ08KcdQku5K9kV8OihUJNKlg0O++H4ui2hQvuyOzLdWnwYSrE tKnuq1kRfh10rpLqbFEO7PFqEvGtLPQn/rlYnRimEtsn3qYp1HEacUGRJA7atrhdti Zbg8pvVJaCjWBvFmtEguBPYPIgjn+WQF6tSOKqSM= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru Subject: [PATCH 1/6] runstate: introduce qemu_system_shutdown_request_safe() helper Date: Fri, 4 Sep 2026 23:57:44 +0300 Message-ID: <20260904205749.510493-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904205749.510493-1-vsementsov@yandex-team.ru> References: <20260904205749.510493-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, 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: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1788555522070158500 Content-Type: text/plain; charset="utf-8" Extract the signal-safe part of qemu_system_shutdown_request() into a helper and reuse it in qemu_system_killed(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- system/runstate.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/system/runstate.c b/system/runstate.c index d3e64d2b625..6bb839b3c0d 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -970,18 +970,34 @@ bool qemu_wakeup_suspend_enabled(void) return wakeup_suspend_enabled; } =20 +/* + * Signal-safe part of qemu_system_shutdown_request(), + * only to be called from qemu_system_killed(). + * Other callers use qemu_system_shutdown_request(). + */ +static void qemu_system_shutdown_request_safe(ShutdownCause reason) +{ + shutdown_requested =3D reason; + if (reason =3D=3D SHUTDOWN_CAUSE_HOST_QMP_QUIT || + reason =3D=3D SHUTDOWN_CAUSE_HOST_SIGNAL) { + force_shutdown =3D true; + } + qemu_notify_event(); +} + +void qemu_system_shutdown_request(ShutdownCause reason) +{ + trace_qemu_system_shutdown_request(reason); + replay_shutdown_request(reason); + qemu_system_shutdown_request_safe(reason); +} + void qemu_system_killed(int signal, pid_t pid) { shutdown_signal =3D signal; shutdown_pid =3D pid; shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; - - /* Cannot call qemu_system_shutdown_request directly because - * we are in a signal handler. - */ - shutdown_requested =3D SHUTDOWN_CAUSE_HOST_SIGNAL; - force_shutdown =3D true; - qemu_notify_event(); + qemu_system_shutdown_request_safe(SHUTDOWN_CAUSE_HOST_SIGNAL); } =20 void qemu_system_shutdown_request_with_code(ShutdownCause reason, @@ -991,17 +1007,6 @@ void qemu_system_shutdown_request_with_code(ShutdownC= ause reason, qemu_system_shutdown_request(reason); } =20 -void qemu_system_shutdown_request(ShutdownCause reason) -{ - trace_qemu_system_shutdown_request(reason); - replay_shutdown_request(reason); - shutdown_requested =3D reason; - if (reason =3D=3D SHUTDOWN_CAUSE_HOST_QMP_QUIT) { - force_shutdown =3D true; - } - qemu_notify_event(); -} - static void qemu_system_powerdown(void) { qapi_event_send_powerdown(); --=20 2.43.0 From nobody Sat Sep 26 20:02:58 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1788555555; cv=none; d=zohomail.com; s=zohoarc; b=kXj9vHGyM22ng/HEJ+pwbvWGcvE9bPdzK2ZyYGCCpGmuVmAjjRagm6ezwA4wy1FM8l+jqOKOBH3I5zFLzg2dvi6Sh7jMnaWc4YGTkyxMK27VhbZDvWTGPTPbApKrP2SpJD2OfY/gOrf/io0QAVh6rWaAQlC7Ct5uIqRIX6/gf80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788555555; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=obUfxhc4vFAow+0ul9iMmZXRbP4zBRL4hPDfuYCs1+Y=; b=gWbrv/CKQz3FWo62IeleVz2Y+CP3/wbPRGZG677udoFTH1QVGiUVczQ1rXpU1VgJB7rrQaQIeyqHhhmp94qKKa0karY/fDEDyjx1WwM7AWmZhZbQKGnniOiTUA7PL7izsALvMb1Jna+vpCfrMGrqXN5ia//F3FIxzbDBSuGIv+8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788555554231737.545665981812; Fri, 4 Sep 2026 13:59:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2az6-000398-BB; Fri, 04 Sep 2026 16:58:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az4-00038a-JN for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:02 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az1-0007wD-IH for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:02 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c11:43a8:0:640:574d:0]) by forwardcorp1b.mail.yandex.net (postfix) with ESMTPS id BAACF8078E; Fri, 04 Sep 2026 23:57:54 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:4d::1:17]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp) with ESMTPSA id rvQjs41YPqM0-buNIuilX; Fri, 04 Sep 2026 23:57:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1788555474; bh=obUfxhc4vFAow+0ul9iMmZXRbP4zBRL4hPDfuYCs1+Y=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=T8e9Dwn+3UGHeWzG29z2wTMEuPrDsuKp7h6k5oKShwdV8Ibn6w2D6yjuLa2NkygfH /Oo7QBR3GlOHoXbcP17CVSriI7CUR3VwdhO0LDpBNCwmFoGniW7EyAPZq8QsMQAlWi Uat+KGus3P6ZUrg6hN0VTo04RvuecCriaiT4Na3o= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru Subject: [PATCH 2/6] runstate: treat SHUTDOWN_CAUSE_HOST_UI as force_shutdown Date: Fri, 4 Sep 2026 23:57:45 +0300 Message-ID: <20260904205749.510493-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904205749.510493-1-vsementsov@yandex-team.ru> References: <20260904205749.510493-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, 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: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1788555558444158500 Content-Type: text/plain; charset="utf-8" Like QMP quit and host signals, UI shutdown requests force QEMU to exit by setting shutdown_action to SHUTDOWN_ACTION_POWEROFF. Set force_shutdown for these requests as well. The only consumer of qemu_force_shutdown_requested() is the vhost-user-blk stop code. When configured to skip synchronization during forced shutdown, it should do so for UI shutdown requests just as it does for QMP quit and host signals. Signed-off-by: Vladimir Sementsov-Ogievskiy --- system/runstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/runstate.c b/system/runstate.c index 6bb839b3c0d..1958168e778 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -979,7 +979,8 @@ static void qemu_system_shutdown_request_safe(ShutdownC= ause reason) { shutdown_requested =3D reason; if (reason =3D=3D SHUTDOWN_CAUSE_HOST_QMP_QUIT || - reason =3D=3D SHUTDOWN_CAUSE_HOST_SIGNAL) { + reason =3D=3D SHUTDOWN_CAUSE_HOST_SIGNAL || + reason =3D=3D SHUTDOWN_CAUSE_HOST_UI) { force_shutdown =3D true; } qemu_notify_event(); --=20 2.43.0 From nobody Sat Sep 26 20:02:58 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1788555537; cv=none; d=zohomail.com; s=zohoarc; b=gMiiKQVtZm5sg1WTWoxJTrh40tAlCQAP9xETTdJSHh1lWynHclNfAmsDw4EMEYrGfXQ/DFiXw5iU3aSvaR02nyVSthH0ZwRqghQc1/o3JX+KjjGgfHF4DKZHNZhp+YEKNb6xX9dFSusuJftttIJe0VAHL6QUOJZMXlUf077TqhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788555537; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EfOJFPjSgVcjOFLAMnKLU9sPtYfAKnhoVr3oXGmPviI=; b=R02KCXa9bQCdbWq2u+NeuKRgqVvMcnDJgVzAY1DJAome3ZSp5FEQmmE39aiNFldP1niG0gOBIF/+vEiv2wcQFsDOu1zcC4CKYz3Ea5Q4EUikMl3pvrWx91rzQfq3PWRHaoQcBEZU4AL6yhRsA4VKKqTR24cm3QXWq2mhZQYYHNw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178855553736417.004968001395582; Fri, 4 Sep 2026 13:58:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2az6-000397-DB; Fri, 04 Sep 2026 16:58:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az3-00037z-8r for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:01 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az1-0007wQ-7G for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:01 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c11:43a8:0:640:574d:0]) by forwardcorp1b.mail.yandex.net (postfix) with ESMTPS id 2AA4F80A59; Fri, 04 Sep 2026 23:57:55 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:4d::1:17]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp) with ESMTPSA id rvQjs41YPqM0-QOmqgnw5; Fri, 04 Sep 2026 23:57:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1788555474; bh=EfOJFPjSgVcjOFLAMnKLU9sPtYfAKnhoVr3oXGmPviI=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=PxsKuONW5qFDze3rJqfpnB0TZwLiXUIW1MVQOy1D/tPqWiwy8ccn+2545+/4IPfMD zlZqCtuuKxcSBwGta9Vh+xM7r4wigBxfWi2psIuF3u7YIECWI0U7zDJI4bJgnpPN11 iXkdJGr0ZejDCvZWMzHSXkuqcWgbJFfJUx0D6EyA= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru Subject: [PATCH 3/6] runstate: inline qemu_shutdown_requested() Date: Fri, 4 Sep 2026 23:57:46 +0300 Message-ID: <20260904205749.510493-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904205749.510493-1-vsementsov@yandex-team.ru> References: <20260904205749.510493-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, 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: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1788555540597158500 Content-Type: text/plain; charset="utf-8" The function has only one caller. Inline it to simplify the upcoming refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy --- system/runstate.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/system/runstate.c b/system/runstate.c index 1958168e778..01f936649b4 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -597,11 +597,6 @@ ShutdownCause qemu_reset_requested_get(void) return reset_requested; } =20 -static int qemu_shutdown_requested(void) -{ - return qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); -} - static void qemu_kill_report(void) { if (!qtest_driver() && shutdown_signal) { @@ -1054,7 +1049,7 @@ static bool main_loop_should_exit(int *status) if (qemu_suspend_requested()) { qemu_system_suspend(); } - request =3D qemu_shutdown_requested(); + request =3D qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); if (request) { qemu_kill_report(); qemu_system_shutdown(request); --=20 2.43.0 From nobody Sat Sep 26 20:02:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1788555518; cv=none; d=zohomail.com; s=zohoarc; b=EzwFF3ACtn1DNlQUFI03P8RS63+ZqSsI90Hmb4hZoriwcgBt743/+j7IqI864Pyxt566LGD3HyIgUqZKSB6S9Qx3v0wFYMz+8WE0KWVpxGRSgK2tsQdwR8AXn9G10UCThQZ7Q8uWv93lMNtg8MGGixyirmY0Wkjii/bTQ/kwmI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788555518; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dlc3dK5WOaqmo7z+t9buAmX2gat8HcjIw965WO9A260=; b=StXL9ebkqeSMaMMXii6KtbT8omW6phYlRgwOyqgNQNrhPznD3hpyoQir1+qYMuNn9SZNE2piDesw1IqtV1El74z0le0Khv/KfB8wt8iz4YQQTjyOgmD04PQzLSMdkUqqA6tC6kNR604RVO5sIz+7igDeLHJW2RyTLMi0qZE3YnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788555517981695.3750752430076; Fri, 4 Sep 2026 13:58:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1409150.1641298 (Exim 4.92) (envelope-from ) id 1x2az3-0006Q3-8o; Fri, 04 Sep 2026 20:58:01 +0000 Received: by outflank-mailman (output) from mailman id 1409150.1641298; Fri, 04 Sep 2026 20:58:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x2az3-0006Pw-5l; Fri, 04 Sep 2026 20:58:01 +0000 Received: by outflank-mailman (input) for mailman id 1409150; Fri, 04 Sep 2026 20:57:59 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x2az1-0006Pp-Cg for xen-devel@lists.xenproject.org; Fri, 04 Sep 2026 20:57:59 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x2ayz-002Wei-Vk for xen-devel@lists.xenproject.org; Fri, 04 Sep 2026 22:57:57 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a9b30cf-2eae-0a2a0a5409dd-0a2a450bea8a-2 for ; Fri, 04 Sep 2026 22:57:57 +0200 Received: from [178.154.239.136] (helo=forwardcorp1b.mail.yandex.net) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a9b30d4-b7e8-0a2a450b0019-b29aef88c08e-3 for ; Fri, 04 Sep 2026 22:57:56 +0200 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c11:43a8:0:640:574d:0]) by forwardcorp1b.mail.yandex.net (postfix) with ESMTPS id 08FC880A61; Fri, 04 Sep 2026 23:57:56 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:4d::1:17]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp) with ESMTPSA id rvQjs41YPqM0-UooXil1Y; Fri, 04 Sep 2026 23:57:55 +0300 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=default header.d=yandex-team.ru header.i="@yandex-team.ru" header.h="Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From" X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1788555475; bh=Dlc3dK5WOaqmo7z+t9buAmX2gat8HcjIw965WO9A260=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=aFCJE6IQeVsZRJl6yv7vJPVyaDOeihMcE1i2xYJwRBLOy+OAqg25ttfEbdwewBfIl GFcGpErcsRrKygFyU1ZvDJfl76GdFJBqnwlEodNaMHoTtAOQGP8UYOH++P+1PVc6ZV vGgqWrgWzf0I5/gPfyq9LRJZN/4JewRXr29PMplM= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org (open list:X86 Xen CPUs) Subject: [PATCH 4/6] runstate: simplify qemu_shutdown_requested_get() Date: Fri, 4 Sep 2026 23:57:47 +0300 Message-ID: <20260904205749.510493-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904205749.510493-1-vsementsov@yandex-team.ru> References: <20260904205749.510493-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1788555477-18AC89EA-99E2A508/0/0 X-purgate-type: clean X-purgate-size: 1992 X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1788555521439158500 Content-Type: text/plain; charset="utf-8" The only caller needs to know whether a shutdown request is pending, not its reason. Return bool and rename the function to qemu_shutdown_requested(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/xen/xen-hvm-common.c | 2 +- include/system/runstate.h | 2 +- system/runstate.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 62d88804c43..4d01a12062d 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -610,7 +610,7 @@ static void cpu_handle_ioreq(void *opaque) if (runstate_is_running()) { ShutdownCause request; =20 - if (qemu_shutdown_requested_get()) { + if (qemu_shutdown_requested()) { destroy_hvm_domain(false); } request =3D qemu_reset_requested_get(); diff --git a/include/system/runstate.h b/include/system/runstate.h index 929379adae4..3ed35921bb7 100644 --- a/include/system/runstate.h +++ b/include/system/runstate.h @@ -146,7 +146,7 @@ void qemu_system_debug_request(void); void qemu_system_vmstop_request(RunState reason); void qemu_system_vmstop_request_prepare(void); bool qemu_vmstop_requested(RunState *r); -ShutdownCause qemu_shutdown_requested_get(void); +bool qemu_shutdown_requested(void); bool qemu_force_shutdown_requested(void); ShutdownCause qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); diff --git a/system/runstate.c b/system/runstate.c index 01f936649b4..2b28e2a30e2 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -582,7 +582,7 @@ static NotifierList shutdown_notifiers =3D NOTIFIER_LIST_INITIALIZER(shutdown_notifiers); static uint32_t wakeup_reason_mask =3D ~(1 << QEMU_WAKEUP_REASON_NONE); =20 -ShutdownCause qemu_shutdown_requested_get(void) +bool qemu_shutdown_requested(void) { return shutdown_requested; } --=20 2.43.0 From nobody Sat Sep 26 20:02:58 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1788555547; cv=none; d=zohomail.com; s=zohoarc; b=OtNRfHS3RnBvAKu7L3l3ulzUAvf7m0CKzhAmyLzCyj8sS5pIVNl/EQA4ljjOwccGH7FL8Di165tT2qa1o+uz0NBdxxy2nKi/akyP41nN+m9FhN0oSqP8qGEUloJ6ZwdOgq1WPg2G7rZSLDKujMmK5GoKMW+FtI8UHRNUc+gS2m8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788555547; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VCxyERGgPaGRWK8x8tRvFf5jF5AfliI97ZERz5vYK1g=; b=MMOYsFaqpo8X2DOj4C+dPyD21bjsyTDDFbwSovDqdXNGA2To0jnEzrj0jKugzke48BSgD1CmjJ9u2k2VR1o8j8DOkZVoztlfG0Jiywd0YAc1aZHx3cG0QRvYgCi/yx2viu3+gIgHNmWcpD3+L5T3va6jA2EU83vnx8tlNHf7DlY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788555547283177.7479883061377; Fri, 4 Sep 2026 13:59:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2az7-00039f-Vk; Fri, 04 Sep 2026 16:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az4-00038r-TV for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:02 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az1-0007xv-Au for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:02 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c11:43a8:0:640:574d:0]) by forwardcorp1b.mail.yandex.net (postfix) with ESMTPS id 116A28065E; Fri, 04 Sep 2026 23:57:58 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:4d::1:17]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp) with ESMTPSA id rvQjs41YPqM0-bhiDhsXJ; Fri, 04 Sep 2026 23:57:57 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1788555477; bh=VCxyERGgPaGRWK8x8tRvFf5jF5AfliI97ZERz5vYK1g=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=beaRtdzNEqO5jfg1/lGWDlBDoTruNqcmu9ij5H3LGDKKq0UZpzv9HN/ryU+SaCZ1Q G8iKwa+FApzs+uxXvq5FsPrCV5o/TJFZpGfvsszGXOuqKyWmLe0TF7pTXz80h6P9Lh PMyIF4dIY8PNVyD9Eb673PURrVbzElqpDMLPIcZk= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, Markus Armbruster , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 5/6] runstate: separate forced and regular shutdown requests Date: Fri, 4 Sep 2026 23:57:48 +0300 Message-ID: <20260904205749.510493-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904205749.510493-1-vsementsov@yandex-team.ru> References: <20260904205749.510493-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, 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: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1788555550826158500 Content-Type: text/plain; charset="utf-8" QMP quit, host signals and UI shutdown requests force QEMU to exit by setting shutdown_action to SHUTDOWN_ACTION_POWEROFF. This can race with guest shutdown processing. With -no-shutdown, consider the following sequence: 1. Management sends system_powerdown, then sends SIGTERM after waiting for the guest to shut down. 2. QEMU starts processing a guest shutdown request. 3. SIGTERM arrives after qemu_kill_report(), while QEMU is sending the guest SHUTDOWN event. 4. The signal handler changes shutdown_action to POWEROFF, so QEMU exits instead of pausing. Management receives SHUTDOWN with guest=3Dtrue, but QEMU exits despite -no-shutdown, without reporting a host SHUTDOWN event or printing the signal diagnostic. Store forced and regular shutdown requests separately, and decide whether to exit based on the request being processed. Leave shutdown_action under user control. A forced request arriving while a regular request is being processed remains pending for the next main loop iteration. Keep qemu_shutdown_requested() checking both kinds of requests for its Xen caller. There is no need to clear shutdown_force_requested with qatomic_xchg(): processing a forced shutdown request always exits the main loop. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Akihiko Odaki --- monitor/qmp-cmds.c | 1 - system/runstate.c | 24 ++++++++++++++++-------- ui/cocoa.m | 1 - ui/sdl2.c | 2 -- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 7525a88e049..6d0ba75ff16 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -44,7 +44,6 @@ NameInfo *qmp_query_name(Error **errp) =20 void qmp_quit(Error **errp) { - shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_QMP_QUIT); } =20 diff --git a/system/runstate.c b/system/runstate.c index 2b28e2a30e2..5d10ff0df99 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -564,9 +564,9 @@ int vm_stop_force_state(RunState state) =20 static ShutdownCause reset_requested; static ShutdownCause shutdown_requested; +static ShutdownCause shutdown_force_requested; static int shutdown_exit_code =3D EXIT_SUCCESS; static int shutdown_signal; -static bool force_shutdown; static pid_t shutdown_pid; static int powerdown_requested; static int debug_requested; @@ -584,12 +584,12 @@ static uint32_t wakeup_reason_mask =3D ~(1 << QEMU_WA= KEUP_REASON_NONE); =20 bool qemu_shutdown_requested(void) { - return shutdown_requested; + return shutdown_requested || shutdown_force_requested; } =20 bool qemu_force_shutdown_requested(void) { - return force_shutdown; + return shutdown_force_requested; } =20 ShutdownCause qemu_reset_requested_get(void) @@ -972,11 +972,12 @@ bool qemu_wakeup_suspend_enabled(void) */ static void qemu_system_shutdown_request_safe(ShutdownCause reason) { - shutdown_requested =3D reason; if (reason =3D=3D SHUTDOWN_CAUSE_HOST_QMP_QUIT || reason =3D=3D SHUTDOWN_CAUSE_HOST_SIGNAL || reason =3D=3D SHUTDOWN_CAUSE_HOST_UI) { - force_shutdown =3D true; + shutdown_force_requested =3D reason; + } else { + shutdown_requested =3D reason; } qemu_notify_event(); } @@ -992,7 +993,6 @@ void qemu_system_killed(int signal, pid_t pid) { shutdown_signal =3D signal; shutdown_pid =3D pid; - shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; qemu_system_shutdown_request_safe(SHUTDOWN_CAUSE_HOST_SIGNAL); } =20 @@ -1042,6 +1042,7 @@ static bool main_loop_should_exit(int *status) { RunState r; ShutdownCause request; + bool force =3D false; =20 if (qemu_debug_requested()) { vm_stop(RUN_STATE_DEBUG); @@ -1049,11 +1050,18 @@ static bool main_loop_should_exit(int *status) if (qemu_suspend_requested()) { qemu_system_suspend(); } - request =3D qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); + + if (shutdown_force_requested) { + force =3D true; + request =3D shutdown_force_requested; + } else { + request =3D qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); + } + if (request) { qemu_kill_report(); qemu_system_shutdown(request); - if (shutdown_action =3D=3D SHUTDOWN_ACTION_PAUSE) { + if (!force && shutdown_action =3D=3D SHUTDOWN_ACTION_PAUSE) { vm_stop(RUN_STATE_SHUTDOWN); } else { if (shutdown_exit_code !=3D EXIT_SUCCESS) { diff --git a/ui/cocoa.m b/ui/cocoa.m index 3751be37922..5447fb637ad 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1221,7 +1221,6 @@ - (void)applicationWillTerminate:(NSNotification *)aN= otification COCOA_DEBUG("QemuCocoaAppController: applicationWillTerminate\n"); =20 with_bql(^{ - shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); }); =20 diff --git a/ui/sdl2.c b/ui/sdl2.c index 1c97d23a47c..d647905a379 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -645,7 +645,6 @@ static void handle_windowevent(SDL_Event *ev) allow_close =3D false; } if (allow_close) { - shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); } } else { @@ -692,7 +691,6 @@ void sdl2_poll_events(struct sdl2_console *scon) allow_close =3D false; } if (allow_close) { - shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); } break; --=20 2.43.0 From nobody Sat Sep 26 20:02:58 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1788555559; cv=none; d=zohomail.com; s=zohoarc; b=RtHDFb7UtxS80Y/j5nTvjDNj+OJ4fgUEJ5Eifn39udo0md212ma6JtMoxs3EOiZ6EUoHBWdsQGHV60ye5F5S6E/dOdayjr9IDnR8n6yUR8ydKLjxsYtNzk3ufwhXoxwfM9qDivzjCdvPtRhyyNkJXnaOvr1vKccfLWNLBPdWRvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788555559; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d4dbH53MPfx1q2KRu2EkXixZG7sgb64R8Vc62UI24tE=; b=hCqVF64cbsjdpSBdPsNh820o27kk02zxF9hAQH48j8TBJFJ/bNIT9bpSmZmTpt118OTdtflpUx/nsZGgnjBzOsANWI1RJY6vkhsaS65d707zUuhFLYCCUB7fhjlFA0LziolnMO3mxEVhZV9kArPyFBQVGUGu9VihD5KZgjFr9EA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788555551716852.2166321538668; Fri, 4 Sep 2026 13:59:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2az9-00039v-Cc; Fri, 04 Sep 2026 16:58:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az6-000399-Eu for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:04 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2az2-0007y0-5B for qemu-devel@nongnu.org; Fri, 04 Sep 2026 16:58:04 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c11:43a8:0:640:574d:0]) by forwardcorp1b.mail.yandex.net (postfix) with ESMTPS id CC927807A6; Fri, 04 Sep 2026 23:57:58 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:4d::1:17]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp) with ESMTPSA id rvQjs41YPqM0-sXWwhiev; Fri, 04 Sep 2026 23:57:58 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1788555478; bh=d4dbH53MPfx1q2KRu2EkXixZG7sgb64R8Vc62UI24tE=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=GyPgqZ7MvXGQH7Gtor95cAcKddxNx/X1P3pEfHMxA5VU21Xmn0YmTgiiDegKmKvU5 KIf8vsAV4eNJfo4zaoiSWzAci5XoV+KfQSiwfs5Rk9QzG1/LdODz4xlVswzmBp0mcY tDX8rkjuCZfR3g1e4dPRH9fA769FII9YIm+B1nj0= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, Markus Armbruster , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 6/6] runstate: make runstate actions private Date: Fri, 4 Sep 2026 23:57:49 +0300 Message-ID: <20260904205749.510493-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904205749.510493-1-vsementsov@yandex-team.ru> References: <20260904205749.510493-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, 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: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1788555574497158500 Content-Type: text/plain; charset="utf-8" The action variables are now used only within system/runstate.c. Move them and qmp_set_action() there, make the variables static, and remove runstate-action.c and its header. Signed-off-by: Vladimir Sementsov-Ogievskiy --- MAINTAINERS | 1 - include/system/runstate-action.h | 19 ------------- monitor/qmp-cmds.c | 1 - system/meson.build | 1 - system/runstate-action.c | 46 -------------------------------- system/runstate.c | 34 ++++++++++++++++++++++- system/vl.c | 2 +- ui/cocoa.m | 1 - ui/sdl2.c | 1 - 9 files changed, 34 insertions(+), 72 deletions(-) delete mode 100644 include/system/runstate-action.h delete mode 100644 system/runstate-action.c diff --git a/MAINTAINERS b/MAINTAINERS index 7183babd6aa..2cee4c71b7a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3514,7 +3514,6 @@ M: Paolo Bonzini S: Maintained F: include/qemu/main-loop.h F: include/system/runstate.h -F: include/system/runstate-action.h F: util/main-loop.c F: util/qemu-timer*.c F: system/vl.c diff --git a/include/system/runstate-action.h b/include/system/runstate-act= ion.h deleted file mode 100644 index db4e3099ae5..00000000000 --- a/include/system/runstate-action.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2020 Oracle and/or its affiliates. - * - * This work is licensed under the terms of the GNU GPL, version 2. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef RUNSTATE_ACTION_H -#define RUNSTATE_ACTION_H - -#include "qapi/qapi-commands-run-state.h" - -/* in system/runstate-action.c */ -extern RebootAction reboot_action; -extern ShutdownAction shutdown_action; -extern PanicAction panic_action; - -#endif /* RUNSTATE_ACTION_H */ diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 6d0ba75ff16..f89237eb238 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -22,7 +22,6 @@ #include "system/system.h" #include "system/kvm.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/block-backend.h" #include "qapi/error.h" #include "qapi/qapi-init-commands.h" diff --git a/system/meson.build b/system/meson.build index 41e2e4a292d..dd4622ae08c 100644 --- a/system/meson.build +++ b/system/meson.build @@ -22,7 +22,6 @@ system_ss.add(files( 'qdev-monitor.c', 'qtest.c', 'rtc.c', - 'runstate-action.c', 'runstate.c', 'watchpoint.c', )) diff --git a/system/runstate-action.c b/system/runstate-action.c deleted file mode 100644 index f912bc837f2..00000000000 --- a/system/runstate-action.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Oracle and/or its affiliates. - * - * This work is licensed under the terms of the GNU GPL, version 2. - * See the COPYING file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include "system/runstate-action.h" -#include "system/watchdog.h" -#include "qemu/config-file.h" -#include "qapi/error.h" -#include "qemu/option_int.h" - -RebootAction reboot_action =3D REBOOT_ACTION_RESET; -ShutdownAction shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; -PanicAction panic_action =3D PANIC_ACTION_SHUTDOWN; - -/* - * Receives actions to be applied for specific guest events - * and sets the internal state as requested. - */ -void qmp_set_action(bool has_reboot, RebootAction reboot, - bool has_shutdown, ShutdownAction shutdown, - bool has_panic, PanicAction panic, - bool has_watchdog, WatchdogAction watchdog, - Error **errp) -{ - if (has_reboot) { - reboot_action =3D reboot; - } - - if (has_panic) { - panic_action =3D panic; - } - - if (has_watchdog) { - qmp_watchdog_set_action(watchdog, errp); - } - - /* Process shutdown last, in case the panic action needs to be altered= */ - if (has_shutdown) { - shutdown_action =3D shutdown; - } -} diff --git a/system/runstate.c b/system/runstate.c index 5d10ff0df99..a5f16da975e 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -2,6 +2,7 @@ * QEMU main system emulation loop * * Copyright (c) 2003-2020 QEMU contributors + * Copyright (c) 2020 Oracle and/or its affiliates. * * Permission is hereby granted, free of charge, to any person obtaining a= copy * of this software and associated documentation files (the "Software"), t= o deal @@ -58,7 +59,6 @@ #include "system/replay.h" #include "system/reset.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/confidential-guest-support.h" #include "system/system.h" #include "system/tpm.h" @@ -75,6 +75,10 @@ static RunState current_run_state =3D RUN_STATE_PRELAUNC= H; static RunState vmstop_requested =3D RUN_STATE__MAX; static QemuMutex vmstop_lock; =20 +static RebootAction reboot_action =3D REBOOT_ACTION_RESET; +static ShutdownAction shutdown_action =3D SHUTDOWN_ACTION_POWEROFF; +static PanicAction panic_action =3D PANIC_ACTION_SHUTDOWN; + typedef struct { RunState from; RunState to; @@ -277,6 +281,34 @@ StatusInfo *qmp_query_status(Error **errp) return info; } =20 +/* + * Receives actions to be applied for specific guest events + * and sets the internal state as requested. + */ +void qmp_set_action(bool has_reboot, RebootAction reboot, + bool has_shutdown, ShutdownAction shutdown, + bool has_panic, PanicAction panic, + bool has_watchdog, WatchdogAction watchdog, + Error **errp) +{ + if (has_reboot) { + reboot_action =3D reboot; + } + + if (has_panic) { + panic_action =3D panic; + } + + if (has_watchdog) { + qmp_watchdog_set_action(watchdog, errp); + } + + /* Process shutdown last, in case the panic action needs to be altered= */ + if (has_shutdown) { + shutdown_action =3D shutdown; + } +} + bool qemu_vmstop_requested(RunState *r) { qemu_mutex_lock(&vmstop_lock); diff --git a/system/vl.c b/system/vl.c index 9bd7664b85c..e1bb105514f 100644 --- a/system/vl.c +++ b/system/vl.c @@ -44,7 +44,6 @@ #include "qemu/uuid.h" #include "system/reset.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/seccomp.h" #include "system/tcg.h" #include "system/xen.h" @@ -136,6 +135,7 @@ #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-visit-qom.h" #include "qapi/qapi-commands-ui.h" #include "block/qdict.h" diff --git a/ui/cocoa.m b/ui/cocoa.m index 5447fb637ad..94bb094ff13 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -37,7 +37,6 @@ #include "ui/kbd-state.h" #include "system/system.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/cpu-throttle.h" #include "qapi/error.h" #include "qapi/qapi-commands-block.h" diff --git a/ui/sdl2.c b/ui/sdl2.c index d647905a379..72ec8819fb1 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -30,7 +30,6 @@ #include "ui/input.h" #include "ui/sdl2.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/system.h" #include "qemu/log.h" #include "qemu-main.h" --=20 2.43.0