diff -r dcdcec634c2d linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Aug 2 16:11:31 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Aug 2 21:09:03 2005 @@ -35,9 +35,15 @@ #include #include #include +#include #include "xenbus_comms.h" #define streq(a, b) (strcmp((a), (b)) == 0) + +/* Protects notifier chain */ +DECLARE_MUTEX(xenstore_control); + +static struct notifier_block *xenstore_chain; /* If something in array of ids matches this device, return it. */ static const struct xenbus_device_id * @@ -295,6 +301,26 @@ .callback = dev_changed, }; +int register_xenstore_notifier(struct notifier_block *nb) +{ + int ret; + + if ((ret = down_interruptible(&xenstore_control)) != 0) + return ret; + ret = notifier_chain_register(&xenstore_chain, nb); + up(&xenstore_control); + return ret; +} +EXPORT_SYMBOL(register_xenstore_notifier); + +void unregister_xenstore_notifier(struct notifier_block *nb) +{ + down(&xenstore_control); + notifier_chain_unregister(&xenstore_chain, nb); + up(&xenstore_control); +} +EXPORT_SYMBOL(unregister_xenstore_notifier); + /* called from a thread in privcmd/privcmd.c */ int do_xenbus_probe(void *unused) { @@ -309,6 +335,15 @@ return err; } + err = notifier_call_chain(&xenstore_chain, 0, 0); + if (err == NOTIFY_BAD) { + printk("%s: calling xenstore notify chain failed\n", + __FUNCTION__); + return -EINVAL; + } + + err = 0; + /* Initialize non-xenbus drivers */ balloon_init_watcher(); diff -r dcdcec634c2d linux-2.6-xen-sparse/include/asm-xen/xenbus.h --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h Tue Aug 2 16:11:31 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h Tue Aug 2 21:09:03 2005 @@ -29,6 +29,7 @@ * IN THE SOFTWARE. */ #include +#include #include /* A xenbus device. */ @@ -112,6 +113,10 @@ void (*callback)(struct xenbus_watch *, const char *node); }; +/* notifer routines for when the xenstore comes up */ +int register_xenstore_notifier(struct notifier_block *nb); +void unregister_xenstore_notifier(struct notifier_block *nb); + int register_xenbus_watch(struct xenbus_watch *watch); void unregister_xenbus_watch(struct xenbus_watch *watch);