aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/xen/control
diff options
context:
space:
mode:
authorRoger Pau Monné <royger@FreeBSD.org>2024-09-30 17:27:56 +0000
committerRoger Pau Monné <royger@FreeBSD.org>2024-10-07 16:59:45 +0000
commit9dd5105f22a2276cf099f0e10e318294fcc4f6a7 (patch)
tree268b4e9adc78cbde1742e4d87c171dfc40c5081f /sys/dev/xen/control
parent596a36ddc47889e1b3bde00566cef2d8695c2847 (diff)
Diffstat (limited to 'sys/dev/xen/control')
-rw-r--r--sys/dev/xen/control/control.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c
index 1dc1df935b84..4601db70ef16 100644
--- a/sys/dev/xen/control/control.c
+++ b/sys/dev/xen/control/control.c
@@ -394,6 +394,20 @@ xctrl_on_watch_event(struct xs_watch *watch, const char **vec, unsigned int len)
}
/*------------------ Private Device Attachment Functions --------------------*/
+
+static void
+notify_support(void)
+{
+ /*
+ * Notify kernel is ready to handle "control/shutdown" events. Ignore
+ * errors if the nodes haven't been created by the toolstack, as the
+ * parent "control" directory should be read-only for the guest.
+ */
+ xs_write(XST_NIL, "control", "feature-poweroff", "1");
+ xs_write(XST_NIL, "control", "feature-reboot", "1");
+ xs_write(XST_NIL, "control", "feature-suspend", "1");
+}
+
/**
* \brief Identify instances of this device type in the system.
*
@@ -455,6 +469,8 @@ xctrl_attach(device_t dev)
EVENTHANDLER_REGISTER(shutdown_final, xctrl_shutdown_final, NULL,
SHUTDOWN_PRI_LAST);
+ notify_support();
+
return (0);
}
@@ -479,6 +495,14 @@ xctrl_detach(device_t dev)
return (0);
}
+static int
+xctrl_resume(device_t dev)
+{
+ notify_support();
+
+ return (0);
+}
+
/*-------------------- Private Device Attachment Data -----------------------*/
static device_method_t xctrl_methods[] = {
/* Device interface */
@@ -486,6 +510,7 @@ static device_method_t xctrl_methods[] = {
DEVMETHOD(device_probe, xctrl_probe),
DEVMETHOD(device_attach, xctrl_attach),
DEVMETHOD(device_detach, xctrl_detach),
+ DEVMETHOD(device_resume, xctrl_resume),
DEVMETHOD_END
};