From nobody Thu Nov 23 16:08:03 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 4Sbjh40LKtz51nd0; Thu, 23 Nov 2023 16:08: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 4Sbjh350pCz4QMF; Thu, 23 Nov 2023 16:08:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700755683; 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=Y/Q+ef3ppE2qPkq2ZHeUdjLOUEQxbO3TnxMryz7y91M=; b=wYJwrkzqFvvwc7fNEa9rTv5E/J0nokQYiq/8jwFWe8qlXPBScLmf5fQIkrCVgi0uA5GQl9 Fhw9CH8ySbk9/64NdL5lnls7fcbrbPRY5qVddbUKDjJPMTjaLfSa1BILRDQgXbwR+QHO5Q v5hjGLcWBgNiLQVpdNa7ZEXU6msCyrejeklBHOK0B5fcoKPGRz8fIm0dfubRuvpKAfKOyz 4vDbp37zQqYKB3XuEHcy5+VpQDqe0qWNvE6MMr+3ns0v6k7WAvMHzrzU0ru3WPeSeQnjbV msH83zdUkBgRQo6+gmk6dtDzra64nbqzdWe7nAFEk77fRKEzW5KsMyjEm73grw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700755683; 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=Y/Q+ef3ppE2qPkq2ZHeUdjLOUEQxbO3TnxMryz7y91M=; b=vgtToOTjCWDHXIZclpJ2VHH+o+90QtX27+aJ6mM8V6+jNfc9MpIe0xapp7neFaeI4I5IDx HJOi9DGSCjTF/zxzTc+VkfhXXl+WgYGryolCBI97pUtIS79ESIA0y/SMzghM/aoRmnvD9E /BQgGhSJZXg3JOhVQ0heLgXhf2DJaPwCDiVOnZ0GK0FPAqq/QmAxKZ87XWLacQG6N95sih YOOzqkBgnaIS3NoBeNNU80nF4Jy+JCh3na3/6Qzgaz4Y6mYecMo7MszoPFjVpDcMLTl0HU ZfoqP0CVbLPCy7xstLhcBt8VY+O1wEsxPglO0rbDZF2MMeoWTptLiJ0EtnIltQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700755683; a=rsa-sha256; cv=none; b=J+OpMTOzM5Mxw6KVceEY3ygnVlUi9G12nhT/FiVSmmhuSnyRHqALYS10PNCzMaNeMf9LZs TNbH2f9e9Uq92CROSdhqP2gemZYs2izjsn9pD81TwR+/i/StygpIR3Xa7ZkYzCk31AKpRe PxM9vm418EQMJLYPdXJerW2dC9CKkFiuF2fnSnvX9gwaDkEDwMZ9UsFTFmHxXbAOgFqV+N PFX0vQ1AcXkktlVwdHAHVFP8lpkvLqw8r3dN9FhIKDh9pEsXOofzeQS7BdH4k4AwSZySN0 y/nEA4T0vhImhzkzIJPv+p8OzN8ZoUVH4s+R6EfMNyH0EdZEI/1NvtAMfn64Nw== 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 4Sbjh345zMz17B2; Thu, 23 Nov 2023 16:08:03 +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 3ANG83Aj007674; Thu, 23 Nov 2023 16:08:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ANG83a9007671; Thu, 23 Nov 2023 16:08:03 GMT (envelope-from git) Date: Thu, 23 Nov 2023 16:08:03 GMT Message-Id: <202311231608.3ANG83a9007671@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 9e0b0f5de67f - main - 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/main X-Git-Reftype: branch X-Git-Commit: 9e0b0f5de67fd46bddf0e12ef7b71d76a7ec1667 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=9e0b0f5de67fd46bddf0e12ef7b71d76a7ec1667 commit 9e0b0f5de67fd46bddf0e12ef7b71d76a7ec1667 Author: Mitchell Horne AuthorDate: 2023-11-23 15:27:20 +0000 Commit: Mitchell Horne CommitDate: 2023-11-23 16:07:42 +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 --- 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);