[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] mini-os: Notify shutdown through weak function call instead of wake queue
To allow for more flexibility, this notifies domain shutdown through a function rather than a wake queue, to let the application use a wake queue only if it wishes. Signed-off-by: Samuel Thibault <samuel.thibaut@xxxxxxxxxxxx> diff -r 090cc3e20d3e extras/mini-os/include/kernel.h --- a/extras/mini-os/include/kernel.h Wed Dec 19 16:04:50 2012 +0000 +++ b/extras/mini-os/include/kernel.h Fri Dec 21 02:01:46 2012 +0100 @@ -1,9 +1,6 @@ #ifndef _KERNEL_H_ #define _KERNEL_H_ -extern unsigned int do_shutdown; -extern unsigned int shutdown_reason; -extern struct wait_queue_head shutdown_queue; extern void do_exit(void) __attribute__((noreturn)); extern void stop_kernel(void); diff -r 090cc3e20d3e extras/mini-os/kernel.c --- a/extras/mini-os/kernel.c Wed Dec 19 16:04:50 2012 +0000 +++ b/extras/mini-os/kernel.c Fri Dec 21 02:01:46 2012 +0100 @@ -48,12 +48,6 @@ uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32]; -#ifdef CONFIG_XENBUS -unsigned int do_shutdown = 0; -unsigned int shutdown_reason; -DECLARE_WAIT_QUEUE_HEAD(shutdown_queue); -#endif - void setup_xen_features(void) { xen_feature_info_t fi; @@ -71,12 +65,19 @@ } #ifdef CONFIG_XENBUS +/* This should be overridden by the application we are linked against. */ +__attribute__((weak)) void app_shutdown(unsigned reason) +{ + printk("Shutdown requested: %d\n", reason); +} + static void shutdown_thread(void *p) { const char *path = "control/shutdown"; const char *token = path; xenbus_event_queue events = NULL; char *shutdown, *err; + unsigned int shutdown_reason; xenbus_watch_path_token(XBT_NIL, path, token, &events); while ((err = xenbus_read(XBT_NIL, path, &shutdown)) != NULL) { @@ -94,10 +95,7 @@ else /* Unknown */ shutdown_reason = SHUTDOWN_crash; - wmb(); - do_shutdown = 1; - wmb(); - wake_up(&shutdown_queue); + app_shutdown(shutdown_reason); } #endif diff -r 090cc3e20d3e extras/mini-os/test.c --- a/extras/mini-os/test.c Wed Dec 19 16:04:50 2012 +0000 +++ b/extras/mini-os/test.c Fri Dec 21 02:01:46 2012 +0100 @@ -45,6 +45,10 @@ #include <xen/features.h> #include <xen/version.h> +static unsigned int do_shutdown = 0; +static unsigned int shutdown_reason; +static DECLARE_WAIT_QUEUE_HEAD(shutdown_queue); + static struct netfront_dev *net_dev; static struct semaphore net_sem = __SEMAPHORE_INITIALIZER(net_sem, 0); @@ -487,6 +491,15 @@ #endif } +void app_shutdown(unsigned reason) +{ + shutdown_reason = reason; + wmb(); + do_shutdown = 1; + wmb(); + wake_up(&shutdown_queue); +} + static void shutdown_thread(void *p) { DEFINE_WAIT(w); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |