ia64/xen-unstable

changeset 6255:9471090bb8ec

Update probe code for backend layout.
Backend directories are of form backend/<type>/<frontend-uuid>/<id>.
This extra level makes an asymmetry with front ends (device/type/id) and
are too long to make nice bus-ids under Linux, but the code isn't too
horrible, and an OS which only wants to be a guest doesn't need to implement
it. It allows backends to calculate the front-end path directly, which
is a nice benefit.
Also: subtype matching is tightened: they must match exactly. That way a future
variant which requires a specific driver will not match current drivers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 18 18:54:38 2005 +0000 (2005-08-18)
parents 18f04796ea89
children 11f556cac45b
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c linux-2.6-xen-sparse/include/asm-xen/xenbus.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Wed Aug 17 12:30:04 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Aug 18 18:54:38 2005 +0000
     1.3 @@ -48,15 +48,8 @@ static const struct xenbus_device_id *
     1.4  match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
     1.5  {
     1.6  	for (; !streq(arr->devicetype, ""); arr++) {
     1.7 -		if (!streq(arr->devicetype, dev->devicetype))
     1.8 -			continue;
     1.9 -
    1.10 -		/* If they don't care what subtype, it's a match. */
    1.11 -		if (streq(arr->subtype, ""))
    1.12 -			return arr;
    1.13 -
    1.14 -		/* If they care, device must have (same) subtype. */
    1.15 -		if (dev->subtype && streq(arr->subtype, dev->subtype))
    1.16 +		if (streq(arr->devicetype, dev->devicetype) &&
    1.17 +		    streq(arr->subtype, dev->subtype ?: ""))
    1.18  			return arr;
    1.19  	}
    1.20  	return NULL;
    1.21 @@ -72,10 +65,101 @@ static int xenbus_match(struct device *_
    1.22  	return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
    1.23  }
    1.24  
    1.25 +struct xen_bus_type
    1.26 +{
    1.27 +	char *root;
    1.28 +	unsigned int levels;
    1.29 +	int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
    1.30 +	int (*probe)(const char *type, const char *dir);
    1.31 +	struct bus_type bus;
    1.32 +};
    1.33 +
    1.34 +/* device/<type>/<id> => <type>-<id> */
    1.35 +static int frontend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
    1.36 +{
    1.37 +	nodename = strchr(nodename, '/');
    1.38 +	if (!nodename || strlen(nodename + 1) >= BUS_ID_SIZE) {
    1.39 +		printk(KERN_WARNING "XENBUS: bad frontend %s\n", nodename);
    1.40 +		return -EINVAL;
    1.41 +	}
    1.42 +
    1.43 +	strlcpy(bus_id, nodename + 1, BUS_ID_SIZE);
    1.44 +	if (!strchr(bus_id, '/')) {
    1.45 +		printk(KERN_WARNING "XENBUS: bus_id %s no slash\n", bus_id);
    1.46 +		return -EINVAL;
    1.47 +	}
    1.48 +	*strchr(bus_id, '/') = '-';
    1.49 +	return 0;
    1.50 +}
    1.51 +
    1.52  /* Bus type for frontend drivers. */
    1.53 -static struct bus_type xenbus_type = {
    1.54 -	.name  = "xenbus",
    1.55 -	.match = xenbus_match,
    1.56 +static int xenbus_probe_frontend(const char *type, const char *name);
    1.57 +static struct xen_bus_type xenbus_frontend = {
    1.58 +	.root = "device",
    1.59 +	.levels = 2, 		/* device/type/<id> */
    1.60 +	.get_bus_id = frontend_bus_id,
    1.61 +	.probe = xenbus_probe_frontend,
    1.62 +	.bus = {
    1.63 +		.name  = "xenbus",
    1.64 +		.match = xenbus_match,
    1.65 +	},
    1.66 +};
    1.67 +
    1.68 +/* For backends, does lookup on uuid (up to /).  Returns domid, or -errno. */
    1.69 +int xenbus_uuid_to_domid(const char *uuid)
    1.70 +{
    1.71 +	int err, domid, len;
    1.72 +	char path[strlen("/domain/") + 50];
    1.73 +
    1.74 +	len = strcspn(uuid, "/");
    1.75 +	if (snprintf(path, sizeof(path), "/domain/%.*s", len, uuid)
    1.76 +	    >= sizeof(path))
    1.77 +		return -ENOSPC;
    1.78 +	err = xenbus_scanf(path, "id", "%i", &domid);
    1.79 +	if (err != 1)
    1.80 +		return err;
    1.81 +	return domid;
    1.82 +}
    1.83 +
    1.84 +/* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
    1.85 +static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
    1.86 +{
    1.87 +	unsigned int typelen, uuidlen;
    1.88 +	int domid;
    1.89 +	const char *p;
    1.90 +
    1.91 +	nodename = strchr(nodename, '/');
    1.92 +	if (!nodename)
    1.93 +		return -EINVAL;
    1.94 +	nodename++;
    1.95 +	typelen = strcspn(nodename, "/");
    1.96 +	if (!typelen || nodename[typelen] != '/')
    1.97 +		return -EINVAL;
    1.98 +	p = nodename + typelen + 1;
    1.99 +	uuidlen = strcspn(p, "/");
   1.100 +	if (!uuidlen || p[uuidlen] != '/')
   1.101 +		return -EINVAL;
   1.102 +	domid = xenbus_uuid_to_domid(p);
   1.103 +	if (domid < 0)
   1.104 +		return domid;
   1.105 +	p += uuidlen + 1;
   1.106 +
   1.107 +	if (snprintf(bus_id, BUS_ID_SIZE,
   1.108 +		     "%.*s-%i-%s", typelen, nodename, domid, p) >= BUS_ID_SIZE)
   1.109 +		return -ENOSPC;
   1.110 +	return 0;
   1.111 +}
   1.112 +
   1.113 +static int xenbus_probe_backend(const char *type, const char *uuid);
   1.114 +static struct xen_bus_type xenbus_backend = {
   1.115 +	.root = "backend",
   1.116 +	.levels = 3, 		/* backend/type/<frontend>/<id> */
   1.117 +	.get_bus_id = backend_bus_id,
   1.118 +	.probe = xenbus_probe_backend,
   1.119 +	.bus = {
   1.120 +		.name  = "xenbus-backend",
   1.121 +		.match = xenbus_match,
   1.122 +	},
   1.123  };
   1.124  
   1.125  static int xenbus_dev_probe(struct device *_dev)
   1.126 @@ -104,12 +188,13 @@ static int xenbus_dev_remove(struct devi
   1.127  	return drv->remove(dev);
   1.128  }
   1.129  
   1.130 -int xenbus_register_driver(struct xenbus_driver *drv)
   1.131 +static int xenbus_register_driver(struct xenbus_driver *drv,
   1.132 +				  struct xen_bus_type *bus)
   1.133  {
   1.134  	int err;
   1.135  
   1.136  	drv->driver.name = drv->name;
   1.137 -	drv->driver.bus = &xenbus_type;
   1.138 +	drv->driver.bus = &bus->bus;
   1.139  	drv->driver.owner = drv->owner;
   1.140  	drv->driver.probe = xenbus_dev_probe;
   1.141  	drv->driver.remove = xenbus_dev_remove;
   1.142 @@ -120,6 +205,16 @@ int xenbus_register_driver(struct xenbus
   1.143  	return err;
   1.144  }
   1.145  
   1.146 +int xenbus_register_device(struct xenbus_driver *drv)
   1.147 +{
   1.148 +	return xenbus_register_driver(drv, &xenbus_frontend);
   1.149 +}
   1.150 +
   1.151 +int xenbus_register_backend(struct xenbus_driver *drv)
   1.152 +{
   1.153 +	return xenbus_register_driver(drv, &xenbus_backend);
   1.154 +}
   1.155 +
   1.156  void xenbus_unregister_driver(struct xenbus_driver *drv)
   1.157  {
   1.158  	down(&xenbus_lock);
   1.159 @@ -130,31 +225,30 @@ void xenbus_unregister_driver(struct xen
   1.160  struct xb_find_info
   1.161  {
   1.162  	struct xenbus_device *dev;
   1.163 -	const char *busid;
   1.164 +	const char *nodename;
   1.165  };
   1.166  
   1.167  static int cmp_dev(struct device *dev, void *data)
   1.168  {
   1.169 +	struct xenbus_device *xendev = to_xenbus_device(dev);
   1.170  	struct xb_find_info *info = data;
   1.171  
   1.172 -	if (streq(dev->bus_id, info->busid)) {
   1.173 -		info->dev = container_of(get_device(dev),
   1.174 -					 struct xenbus_device, dev);
   1.175 +	if (streq(xendev->nodename, info->nodename)) {
   1.176 +		info->dev = xendev;
   1.177  		return 1;
   1.178  	}
   1.179  	return 0;
   1.180  }
   1.181  
   1.182 -/* FIXME: device_find is fixed in 2.6.13-rc2 according to Greg KH --RR */
   1.183 -struct xenbus_device *xenbus_device_find(const char *busid)
   1.184 +struct xenbus_device *xenbus_device_find(const char *nodename,
   1.185 +					 struct bus_type *bus)
   1.186  {
   1.187 -	struct xb_find_info info = { .dev = NULL, .busid = busid };
   1.188 +	struct xb_find_info info = { .dev = NULL, .nodename = nodename };
   1.189  
   1.190 -	bus_for_each_dev(&xenbus_type, NULL, &info, cmp_dev);
   1.191 +	bus_for_each_dev(bus, NULL, &info, cmp_dev);
   1.192  	return info.dev;
   1.193  }
   1.194  
   1.195 -
   1.196  static void xenbus_release_device(struct device *dev)
   1.197  {
   1.198  	if (dev) {
   1.199 @@ -164,18 +258,37 @@ static void xenbus_release_device(struct
   1.200  		kfree(xendev);
   1.201  	}
   1.202  }
   1.203 -/* devices/<typename>/<name> */
   1.204 -static int xenbus_probe_device(const char *dirpath, const char *devicetype,
   1.205 -			       const char *name)
   1.206 +
   1.207 +/* Simplified asprintf. */
   1.208 +static char *kasprintf(const char *fmt, ...)
   1.209 +{
   1.210 +	va_list ap;
   1.211 +	unsigned int len;
   1.212 +	char *p, dummy[1];
   1.213 +
   1.214 +	va_start(ap, fmt);
   1.215 +	/* FIXME: vsnprintf has a bug, NULL should work */
   1.216 +	len = vsnprintf(dummy, 0, fmt, ap);
   1.217 +	va_end(ap);
   1.218 +
   1.219 +	p = kmalloc(len + 1, GFP_KERNEL);
   1.220 +	if (!p)
   1.221 +		return NULL;
   1.222 +	va_start(ap, fmt);
   1.223 +	vsprintf(p, fmt, ap);
   1.224 +	va_end(ap);
   1.225 +	return p;
   1.226 +}
   1.227 +
   1.228 +static int xenbus_probe_node(struct xen_bus_type *bus,
   1.229 +			     const char *type,
   1.230 +			     const char *nodename)
   1.231  {
   1.232  	int err;
   1.233  	struct xenbus_device *xendev;
   1.234  	unsigned int stringlen;
   1.235  
   1.236 -	/* Nodename: /device/<typename>/<name>/ */
   1.237 -	stringlen = strlen(dirpath) + strlen(devicetype) + strlen(name) + 3;
   1.238 -	/* Typename */
   1.239 -	stringlen += strlen(devicetype) + 1;
   1.240 +	stringlen = strlen(nodename) + 1 + strlen(type) + 1;
   1.241  	xendev = kmalloc(sizeof(*xendev) + stringlen, GFP_KERNEL);
   1.242  	if (!xendev)
   1.243  		return -ENOMEM;
   1.244 @@ -183,38 +296,108 @@ static int xenbus_probe_device(const cha
   1.245  
   1.246  	/* Copy the strings into the extra space. */
   1.247  	xendev->nodename = (char *)(xendev + 1);
   1.248 -	sprintf(xendev->nodename, "%s/%s/%s", dirpath, devicetype, name);
   1.249 +	strcpy(xendev->nodename, nodename);
   1.250  	xendev->devicetype = xendev->nodename + strlen(xendev->nodename) + 1;
   1.251 -	strcpy(xendev->devicetype, devicetype);
   1.252 +	strcpy(xendev->devicetype, type);
   1.253  
   1.254 -	/* FIXME: look for "subtype" field. */
   1.255 -	snprintf(xendev->dev.bus_id, BUS_ID_SIZE, "%s-%s", devicetype, name);
   1.256 -	xendev->dev.bus = &xenbus_type;
   1.257 +	/* This might not exist, but that's OK. */
   1.258 +	xendev->subtype = xenbus_read(xendev->nodename, "subtype", NULL);
   1.259 +	if (IS_ERR(xendev->subtype))
   1.260 +		xendev->subtype = NULL;
   1.261 +	
   1.262 +	err = bus->get_bus_id(xendev->dev.bus_id, xendev->nodename);
   1.263 +	if (err) {
   1.264 +		printk("XENBUS: Failed to get bus id for %s: error %i\n",
   1.265 +		       xendev->nodename, err);
   1.266 +		kfree(xendev);
   1.267 +		return err;
   1.268 +	}
   1.269 +
   1.270 +	xendev->dev.bus = &bus->bus;
   1.271  	xendev->dev.release = xenbus_release_device;
   1.272  
   1.273  	/* Register with generic device framework. */
   1.274  	err = device_register(&xendev->dev);
   1.275  	if (err) {
   1.276 -		printk("XENBUS: Registering device %s: error %i\n",
   1.277 -		       xendev->dev.bus_id, err);
   1.278 +		printk("XENBUS: Registering %s device %s: error %i\n",
   1.279 +		       bus->bus.name, xendev->dev.bus_id, err);
   1.280  		kfree(xendev);
   1.281  	}
   1.282  	return err;
   1.283  }
   1.284  
   1.285 -static int xenbus_probe_device_type(const char *dirpath, const char *typename)
   1.286 +/* device/<typename>/<name> */
   1.287 +static int xenbus_probe_frontend(const char *type, const char *name)
   1.288 +{
   1.289 +	char *nodename;
   1.290 +	int err;
   1.291 +
   1.292 +	nodename = kasprintf("%s/%s/%s", xenbus_frontend.root, type, name);
   1.293 +	if (!nodename)
   1.294 +		return -ENOMEM;
   1.295 +	
   1.296 +	err = xenbus_probe_node(&xenbus_frontend, type, nodename);
   1.297 +	kfree(nodename);
   1.298 +	return err;
   1.299 +}
   1.300 +
   1.301 +/* backend/<typename>/<frontend-uuid>/<name> */
   1.302 +static int xenbus_probe_backend_unit(const char *dir,
   1.303 +				     const char *type,
   1.304 +				     const char *name)
   1.305 +{
   1.306 +	char *nodename;
   1.307 +	int err;
   1.308 +
   1.309 +	nodename = kasprintf("%s/%s", dir, name);
   1.310 +	if (!nodename)
   1.311 +		return -ENOMEM;
   1.312 +
   1.313 +	err = xenbus_probe_node(&xenbus_backend, type, nodename);
   1.314 +	kfree(nodename);
   1.315 +	return err;
   1.316 +}
   1.317 +
   1.318 +/* backend/<typename>/<frontend-uuid> */
   1.319 +static int xenbus_probe_backend(const char *type, const char *uuid)
   1.320 +{
   1.321 +	char *nodename;
   1.322 +	int err = 0;
   1.323 +	char **dir;
   1.324 +	unsigned int i, dir_n = 0;
   1.325 +
   1.326 +	nodename = kasprintf("%s/%s/%s", xenbus_backend.root, type, uuid);
   1.327 +	if (!nodename)
   1.328 +		return -ENOMEM;
   1.329 +
   1.330 +	dir = xenbus_directory(nodename, "", &dir_n);
   1.331 +	if (IS_ERR(dir)) {
   1.332 +		kfree(nodename);
   1.333 +		return PTR_ERR(dir);
   1.334 +	}
   1.335 +
   1.336 +	for (i = 0; i < dir_n; i++) {
   1.337 +		err = xenbus_probe_backend_unit(nodename, type, dir[i]);
   1.338 +		if (err)
   1.339 +			break;
   1.340 +	}
   1.341 +	kfree(nodename);
   1.342 +	return err;
   1.343 +}
   1.344 +
   1.345 +static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
   1.346  {
   1.347  	int err = 0;
   1.348  	char **dir;
   1.349  	unsigned int dir_n = 0;
   1.350  	int i;
   1.351  
   1.352 -	dir = xenbus_directory(dirpath, typename, &dir_n);
   1.353 +	dir = xenbus_directory(bus->root, type, &dir_n);
   1.354  	if (IS_ERR(dir))
   1.355  		return PTR_ERR(dir);
   1.356  
   1.357  	for (i = 0; i < dir_n; i++) {
   1.358 -		err = xenbus_probe_device(dirpath, typename, dir[i]);
   1.359 +		err = bus->probe(type, dir[i]);
   1.360  		if (err)
   1.361  			break;
   1.362  	}
   1.363 @@ -222,18 +405,18 @@ static int xenbus_probe_device_type(cons
   1.364  	return err;
   1.365  }
   1.366  
   1.367 -static int xenbus_probe_devices(const char *path)
   1.368 +static int xenbus_probe_devices(struct xen_bus_type *bus)
   1.369  {
   1.370  	int err = 0;
   1.371  	char **dir;
   1.372  	unsigned int i, dir_n;
   1.373  
   1.374 -	dir = xenbus_directory(path, "", &dir_n);
   1.375 +	dir = xenbus_directory(bus->root, "", &dir_n);
   1.376  	if (IS_ERR(dir))
   1.377  		return PTR_ERR(dir);
   1.378  
   1.379  	for (i = 0; i < dir_n; i++) {
   1.380 -		err = xenbus_probe_device_type(path, dir[i]);
   1.381 +		err = xenbus_probe_device_type(bus, dir[i]);
   1.382  		if (err)
   1.383  			break;
   1.384  	}
   1.385 @@ -251,58 +434,96 @@ static unsigned int char_count(const cha
   1.386  	return ret;
   1.387  }
   1.388  
   1.389 -static void dev_changed(struct xenbus_watch *watch, const char *node)
   1.390 +static void dev_changed(const char *node, struct xen_bus_type *bus)
   1.391  {
   1.392 -	char busid[BUS_ID_SIZE];
   1.393  	int exists;
   1.394  	struct xenbus_device *dev;
   1.395 -	char *p;
   1.396 +	char type[BUS_ID_SIZE];
   1.397 +	const char *p;
   1.398  
   1.399 -	/* Node is of form device/<type>/<identifier>[/...] */
   1.400 -	if (char_count(node, '/') != 2)
   1.401 +	/* FIXME: wouldn't need this if we could limit watch depth. */
   1.402 +	if (char_count(node, '/') != bus->levels)
   1.403  		return;
   1.404  
   1.405 +	/* backend/<type>/... or device/<type>/... */
   1.406 +	p = strchr(node, '/') + 1;
   1.407 +	snprintf(type, BUS_ID_SIZE, "%.*s", strcspn(p, "/"), p);
   1.408 +	type[BUS_ID_SIZE-1] = '\0';
   1.409 +
   1.410  	/* Created or deleted? */
   1.411  	exists = xenbus_exists(node, "");
   1.412 +	dev = xenbus_device_find(node, &bus->bus);
   1.413  
   1.414 -	p = strchr(node, '/') + 1;
   1.415 -	if (strlen(p) + 1 > BUS_ID_SIZE) {
   1.416 -		printk("Device for node %s is too big!\n", node);
   1.417 -		return;
   1.418 -	}
   1.419 -	/* Bus ID is name with / changed to - */
   1.420 -	strcpy(busid, p);
   1.421 -	*strchr(busid, '/') = '-';
   1.422 -
   1.423 -	dev = xenbus_device_find(busid);
   1.424 -	printk("xenbus: device %s %s\n", busid, dev ? "exists" : "new");
   1.425 +	printk("xenbus: device %s %s\n", node, dev ? "exists" : "new");
   1.426  	if (dev && !exists) {
   1.427 -		printk("xenbus: Unregistering device %s\n", busid);
   1.428 -		/* FIXME: free? */
   1.429 +		printk("xenbus: Unregistering device %s\n", node);
   1.430  		device_unregister(&dev->dev);
   1.431  	} else if (!dev && exists) {
   1.432 -		printk("xenbus: Adding device %s\n", busid);
   1.433 -		/* Hack bus id back into two strings. */
   1.434 -		*strrchr(busid, '-') = '\0';
   1.435 -		xenbus_probe_device("device", busid, busid+strlen(busid)+1);
   1.436 +		printk("xenbus: Adding device %s\n", node);
   1.437 +		xenbus_probe_node(bus, type, node);
   1.438  	} else
   1.439 -		printk("xenbus: strange, %s already %s\n", busid,
   1.440 +		printk("xenbus: strange, %s already %s\n", node,
   1.441  		       exists ? "exists" : "gone");
   1.442  	if (dev)
   1.443  		put_device(&dev->dev);
   1.444  }
   1.445  
   1.446 +static void frontend_changed(struct xenbus_watch *watch, const char *node)
   1.447 +{
   1.448 +	dev_changed(node, &xenbus_frontend);
   1.449 +}
   1.450 +
   1.451 +static void backend_changed(struct xenbus_watch *watch, const char *node)
   1.452 +{
   1.453 +	dev_changed(node, &xenbus_backend);
   1.454 +}
   1.455 +
   1.456  /* We watch for devices appearing and vanishing. */
   1.457 -static struct xenbus_watch dev_watch = {
   1.458 +static struct xenbus_watch fe_watch = {
   1.459  	/* FIXME: Ideally we'd only watch for changes 2 levels deep... */
   1.460  	.node = "device",
   1.461 -	.callback = dev_changed,
   1.462 +	.callback = frontend_changed,
   1.463 +};
   1.464 +
   1.465 +static struct xenbus_watch be_watch = {
   1.466 +	.node = "backend",
   1.467 +	.callback = backend_changed,
   1.468  };
   1.469  
   1.470 +static int suspend_dev(struct device *dev, void *data)
   1.471 +{
   1.472 +	int err = 0;
   1.473 +	struct xenbus_driver *drv = to_xenbus_driver(dev->driver);
   1.474 +	struct xenbus_device *xdev
   1.475 +		= container_of(dev, struct xenbus_device, dev);
   1.476 +
   1.477 +	if (drv->suspend)
   1.478 +		err = drv->suspend(xdev);
   1.479 +	if (err)
   1.480 +		printk("xenbus: suspend %s failed: %i\n", dev->bus_id, err);
   1.481 +	return 0;
   1.482 +}
   1.483 +
   1.484 +static int resume_dev(struct device *dev, void *data)
   1.485 +{
   1.486 +	int err = 0;
   1.487 +	struct xenbus_driver *drv = to_xenbus_driver(dev->driver);
   1.488 +	struct xenbus_device *xdev
   1.489 +		= container_of(dev, struct xenbus_device, dev);
   1.490 +
   1.491 +	if (drv->resume)
   1.492 +		err = drv->resume(xdev);
   1.493 +	if (err)
   1.494 +		printk("xenbus: resume %s failed: %i\n", dev->bus_id, err);
   1.495 +	return 0;
   1.496 +}
   1.497 +
   1.498  void xenbus_suspend(void)
   1.499  {
   1.500  	/* We keep lock, so no comms can happen as page moves. */
   1.501  	down(&xenbus_lock);
   1.502 +	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
   1.503 +	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
   1.504  	xb_suspend_comms();
   1.505  }
   1.506  
   1.507 @@ -310,6 +531,8 @@ void xenbus_resume(void)
   1.508  {
   1.509  	xb_init_comms();
   1.510  	reregister_xenbus_watches();
   1.511 +	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
   1.512 +	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
   1.513  	up(&xenbus_lock);
   1.514  }
   1.515  
   1.516 @@ -354,30 +577,21 @@ int do_xenbus_probe(void *unused)
   1.517  	}
   1.518  
   1.519  	down(&xenbus_lock);
   1.520 -	err = notifier_call_chain(&xenstore_chain, 0, 0);
   1.521 -	up(&xenbus_lock);
   1.522 -
   1.523 -	if (err == NOTIFY_BAD) {
   1.524 -		printk("%s: calling xenstore notify chain failed\n",
   1.525 -		       __FUNCTION__);
   1.526 -		return -EINVAL;
   1.527 -	}
   1.528 -
   1.529 -	err = 0;
   1.530 -
   1.531 -	down(&xenbus_lock);
   1.532  	/* Enumerate devices in xenstore. */
   1.533 -	xenbus_probe_devices("device");
   1.534 +	xenbus_probe_devices(&xenbus_frontend);
   1.535 +	xenbus_probe_devices(&xenbus_backend);
   1.536  	/* Watch for changes. */
   1.537 -	register_xenbus_watch(&dev_watch);
   1.538 +	register_xenbus_watch(&fe_watch);
   1.539 +	register_xenbus_watch(&be_watch);
   1.540  	up(&xenbus_lock);
   1.541  	return 0;
   1.542  }
   1.543  
   1.544  static int __init xenbus_probe_init(void)
   1.545  {
   1.546 -	bus_register(&xenbus_type);
   1.547 -
   1.548 +	bus_register(&xenbus_frontend.bus);
   1.549 +	bus_register(&xenbus_backend.bus);
   1.550 +	
   1.551  	if (!xen_start_info.store_evtchn)
   1.552  		return 0;
   1.553  
     2.1 --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Wed Aug 17 12:30:04 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Thu Aug 18 18:54:38 2005 +0000
     2.3 @@ -61,9 +61,11 @@ struct xenbus_driver {
     2.4  	char *name;
     2.5  	struct module *owner;
     2.6  	const struct xenbus_device_id *ids;
     2.7 -	int  (*probe)    (struct xenbus_device * dev,
     2.8 -			  const struct xenbus_device_id * id);
     2.9 -	int  (*remove)   (struct xenbus_device * dev);
    2.10 +	int (*probe)(struct xenbus_device *dev,
    2.11 +		     const struct xenbus_device_id *id);
    2.12 +	int (*remove)(struct xenbus_device *dev);
    2.13 +	int (*suspend)(struct xenbus_device *dev);
    2.14 +	int (*resume)(struct xenbus_device *dev);
    2.15  	struct device_driver driver;
    2.16  };
    2.17  
    2.18 @@ -72,7 +74,8 @@ static inline struct xenbus_driver *to_x
    2.19  	return container_of(drv, struct xenbus_driver, driver);
    2.20  }
    2.21  
    2.22 -int xenbus_register_driver(struct xenbus_driver *drv);
    2.23 +int xenbus_register_device(struct xenbus_driver *drv);
    2.24 +int xenbus_register_backend(struct xenbus_driver *drv);
    2.25  void xenbus_unregister_driver(struct xenbus_driver *drv);
    2.26  
    2.27  /* Caller must hold this lock to call these functions: it's also held
    2.28 @@ -123,6 +126,9 @@ int register_xenbus_watch(struct xenbus_
    2.29  void unregister_xenbus_watch(struct xenbus_watch *watch);
    2.30  void reregister_xenbus_watches(void);
    2.31  
    2.32 +/* For backends, does lookup on uuid (up to /).  Returns domid, or -errno. */
    2.33 +int xenbus_uuid_to_domid(const char *uuid);
    2.34 +
    2.35  /* Called from xen core code. */
    2.36  void xenbus_suspend(void);
    2.37  void xenbus_resume(void);