1 /******************************************************************************
2 * Talks to Xen Store to figure out what devices we have.
4 * Copyright (C) 2005 Rusty Russell, IBM Corporation
5 * Copyright (C) 2005 Mike Wray, Hewlett-Packard
6 * Copyright (C) 2005, 2006 XenSource Ltd
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
33 #define DPRINTK(fmt, args...) \
34 pr_debug("xenbus_probe (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args)
36 #include <linux/kernel.h>
37 #include <linux/err.h>
38 #include <linux/string.h>
39 #include <linux/ctype.h>
40 #include <linux/fcntl.h>
42 #include <linux/notifier.h>
43 #include <linux/kthread.h>
47 #include <asm/pgtable.h>
48 #include <asm/hypervisor.h>
49 #include <xen/xenbus.h>
50 #include <xen/xen_proc.h>
51 #include <xen/evtchn.h>
52 #include <xen/features.h>
54 #include "xenbus_comms.h"
56 extern struct mutex xenwatch_mutex;
58 static struct notifier_block *xenstore_chain;
60 /* If something in array of ids matches this device, return it. */
61 static const struct xenbus_device_id *
62 match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
64 for (; *arr->devicetype != '\0'; arr++) {
65 if (!strcmp(arr->devicetype, dev->devicetype))
71 static int xenbus_match(struct device *_dev, struct device_driver *_drv)
73 struct xenbus_driver *drv = to_xenbus_driver(_drv);
78 return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
85 int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
86 int (*probe)(const char *type, const char *dir);
92 /* device/<type>/<id> => <type>-<id> */
93 static int frontend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
95 nodename = strchr(nodename, '/');
96 if (!nodename || strlen(nodename + 1) >= BUS_ID_SIZE) {
97 printk(KERN_WARNING "XENBUS: bad frontend %s\n", nodename);
101 strlcpy(bus_id, nodename + 1, BUS_ID_SIZE);
102 if (!strchr(bus_id, '/')) {
103 printk(KERN_WARNING "XENBUS: bus_id %s no slash\n", bus_id);
106 *strchr(bus_id, '/') = '-';
111 static void free_otherend_details(struct xenbus_device *dev)
113 kfree(dev->otherend);
114 dev->otherend = NULL;
118 static void free_otherend_watch(struct xenbus_device *dev)
120 if (dev->otherend_watch.node) {
121 unregister_xenbus_watch(&dev->otherend_watch);
122 kfree(dev->otherend_watch.node);
123 dev->otherend_watch.node = NULL;
128 static int read_otherend_details(struct xenbus_device *xendev,
129 char *id_node, char *path_node)
131 int err = xenbus_gather(XBT_NULL, xendev->nodename,
132 id_node, "%i", &xendev->otherend_id,
133 path_node, NULL, &xendev->otherend,
136 xenbus_dev_fatal(xendev, err,
137 "reading other end details from %s",
141 if (strlen(xendev->otherend) == 0 ||
142 !xenbus_exists(XBT_NULL, xendev->otherend, "")) {
143 xenbus_dev_fatal(xendev, -ENOENT, "missing other end from %s",
145 free_otherend_details(xendev);
153 static int read_backend_details(struct xenbus_device *xendev)
155 return read_otherend_details(xendev, "backend-id", "backend");
159 static int read_frontend_details(struct xenbus_device *xendev)
161 return read_otherend_details(xendev, "frontend-id", "frontend");
165 /* Bus type for frontend drivers. */
166 static int xenbus_probe_frontend(const char *type, const char *name);
167 static struct xen_bus_type xenbus_frontend = {
169 .levels = 2, /* device/type/<id> */
170 .get_bus_id = frontend_bus_id,
171 .probe = xenbus_probe_frontend,
174 .match = xenbus_match,
181 /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
182 static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
185 const char *devid, *type, *frontend;
186 unsigned int typelen;
188 type = strchr(nodename, '/');
192 typelen = strcspn(type, "/");
193 if (!typelen || type[typelen] != '/')
196 devid = strrchr(nodename, '/') + 1;
198 err = xenbus_gather(XBT_NULL, nodename, "frontend-id", "%i", &domid,
199 "frontend", NULL, &frontend,
203 if (strlen(frontend) == 0)
205 if (!err && !xenbus_exists(XBT_NULL, frontend, ""))
213 if (snprintf(bus_id, BUS_ID_SIZE,
214 "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
219 static int xenbus_uevent_backend(struct device *dev, char **envp,
220 int num_envp, char *buffer, int buffer_size);
221 static int xenbus_probe_backend(const char *type, const char *domid);
222 static struct xen_bus_type xenbus_backend = {
224 .levels = 3, /* backend/type/<frontend>/<id> */
225 .get_bus_id = backend_bus_id,
226 .probe = xenbus_probe_backend,
228 .name = "xen-backend",
229 .match = xenbus_match,
230 .uevent = xenbus_uevent_backend,
233 .bus_id = "xen-backend",
237 static int xenbus_uevent_backend(struct device *dev, char **envp,
238 int num_envp, char *buffer, int buffer_size)
240 struct xenbus_device *xdev;
241 struct xenbus_driver *drv;
250 xdev = to_xenbus_device(dev);
254 /* stuff we want to pass to /sbin/hotplug */
255 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
256 "XENBUS_TYPE=%s", xdev->devicetype);
258 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
259 "XENBUS_PATH=%s", xdev->nodename);
261 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
262 "XENBUS_BASE_PATH=%s", xenbus_backend.root);
264 /* terminate, set to next free slot, shrink available space */
268 buffer = &buffer[length];
269 buffer_size -= length;
272 drv = to_xenbus_driver(dev->driver);
273 if (drv && drv->uevent)
274 return drv->uevent(xdev, envp, num_envp, buffer,
281 static void otherend_changed(struct xenbus_watch *watch,
282 const char **vec, unsigned int len)
284 struct xenbus_device *dev =
285 container_of(watch, struct xenbus_device, otherend_watch);
286 struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver);
289 /* Protect us against watches firing on old details when the otherend
290 details change, say immediately after a resume. */
291 if (!dev->otherend ||
292 strncmp(dev->otherend, vec[XS_WATCH_PATH],
293 strlen(dev->otherend))) {
294 DPRINTK("Ignoring watch at %s", vec[XS_WATCH_PATH]);
298 state = xenbus_read_driver_state(dev->otherend);
300 DPRINTK("state is %d, %s, %s",
301 state, dev->otherend_watch.node, vec[XS_WATCH_PATH]);
302 if (drv->otherend_changed)
303 drv->otherend_changed(dev, state);
307 static int talk_to_otherend(struct xenbus_device *dev)
309 struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver);
311 free_otherend_watch(dev);
312 free_otherend_details(dev);
314 return drv->read_otherend_details(dev);
318 static int watch_otherend(struct xenbus_device *dev)
320 return xenbus_watch_path2(dev, dev->otherend, "state",
321 &dev->otherend_watch, otherend_changed);
325 static int xenbus_dev_probe(struct device *_dev)
327 struct xenbus_device *dev = to_xenbus_device(_dev);
328 struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
329 const struct xenbus_device_id *id;
339 id = match_device(drv->ids, dev);
345 err = talk_to_otherend(dev);
348 "xenbus_probe: talk_to_otherend on %s failed.\n",
353 err = drv->probe(dev, id);
357 err = watch_otherend(dev);
360 "xenbus_probe: watch_otherend on %s failed.\n",
367 xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename);
368 xenbus_switch_state(dev, XenbusStateClosed);
372 static int xenbus_dev_remove(struct device *_dev)
374 struct xenbus_device *dev = to_xenbus_device(_dev);
375 struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
379 free_otherend_watch(dev);
380 free_otherend_details(dev);
385 xenbus_switch_state(dev, XenbusStateClosed);
389 static int xenbus_register_driver_common(struct xenbus_driver *drv,
390 struct xen_bus_type *bus)
394 drv->driver.name = drv->name;
395 drv->driver.bus = &bus->bus;
396 drv->driver.owner = drv->owner;
397 drv->driver.probe = xenbus_dev_probe;
398 drv->driver.remove = xenbus_dev_remove;
400 mutex_lock(&xenwatch_mutex);
401 ret = driver_register(&drv->driver);
402 mutex_unlock(&xenwatch_mutex);
406 int xenbus_register_frontend(struct xenbus_driver *drv)
408 drv->read_otherend_details = read_backend_details;
410 return xenbus_register_driver_common(drv, &xenbus_frontend);
412 EXPORT_SYMBOL_GPL(xenbus_register_frontend);
414 int xenbus_register_backend(struct xenbus_driver *drv)
416 drv->read_otherend_details = read_frontend_details;
418 return xenbus_register_driver_common(drv, &xenbus_backend);
420 EXPORT_SYMBOL_GPL(xenbus_register_backend);
422 void xenbus_unregister_driver(struct xenbus_driver *drv)
424 driver_unregister(&drv->driver);
426 EXPORT_SYMBOL_GPL(xenbus_unregister_driver);
430 struct xenbus_device *dev;
431 const char *nodename;
434 static int cmp_dev(struct device *dev, void *data)
436 struct xenbus_device *xendev = to_xenbus_device(dev);
437 struct xb_find_info *info = data;
439 if (!strcmp(xendev->nodename, info->nodename)) {
447 struct xenbus_device *xenbus_device_find(const char *nodename,
448 struct bus_type *bus)
450 struct xb_find_info info = { .dev = NULL, .nodename = nodename };
452 bus_for_each_dev(bus, NULL, &info, cmp_dev);
456 static int cleanup_dev(struct device *dev, void *data)
458 struct xenbus_device *xendev = to_xenbus_device(dev);
459 struct xb_find_info *info = data;
460 int len = strlen(info->nodename);
462 DPRINTK("%s", info->nodename);
464 /* Match the info->nodename path, or any subdirectory of that path. */
465 if (strncmp(xendev->nodename, info->nodename, len))
468 /* If the node name is longer, ensure it really is a subdirectory. */
469 if ((strlen(xendev->nodename) > len) && (xendev->nodename[len] != '/'))
477 static void xenbus_cleanup_devices(const char *path, struct bus_type *bus)
479 struct xb_find_info info = { .nodename = path };
483 bus_for_each_dev(bus, NULL, &info, cleanup_dev);
485 device_unregister(&info.dev->dev);
486 put_device(&info.dev->dev);
491 static void xenbus_dev_release(struct device *dev)
494 kfree(to_xenbus_device(dev));
497 /* Simplified asprintf. */
498 char *kasprintf(const char *fmt, ...)
505 /* FIXME: vsnprintf has a bug, NULL should work */
506 len = vsnprintf(dummy, 0, fmt, ap);
509 p = kmalloc(len + 1, GFP_KERNEL);
513 vsprintf(p, fmt, ap);
518 static ssize_t xendev_show_nodename(struct device *dev,
519 struct device_attribute *attr, char *buf)
521 return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
523 DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
525 static ssize_t xendev_show_devtype(struct device *dev,
526 struct device_attribute *attr, char *buf)
528 return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
530 DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
533 static int xenbus_probe_node(struct xen_bus_type *bus,
535 const char *nodename)
538 struct xenbus_device *xendev;
542 XenbusState state = xenbus_read_driver_state(nodename);
544 if (state != XenbusStateInitialising) {
545 /* Device is not new, so ignore it. This can happen if a
546 device is going away after switching to Closed. */
550 stringlen = strlen(nodename) + 1 + strlen(type) + 1;
551 xendev = kzalloc(sizeof(*xendev) + stringlen, GFP_KERNEL);
555 /* Copy the strings into the extra space. */
557 tmpstring = (char *)(xendev + 1);
558 strcpy(tmpstring, nodename);
559 xendev->nodename = tmpstring;
561 tmpstring += strlen(tmpstring) + 1;
562 strcpy(tmpstring, type);
563 xendev->devicetype = tmpstring;
565 xendev->dev.parent = &bus->dev;
566 xendev->dev.bus = &bus->bus;
567 xendev->dev.release = xenbus_dev_release;
569 err = bus->get_bus_id(xendev->dev.bus_id, xendev->nodename);
573 /* Register with generic device framework. */
574 err = device_register(&xendev->dev);
578 device_create_file(&xendev->dev, &dev_attr_nodename);
579 device_create_file(&xendev->dev, &dev_attr_devtype);
587 /* device/<typename>/<name> */
588 static int xenbus_probe_frontend(const char *type, const char *name)
593 nodename = kasprintf("%s/%s/%s", xenbus_frontend.root, type, name);
597 DPRINTK("%s", nodename);
599 err = xenbus_probe_node(&xenbus_frontend, type, nodename);
604 /* backend/<typename>/<frontend-uuid>/<name> */
605 static int xenbus_probe_backend_unit(const char *dir,
612 nodename = kasprintf("%s/%s", dir, name);
616 DPRINTK("%s\n", nodename);
618 err = xenbus_probe_node(&xenbus_backend, type, nodename);
623 /* backend/<typename>/<frontend-domid> */
624 static int xenbus_probe_backend(const char *type, const char *domid)
629 unsigned int i, dir_n = 0;
633 nodename = kasprintf("%s/%s/%s", xenbus_backend.root, type, domid);
637 dir = xenbus_directory(XBT_NULL, nodename, "", &dir_n);
643 for (i = 0; i < dir_n; i++) {
644 err = xenbus_probe_backend_unit(nodename, type, dir[i]);
653 static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
657 unsigned int dir_n = 0;
660 dir = xenbus_directory(XBT_NULL, bus->root, type, &dir_n);
664 for (i = 0; i < dir_n; i++) {
665 err = bus->probe(type, dir[i]);
673 static int xenbus_probe_devices(struct xen_bus_type *bus)
677 unsigned int i, dir_n;
679 dir = xenbus_directory(XBT_NULL, bus->root, "", &dir_n);
683 for (i = 0; i < dir_n; i++) {
684 err = xenbus_probe_device_type(bus, dir[i]);
692 static unsigned int char_count(const char *str, char c)
694 unsigned int i, ret = 0;
696 for (i = 0; str[i]; i++)
702 static int strsep_len(const char *str, char c, unsigned int len)
706 for (i = 0; str[i]; i++)
712 return (len == 0) ? i : -ERANGE;
715 static void dev_changed(const char *node, struct xen_bus_type *bus)
718 struct xenbus_device *dev;
719 char type[BUS_ID_SIZE];
720 const char *p, *root;
722 if (char_count(node, '/') < 2)
725 exists = xenbus_exists(XBT_NULL, node, "");
727 xenbus_cleanup_devices(node, &bus->bus);
731 /* backend/<type>/... or device/<type>/... */
732 p = strchr(node, '/') + 1;
733 snprintf(type, BUS_ID_SIZE, "%.*s", (int)strcspn(p, "/"), p);
734 type[BUS_ID_SIZE-1] = '\0';
736 rootlen = strsep_len(node, '/', bus->levels);
739 root = kasprintf("%.*s", rootlen, node);
743 dev = xenbus_device_find(root, &bus->bus);
745 xenbus_probe_node(bus, type, root);
747 put_device(&dev->dev);
752 static void frontend_changed(struct xenbus_watch *watch,
753 const char **vec, unsigned int len)
757 dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
760 static void backend_changed(struct xenbus_watch *watch,
761 const char **vec, unsigned int len)
765 dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
768 /* We watch for devices appearing and vanishing. */
769 static struct xenbus_watch fe_watch = {
771 .callback = frontend_changed,
774 static struct xenbus_watch be_watch = {
776 .callback = backend_changed,
779 static int suspend_dev(struct device *dev, void *data)
782 struct xenbus_driver *drv;
783 struct xenbus_device *xdev;
787 if (dev->driver == NULL)
789 drv = to_xenbus_driver(dev->driver);
790 xdev = container_of(dev, struct xenbus_device, dev);
792 err = drv->suspend(xdev);
795 "xenbus: suspend %s failed: %i\n", dev->bus_id, err);
799 static int resume_dev(struct device *dev, void *data)
802 struct xenbus_driver *drv;
803 struct xenbus_device *xdev;
807 if (dev->driver == NULL)
809 drv = to_xenbus_driver(dev->driver);
810 xdev = container_of(dev, struct xenbus_device, dev);
812 err = talk_to_otherend(xdev);
815 "xenbus: resume (talk_to_otherend) %s failed: %i\n",
820 err = watch_otherend(xdev);
823 "xenbus_probe: resume (watch_otherend) %s failed: "
824 "%d.\n", dev->bus_id, err);
828 xdev->state = XenbusStateInitialising;
831 err = drv->resume(xdev);
834 "xenbus: resume %s failed: %i\n", dev->bus_id, err);
838 void xenbus_suspend(void)
842 bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
843 bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
846 EXPORT_SYMBOL_GPL(xenbus_suspend);
848 void xenbus_resume(void)
852 bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
853 bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
855 EXPORT_SYMBOL_GPL(xenbus_resume);
858 /* A flag to determine if xenstored is 'ready' (i.e. has started) */
859 int xenstored_ready = 0;
862 int register_xenstore_notifier(struct notifier_block *nb)
866 if (xenstored_ready > 0)
867 ret = nb->notifier_call(nb, 0, NULL);
869 notifier_chain_register(&xenstore_chain, nb);
873 EXPORT_SYMBOL_GPL(register_xenstore_notifier);
875 void unregister_xenstore_notifier(struct notifier_block *nb)
877 notifier_chain_unregister(&xenstore_chain, nb);
879 EXPORT_SYMBOL_GPL(unregister_xenstore_notifier);
882 static int all_devices_ready_(struct device *dev, void *data)
884 struct xenbus_device *xendev = to_xenbus_device(dev);
887 if (xendev->state != XenbusStateConnected) {
896 static int all_devices_ready(void)
899 bus_for_each_dev(&xenbus_frontend.bus, NULL, &ready,
905 void xenbus_probe(void *unused)
907 BUG_ON((xenstored_ready <= 0));
909 /* Enumerate devices in xenstore. */
910 xenbus_probe_devices(&xenbus_frontend);
911 xenbus_probe_devices(&xenbus_backend);
913 /* Watch for changes. */
914 register_xenbus_watch(&fe_watch);
915 register_xenbus_watch(&be_watch);
917 /* Notify others that xenstore is up */
918 notifier_call_chain(&xenstore_chain, 0, NULL);
922 static struct file_operations xsd_kva_fops;
923 static struct proc_dir_entry *xsd_kva_intf;
924 static struct proc_dir_entry *xsd_port_intf;
926 static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
928 size_t size = vma->vm_end - vma->vm_start;
930 if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
933 if (remap_pfn_range(vma, vma->vm_start,
934 mfn_to_pfn(xen_start_info->store_mfn),
935 size, vma->vm_page_prot))
941 static int xsd_kva_read(char *page, char **start, off_t off,
942 int count, int *eof, void *data)
946 len = sprintf(page, "0x%p", mfn_to_virt(xen_start_info->store_mfn));
951 static int xsd_port_read(char *page, char **start, off_t off,
952 int count, int *eof, void *data)
956 len = sprintf(page, "%d", xen_start_info->store_evtchn);
962 static int __init xenbus_probe_init(void)
965 unsigned long page = 0;
969 if (xen_init() < 0) {
974 /* Register ourselves with the kernel bus subsystem */
975 bus_register(&xenbus_frontend.bus);
976 bus_register(&xenbus_backend.bus);
979 * Domain0 doesn't have a store_evtchn or store_mfn yet.
981 dom0 = (xen_start_info->store_evtchn == 0);
984 evtchn_op_t op = { 0 };
987 page = get_zeroed_page(GFP_KERNEL);
991 xen_start_info->store_mfn =
992 pfn_to_mfn(virt_to_phys((void *)page) >>
995 /* Next allocate a local port which xenstored can bind to */
996 op.cmd = EVTCHNOP_alloc_unbound;
997 op.u.alloc_unbound.dom = DOMID_SELF;
998 op.u.alloc_unbound.remote_dom = 0;
1000 err = HYPERVISOR_event_channel_op(&op);
1004 xen_start_info->store_evtchn = op.u.alloc_unbound.port;
1006 /* And finally publish the above info in /proc/xen */
1007 xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0600);
1009 memcpy(&xsd_kva_fops, xsd_kva_intf->proc_fops,
1010 sizeof(xsd_kva_fops));
1011 xsd_kva_fops.mmap = xsd_kva_mmap;
1012 xsd_kva_intf->proc_fops = &xsd_kva_fops;
1013 xsd_kva_intf->read_proc = xsd_kva_read;
1015 xsd_port_intf = create_xen_proc_entry("xsd_port", 0400);
1017 xsd_port_intf->read_proc = xsd_port_read;
1019 xenstored_ready = 1;
1021 /* Initialize the interface to xenstore. */
1025 "XENBUS: Error initializing xenstore comms: %i\n", err);
1029 /* Register ourselves with the kernel device subsystem */
1030 device_register(&xenbus_frontend.dev);
1031 device_register(&xenbus_backend.dev);
1043 * Do not unregister the xenbus front/backend buses here. The
1044 * buses must exist because front/backend drivers will use
1045 * them when they are registered.
1051 postcore_initcall(xenbus_probe_init);
1055 * On a 10 second timeout, wait for all devices currently configured. We need
1056 * to do this to guarantee that the filesystems and / or network devices
1057 * needed for boot are available, before we can allow the boot to proceed.
1059 * This needs to be on a late_initcall, to happen after the frontend device
1060 * drivers have been initialised, but before the root fs is mounted.
1062 * A possible improvement here would be to have the tools add a per-device
1063 * flag to the store entry, indicating whether it is needed at boot time.
1064 * This would allow people who knew what they were doing to accelerate their
1065 * boot slightly, but of course needs tools or manual intervention to set up
1066 * those flags correctly.
1068 static int __init wait_for_devices(void)
1070 unsigned long timeout = jiffies + 10*HZ;
1072 while (time_before(jiffies, timeout)) {
1073 if (all_devices_ready())
1075 schedule_timeout_interruptible(HZ/10);
1078 printk(KERN_WARNING "XENBUS: Timeout connecting to devices!\n");
1082 late_initcall(wait_for_devices);
1087 * c-file-style: "linux"
1088 * indent-tabs-mode: t