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/mutex.h>
48 #include <asm/xen/hypervisor.h>
49 #include <xen/xenbus.h>
51 #include "xenbus_comms.h"
52 #include "xenbus_probe.h"
54 struct xs_stored_msg
{
55 struct list_head list
;
57 struct xsd_sockmsg hdr
;
65 /* Queued watch events. */
67 struct xenbus_watch
*handle
;
69 unsigned int vec_size
;
75 /* A list of replies. Currently only one will ever be outstanding. */
76 struct list_head reply_list
;
77 spinlock_t reply_lock
;
78 wait_queue_head_t reply_waitq
;
81 * Mutex ordering: transaction_mutex -> watch_mutex -> request_mutex.
82 * response_mutex is never taken simultaneously with the other three.
84 * transaction_mutex must be held before incrementing
85 * transaction_count. The mutex is held when a suspend is in
86 * progress to prevent new transactions starting.
88 * When decrementing transaction_count to zero the wait queue
89 * should be woken up, the suspend code waits for count to
93 /* One request at a time. */
94 struct mutex request_mutex
;
96 /* Protect xenbus reader thread against save/restore. */
97 struct mutex response_mutex
;
99 /* Protect transactions against save/restore. */
100 struct mutex transaction_mutex
;
101 atomic_t transaction_count
;
102 wait_queue_head_t transaction_wq
;
104 /* Protect watch (de)register against save/restore. */
105 struct rw_semaphore watch_mutex
;
108 static struct xs_handle xs_state
;
110 /* List of registered watches, and a lock to protect it. */
111 static LIST_HEAD(watches
);
112 static DEFINE_SPINLOCK(watches_lock
);
114 /* List of pending watch callback events, and a lock to protect it. */
115 static LIST_HEAD(watch_events
);
116 static DEFINE_SPINLOCK(watch_events_lock
);
119 * Details of the xenwatch callback kernel thread. The thread waits on the
120 * watch_events_waitq for work to do (queued on watch_events list). When it
121 * wakes up it acquires the xenwatch_mutex before reading the list and
124 static pid_t xenwatch_pid
;
125 static DEFINE_MUTEX(xenwatch_mutex
);
126 static DECLARE_WAIT_QUEUE_HEAD(watch_events_waitq
);
128 static int get_error(const char *errorstring
)
132 for (i
= 0; strcmp(errorstring
, xsd_errors
[i
].errstring
) != 0; i
++) {
133 if (i
== ARRAY_SIZE(xsd_errors
) - 1) {
134 pr_warn("xen store gave: unknown error %s\n",
139 return xsd_errors
[i
].errnum
;
142 static bool xenbus_ok(void)
144 switch (xen_store_domain_type
) {
146 switch (system_state
) {
147 case SYSTEM_POWER_OFF
:
157 /* FIXME: Could check that the remote domain is alive,
158 * but it is normally initial domain. */
165 static void *read_reply(enum xsd_sockmsg_type
*type
, unsigned int *len
)
167 struct xs_stored_msg
*msg
;
170 spin_lock(&xs_state
.reply_lock
);
172 while (list_empty(&xs_state
.reply_list
)) {
173 spin_unlock(&xs_state
.reply_lock
);
175 /* XXX FIXME: Avoid synchronous wait for response here. */
176 wait_event_timeout(xs_state
.reply_waitq
,
177 !list_empty(&xs_state
.reply_list
),
178 msecs_to_jiffies(500));
181 * If we are in the process of being shut-down there is
182 * no point of trying to contact XenBus - it is either
183 * killed (xenstored application) or the other domain
184 * has been killed or is unreachable.
186 return ERR_PTR(-EIO
);
188 spin_lock(&xs_state
.reply_lock
);
191 msg
= list_entry(xs_state
.reply_list
.next
,
192 struct xs_stored_msg
, list
);
193 list_del(&msg
->list
);
195 spin_unlock(&xs_state
.reply_lock
);
197 *type
= msg
->hdr
.type
;
200 body
= msg
->u
.reply
.body
;
207 static void transaction_start(void)
209 mutex_lock(&xs_state
.transaction_mutex
);
210 atomic_inc(&xs_state
.transaction_count
);
211 mutex_unlock(&xs_state
.transaction_mutex
);
214 static void transaction_end(void)
216 if (atomic_dec_and_test(&xs_state
.transaction_count
))
217 wake_up(&xs_state
.transaction_wq
);
220 static void transaction_suspend(void)
222 mutex_lock(&xs_state
.transaction_mutex
);
223 wait_event(xs_state
.transaction_wq
,
224 atomic_read(&xs_state
.transaction_count
) == 0);
227 static void transaction_resume(void)
229 mutex_unlock(&xs_state
.transaction_mutex
);
232 void *xenbus_dev_request_and_reply(struct xsd_sockmsg
*msg
)
235 enum xsd_sockmsg_type type
= msg
->type
;
238 if (type
== XS_TRANSACTION_START
)
241 mutex_lock(&xs_state
.request_mutex
);
243 err
= xb_write(msg
, sizeof(*msg
) + msg
->len
);
245 msg
->type
= XS_ERROR
;
248 ret
= read_reply(&msg
->type
, &msg
->len
);
250 mutex_unlock(&xs_state
.request_mutex
);
252 if ((msg
->type
== XS_TRANSACTION_END
) ||
253 ((type
== XS_TRANSACTION_START
) && (msg
->type
== XS_ERROR
)))
258 EXPORT_SYMBOL(xenbus_dev_request_and_reply
);
260 /* Send message to xs, get kmalloc'ed reply. ERR_PTR() on error. */
261 static void *xs_talkv(struct xenbus_transaction t
,
262 enum xsd_sockmsg_type type
,
263 const struct kvec
*iovec
,
264 unsigned int num_vecs
,
267 struct xsd_sockmsg msg
;
276 for (i
= 0; i
< num_vecs
; i
++)
277 msg
.len
+= iovec
[i
].iov_len
;
279 mutex_lock(&xs_state
.request_mutex
);
281 err
= xb_write(&msg
, sizeof(msg
));
283 mutex_unlock(&xs_state
.request_mutex
);
287 for (i
= 0; i
< num_vecs
; i
++) {
288 err
= xb_write(iovec
[i
].iov_base
, iovec
[i
].iov_len
);
290 mutex_unlock(&xs_state
.request_mutex
);
295 ret
= read_reply(&msg
.type
, len
);
297 mutex_unlock(&xs_state
.request_mutex
);
302 if (msg
.type
== XS_ERROR
) {
303 err
= get_error(ret
);
305 return ERR_PTR(-err
);
308 if (msg
.type
!= type
) {
309 pr_warn_ratelimited("unexpected type [%d], expected [%d]\n",
312 return ERR_PTR(-EINVAL
);
317 /* Simplified version of xs_talkv: single message. */
318 static void *xs_single(struct xenbus_transaction t
,
319 enum xsd_sockmsg_type type
,
325 iovec
.iov_base
= (void *)string
;
326 iovec
.iov_len
= strlen(string
) + 1;
327 return xs_talkv(t
, type
, &iovec
, 1, len
);
330 /* Many commands only need an ack, don't care what it says. */
331 static int xs_error(char *reply
)
334 return PTR_ERR(reply
);
339 static unsigned int count_strings(const char *strings
, unsigned int len
)
344 for (p
= strings
, num
= 0; p
< strings
+ len
; p
+= strlen(p
) + 1)
350 /* Return the path to dir with /name appended. Buffer must be kfree()'ed. */
351 static char *join(const char *dir
, const char *name
)
355 if (strlen(name
) == 0)
356 buffer
= kasprintf(GFP_NOIO
| __GFP_HIGH
, "%s", dir
);
358 buffer
= kasprintf(GFP_NOIO
| __GFP_HIGH
, "%s/%s", dir
, name
);
359 return (!buffer
) ? ERR_PTR(-ENOMEM
) : buffer
;
362 static char **split(char *strings
, unsigned int len
, unsigned int *num
)
366 /* Count the strings. */
367 *num
= count_strings(strings
, len
);
369 /* Transfer to one big alloc for easy freeing. */
370 ret
= kmalloc(*num
* sizeof(char *) + len
, GFP_NOIO
| __GFP_HIGH
);
373 return ERR_PTR(-ENOMEM
);
375 memcpy(&ret
[*num
], strings
, len
);
378 strings
= (char *)&ret
[*num
];
379 for (p
= strings
, *num
= 0; p
< strings
+ len
; p
+= strlen(p
) + 1)
385 char **xenbus_directory(struct xenbus_transaction t
,
386 const char *dir
, const char *node
, unsigned int *num
)
388 char *strings
, *path
;
391 path
= join(dir
, node
);
393 return (char **)path
;
395 strings
= xs_single(t
, XS_DIRECTORY
, path
, &len
);
398 return (char **)strings
;
400 return split(strings
, len
, num
);
402 EXPORT_SYMBOL_GPL(xenbus_directory
);
404 /* Check if a path exists. Return 1 if it does. */
405 int xenbus_exists(struct xenbus_transaction t
,
406 const char *dir
, const char *node
)
411 d
= xenbus_directory(t
, dir
, node
, &dir_n
);
417 EXPORT_SYMBOL_GPL(xenbus_exists
);
419 /* Get the value of a single file.
420 * Returns a kmalloced value: call free() on it after use.
421 * len indicates length in bytes.
423 void *xenbus_read(struct xenbus_transaction t
,
424 const char *dir
, const char *node
, unsigned int *len
)
429 path
= join(dir
, node
);
433 ret
= xs_single(t
, XS_READ
, path
, len
);
437 EXPORT_SYMBOL_GPL(xenbus_read
);
439 /* Write the value of a single file.
440 * Returns -err on failure.
442 int xenbus_write(struct xenbus_transaction t
,
443 const char *dir
, const char *node
, const char *string
)
446 struct kvec iovec
[2];
449 path
= join(dir
, node
);
451 return PTR_ERR(path
);
453 iovec
[0].iov_base
= (void *)path
;
454 iovec
[0].iov_len
= strlen(path
) + 1;
455 iovec
[1].iov_base
= (void *)string
;
456 iovec
[1].iov_len
= strlen(string
);
458 ret
= xs_error(xs_talkv(t
, XS_WRITE
, iovec
, ARRAY_SIZE(iovec
), NULL
));
462 EXPORT_SYMBOL_GPL(xenbus_write
);
464 /* Create a new directory. */
465 int xenbus_mkdir(struct xenbus_transaction t
,
466 const char *dir
, const char *node
)
471 path
= join(dir
, node
);
473 return PTR_ERR(path
);
475 ret
= xs_error(xs_single(t
, XS_MKDIR
, path
, NULL
));
479 EXPORT_SYMBOL_GPL(xenbus_mkdir
);
481 /* Destroy a file or directory (directories must be empty). */
482 int xenbus_rm(struct xenbus_transaction t
, const char *dir
, const char *node
)
487 path
= join(dir
, node
);
489 return PTR_ERR(path
);
491 ret
= xs_error(xs_single(t
, XS_RM
, path
, NULL
));
495 EXPORT_SYMBOL_GPL(xenbus_rm
);
497 /* Start a transaction: changes by others will not be seen during this
498 * transaction, and changes will not be visible to others until end.
500 int xenbus_transaction_start(struct xenbus_transaction
*t
)
506 id_str
= xs_single(XBT_NIL
, XS_TRANSACTION_START
, "", NULL
);
507 if (IS_ERR(id_str
)) {
509 return PTR_ERR(id_str
);
512 t
->id
= simple_strtoul(id_str
, NULL
, 0);
516 EXPORT_SYMBOL_GPL(xenbus_transaction_start
);
518 /* End a transaction.
519 * If abandon is true, transaction is discarded instead of committed.
521 int xenbus_transaction_end(struct xenbus_transaction t
, int abort
)
527 strcpy(abortstr
, "F");
529 strcpy(abortstr
, "T");
531 err
= xs_error(xs_single(t
, XS_TRANSACTION_END
, abortstr
, NULL
));
537 EXPORT_SYMBOL_GPL(xenbus_transaction_end
);
539 /* Single read and scanf: returns -errno or num scanned. */
540 int xenbus_scanf(struct xenbus_transaction t
,
541 const char *dir
, const char *node
, const char *fmt
, ...)
547 val
= xenbus_read(t
, dir
, node
, NULL
);
552 ret
= vsscanf(val
, fmt
, ap
);
555 /* Distinctive errno. */
560 EXPORT_SYMBOL_GPL(xenbus_scanf
);
562 /* Single printf and write: returns -errno or 0. */
563 int xenbus_printf(struct xenbus_transaction t
,
564 const char *dir
, const char *node
, const char *fmt
, ...)
571 buf
= kvasprintf(GFP_NOIO
| __GFP_HIGH
, fmt
, ap
);
577 ret
= xenbus_write(t
, dir
, node
, buf
);
583 EXPORT_SYMBOL_GPL(xenbus_printf
);
585 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
586 int xenbus_gather(struct xenbus_transaction t
, const char *dir
, ...)
593 while (ret
== 0 && (name
= va_arg(ap
, char *)) != NULL
) {
594 const char *fmt
= va_arg(ap
, char *);
595 void *result
= va_arg(ap
, void *);
598 p
= xenbus_read(t
, dir
, name
, NULL
);
604 if (sscanf(p
, fmt
, result
) == 0)
608 *(char **)result
= p
;
613 EXPORT_SYMBOL_GPL(xenbus_gather
);
615 static int xs_watch(const char *path
, const char *token
)
619 iov
[0].iov_base
= (void *)path
;
620 iov
[0].iov_len
= strlen(path
) + 1;
621 iov
[1].iov_base
= (void *)token
;
622 iov
[1].iov_len
= strlen(token
) + 1;
624 return xs_error(xs_talkv(XBT_NIL
, XS_WATCH
, iov
,
625 ARRAY_SIZE(iov
), NULL
));
628 static int xs_unwatch(const char *path
, const char *token
)
632 iov
[0].iov_base
= (char *)path
;
633 iov
[0].iov_len
= strlen(path
) + 1;
634 iov
[1].iov_base
= (char *)token
;
635 iov
[1].iov_len
= strlen(token
) + 1;
637 return xs_error(xs_talkv(XBT_NIL
, XS_UNWATCH
, iov
,
638 ARRAY_SIZE(iov
), NULL
));
641 static struct xenbus_watch
*find_watch(const char *token
)
643 struct xenbus_watch
*i
, *cmp
;
645 cmp
= (void *)simple_strtoul(token
, NULL
, 16);
647 list_for_each_entry(i
, &watches
, list
)
654 * Certain older XenBus toolstack cannot handle reading values that are
655 * not populated. Some Xen 3.4 installation are incapable of doing this
656 * so if we are running on anything older than 4 do not attempt to read
657 * control/platform-feature-xs_reset_watches.
659 static bool xen_strict_xenbus_quirk(void)
662 uint32_t eax
, ebx
, ecx
, edx
, base
;
664 base
= xen_cpuid_base();
665 cpuid(base
+ 1, &eax
, &ebx
, &ecx
, &edx
);
673 static void xs_reset_watches(void)
675 int err
, supported
= 0;
677 if (!xen_hvm_domain() || xen_initial_domain())
680 if (xen_strict_xenbus_quirk())
683 err
= xenbus_scanf(XBT_NIL
, "control",
684 "platform-feature-xs_reset_watches", "%d", &supported
);
685 if (err
!= 1 || !supported
)
688 err
= xs_error(xs_single(XBT_NIL
, XS_RESET_WATCHES
, "", NULL
));
689 if (err
&& err
!= -EEXIST
)
690 pr_warn("xs_reset_watches failed: %d\n", err
);
693 /* Register callback to watch this node. */
694 int register_xenbus_watch(struct xenbus_watch
*watch
)
696 /* Pointer in ascii is the token. */
697 char token
[sizeof(watch
) * 2 + 1];
700 sprintf(token
, "%lX", (long)watch
);
702 down_read(&xs_state
.watch_mutex
);
704 spin_lock(&watches_lock
);
705 BUG_ON(find_watch(token
));
706 list_add(&watch
->list
, &watches
);
707 spin_unlock(&watches_lock
);
709 err
= xs_watch(watch
->node
, token
);
712 spin_lock(&watches_lock
);
713 list_del(&watch
->list
);
714 spin_unlock(&watches_lock
);
717 up_read(&xs_state
.watch_mutex
);
721 EXPORT_SYMBOL_GPL(register_xenbus_watch
);
723 void unregister_xenbus_watch(struct xenbus_watch
*watch
)
725 struct xs_stored_msg
*msg
, *tmp
;
726 char token
[sizeof(watch
) * 2 + 1];
729 sprintf(token
, "%lX", (long)watch
);
731 down_read(&xs_state
.watch_mutex
);
733 spin_lock(&watches_lock
);
734 BUG_ON(!find_watch(token
));
735 list_del(&watch
->list
);
736 spin_unlock(&watches_lock
);
738 err
= xs_unwatch(watch
->node
, token
);
740 pr_warn("Failed to release watch %s: %i\n", watch
->node
, err
);
742 up_read(&xs_state
.watch_mutex
);
744 /* Make sure there are no callbacks running currently (unless
746 if (current
->pid
!= xenwatch_pid
)
747 mutex_lock(&xenwatch_mutex
);
749 /* Cancel pending watch events. */
750 spin_lock(&watch_events_lock
);
751 list_for_each_entry_safe(msg
, tmp
, &watch_events
, list
) {
752 if (msg
->u
.watch
.handle
!= watch
)
754 list_del(&msg
->list
);
755 kfree(msg
->u
.watch
.vec
);
758 spin_unlock(&watch_events_lock
);
760 if (current
->pid
!= xenwatch_pid
)
761 mutex_unlock(&xenwatch_mutex
);
763 EXPORT_SYMBOL_GPL(unregister_xenbus_watch
);
765 void xs_suspend(void)
767 transaction_suspend();
768 down_write(&xs_state
.watch_mutex
);
769 mutex_lock(&xs_state
.request_mutex
);
770 mutex_lock(&xs_state
.response_mutex
);
775 struct xenbus_watch
*watch
;
776 char token
[sizeof(watch
) * 2 + 1];
780 mutex_unlock(&xs_state
.response_mutex
);
781 mutex_unlock(&xs_state
.request_mutex
);
782 transaction_resume();
784 /* No need for watches_lock: the watch_mutex is sufficient. */
785 list_for_each_entry(watch
, &watches
, list
) {
786 sprintf(token
, "%lX", (long)watch
);
787 xs_watch(watch
->node
, token
);
790 up_write(&xs_state
.watch_mutex
);
793 void xs_suspend_cancel(void)
795 mutex_unlock(&xs_state
.response_mutex
);
796 mutex_unlock(&xs_state
.request_mutex
);
797 up_write(&xs_state
.watch_mutex
);
798 mutex_unlock(&xs_state
.transaction_mutex
);
801 static int xenwatch_thread(void *unused
)
803 struct list_head
*ent
;
804 struct xs_stored_msg
*msg
;
807 wait_event_interruptible(watch_events_waitq
,
808 !list_empty(&watch_events
));
810 if (kthread_should_stop())
813 mutex_lock(&xenwatch_mutex
);
815 spin_lock(&watch_events_lock
);
816 ent
= watch_events
.next
;
817 if (ent
!= &watch_events
)
819 spin_unlock(&watch_events_lock
);
821 if (ent
!= &watch_events
) {
822 msg
= list_entry(ent
, struct xs_stored_msg
, list
);
823 msg
->u
.watch
.handle
->callback(
825 (const char **)msg
->u
.watch
.vec
,
826 msg
->u
.watch
.vec_size
);
827 kfree(msg
->u
.watch
.vec
);
831 mutex_unlock(&xenwatch_mutex
);
837 static int process_msg(void)
839 struct xs_stored_msg
*msg
;
844 * We must disallow save/restore while reading a xenstore message.
845 * A partial read across s/r leaves us out of sync with xenstored.
848 err
= xb_wait_for_data_to_read();
851 mutex_lock(&xs_state
.response_mutex
);
852 if (xb_data_to_read())
854 /* We raced with save/restore: pending data 'disappeared'. */
855 mutex_unlock(&xs_state
.response_mutex
);
859 msg
= kmalloc(sizeof(*msg
), GFP_NOIO
| __GFP_HIGH
);
865 err
= xb_read(&msg
->hdr
, sizeof(msg
->hdr
));
871 if (msg
->hdr
.len
> XENSTORE_PAYLOAD_MAX
) {
877 body
= kmalloc(msg
->hdr
.len
+ 1, GFP_NOIO
| __GFP_HIGH
);
884 err
= xb_read(body
, msg
->hdr
.len
);
890 body
[msg
->hdr
.len
] = '\0';
892 if (msg
->hdr
.type
== XS_WATCH_EVENT
) {
893 msg
->u
.watch
.vec
= split(body
, msg
->hdr
.len
,
894 &msg
->u
.watch
.vec_size
);
895 if (IS_ERR(msg
->u
.watch
.vec
)) {
896 err
= PTR_ERR(msg
->u
.watch
.vec
);
901 spin_lock(&watches_lock
);
902 msg
->u
.watch
.handle
= find_watch(
903 msg
->u
.watch
.vec
[XS_WATCH_TOKEN
]);
904 if (msg
->u
.watch
.handle
!= NULL
) {
905 spin_lock(&watch_events_lock
);
906 list_add_tail(&msg
->list
, &watch_events
);
907 wake_up(&watch_events_waitq
);
908 spin_unlock(&watch_events_lock
);
910 kfree(msg
->u
.watch
.vec
);
913 spin_unlock(&watches_lock
);
915 msg
->u
.reply
.body
= body
;
916 spin_lock(&xs_state
.reply_lock
);
917 list_add_tail(&msg
->list
, &xs_state
.reply_list
);
918 spin_unlock(&xs_state
.reply_lock
);
919 wake_up(&xs_state
.reply_waitq
);
923 mutex_unlock(&xs_state
.response_mutex
);
927 static int xenbus_thread(void *unused
)
934 pr_warn("error %d while reading message\n", err
);
935 if (kthread_should_stop())
945 struct task_struct
*task
;
947 INIT_LIST_HEAD(&xs_state
.reply_list
);
948 spin_lock_init(&xs_state
.reply_lock
);
949 init_waitqueue_head(&xs_state
.reply_waitq
);
951 mutex_init(&xs_state
.request_mutex
);
952 mutex_init(&xs_state
.response_mutex
);
953 mutex_init(&xs_state
.transaction_mutex
);
954 init_rwsem(&xs_state
.watch_mutex
);
955 atomic_set(&xs_state
.transaction_count
, 0);
956 init_waitqueue_head(&xs_state
.transaction_wq
);
958 /* Initialize the shared memory rings to talk to xenstored */
959 err
= xb_init_comms();
963 task
= kthread_run(xenwatch_thread
, NULL
, "xenwatch");
965 return PTR_ERR(task
);
966 xenwatch_pid
= task
->pid
;
968 task
= kthread_run(xenbus_thread
, NULL
, "xenbus");
970 return PTR_ERR(task
);
972 /* shutdown watches for kexec boot */