From nobody Sun Dec 14 05:52:07 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1752534531; cv=none; d=zohomail.com; s=zohoarc; b=eL80ruEer2rPMPSEiCfVoyncJ5aGIZmFf6gO5Xh7qIa4kIcmRiiksgSXJz1o4LlTY+5kKPaA6CBAPNh9QOyt5haCJry9hdL5MzEb0cSwu1IaH3JhwjVuOEwxrIVGvBu1PD9y8R+UpXsjmn9ldhHmw0QlWt8siLqm1grkIdPFcEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752534531; h=Content-Type: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=gJuqhChPRmOX5xRXsCyEYU8+IpMhen8QYBWBgrWseb8=; b=d0rYx3M2ZbvhJmiS0iY62sy4ButCO8hpzB5fEubBxfmsTAS/sZXoShCJzvFtsmuz00lIYSgqdyk7UX+B3Wrxbl2dP/TXfRpF9Tpj3ry8X+aV7c0AyDNbnHh38FJiEXhEMfeA7B0juFQzYmysgL8UxA+rxzkosAyVRkFbkvXL3TY= 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 1752534531272344.6244943420286; Mon, 14 Jul 2025 16:08:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ubSFw-0002L4-Pp; Mon, 14 Jul 2025 19:06: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 1ubSFt-00023N-AX for qemu-devel@nongnu.org; Mon, 14 Jul 2025 19:06:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubSFr-0005NL-FO for qemu-devel@nongnu.org; Mon, 14 Jul 2025 19:06:40 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-wufOlXSNPWeMpxNn2lG5Rw-1; Mon, 14 Jul 2025 19:06:37 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4f3796779so2162776f8f.1 for ; Mon, 14 Jul 2025 16:06:37 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:150d:fc00:de3:4725:47c6:6809]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b5e8e1e135sm13638629f8f.72.2025.07.14.16.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 16:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752534398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gJuqhChPRmOX5xRXsCyEYU8+IpMhen8QYBWBgrWseb8=; b=CfwezSMjq9t7neOiT1LrO3G3K+mJadIGM3EvdOVcYzQKKWD7345O6W+YkoIWtKQx41oXaY NBVDECu5zobHeQx2jxImi32ELrBcA3fKp8DbEFTkBUZUjplXeracowE1rhPi3f2Yqpu3QJ dFNQZ0I3CGcODw9dPS0gMTDkwunc5Ms= X-MC-Unique: wufOlXSNPWeMpxNn2lG5Rw-1 X-Mimecast-MFC-AGG-ID: wufOlXSNPWeMpxNn2lG5Rw_1752534396 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752534396; x=1753139196; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gJuqhChPRmOX5xRXsCyEYU8+IpMhen8QYBWBgrWseb8=; b=Jftl4E9cVCkX45vX6SsL8J9L4P8uneKFL9Hlq0mTamIZchovFwabjfefy9t4VempVV vu8SylR5Oz4z2hTl7is7EJNf4iCKr/TPG1N4hJmei2Wnu3TtBhL9GxZvC204w1zPQuBe cfpxsfmTGcFW0EsmAhw6wPW806DpIY89EjGeWjTz5lZPLOBe9fuaSZ3/T5465DaHViDp 2mSqNlUpeXmY4VPy3JtQW6XCd9Ti1J9Y9xyNzNpBtYhH4Ir987AOToSDowaHBqm4ZKjF SdgtJb++myAUqVAmlA6we7uucxINCpuiuqD7tFj3V4+JlxC+aFPaiKjt9fULP7B4EGWT UD6A== X-Gm-Message-State: AOJu0Yyk/yCkbB1B4SFI9oSVQTxz59uiBLWKG+QB4ohsJnr/Q0Y/2crj 6rw7wN6YwOUyCZkPIE1AvB7ooOpVeHr0EbRTb5JFrkosNpkGg/pzaDzkKtAJEUlobAp7Y58QeSo +014kGmWBH0aXmr1jqde0eqAQjHRPHf+lB06wzTZs8RbJZZ76TVKmLJqUfqKvCwJqMX5fQF1Ryr J7A66l9p5oyZMbCBfyoYFWBVXlSfumvfSAbA== X-Gm-Gg: ASbGncttq0Ookd6jTZC081JjHMMwLFb89z1kYIIhIV4VAqOVqdSrhwX3vvQ9HV+lnZj KKD1rgvtx1McrqAnsPGei/+lYpIOGhid1/VWpgOuy4UuigYdIPy2Wtcb8wyDHkryx5jX+NTviQS 1S1nfllkTLdIX1Jw77pV3pIQnuQ9UYp/mmxhfanBR1JO2FSOc+INkGnpn5ptC3pODQclqxzKEBt pQKEDf6sadOazarVTtL86V2XhV0gLhyne5PJLCsKjj/cd7piYFBmxkYiogyqYMHQxm6EeijcVoB pSlPqC06mYZOKPFAtLpu7GmXnvsqZ97+ X-Received: by 2002:a5d:60ca:0:b0:3a5:2a24:fbf5 with SMTP id ffacd0b85a97d-3b60a15700amr197361f8f.18.1752534395907; Mon, 14 Jul 2025 16:06:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQOFl1MFDKvX4Qy4Ii82y2NGJiGxSDTtb+K+1NBFlF1rTvbUllIyCQwqQhRNN+ot736otvDw== X-Received: by 2002:a5d:60ca:0:b0:3a5:2a24:fbf5 with SMTP id ffacd0b85a97d-3b60a15700amr197347f8f.18.1752534395475; Mon, 14 Jul 2025 16:06:35 -0700 (PDT) Date: Mon, 14 Jul 2025 19:06:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Daniil Tatianin , Vladimir Sementsov-Ogievskiy , Paolo Bonzini Subject: [PULL 08/97] softmmu/runstate: add a way to detect force shutdowns Message-ID: <260f826cf8f2fe54f3cf4de541d761cf616e15ea.1752534227.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1752534532348116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniil Tatianin This can be useful for devices that might take too long to shut down gracefully, but may have a way to shutdown quickly otherwise if needed or explicitly requested by a force shutdown. For now we only consider SIGTERM or the QMP quit() command a force shutdown, since those bypass the guest entirely and are equivalent to pulling the power plug. Signed-off-by: Daniil Tatianin Message-Id: <20250609212547.2859224-2-d-tatianin@yandex-team.ru> Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/system/runstate.h | 1 + system/runstate.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/system/runstate.h b/include/system/runstate.h index fdd5c4a517..b406a3960e 100644 --- a/include/system/runstate.h +++ b/include/system/runstate.h @@ -107,6 +107,7 @@ 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_force_shutdown_requested(void); ShutdownCause qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(ShutdownCause reason); diff --git a/system/runstate.c b/system/runstate.c index 38900c935a..e18eb8cb0c 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -437,6 +437,7 @@ static ShutdownCause reset_requested; static ShutdownCause shutdown_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; @@ -457,6 +458,11 @@ ShutdownCause qemu_shutdown_requested_get(void) return shutdown_requested; } =20 +bool qemu_force_shutdown_requested(void) +{ + return force_shutdown; +} + ShutdownCause qemu_reset_requested_get(void) { return reset_requested; @@ -805,6 +811,7 @@ void qemu_system_killed(int signal, pid_t pid) * we are in a signal handler. */ shutdown_requested =3D SHUTDOWN_CAUSE_HOST_SIGNAL; + force_shutdown =3D true; qemu_notify_event(); } =20 @@ -820,6 +827,9 @@ 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(); } =20 --=20 MST