From nobody Thu Sep 19 00:56:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720046931; cv=none; d=zohomail.com; s=zohoarc; b=FMsNh+U+oVV3Ybq2tLj5YRO4l3YzGyJ20tRogcYtBlS/FX+4mJiosZ/ePmsAThV5PoTJHHvnwRnuSI/vxL49SG6SbU2hN332eWbLqK2G+1ot/f1eon7zSwKElSxKCl+P0jIyVJz8X/bUcBABqK4BuCQXPow5Q5E5y5aQ6B73WGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720046931; h=Content-Type: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=kZkfnrsmrcpCA4paPRwjE2CzS2LM1h/03EC8/LUs/AI=; b=NhEBz4pQx3s24vuS1rJpDWrVv2bM42DWu1qWjKQxx5jluD0I597v2Rl0iE5aQHKBthf0XurknKM9I/wg/1vqd9cHqnLxHhQluz3I1w7udqC+819ffSHayVd7OnAsUv+j7HWUtAbCuj/s6ZG00gjvCZ5maPlX97L1btcOKnB+RnM= 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 1720046931779169.78083402930713; Wed, 3 Jul 2024 15:48:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8km-00037T-Mm; Wed, 03 Jul 2024 18:47:08 -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 1sP8kj-0002jZ-AF for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sP8ke-0001Wj-HO for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:04 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-lh1XtLPJNtW_lRclZy1qvA-1; Wed, 03 Jul 2024 18:46:55 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a728c02df80so1419666b.1 for ; Wed, 03 Jul 2024 15:46:55 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0900f1sm543684566b.168.2024.07.03.15.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046816; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kZkfnrsmrcpCA4paPRwjE2CzS2LM1h/03EC8/LUs/AI=; b=NrxoEYT0UgUrRrjexz4nq9yYlSaoE/kXFGnghMfCFAt5/DN5SSy2MOsLkNkfUJlNrP3Twa +5/7Niu2LL/V6G9Assqk5R4ByNxqhxe5IzjTOcaOFIMtoX34RpTeKjrcMkIxzRIYNaheYu 3HSjzn5Rj0KNYFmL4Ds/LMxK+KYEHLA= X-MC-Unique: lh1XtLPJNtW_lRclZy1qvA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046814; x=1720651614; h=in-reply-to:content-transfer-encoding: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=kZkfnrsmrcpCA4paPRwjE2CzS2LM1h/03EC8/LUs/AI=; b=J4NbrLgwO0cBhwYMQjmqFQn4pOZgaWEQq+g+pDkVLJSZt4PoGcwaVWL+cKiFMeCbBN Vz5o30EL0K0Nj6GTUYcJzQ8XX7PUSDz/3pQNBSPhNg8xsUf2qlp4SCs4Do27jvhH1T5g RuP/Uq6qCvb9jMeQFDzcFfZ+bBRFmIpI6TioedzPWK3kK+8f0NXVzfbqi1lnoEQrBtd4 /rkXwIAEKkdAx9wuwApCdRhJVfEfKNvJdGlKl7goCEHDnGYWzfaRGK67nRBX9xGJ4u5W 5nkVuWSb9afCL9SGx0p/itaRnkspt4pZUNWYfrIlts3N203tpp9lLqJpm5kGL3x+8YJy nhEg== X-Gm-Message-State: AOJu0YweBf68Yi5qpzjyn2FrZaYWrAcJgkCKoj/5NNS2ChxfOkK/Xp83 D4XO4tUK8VGPUdf6D2oA7MO+JDhiD/K6T6U8ZoRG+2uPtuFOaRyN7kn7vXjv0u91Iz+i3QrRCux iwC5ZNye8DCoRNFeQIZHUhOm1Qhbbj6Ei2Evp1UJNfMzYpAeyBR3/6aPpskjf2OPRWm6N/qWnNv LHDp4PbTvZUVOGFLgu0iwgfUSQQXv1Rw== X-Received: by 2002:a17:906:e206:b0:a6f:b3af:2add with SMTP id a640c23a62f3a-a7514454648mr794781666b.45.1720046814158; Wed, 03 Jul 2024 15:46:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2ZS0q05QJ4Am/5bRx7I4vmSPmcFJve5W+TRFKbc82EfIWirtYxQGQ6oF6m6APGWFD/3/Zfg== X-Received: by 2002:a17:906:e206:b0:a6f:b3af:2add with SMTP id a640c23a62f3a-a7514454648mr794780466b.45.1720046813435; Wed, 03 Jul 2024 15:46:53 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Cornelia Huck , Paolo Bonzini Subject: [PULL v3 33/85] hw/misc/pvpanic: add support for normal shutdowns Message-ID: <6269086b0179e3d70750672174ed7fbd29ac7eaa.1720046570.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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.129.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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1720046933597100003 From: Thomas Wei=C3=9Fschuh Shutdown requests are normally hardware dependent. By extending pvpanic to also handle shutdown requests, guests can submit such requests with an easily implementable and cross-platform mechanism. Acked-by: Cornelia Huck Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240527-pvpanic-shutdown-v8-5-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/misc/pvpanic.h | 4 +++- include/sysemu/runstate.h | 1 + hw/misc/pvpanic.c | 5 +++++ system/runstate.c | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index 1e5b20e4ed..9a71a5ad0d 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -20,7 +20,9 @@ =20 #include "standard-headers/misc/pvpanic.h" =20 -#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) +#define PVPANIC_EVENTS (PVPANIC_PANICKED | \ + PVPANIC_CRASH_LOADED | \ + PVPANIC_SHUTDOWN) =20 #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 0117d243c4..e210a37abf 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -104,6 +104,7 @@ void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(ShutdownCause reason); void qemu_system_guest_panicked(GuestPanicInformation *info); void qemu_system_guest_crashloaded(GuestPanicInformation *info); +void qemu_system_guest_pvshutdown(void); bool qemu_system_dump_in_progress(void); =20 #endif diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 4b2307d2c2..3b893340c0 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -41,6 +41,11 @@ static void handle_event(int event) qemu_system_guest_crashloaded(NULL); return; } + + if (event & PVPANIC_SHUTDOWN) { + qemu_system_guest_pvshutdown(); + return; + } } =20 /* return supported events on read */ diff --git a/system/runstate.c b/system/runstate.c index ec32e270cb..fc49fd3e61 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -584,6 +584,11 @@ void qemu_system_guest_crashloaded(GuestPanicInformati= on *info) qapi_free_GuestPanicInformation(info); } =20 +void qemu_system_guest_pvshutdown(void) +{ + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); +} + void qemu_system_reset_request(ShutdownCause reason) { if (reboot_action =3D=3D REBOOT_ACTION_SHUTDOWN && --=20 MST