From: Anthony Liguori <aliguori@us.ibm.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Dan Smith <danms@us.ibm.com>, xen-devel@lists.xensource.com
Subject: Re: [PATCH] Convert balloon driver to xenstore
Date: Tue, 02 Aug 2005 21:13:37 -0500 [thread overview]
Message-ID: <42F02851.4050905@us.ibm.com> (raw)
In-Reply-To: <1123031513.7228.6.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 698 bytes --]
Rusty Russell wrote:
>On Tue, 2005-08-02 at 06:51 -0700, Dan Smith wrote:
>
>
>Generally, you will want to do a module_init() and initialize your
>driver. If it's in domain 0, it needs to be initialized later (the
>store isn't up yet): the standard way of doing this is a notifier chain.
>
>Something like the following:
>
>static struct notifier_block store_notify =
>{
> .notifier_call = balloon_setup,
>};
>
>static int balloon_init()
>{
> if (!xen_start_info.store_evtchn)
> register_xenstore_notifier(&store_notify);
> else
> balloon_setup(&store_notify, 0, NULL);
> return 0;
>}
>
>
How does this look?
Regards,
Anthony Liguori
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
[-- Attachment #2: xenbus_notifier.diff --]
[-- Type: text/x-patch, Size: 2385 bytes --]
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 <linux/ctype.h>
#include <linux/fcntl.h>
#include <stdarg.h>
+#include <linux/notifier.h>
#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 <linux/device.h>
+#include <linux/notifier.h>
#include <asm/semaphore.h>
/* 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);
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2005-08-03 2:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-01 17:19 [PATCH] Convert balloon driver to xenstore Dan Smith
2005-08-02 10:11 ` aq
2005-08-02 13:51 ` Dan Smith
2005-08-03 1:11 ` Rusty Russell
2005-08-03 2:13 ` Anthony Liguori [this message]
2005-08-03 3:45 ` aq
2005-08-03 5:18 ` Anthony Liguori
2005-08-03 8:02 ` aq
2005-08-03 13:47 ` Dan Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42F02851.4050905@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=danms@us.ibm.com \
--cc=rusty@rustcorp.com.au \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.