From nobody Tue Nov 26 15:31: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 ARC-Seal: i=1; a=rsa-sha256; t=1706556527; cv=none; d=zohomail.com; s=zohoarc; b=jnwL73NvHY9ecaXTTHi7JhkmX/z5wAQWum+sq2GfJ5aX2QsFEmCEBCDASoRTktNSLPWUj4HuXdNkdiFOBMyTTvamdII+/Vxf1RntUnOPEZN0wXmzh4iDFaMmvip9bbNpqF6N9Ev15eo7RB9TLeIm5/XvbyOjiof0HiNv2fjyelc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706556527; 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=PrJ/QZiDRTRunY4lGJ6gyDUBVB7r1UwsqRLJEe5YjXQ=; b=egDLcKQWelfH9EZz0q3lPoqa52bFGw5ICtDLNNxLQ2PXSEVWzArxcQoFzyt/GbvOwl/uKpk3Z3CN0xG6FTKlOEXMUKMJSMuWKfw6i5OAYIYPaYKnSpK64q+W5PdET2UQjDBLSqMwu6c6FRKHRphML3z7kzYlfcARI3cIAY8hFvo= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706556527366212.55691006478514; Mon, 29 Jan 2024 11:28:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUXJ9-0003iY-1x; Mon, 29 Jan 2024 14:28:40 -0500 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 1rUXJ0-0003gy-Gv for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:30 -0500 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUXIw-0003On-6U for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1706556501; bh=X4WxZBufGX/UnJFogrkJp44vwGZ4MHDnluYEmxnIQqk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RRSoVRQ4gF8/Ykw258jWt3g1uqkEn/QnU72RDxuMvV2qZmifWSbw9R1F+74QorCTl p1M/44EtBGMTUw0VDsSjxs752brSSRGWvOA6KtPgESUBlPBI1GY1G9EO9uWDJ2yBXA 3WI1/pwpeLTO8MQD9oUg99lXBB3C2zuQ/8Bjuk1U= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 29 Jan 2024 20:28:09 +0100 Subject: [PATCH v5 1/6] linux-headers: drop pvpanic.h MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240129-pvpanic-shutdown-v5-1-f5a060b87c74@t-8ch.de> References: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> In-Reply-To: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> To: "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, Alejandro Jimenez , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706556500; l=3773; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=X4WxZBufGX/UnJFogrkJp44vwGZ4MHDnluYEmxnIQqk=; b=YwXSJbitSwN0KNiQ4EdDJbdoufif9dN3B8MqBbcIkaP17J/qBB78HwwNPICdDLQzcSrd/t/Tx PH7i7pCum9jCKaXN9Z8vz3PuR15MSAur455X8W6lg5mP1WFqW9DpdfW X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=2a01:4f8:c010:41de::1; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1706556529827100007 misc/pvpanic.h from the Linux UAPI does not define a Linux UAPI but a qemu device API. This leads to a weird process when updates to the interface are needed: 1) Change to the specification in the qemu tree 2) Change to the header in the Linux tree 3) Re-import of the header into Qemu. The kernel prefers to drop the header anyways. Prepare for the removal from the Linux UAPI headers by moving the contents to the existing pvpanic.h header. Link: https://lore.kernel.org/lkml/2023110431-pacemaker-pruning-0e4c@gregkh/ Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Thomas Wei=C3=9Fschuh --- hw/misc/pvpanic-isa.c | 1 - hw/misc/pvpanic-pci.c | 1 - hw/misc/pvpanic.c | 1 - include/hw/misc/pvpanic.h | 3 +++ include/standard-headers/linux/pvpanic.h | 9 --------- scripts/update-linux-headers.sh | 3 +-- 6 files changed, 4 insertions(+), 14 deletions(-) diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c index ccec50f61bbd..ef438a31fbe9 100644 --- a/hw/misc/pvpanic-isa.c +++ b/hw/misc/pvpanic-isa.c @@ -21,7 +21,6 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/isa/isa.h" -#include "standard-headers/linux/pvpanic.h" #include "hw/acpi/acpi_aml_interface.h" =20 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE) diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c index c01e4ce8646a..01e269b55284 100644 --- a/hw/misc/pvpanic-pci.c +++ b/hw/misc/pvpanic-pci.c @@ -21,7 +21,6 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/pci/pci_device.h" -#include "standard-headers/linux/pvpanic.h" =20 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE) =20 diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 1540e9091a45..4915ef256e74 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -21,7 +21,6 @@ #include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h" #include "qom/object.h" -#include "standard-headers/linux/pvpanic.h" =20 static void handle_event(int event) { diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index fab94165d03d..dffca827f77a 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -18,6 +18,9 @@ #include "exec/memory.h" #include "qom/object.h" =20 +#define PVPANIC_PANICKED (1 << 0) +#define PVPANIC_CRASH_LOADED (1 << 1) + #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" =20 diff --git a/include/standard-headers/linux/pvpanic.h b/include/standard-he= aders/linux/pvpanic.h deleted file mode 100644 index 54b7485390d3..000000000000 --- a/include/standard-headers/linux/pvpanic.h +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ - -#ifndef __PVPANIC_H__ -#define __PVPANIC_H__ - -#define PVPANIC_PANICKED (1 << 0) -#define PVPANIC_CRASH_LOADED (1 << 1) - -#endif /* __PVPANIC_H__ */ diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers= .sh index a0006eec6fd1..c4fea51c93fd 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -218,8 +218,7 @@ for i in "$tmpdir"/include/linux/*virtio*.h \ "$tmpdir/include/linux/const.h" \ "$tmpdir/include/linux/kernel.h" \ "$tmpdir/include/linux/vhost_types.h" \ - "$tmpdir/include/linux/sysinfo.h" \ - "$tmpdir/include/misc/pvpanic.h"; do + "$tmpdir/include/linux/sysinfo.h"; do cp_portable "$i" "$output/include/standard-headers/linux" done mkdir -p "$output/include/standard-headers/drm" --=20 2.43.0 From nobody Tue Nov 26 15:31: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 ARC-Seal: i=1; a=rsa-sha256; t=1706556565; cv=none; d=zohomail.com; s=zohoarc; b=OGv84n9psMhs05OJPHdnZMsMSy2TSpqc5T1QHc/a4EQ/PwQrFvO3irslOiWebSX/iRjFzfHdF72p+je+G8hYl56vnkwt+ZKpH9eYBAB1OdSDkm8OyolncgyN84aFJmIDUyo7Xv5k2Ty8FJS4AN+fnQnxX5seOVK5DX9VXe6RMtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706556565; 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=3tnnAKcwmGQfFDVrRI71r1vY2ZNDjHdr7rouK+szD6I=; b=jDJ6rOR3Nm50+QeZesdbyo4ec9kMydpC7al6+4KVtHoZAWV2nj994KYtLRvb0RWJReNPP0TzPBYp3DEmOD1j0gOJ/9wBG+H1imgKMz6LJF5GlInVe50Smd7UP85meRGyp+phrfQI7c5rpWfuJKkEMdqHsh/k+9ljQmrw+bdRaNg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706556565962242.31636396340775; Mon, 29 Jan 2024 11:29:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUXJ7-0003iA-I6; Mon, 29 Jan 2024 14:28:37 -0500 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 1rUXJ0-0003gw-FY for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:30 -0500 Received: from todd.t-8ch.de ([159.69.126.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUXIw-0003Oi-14 for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1706556501; bh=TyE3V4WNTBi5C+FXFjl4iBVhtJ1IqwhgPBjqAGaupiw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EzimEAnLcAR4XRBQ5a1CKn1wQ+RawXkx4rCpaJ4+a0SZt0MlD+BNsOzEmxI0NSwSy msXN6r5AYScH4f/7DgvHLrVyd/3wZAHmdCbfHm7Fdplk1xmCmVMbEkKk/VvqH64YAP PTEcduW4AbSDrdsERPFxl4WKDOwu9UbzjrQUsuHQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 29 Jan 2024 20:28:10 +0100 Subject: [PATCH v5 2/6] hw/misc/pvpanic: centralize definition of supported events MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240129-pvpanic-shutdown-v5-2-f5a060b87c74@t-8ch.de> References: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> In-Reply-To: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> To: "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, Alejandro Jimenez , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706556500; l=2517; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=TyE3V4WNTBi5C+FXFjl4iBVhtJ1IqwhgPBjqAGaupiw=; b=K6+Todg0GcZ+sI/0XQRNhu2SDr+ynDRId9aogthwmenZPRDFfUumerC/d56UCRCa87QFIWL9G stn5QqGFoBTB8KL9070gjaDuGXE1SDWk+d1ppDMYoX6jnmQhyOQ0SF6 X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=159.69.126.157; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1706556567769100002 The different components of pvpanic duplicate the list of supported events. Move it to the shared header file to minimize changes when new events are added. Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Thomas Wei=C3=9Fschuh --- hw/misc/pvpanic-isa.c | 2 +- hw/misc/pvpanic-pci.c | 2 +- hw/misc/pvpanic.c | 2 +- include/hw/misc/pvpanic.h | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c index ef438a31fbe9..9a923b786907 100644 --- a/hw/misc/pvpanic-isa.c +++ b/hw/misc/pvpanic-isa.c @@ -101,7 +101,7 @@ static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, A= ml *scope) static Property pvpanic_isa_properties[] =3D { DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505= ), DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, - PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), + PVPANIC_EVENTS), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c index 01e269b55284..be4063121e1d 100644 --- a/hw/misc/pvpanic-pci.c +++ b/hw/misc/pvpanic-pci.c @@ -54,7 +54,7 @@ static void pvpanic_pci_realizefn(PCIDevice *dev, Error *= *errp) =20 static Property pvpanic_pci_properties[] =3D { DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, - PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), + PVPANIC_EVENTS), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 4915ef256e74..a4982cc5928e 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -26,7 +26,7 @@ static void handle_event(int event) { static bool logged; =20 - if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) && !logged) { + if (event & ~PVPANIC_EVENTS && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", ev= ent); logged =3D true; } diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index dffca827f77a..48f2ec4c86a1 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -20,6 +20,7 @@ =20 #define PVPANIC_PANICKED (1 << 0) #define PVPANIC_CRASH_LOADED (1 << 1) +#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) =20 #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" --=20 2.43.0 From nobody Tue Nov 26 15:31: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 ARC-Seal: i=1; a=rsa-sha256; t=1706556526; cv=none; d=zohomail.com; s=zohoarc; b=fKu3Q2ujWwJ6VoKLMr4Zo4EQNVO6u/e1wsyr0NmVquFsjGGAQ/pCxPsTyz3HC1N9ooRf5TtLfLiCDonBu1FiUDwKsWixudfUQmqFxNfQ4PzYdg9It5XxC1acpWpQ77Nx2b7e9JVw+YE5D6I84IVFAfWELPFf3Xq1JZwdqemrWWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706556526; 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=tHhb2CeNW5OYCXcVtOCL9irtY1E2zdBfUBRyt57cA3k=; b=kHU68AaS84O9TIb985KVmWUZEFPoBQbBxRPww1+QPSnkDJeUWANWCYLaGkgBPrn5v2zoRJw5Oyi00sLgabbD8cJw+fx8nzzbEhUuJ4BsOCpW3WI/wPb+DUq8VNl2ce0xaqTdloBMn5rrLStCzCgZQcdVwAWsxhXKblyILdJ+hTg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706556526263625.8962169394902; Mon, 29 Jan 2024 11:28:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUXJ4-0003hJ-57; Mon, 29 Jan 2024 14:28:34 -0500 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 1rUXIy-0003gb-6u for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:28 -0500 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUXIv-0003Ol-Ul for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1706556501; bh=74QhrVR/63+4QItElafq1F3na7ckc/nS7arttH/g2h8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=itwmbLeGnEl5aWJTUb7h459e8cUzqRDzPugVWwoNWBMNMYHsEWJiJiq8bnQG5QhcK jv76xMPh/Rm+YBEZiZwwsqzW9/Vpr5RI6Qh4P3Wddn2FzRbh7V+EeQjGgtCmgCF9oa bmG64Pd1URYSVXlX+xRhRLKqEB/hot8U9lt2pMg8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 29 Jan 2024 20:28:11 +0100 Subject: [PATCH v5 3/6] tests/qtest/pvpanic: use centralized definition of supported events MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240129-pvpanic-shutdown-v5-3-f5a060b87c74@t-8ch.de> References: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> In-Reply-To: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> To: "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, Alejandro Jimenez , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706556500; l=2303; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=74QhrVR/63+4QItElafq1F3na7ckc/nS7arttH/g2h8=; b=RtsUIaM+FWOnK8O5KZbeeNLbXlbqG27bvxzdVHuL4FwtJOQwLiNXzUY7zVmDxyFdV6PtULuXI q8UH7mOSkguDWM5v3F91Ng8sYkmRpbHHfH41EUa1yuY5EBB5dNik/mi X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=2a01:4f8:c010:41de::1; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1706556528852100001 Avoid the necessity to update all tests when new events are added to the device. Acked-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Thomas Wei=C3=9Fschuh --- tests/qtest/pvpanic-pci-test.c | 5 +++-- tests/qtest/pvpanic-test.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c index 2c05b376ba72..b372caf41dc0 100644 --- a/tests/qtest/pvpanic-pci-test.c +++ b/tests/qtest/pvpanic-pci-test.c @@ -16,6 +16,7 @@ #include "qapi/qmp/qdict.h" #include "libqos/pci.h" #include "libqos/pci-pc.h" +#include "hw/misc/pvpanic.h" #include "hw/pci/pci_regs.h" =20 static void test_panic_nopause(void) @@ -34,7 +35,7 @@ static void test_panic_nopause(void) bar =3D qpci_iomap(dev, 0, NULL); =20 qpci_memread(dev, bar, 0, &val, sizeof(val)); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 val =3D 1; qpci_memwrite(dev, bar, 0, &val, sizeof(val)); @@ -67,7 +68,7 @@ static void test_panic(void) bar =3D qpci_iomap(dev, 0, NULL); =20 qpci_memread(dev, bar, 0, &val, sizeof(val)); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 val =3D 1; qpci_memwrite(dev, bar, 0, &val, sizeof(val)); diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index 78f1cf8186b0..ccc603472f5d 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" +#include "hw/misc/pvpanic.h" =20 static void test_panic_nopause(void) { @@ -20,7 +21,7 @@ static void test_panic_nopause(void) qts =3D qtest_init("-device pvpanic -action panic=3Dnone"); =20 val =3D qtest_inb(qts, 0x505); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 qtest_outb(qts, 0x505, 0x1); =20 @@ -43,7 +44,7 @@ static void test_panic(void) qts =3D qtest_init("-device pvpanic -action panic=3Dpause"); =20 val =3D qtest_inb(qts, 0x505); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 qtest_outb(qts, 0x505, 0x1); =20 --=20 2.43.0 From nobody Tue Nov 26 15:31: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 ARC-Seal: i=1; a=rsa-sha256; t=1706556590; cv=none; d=zohomail.com; s=zohoarc; b=Py3N8n/ta23T6d09syw/D83gu8Jd3zGU1twwB0g/fxWdgwjkbe7BpPC/TagShn2VoH7POKaD0ZXP2ZmMHJyuS80Zuv15Xsr05sbii43XitVwJZAdh0pxzaQhGcuvt+UjoNu2iIwM2iCWvY6lu9alWXwaN2FsUEYPUjMsMRTVZWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706556590; 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=B8mD9DMtKDj5EiYq5jfMKyizYpdbAoOgJKBW03YgoII=; b=mMvTv4St8v5kZufhJ5nqdZ6I2X3rCHgaH8cjeLPx24UTknlygboLSAuHV9tK0ksZjStoSGD4rvB7mtTWqUJJmKtXju4DNxDVIbcWTTpNbG5L9WHtmOzQaY1VvJAYnXDqccC7rkTZ8isqQh71TJT/uggxqsp6Y++kKySvOtdJ+/E= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706556589994990.6195088997513; Mon, 29 Jan 2024 11:29:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUXJ8-0003iB-OI; Mon, 29 Jan 2024 14:28:38 -0500 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 1rUXJ0-0003gx-Gy for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:30 -0500 Received: from todd.t-8ch.de ([159.69.126.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUXIv-0003Ok-UV for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1706556501; bh=4DspYvGcedbZAyyXHFoUQRfkUa0jnSBjsecnaCtoxI4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X+iXYpoj4FuWlnVXashcOpVXnNkVn1HYDg8WpUYUK0l6v2mJRe5Od9MIK1lKbmGen nEHLw1uoCI1XQoP8oCxGCObEES5Uay8IdNImjFLncTGezNBBBtaQLtbNL+aKirTbu/ TT0imyz6Sh0N/YVB76TRDI4YBH7K4tNLoAP1NEtE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 29 Jan 2024 20:28:12 +0100 Subject: [PATCH v5 4/6] hw/misc/pvpanic: add support for normal shutdowns MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240129-pvpanic-shutdown-v5-4-f5a060b87c74@t-8ch.de> References: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> In-Reply-To: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> To: "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, Alejandro Jimenez , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706556500; l=3037; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=4DspYvGcedbZAyyXHFoUQRfkUa0jnSBjsecnaCtoxI4=; b=Hbg6+LRMJ5tRnv6kcXlg640RF3yQC8mhC/Ysf+VyZgHybMqLLM/d1iFuJ+hz99KyiVryi/u2z tddVVjk0sRaBbQxHZescnqCzY+Jcs+HnJ5UR7D4NaUqwd+XEyGOzOM8 X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=159.69.126.157; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1706556591667100003 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 --- docs/specs/pvpanic.rst | 2 ++ hw/misc/pvpanic.c | 5 +++++ include/hw/misc/pvpanic.h | 3 ++- include/sysemu/runstate.h | 1 + system/runstate.c | 5 +++++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/specs/pvpanic.rst b/docs/specs/pvpanic.rst index f894bc19555f..796cc0348a38 100644 --- a/docs/specs/pvpanic.rst +++ b/docs/specs/pvpanic.rst @@ -29,6 +29,8 @@ bit 1 a guest panic has happened and will be handled by the guest; the host should record it or report it, but should not affect the execution of the guest. +bit 2 + a guest shutdown has happened and should be processed by the host =20 PCI Interface ------------- diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index a4982cc5928e..0e9505451a7a 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -40,6 +40,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/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index 48f2ec4c86a1..9e36a02d5a4f 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -20,7 +20,8 @@ =20 #define PVPANIC_PANICKED (1 << 0) #define PVPANIC_CRASH_LOADED (1 << 1) -#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) +#define PVPANIC_SHUTDOWN (1 << 2) +#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 0117d243c4ed..e210a37abf0f 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/system/runstate.c b/system/runstate.c index d6ab860ecaa7..572499513034 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -572,6 +572,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 2.43.0 From nobody Tue Nov 26 15:31: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 ARC-Seal: i=1; a=rsa-sha256; t=1706556566; cv=none; d=zohomail.com; s=zohoarc; b=OXeatBev4ZH0kB+9cnPQ/vuUduaI+wVY2rZIiJsHeI2R3gy37plZkvyEUblEIUKm7T7IAW8c3QxIWONeo90zJwBETY3o3DV7I0q75Gokz006vdOx4AmZyKAdW+4PoXNGhB7tw+EDv/F2qGd8fEWY8DRVcK2QHSSH+Rkmm7nVHYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706556566; 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=JQJY1IJdvZGcvKTvJ/GE5QYzw1Nc6KIWEspzqlUB9Zs=; b=SSAFZDr3TTECBzas4EbNYQDlkUPAraiEXfxE0rxfHDMCK8jiVrgQnyNxkM3pezAETCPQAxen93XXAEqrMJyjgCj5WHrwTUMrbok3tbitsWBn5STfrE4BX6hxHzWKU493n2iE7dU+E7E+WMopW7ezkfOKtNuN4AZl9qV2VcV0M5I= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706556566608272.6885312226418; Mon, 29 Jan 2024 11:29:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUXJM-0003oH-GJ; Mon, 29 Jan 2024 14:28:53 -0500 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 1rUXJE-0003j8-UF for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:46 -0500 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUXIz-0003PL-3x for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1706556501; bh=pLDGQUmcOkurLoPLQFej1T/V3Bo/OA3pqVp4oxQAW5A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C83ILLLz/ECOHmmN5YZrdw9YNgRC3kiU0Oyz2Ve0vAZd97LM36G8QXLuvr4pwvlhi QXBlG/VtA+Ee07ZNm8jftk9MsxhRXZOiiukB0Bb0XQMsOthKMviQXKJiw6Bndgt2mp wiQYb7kSGfXcFNlB9L+uttU34zbFpajwHNyENax8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 29 Jan 2024 20:28:13 +0100 Subject: [PATCH v5 5/6] pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240129-pvpanic-shutdown-v5-5-f5a060b87c74@t-8ch.de> References: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> In-Reply-To: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> To: "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, Alejandro Jimenez , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706556500; l=1642; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=jDQrzFDng3hs6cePBwRlPLgJKcbRtWnG6BeDN4GONAU=; b=kDpOnDpPDOPQBOfwzincEAxk3mdcPgq+sM3blw+1qW3wmGZ98Uv0Zib6brEm7jLdxkMlQXfvh Snb3IdJNTMWDlhCsJ5ZzDxeXQhFWaSrSZn+rmLk1+iGBiaOTwkbEJ72 X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=2a01:4f8:c010:41de::1; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1706556567764100001 From: Alejandro Jimenez Emit a QMP event on receiving a PVPANIC_SHUTDOWN event. Even though a typic= al SHUTDOWN event will be sent, it will be indistinguishable from a shutdown originating from other cases (e.g. KVM exit due to KVM_SYSTEM_EVENT_SHUTDOW= N) that also issue the guest-shutdown cause. A management layer application can detect the new GUEST_PVSHUTDOWN event to determine if the guest is using the pvpanic interface to request shutdowns. Signed-off-by: Alejandro Jimenez --- qapi/run-state.json | 14 ++++++++++++++ system/runstate.c | 1 + 2 files changed, 15 insertions(+) diff --git a/qapi/run-state.json b/qapi/run-state.json index 08bc99cb8561..d5a63e14ba7e 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -460,6 +460,20 @@ { 'event': 'GUEST_CRASHLOADED', 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } =20 +## +# @GUEST_PVSHUTDOWN: +# +# Emitted when guest submits a shutdown request via pvpanic interface +# +# Since: 8.3 +# +# Example: +# +# <- { "event": "GUEST_PVSHUTDOWN", +# "timestamp": { "seconds": 1648245259, "microseconds": 893771 } } +## +{ 'event': 'GUEST_PVSHUTDOWN' } + ## # @GuestPanicAction: # diff --git a/system/runstate.c b/system/runstate.c index 572499513034..02b0a1f8b9d0 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -574,6 +574,7 @@ void qemu_system_guest_crashloaded(GuestPanicInformatio= n *info) =20 void qemu_system_guest_pvshutdown(void) { + qapi_event_send_guest_pvshutdown(); qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); } =20 --=20 2.43.0 From nobody Tue Nov 26 15:31: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 ARC-Seal: i=1; a=rsa-sha256; t=1706556567; cv=none; d=zohomail.com; s=zohoarc; b=R2D4kzuCuABoZXKRDVmYQgwh1ZXnju4GLaYyoNYFuwvcuaEs95M3TxOpUG518C5/VLXv+1YjHO4kIOi8ZWONr+XfBkAF4BZ/TLA6iq2C0Kf33KRsaA4xtKN/7xvIsvA1AWVHpUA71QchZL+66NdjTRjWWA3RPAaneqfqdGkT+aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706556567; 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=yjnaVw8BVGGNfkXUO7iIe+CrenKbvlpPtxIIzJMu2RI=; b=BfZVVCQ+8a9QuXTSmCGZe7onOchAn7Uyn4qS51VMHHaTY60bFkI9EfI8j6nBAKhqtX/rS6MRjl4FBEvfrsH0HsvCQbyj+++F5kuZqjh4X/8s8QGzs0B6oRzuLcp+cammYPoExNxIbcASb5HBwQxajPVHeHbBmBG89FOGRKwIQKU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706556567636441.3724959659846; Mon, 29 Jan 2024 11:29:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUXJG-0003me-Ii; Mon, 29 Jan 2024 14:28:46 -0500 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 1rUXJ0-0003hH-Rq for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:31 -0500 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUXIz-0003PK-3P for qemu-devel@nongnu.org; Mon, 29 Jan 2024 14:28:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1706556502; bh=vibaDeYrrVakh6yqO/sDW4wrgFCaT64hDwMn4mJuptA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lcZhgsBD9IrzPAJXQy6nJ5X2+ndFIRvDlRrArdspTaDu6adM9+HVlX9VZaaEBynn4 215TYNLpREmlruffhTPhzckuykgeDKo8m48mwuUxZYU/ZtUofVog3fhWR2o6Lv1Z4d NW9TOtqEwVcQOIb1LpjWLK/sRQiAEoeO3TvwPMGY= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 29 Jan 2024 20:28:14 +0100 Subject: [PATCH v5 6/6] tests/qtest/pvpanic: add tests for pvshutdown event MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240129-pvpanic-shutdown-v5-6-f5a060b87c74@t-8ch.de> References: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> In-Reply-To: <20240129-pvpanic-shutdown-v5-0-f5a060b87c74@t-8ch.de> To: "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Thomas Huth , Laurent Vivier Cc: qemu-devel@nongnu.org, Alejandro Jimenez , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706556500; l=3454; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=vibaDeYrrVakh6yqO/sDW4wrgFCaT64hDwMn4mJuptA=; b=N4CXnC4BZfhj8mwqp5HSmET23N65wt+4GJNYattcOFIBPhb/MC2N+q2dZzPuwxrhhbtGJp43D U69IUnv1lbrAjjxzMtgxDrapK7E4JzInSEwEKSEPReO0r7T+/nF95WZ X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=2a01:4f8:c010:41de::1; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1706556569599100011 Validate that a shutdown via the pvpanic device emits the correct QMP events. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Thomas Huth --- tests/qtest/pvpanic-pci-test.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/qtest/pvpanic-test.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c index b372caf41dc0..e1c05d383219 100644 --- a/tests/qtest/pvpanic-pci-test.c +++ b/tests/qtest/pvpanic-pci-test.c @@ -85,11 +85,50 @@ static void test_panic(void) qtest_quit(qts); } =20 +static void test_pvshutdown(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + QPCIBus *pcibus; + QPCIDevice *dev; + QPCIBar bar; + + qts =3D qtest_init("-device pvpanic-pci,addr=3D04.0"); + pcibus =3D qpci_new_pc(qts, NULL); + dev =3D qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); + qpci_device_enable(dev); + bar =3D qpci_iomap(dev, 0, NULL); + + qpci_memread(dev, bar, 0, &val, sizeof(val)); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); + + val =3D 4; + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); + + response =3D qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN"); + qobject_unref(response); + + response =3D qtest_qmp_eventwait_ref(qts, "SHUTDOWN"); + g_assert(qdict_haskey(response, "data")); + data =3D qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "guest")); + g_assert(qdict_get_bool(data, "guest")); + g_assert(qdict_haskey(data, "reason")); + g_assert_cmpstr(qdict_get_str(data, "reason"), =3D=3D, "guest-shutdown= "); + qobject_unref(response); + + g_free(dev); + qpci_free_pc(pcibus); + qtest_quit(qts); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic-pci/panic", test_panic); qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause); + qtest_add_func("/pvpanic-pci/pvshutdown", test_pvshutdown); =20 return g_test_run(); } diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index ccc603472f5d..ff1f25f46586 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -58,11 +58,40 @@ static void test_panic(void) qtest_quit(qts); } =20 +static void test_pvshutdown(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + + qts =3D qtest_init("-device pvpanic"); + + val =3D qtest_inb(qts, 0x505); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); + + qtest_outb(qts, 0x505, 0x4); + + response =3D qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN"); + qobject_unref(response); + + response =3D qtest_qmp_eventwait_ref(qts, "SHUTDOWN"); + g_assert(qdict_haskey(response, "data")); + data =3D qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "guest")); + g_assert(qdict_get_bool(data, "guest")); + g_assert(qdict_haskey(data, "reason")); + g_assert_cmpstr(qdict_get_str(data, "reason"), =3D=3D, "guest-shutdown= "); + qobject_unref(response); + + qtest_quit(qts); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic/panic", test_panic); qtest_add_func("/pvpanic/panic-nopause", test_panic_nopause); + qtest_add_func("/pvpanic/pvshutdown", test_pvshutdown); =20 return g_test_run(); } --=20 2.43.0