From nobody Fri Dec 08 22:03:04 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Sn4rm6fx7z53V0h; Fri, 8 Dec 2023 22:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Sn4rm63sLz4St1; Fri, 8 Dec 2023 22:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702072984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qRhOPP+KNOHiD5lRmv+ZdrSnF21x5jHizfeAz8YoF5s=; b=SrwypSZJsIrh2CzxZqxX2g3Elbmj8s+wLxIMCvm6aTI5cBnVQfQKbplRX0AWnx9aQ0e/J9 uOvL7/rvRCuOGoPoaB5Ai0tWDjmHVRv9KFsr5so5HYoB/gYC3dfxZbDF9qgdLT2+L95nhJ xNQQuzco4tTOvrGMFsZvqIkcR9QAj/NqbitxEhYUeQeKtAI/jZlCchNCU3M88/hAr2qtTy v3jLvLrc+bGXsE7ATobDnvOLBRCYf0tmOIkA4shFtwPVQMjwtMDCSYRAi9HTUQdmhb4bS+ vQ3/1taXoaVU7zmxP85Hpyq3sFIekKllVKx+yCmvhR95QnB4Mz2H97PdxXLAEw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702072984; a=rsa-sha256; cv=none; b=mtWcvE9gfh05ucI03ftO6gEsrz63JKTSYnyuAgULFrT3yvW2qM62aO1HJjhQLUCl8cjOIP IIXPWPXSNnSffrwjvk8MiAMWYFpSbvHTi5UJYd5S8N16d8tUxb0TTU+bdugV4aDXng6pcI cV+wT4FIzhxH69zDGtvar4CpeIPO2CWRuXr9Vh8oHN/7UlVmuDOOOp6p6pRG7SqlG8tb58 jzBSLsk1R0IVgT8HGMyhvCsrrkgAoL6IKXzJlgtNOKqt82+YTsLvHOWEV01bGa9LGbWBLu 3lGsEgcUmeVBbyqZlyADTyiWtnFYOlEL+rG9mWAcRqWmuf/WGdihjbzOfXrSGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702072984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qRhOPP+KNOHiD5lRmv+ZdrSnF21x5jHizfeAz8YoF5s=; b=Wb1vSFBe1QaJU4Sm/Egxf33bNh6tIHLmBPomFDcNZsUvNj8MamUHt/qKbl2T4bHY+Q3KTa XqOxOgOQ8p8GLko0HY9uZET7eU9PkXbOmWnzPolVo9yA9fOz7DQJF8PlXPkQUpY6zYkbnV /v0RHBkGVTbuA3FlIq3VzWMiHlRIQfyL/V/a2Fxa4+UKifYCiTawTwp9mC5U9Z143MMwPs xgD+oKwuTgBcQasTfW/qloqSs+JF82382ZqmAMPv+D/MyZKeWHY82CaWIqhLGrnctWJiOL 50soFNqndn5080Dtj4AENt21eP6CpYgrDUV4D+9FIGdrbKM9gy9iJZ9d270v2g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Sn4rm57rtzdrs; Fri, 8 Dec 2023 22:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B8M34xZ020835; Fri, 8 Dec 2023 22:03:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B8M34oT020832; Fri, 8 Dec 2023 22:03:04 GMT (envelope-from git) Date: Fri, 8 Dec 2023 22:03:04 GMT Message-Id: <202312082203.3B8M34oT020832@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: c13f564f9176 - stable/14 - xen: improve shutdown hook List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c13f564f9176c3d946e61519ddbfa0c1e23114ab Auto-Submitted: auto-generated The branch stable/14 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=c13f564f9176c3d946e61519ddbfa0c1e23114ab commit c13f564f9176c3d946e61519ddbfa0c1e23114ab Author: Mitchell Horne AuthorDate: 2023-11-23 15:27:20 +0000 Commit: Mitchell Horne CommitDate: 2023-12-08 22:02:44 +0000 xen: improve shutdown hook Make better use of the shutdown flags. In particular this now handles standard reboot where RB_POWERCYCLE is not set, and indicates a crash when the system has panicked. While here, give the function a prefix. Reviewed by: royger, markj MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42343 (cherry picked from commit 9e0b0f5de67fd46bddf0e12ef7b71d76a7ec1667) --- sys/dev/xen/control/control.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c index 9ea0222809a0..37b4bff709c7 100644 --- a/sys/dev/xen/control/control.c +++ b/sys/dev/xen/control/control.c @@ -345,12 +345,18 @@ xctrl_crash(void) } static void -shutdown_final(void *arg, int howto) +xctrl_shutdown_final(void *arg, int howto) { - /* Inform the hypervisor that shutdown is complete. */ - if (howto & RB_POWEROFF) + /* + * Inform the hypervisor that shutdown is complete, and specify the + * nature of the shutdown. RB_HALT is not handled by this function. + */ + if (KERNEL_PANICKED()) + HYPERVISOR_shutdown(SHUTDOWN_crash); + else if ((howto & RB_POWEROFF) != 0) HYPERVISOR_shutdown(SHUTDOWN_poweroff); - else if (howto & RB_POWERCYCLE) + else if ((howto & RB_HALT) == 0) + /* RB_POWERCYCLE or regular reset. */ HYPERVISOR_shutdown(SHUTDOWN_reboot); } @@ -446,7 +452,7 @@ xctrl_attach(device_t dev) xctrl->xctrl_watch.max_pending = 1; xs_register_watch(&xctrl->xctrl_watch); - EVENTHANDLER_REGISTER(shutdown_final, shutdown_final, NULL, + EVENTHANDLER_REGISTER(shutdown_final, xctrl_shutdown_final, NULL, SHUTDOWN_PRI_LAST); return (0);