From nobody Fri Mar 29 10:12:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1578650827; cv=none; d=zohomail.com; s=zohoarc; b=DmdnF8pDHSuommGpHhs0+wn4Go1FKA3YgfKvsBh0WwRwQ6iHxBDYqrj6+EL69XcNuXC9zf6uveqw3ovyk1gpd6qQpRWuOkGI4dtsxuWk1CQoNi4LPKjbnZAsBPDQaOuNiNFVda3rMTkM6rOJo4yh5hp+PMgLgXVNX4Dcsy5SXoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578650827; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TPKmHZ1Nk2MsIZoUYh18WfXWM/271xyHVRZf7xUcajg=; b=XtYjkpWRi/7TDgtMBTVMQ2pQnvwIe9OWukRl8NBolIPqhhUxIx8hIxKHkmK0urDkPuCzeNbbZ7FGnwCxyzJDSDWlCoC2C/DthdsJW1R9hU5tZ0KjeMYZu5oIgkFS3aYUEhBwyjsUFdg76P8i4+014zppKArAT+eJ2t5wCO+84k4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578650826997536.7390657899408; Fri, 10 Jan 2020 02:07:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-lKZwq1isPkau1pAZvF4HEA-1; Fri, 10 Jan 2020 05:07:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 489861034B21; Fri, 10 Jan 2020 10:06:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2263C80620; Fri, 10 Jan 2020 10:06:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CBEEC503D5; Fri, 10 Jan 2020 10:06:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00AA6sB8000365 for ; Fri, 10 Jan 2020 05:06:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 784EC2166B28; Fri, 10 Jan 2020 10:06:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 732112166B29 for ; Fri, 10 Jan 2020 10:06:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E245E180192C for ; Fri, 10 Jan 2020 10:06:51 +0000 (UTC) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-3qHIzdvAN7q6i4XGErDw0w-1; Fri, 10 Jan 2020 05:06:50 -0500 Received: by mail-pf1-f196.google.com with SMTP id 195so889977pfw.11 for ; Fri, 10 Jan 2020 02:06:49 -0800 (PST) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id q21sm2179039pff.105.2020.01.10.02.06.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jan 2020 02:06:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578650825; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TPKmHZ1Nk2MsIZoUYh18WfXWM/271xyHVRZf7xUcajg=; b=bHu7FRSiIKorbKJq/rd2Z5TQqTso481Sm/M8woBRAIsVDWhcBJZPqsR8WjNY4uLBrxF0Tn 4Qp4iFcLUCBB5TGsWQwX3UNvOHnSJhvnJ2mVrJ/gCgLrbp+Dc/DFz/dgjEHyXOn9/G7njN vwUrclc9NI6WbpiPi+WXby6JFsFYS8w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fshKwfwt9Dp2Wq1APH+4/EX0Jo99Mva81d26eLwAGKU=; b=cDSxYPj25SknMz29LYdE99Bxs2I7bFnzXGEYQvy8DBZLDyQe/GFpUzIY4eba8SATRW f/8MF+jQ2SxLQVqF8A3KneIsFh8YXImwtqcgu357NFrepv6vYElmq2UzArkmJsoL60/R FJlz1ePchhpU8Q+BCZ96tf71hG7SZfcZU1zUeo4fw5Ydr0Nnj3KwdF6A6UEAtrURYDhh u6yLoCD0cWYts//ZBXi8MXFlGjBU/wqcnYGGdBux+z004/rL72t0AadXXh8IrE7lPmB6 6gkBfbx9Ikt9d9mARiZzWzZpBWUNLvBIG6HxcLt2tIz0oJYSdAEDFZvRiWQiP68UNoVP +F7Q== X-Gm-Message-State: APjAAAXIWhs33agMQ93MyrEJ75lDE8P7FQKX9YF8GbreEQymjrbe9wDj TEAALTy/ockl4OQjCunNM1NiTQ== X-Google-Smtp-Source: APXvYqwLM80h5i/WiPXHqIG/DdJ1TUWK+d+JqiEcoNNkviF23F6YROu6y6DgPL2cKbxCTsnfqsFYxg== X-Received: by 2002:a63:201d:: with SMTP id g29mr3428289pgg.427.1578650808856; Fri, 10 Jan 2020 02:06:48 -0800 (PST) From: zhenwei pi To: pbonzini@redhat.com Date: Fri, 10 Jan 2020 18:06:34 +0800 Message-Id: <20200110100634.491936-3-pizhenwei@bytedance.com> In-Reply-To: <20200110100634.491936-1-pizhenwei@bytedance.com> References: <20200110100634.491936-1-pizhenwei@bytedance.com> X-MC-Unique: 3qHIzdvAN7q6i4XGErDw0w-1 X-MC-Unique: lKZwq1isPkau1pAZvF4HEA-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 00AA6sB8000365 X-loop: libvir-list@redhat.com Cc: yelu@bytedance.com, libvir-list@redhat.com, gregkh@linuxfoundation.org, qemu-devel@nongnu.org, zhenwei pi , linux-kernel@vger.kernel.org, mprivozn@redhat.com Subject: [libvirt] [PATCH 2/2] pvpanic: implement crashloaded event handling X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Handle bit 1 write, then post event to monitor. Suggested by Paolo, declear a new event, using GUEST_PANICKED could cause upper layers to react by shutting down or rebooting the guest. In advance for extention, add GuestPanicInformation in event message. Signed-off-by: zhenwei pi --- hw/misc/pvpanic.c | 11 +++++++++-- include/sysemu/runstate.h | 1 + qapi/run-state.json | 22 +++++++++++++++++++++- vl.c | 12 ++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index d65ac86478..4ebda7872a 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -21,11 +21,13 @@ #include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h" =20 -/* The bit of supported pv event */ +/* The bit of supported pv event, TODO: include uapi header and remove thi= s */ #define PVPANIC_F_PANICKED 0 +#define PVPANIC_F_CRASHLOADED 1 =20 /* The pv event value */ #define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) +#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) =20 #define ISA_PVPANIC_DEVICE(obj) \ OBJECT_CHECK(PVPanicState, (obj), TYPE_PVPANIC) @@ -34,7 +36,7 @@ static void handle_event(int event) { static bool logged; =20 - if (event & ~PVPANIC_PANICKED && !logged) { + if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASHLOADED) && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", ev= ent); logged =3D true; } @@ -43,6 +45,11 @@ static void handle_event(int event) qemu_system_guest_panicked(NULL); return; } + + if (event & PVPANIC_CRASHLOADED) { + qemu_system_guest_crashloaded(NULL); + return; + } } =20 #include "hw/isa/isa.h" diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 0b41555609..f760094858 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -63,6 +63,7 @@ ShutdownCause qemu_reset_requested_get(void); 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); =20 #endif =20 diff --git a/qapi/run-state.json b/qapi/run-state.json index d7477cd715..b7a91f3125 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -357,6 +357,26 @@ 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } =20 ## +# @GUEST_CRASHLOADED: +# +# Emitted when guest OS crash loaded is detected +# +# @action: action that has been taken, currently always "run" +# +# @info: information about a panic (since 2.9) +# +# Since: 5.0 +# +# Example: +# +# <- { "event": "GUEST_CRASHLOADED", +# "data": { "action": "run" } } +# +## +{ 'event': 'GUEST_CRASHLOADED', + 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } + +## # @GuestPanicAction: # # An enumeration of the actions taken when guest OS panic is detected @@ -366,7 +386,7 @@ # Since: 2.1 (poweroff since 2.8) ## { 'enum': 'GuestPanicAction', - 'data': [ 'pause', 'poweroff' ] } + 'data': [ 'pause', 'poweroff', 'run' ] } =20 ## # @GuestPanicInformationType: diff --git a/vl.c b/vl.c index 86474a55c9..5b1b2ef095 100644 --- a/vl.c +++ b/vl.c @@ -1468,6 +1468,18 @@ void qemu_system_guest_panicked(GuestPanicInformatio= n *info) } } =20 +void qemu_system_guest_crashloaded(GuestPanicInformation *info) +{ + qemu_log_mask(LOG_GUEST_ERROR, "Guest crash loaded"); + + qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, + !!info, info); + + if (info) { + qapi_free_GuestPanicInformation(info); + } +} + void qemu_system_reset_request(ShutdownCause reason) { if (no_reboot && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list