1 /******************************************************************************
4 * This is the kernel equivalent of the "xs" library. We don't need everything
5 * and we use xenbus_comms for communication.
7 * Copyright (C) 2005 Rusty Russell, IBM Corporation
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation; or, when distributed
12 * separately from the Linux kernel or incorporated into other
13 * software packages, subject to the following license:
15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 * of this source file (the "Software"), to deal in the Software without
17 * restriction, including without limitation the rights to use, copy, modify,
18 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
19 * and to permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
22 * The above copyright notice and this permission notice shall be included in
23 * all copies or substantial portions of the Software.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
34 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
36 #include <linux/unistd.h>
37 #include <linux/errno.h>
38 #include <linux/types.h>
39 #include <linux/uio.h>
40 #include <linux/kernel.h>
41 #include <linux/string.h>
42 #include <linux/err.h>
43 #include <linux/slab.h>
44 #include <linux/fcntl.h>
45 #include <linux/kthread.h>
46 #include <linux/rwsem.h>
47 #include <linux/module.h>
48 #include <linux/mutex.h>
49 #include <asm/xen/hypervisor.h>
50 #include <xen/xenbus.h>
52 #include "xenbus_comms.h"
53 #include "xenbus_probe.h"
55 struct xs_stored_msg
{
56 struct list_head list
;
58 struct xsd_sockmsg hdr
;
66 /* Queued watch events. */
68 struct xenbus_watch
*handle
;
70 unsigned int vec_size
;
76 /* A list of replies. Currently only one will ever be outstanding. */
77 struct list_head reply_list
;
78 spinlock_t reply_lock
;
79 wait_queue_head_t reply_waitq
;
82 * Mutex ordering: transaction_mutex -> watch_mutex -> request_mutex.
83 * response_mutex is never taken simultaneously with the other three.
85 * transaction_mutex must be held before incrementing
86 * transaction_count. The mutex is held when a suspend is in
87 * progress to prevent new transactions starting.
89 * When decrementing transaction_count to zero the wait queue
90 * should be woken up, the suspend code waits for count to
94 /* One request at a time. */
95 struct mutex request_mutex
;
97 /* Protect xenbus reader thread against save/restore. */
98 struct mutex response_mutex
;
100 /* Protect transactions against save/restore. */
101 struct mutex transaction_mutex
;
102 atomic_t transaction_count
;
103 wait_queue_head_t transaction_wq
;
105 /* Protect watch (de)register against save/restore. */
106 struct rw_semaphore watch_mutex
;
109 static struct xs_handle xs_state
;
111 /* List of registered watches, and a lock to protect it. */
112 static LIST_HEAD(watches
);
113 static DEFINE_SPINLOCK(watches_lock
);
115 /* List of pending watch callback events, and a lock to protect it. */
116 static LIST_HEAD(watch_events
);
117 static DEFINE_SPINLOCK(watch_events_lock
);
120 * Details of the xenwatch callback kernel thread. The thread waits on the
121 * watch_events_waitq for work to do (queued on watch_events list). When it
122 * wakes up it acquires the xenwatch_mutex before reading the list and
125 static pid_t xenwatch_pid
;
126 static DEFINE_MUTEX(xenwatch_mutex
);
127 static DECLARE_WAIT_QUEUE_HEAD(watch_events_waitq
);
129 static int get_error(const char *errorstring
)
133 for (i
= 0; strcmp(errorstring
, xsd_errors
[i
].errstring
) != 0; i
++) {
134 if (i
== ARRAY_SIZE(xsd_errors
) - 1) {
135 pr_warn("xen store gave: unknown error %s\n",
140 return xsd_errors
[i
].errnum
;
143 static bool xenbus_ok(void)
145 switch (xen_store_domain_type
) {
147 switch (system_state
) {
148 case SYSTEM_POWER_OFF
:
158 /* FIXME: Could check that the remote domain is alive,
159 * but it is normally initial domain. */
166 static void *read_reply(enum xsd_sockmsg_type
*type
, unsigned int *len
)
168 struct xs_stored_msg
*msg
;
171 spin_lock(&xs_state
.reply_lock
);
173 while (list_empty(&xs_state
.reply_list
)) {
174 spin_unlock(&xs_state
.reply_lock
);
176 /* XXX FIXME: Avoid synchronous wait for response here. */
177 wait_event_timeout(xs_state
.reply_waitq
,
178 !list_empty(&xs_state
.reply_list
),
179 msecs_to_jiffies(500));
182 * If we are in the process of being shut-down there is
183 * no point of trying to contact XenBus - it is either
184 * killed (xenstored application) or the other domain
185 * has been killed or is unreachable.
187 return ERR_PTR(-EIO
);
189 spin_lock(&xs_state
.reply_lock
);
192 msg
= list_entry(xs_state
.reply_list
.next
,
193 struct xs_stored_msg
, list
);
194 list_del(&msg
->list
);
196 spin_unlock(&xs_state
.reply_lock
);
198 *type
= msg
->hdr
.type
;
201 body
= msg
->u
.reply
.body
;
208 static void transaction_start(void)
210 mutex_lock(&xs_state
.transaction_mutex
);
211 atomic_inc(&xs_state
.transaction_count
);
212 mutex_unlock(&xs_state
.transaction_mutex
);
215 static void transaction_end(void)
217 if (atomic_dec_and_test(&xs_state
.transaction_count
))
218 wake_up(&xs_state
.transaction_wq
);
221 static void transaction_suspend(void)
223 mutex_lock(&xs_state
.transaction_mutex
);
224 wait_event(xs_state
.transaction_wq
,
225 atomic_read(&xs_state
.transaction_count
) == 0);
228 static void transaction_resume(void)
230 mutex_unlock(&xs_state
.transaction_mutex
);
233 void *xenbus_dev_request_and_reply(struct xsd_sockmsg
*msg
)
236 struct xsd_sockmsg req_msg
= *msg
;
239 if (req_msg
.type
== XS_TRANSACTION_START
)
242 mutex_lock(&xs_state
.request_mutex
);
244 err
= xb_write(msg
, sizeof(*msg
) + msg
->len
);
246 msg
->type
= XS_ERROR
;
249 ret
= read_reply(&msg
->type
, &msg
->len
);
251 mutex_unlock(&xs_state
.request_mutex
);
253 if ((msg
->type
== XS_TRANSACTION_END
) ||
254 ((req_msg
.type
== XS_TRANSACTION_START
) &&
255 (msg
->type
== XS_ERROR
)))
260 EXPORT_SYMBOL(xenbus_dev_request_and_reply
);
262 /* Send message to xs, get kmalloc'ed reply. ERR_PTR() on error. */
263 static void *xs_talkv(struct xenbus_transaction t
,
264 enum xsd_sockmsg_type type
,
265 const struct kvec
*iovec
,
266 unsigned int num_vecs
,
269 struct xsd_sockmsg msg
;
278 for (i
= 0; i
< num_vecs
; i
++)
279 msg
.len
+= iovec
[i
].iov_len
;
281 mutex_lock(&xs_state
.request_mutex
);
283 err
= xb_write(&msg
, sizeof(msg
));
285 mutex_unlock(&xs_state
.request_mutex
);
289 for (i
= 0; i
< num_vecs
; i
++) {
290 err
= xb_write(iovec
[i
].iov_base
, iovec
[i
].iov_len
);
292 mutex_unlock(&xs_state
.request_mutex
);
297 ret
= read_reply(&msg
.type
, len
);
299 mutex_unlock(&xs_state
.request_mutex
);
304 if (msg
.type
== XS_ERROR
) {
305 err
= get_error(ret
);
307 return ERR_PTR(-err
);
310 if (msg
.type
!= type
) {
311 pr_warn_ratelimited("unexpected type [%d], expected [%d]\n",
314 return ERR_PTR(-EINVAL
);
319 /* Simplified version of xs_talkv: single message. */
320 static void *xs_single(struct xenbus_transaction t
,
321 enum xsd_sockmsg_type type
,
327 iovec
.iov_base
= (void *)string
;
328 iovec
.iov_len
= strlen(string
) + 1;
329 return xs_talkv(t
, type
, &iovec
, 1, len
);
332 /* Many commands only need an ack, don't care what it says. */
333 static int xs_error(char *reply
)
336 return PTR_ERR(reply
);
341 static unsigned int count_strings(const char *strings
, unsigned int len
)
346 for (p
= strings
, num
= 0; p
< strings
+ len
; p
+= strlen(p
) + 1)
352 /* Return the path to dir with /name appended. Buffer must be kfree()'ed. */
353 static char *join(const char *dir
, const char *name
)
357 if (strlen(name
) == 0)
358 buffer
= kasprintf(GFP_NOIO
| __GFP_HIGH
, "%s", dir
);
360 buffer
= kasprintf(GFP_NOIO
| __GFP_HIGH
, "%s/%s", dir
, name
);
361 return (!buffer
) ? ERR_PTR(-ENOMEM
) : buffer
;
364 static char **split(char *strings
, unsigned int len
, unsigned int *num
)
368 /* Count the strings. */
369 *num
= count_strings(strings
, len
);
371 /* Transfer to one big alloc for easy freeing. */
372 ret
= kmalloc(*num
* sizeof(char *) + len
, GFP_NOIO
| __GFP_HIGH
);
375 return ERR_PTR(-ENOMEM
);
377 memcpy(&ret
[*num
], strings
, len
);
380 strings
= (char *)&ret
[*num
];
381 for (p
= strings
, *num
= 0; p
< strings
+ len
; p
+= strlen(p
) + 1)
387 char **xenbus_directory(struct xenbus_transaction t
,
388 const char *dir
, const char *node
, unsigned int *num
)
390 char *strings
, *path
;
393 path
= join(dir
, node
);
395 return (char **)path
;
397 strings
= xs_single(t
, XS_DIRECTORY
, path
, &len
);
400 return (char **)strings
;
402 return split(strings
, len
, num
);
404 EXPORT_SYMBOL_GPL(xenbus_directory
);
406 /* Check if a path exists. Return 1 if it does. */
407 int xenbus_exists(struct xenbus_transaction t
,
408 const char *dir
, const char *node
)
413 d
= xenbus_directory(t
, dir
, node
, &dir_n
);
419 EXPORT_SYMBOL_GPL(xenbus_exists
);
421 /* Get the value of a single file.
422 * Returns a kmalloced value: call free() on it after use.
423 * len indicates length in bytes.
425 void *xenbus_read(struct xenbus_transaction t
,
426 const char *dir
, const char *node
, unsigned int *len
)
431 path
= join(dir
, node
);
435 ret
= xs_single(t
, XS_READ
, path
, len
);
439 EXPORT_SYMBOL_GPL(xenbus_read
);
441 /* Write the value of a single file.
442 * Returns -err on failure.
444 int xenbus_write(struct xenbus_transaction t
,
445 const char *dir
, const char *node
, const char *string
)
448 struct kvec iovec
[2];
451 path
= join(dir
, node
);
453 return PTR_ERR(path
);
455 iovec
[0].iov_base
= (void *)path
;
456 iovec
[0].iov_len
= strlen(path
) + 1;
457 iovec
[1].iov_base
= (void *)string
;
458 iovec
[1].iov_len
= strlen(string
);
460 ret
= xs_error(xs_talkv(t
, XS_WRITE
, iovec
, ARRAY_SIZE(iovec
), NULL
));
464 EXPORT_SYMBOL_GPL(xenbus_write
);
466 /* Create a new directory. */
467 int xenbus_mkdir(struct xenbus_transaction t
,
468 const char *dir
, const char *node
)
473 path
= join(dir
, node
);
475 return PTR_ERR(path
);
477 ret
= xs_error(xs_single(t
, XS_MKDIR
, path
, NULL
));
481 EXPORT_SYMBOL_GPL(xenbus_mkdir
);
483 /* Destroy a file or directory (directories must be empty). */
484 int xenbus_rm(struct xenbus_transaction t
, const char *dir
, const char *node
)
489 path
= join(dir
, node
);
491 return PTR_ERR(path
);
493 ret
= xs_error(xs_single(t
, XS_RM
, path
, NULL
));
497 EXPORT_SYMBOL_GPL(xenbus_rm
);
499 /* Start a transaction: changes by others will not be seen during this
500 * transaction, and changes will not be visible to others until end.
502 int xenbus_transaction_start(struct xenbus_transaction
*t
)
508 id_str
= xs_single(XBT_NIL
, XS_TRANSACTION_START
, "", NULL
);
509 if (IS_ERR(id_str
)) {
511 return PTR_ERR(id_str
);
514 t
->id
= simple_strtoul(id_str
, NULL
, 0);
518 EXPORT_SYMBOL_GPL(xenbus_transaction_start
);
520 /* End a transaction.
521 * If abandon is true, transaction is discarded instead of committed.
523 int xenbus_transaction_end(struct xenbus_transaction t
, int abort
)
529 strcpy(abortstr
, "F");
531 strcpy(abortstr
, "T");
533 err
= xs_error(xs_single(t
, XS_TRANSACTION_END
, abortstr
, NULL
));
539 EXPORT_SYMBOL_GPL(xenbus_transaction_end
);
541 /* Single read and scanf: returns -errno or num scanned. */
542 int xenbus_scanf(struct xenbus_transaction t
,
543 const char *dir
, const char *node
, const char *fmt
, ...)
549 val
= xenbus_read(t
, dir
, node
, NULL
);
554 ret
= vsscanf(val
, fmt
, ap
);
557 /* Distinctive errno. */
562 EXPORT_SYMBOL_GPL(xenbus_scanf
);
564 /* Single printf and write: returns -errno or 0. */
565 int xenbus_printf(struct xenbus_transaction t
,
566 const char *dir
, const char *node
, const char *fmt
, ...)
573 buf
= kvasprintf(GFP_NOIO
| __GFP_HIGH
, fmt
, ap
);
579 ret
= xenbus_write(t
, dir
, node
, buf
);
585 EXPORT_SYMBOL_GPL(xenbus_printf
);
587 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
588 int xenbus_gather(struct xenbus_transaction t
, const char *dir
, ...)
595 while (ret
== 0 && (name
= va_arg(ap
, char *)) != NULL
) {
596 const char *fmt
= va_arg(ap
, char *);
597 void *result
= va_arg(ap
, void *);
600 p
= xenbus_read(t
, dir
, name
, NULL
);
606 if (sscanf(p
, fmt
, result
) == 0)
610 *(char **)result
= p
;
615 EXPORT_SYMBOL_GPL(xenbus_gather
);
617 static int xs_watch(const char *path
, const char *token
)
621 iov
[0].iov_base
= (void *)path
;
622 iov
[0].iov_len
= strlen(path
) + 1;
623 iov
[1].iov_base
= (void *)token
;
624 iov
[1].iov_len
= strlen(token
) + 1;
626 return xs_error(xs_talkv(XBT_NIL
, XS_WATCH
, iov
,
627 ARRAY_SIZE(iov
), NULL
));
630 static int xs_unwatch(const char *path
, const char *token
)
634 iov
[0].iov_base
= (char *)path
;
635 iov
[0].iov_len
= strlen(path
) + 1;
636 iov
[1].iov_base
= (char *)token
;
637 iov
[1].iov_len
= strlen(token
) + 1;
639 return xs_error(xs_talkv(XBT_NIL
, XS_UNWATCH
, iov
,
640 ARRAY_SIZE(iov
), NULL
));
643 static struct xenbus_watch
*find_watch(const char *token
)
645 struct xenbus_watch
*i
, *cmp
;
647 cmp
= (void *)simple_strtoul(token
, NULL
, 16);
649 list_for_each_entry(i
, &watches
, list
)
656 * Certain older XenBus toolstack cannot handle reading values that are
657 * not populated. Some Xen 3.4 installation are incapable of doing this
658 * so if we are running on anything older than 4 do not attempt to read
659 * control/platform-feature-xs_reset_watches.
661 static bool xen_strict_xenbus_quirk(void)
664 uint32_t eax
, ebx
, ecx
, edx
, base
;
666 base
= xen_cpuid_base();
667 cpuid(base
+ 1, &eax
, &ebx
, &ecx
, &edx
);
675 static void xs_reset_watches(void)
677 int err
, supported
= 0;
679 if (!xen_hvm_domain() || xen_initial_domain())
682 if (xen_strict_xenbus_quirk())
685 err
= xenbus_scanf(XBT_NIL
, "control",
686 "platform-feature-xs_reset_watches", "%d", &supported
);
687 if (err
!= 1 || !supported
)
690 err
= xs_error(xs_single(XBT_NIL
, XS_RESET_WATCHES
, "", NULL
));
691 if (err
&& err
!= -EEXIST
)
692 pr_warn("xs_reset_watches failed: %d\n", err
);
695 /* Register callback to watch this node. */
696 int register_xenbus_watch(struct xenbus_watch
*watch
)
698 /* Pointer in ascii is the token. */
699 char token
[sizeof(watch
) * 2 + 1];
702 sprintf(token
, "%lX", (long)watch
);
704 down_read(&xs_state
.watch_mutex
);
706 spin_lock(&watches_lock
);
707 BUG_ON(find_watch(token
));
708 list_add(&watch
->list
, &watches
);
709 spin_unlock(&watches_lock
);
711 err
= xs_watch(watch
->node
, token
);
714 spin_lock(&watches_lock
);
715 list_del(&watch
->list
);
716 spin_unlock(&watches_lock
);
719 up_read(&xs_state
.watch_mutex
);
723 EXPORT_SYMBOL_GPL(register_xenbus_watch
);
725 void unregister_xenbus_watch(struct xenbus_watch
*watch
)
727 struct xs_stored_msg
*msg
, *tmp
;
728 char token
[sizeof(watch
) * 2 + 1];
731 sprintf(token
, "%lX", (long)watch
);
733 down_read(&xs_state
.watch_mutex
);
735 spin_lock(&watches_lock
);
736 BUG_ON(!find_watch(token
));
737 list_del(&watch
->list
);
738 spin_unlock(&watches_lock
);
740 err
= xs_unwatch(watch
->node
, token
);
742 pr_warn("Failed to release watch %s: %i\n", watch
->node
, err
);
744 up_read(&xs_state
.watch_mutex
);
746 /* Make sure there are no callbacks running currently (unless
748 if (current
->pid
!= xenwatch_pid
)
749 mutex_lock(&xenwatch_mutex
);
751 /* Cancel pending watch events. */
752 spin_lock(&watch_events_lock
);
753 list_for_each_entry_safe(msg
, tmp
, &watch_events
, list
) {
754 if (msg
->u
.watch
.handle
!= watch
)
756 list_del(&msg
->list
);
757 kfree(msg
->u
.watch
.vec
);
760 spin_unlock(&watch_events_lock
);
762 if (current
->pid
!= xenwatch_pid
)
763 mutex_unlock(&xenwatch_mutex
);
765 EXPORT_SYMBOL_GPL(unregister_xenbus_watch
);
767 void xs_suspend(void)
769 transaction_suspend();
770 down_write(&xs_state
.watch_mutex
);
771 mutex_lock(&xs_state
.request_mutex
);
772 mutex_lock(&xs_state
.response_mutex
);
777 struct xenbus_watch
*watch
;
778 char token
[sizeof(watch
) * 2 + 1];
782 mutex_unlock(&xs_state
.response_mutex
);
783 mutex_unlock(&xs_state
.request_mutex
);
784 transaction_resume();
786 /* No need for watches_lock: the watch_mutex is sufficient. */
787 list_for_each_entry(watch
, &watches
, list
) {
788 sprintf(token
, "%lX", (long)watch
);
789 xs_watch(watch
->node
, token
);
792 up_write(&xs_state
.watch_mutex
);
795 void xs_suspend_cancel(void)
797 mutex_unlock(&xs_state
.response_mutex
);
798 mutex_unlock(&xs_state
.request_mutex
);
799 up_write(&xs_state
.watch_mutex
);
800 mutex_unlock(&xs_state
.transaction_mutex
);
803 static int xenwatch_thread(void *unused
)
805 struct list_head
*ent
;
806 struct xs_stored_msg
*msg
;
809 wait_event_interruptible(watch_events_waitq
,
810 !list_empty(&watch_events
));
812 if (kthread_should_stop())
815 mutex_lock(&xenwatch_mutex
);
817 spin_lock(&watch_events_lock
);
818 ent
= watch_events
.next
;
819 if (ent
!= &watch_events
)
821 spin_unlock(&watch_events_lock
);
823 if (ent
!= &watch_events
) {
824 msg
= list_entry(ent
, struct xs_stored_msg
, list
);
825 msg
->u
.watch
.handle
->callback(
827 (const char **)msg
->u
.watch
.vec
,
828 msg
->u
.watch
.vec_size
);
829 kfree(msg
->u
.watch
.vec
);
833 mutex_unlock(&xenwatch_mutex
);
839 static int process_msg(void)
841 struct xs_stored_msg
*msg
;
846 * We must disallow save/restore while reading a xenstore message.
847 * A partial read across s/r leaves us out of sync with xenstored.
850 err
= xb_wait_for_data_to_read();
853 mutex_lock(&xs_state
.response_mutex
);
854 if (xb_data_to_read())
856 /* We raced with save/restore: pending data 'disappeared'. */
857 mutex_unlock(&xs_state
.response_mutex
);
861 msg
= kmalloc(sizeof(*msg
), GFP_NOIO
| __GFP_HIGH
);
867 err
= xb_read(&msg
->hdr
, sizeof(msg
->hdr
));
873 if (msg
->hdr
.len
> XENSTORE_PAYLOAD_MAX
) {
879 body
= kmalloc(msg
->hdr
.len
+ 1, GFP_NOIO
| __GFP_HIGH
);
886 err
= xb_read(body
, msg
->hdr
.len
);
892 body
[msg
->hdr
.len
] = '\0';
894 if (msg
->hdr
.type
== XS_WATCH_EVENT
) {
895 msg
->u
.watch
.vec
= split(body
, msg
->hdr
.len
,
896 &msg
->u
.watch
.vec_size
);
897 if (IS_ERR(msg
->u
.watch
.vec
)) {
898 err
= PTR_ERR(msg
->u
.watch
.vec
);
903 spin_lock(&watches_lock
);
904 msg
->u
.watch
.handle
= find_watch(
905 msg
->u
.watch
.vec
[XS_WATCH_TOKEN
]);
906 if (msg
->u
.watch
.handle
!= NULL
) {
907 spin_lock(&watch_events_lock
);
908 list_add_tail(&msg
->list
, &watch_events
);
909 wake_up(&watch_events_waitq
);
910 spin_unlock(&watch_events_lock
);
912 kfree(msg
->u
.watch
.vec
);
915 spin_unlock(&watches_lock
);
917 msg
->u
.reply
.body
= body
;
918 spin_lock(&xs_state
.reply_lock
);
919 list_add_tail(&msg
->list
, &xs_state
.reply_list
);
920 spin_unlock(&xs_state
.reply_lock
);
921 wake_up(&xs_state
.reply_waitq
);
925 mutex_unlock(&xs_state
.response_mutex
);
929 static int xenbus_thread(void *unused
)
936 pr_warn("error %d while reading message\n", err
);
937 if (kthread_should_stop())
947 struct task_struct
*task
;
949 INIT_LIST_HEAD(&xs_state
.reply_list
);
950 spin_lock_init(&xs_state
.reply_lock
);
951 init_waitqueue_head(&xs_state
.reply_waitq
);
953 mutex_init(&xs_state
.request_mutex
);
954 mutex_init(&xs_state
.response_mutex
);
955 mutex_init(&xs_state
.transaction_mutex
);
956 init_rwsem(&xs_state
.watch_mutex
);
957 atomic_set(&xs_state
.transaction_count
, 0);
958 init_waitqueue_head(&xs_state
.transaction_wq
);
960 /* Initialize the shared memory rings to talk to xenstored */
961 err
= xb_init_comms();
965 task
= kthread_run(xenwatch_thread
, NULL
, "xenwatch");
967 return PTR_ERR(task
);
968 xenwatch_pid
= task
->pid
;
970 task
= kthread_run(xenbus_thread
, NULL
, "xenbus");
972 return PTR_ERR(task
);
974 /* shutdown watches for kexec boot */