ia64/xen-unstable

changeset 13378:e66f047bc97e

[BLKTAP/BLKBACK] name blktap/blkback kernel threads as "domid.virtual_devname"

Signed-off-by: Jake Wires <jwires@xensource.com>
author Jake Wires <jwires@xensource.com>
date Tue Jan 09 18:56:44 2007 -0800 (2007-01-09)
parents b61be7771104
children dc0638bb4628
files linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Wed Jan 10 17:56:54 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Jan 09 18:56:44 2007 -0800
     1.3 @@ -42,9 +42,30 @@ static int connect_ring(struct backend_i
     1.4  static void backend_changed(struct xenbus_watch *, const char **,
     1.5  			    unsigned int);
     1.6  
     1.7 +static int blkback_name(blkif_t *blkif, char *buf)
     1.8 +{
     1.9 +	char *devpath, *devname;
    1.10 +	struct xenbus_device *dev = blkif->be->dev;
    1.11 +
    1.12 +	devpath = xenbus_read(XBT_NIL, dev->nodename, "dev", NULL);
    1.13 +	if (IS_ERR(devpath)) 
    1.14 +		return PTR_ERR(devpath);
    1.15 +	
    1.16 +	if ((devname = strstr(devpath, "/dev/")) != NULL)
    1.17 +		devname += strlen("/dev/");
    1.18 +	else
    1.19 +		devname  = devpath;
    1.20 +
    1.21 +	snprintf(buf, TASK_COMM_LEN, "blkback.%d.%s", blkif->domid, devname);
    1.22 +	kfree(devpath);
    1.23 +	
    1.24 +	return 0;
    1.25 +}
    1.26 +
    1.27  static void update_blkif_status(blkif_t *blkif)
    1.28  { 
    1.29  	int err;
    1.30 +	char name[TASK_COMM_LEN];
    1.31  
    1.32  	/* Not ready to connect? */
    1.33  	if (!blkif->irq || !blkif->vbd.bdev)
    1.34 @@ -59,10 +80,13 @@ static void update_blkif_status(blkif_t 
    1.35  	if (blkif->be->dev->state != XenbusStateConnected)
    1.36  		return;
    1.37  
    1.38 -	blkif->xenblkd = kthread_run(blkif_schedule, blkif,
    1.39 -				     "xvd %d %02x:%02x",
    1.40 -				     blkif->domid,
    1.41 -				     blkif->be->major, blkif->be->minor);
    1.42 +	err = blkback_name(blkif, name);
    1.43 +	if (err) {
    1.44 +		xenbus_dev_error(blkif->be->dev, err, "get blkback dev name");
    1.45 +		return;
    1.46 +	}
    1.47 +
    1.48 +	blkif->xenblkd = kthread_run(blkif_schedule, blkif, name);
    1.49  	if (IS_ERR(blkif->xenblkd)) {
    1.50  		err = PTR_ERR(blkif->xenblkd);
    1.51  		blkif->xenblkd = NULL;
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Wed Jan 10 17:56:54 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Tue Jan 09 18:56:44 2007 -0800
     2.3 @@ -92,9 +92,30 @@ static long get_id(const char *str)
     2.4          return simple_strtol(num, NULL, 10);
     2.5  }				
     2.6  
     2.7 +static int blktap_name(blkif_t *blkif, char *buf)
     2.8 +{
     2.9 +	char *devpath, *devname;
    2.10 +	struct xenbus_device *dev = blkif->be->dev;
    2.11 +
    2.12 +	devpath = xenbus_read(XBT_NIL, dev->nodename, "dev", NULL);
    2.13 +	if (IS_ERR(devpath)) 
    2.14 +		return PTR_ERR(devpath);
    2.15 +	
    2.16 +	if ((devname = strstr(devpath, "/dev/")) != NULL)
    2.17 +		devname += strlen("/dev/");
    2.18 +	else
    2.19 +		devname  = devpath;
    2.20 +
    2.21 +	snprintf(buf, TASK_COMM_LEN, "blktap.%d.%s", blkif->domid, devname);
    2.22 +	kfree(devpath);
    2.23 +	
    2.24 +	return 0;
    2.25 +}
    2.26 +
    2.27  static void tap_update_blkif_status(blkif_t *blkif)
    2.28  { 
    2.29  	int err;
    2.30 +	char name[TASK_COMM_LEN];
    2.31  
    2.32  	/* Not ready to connect? */
    2.33  	if(!blkif->irq || !blkif->sectors) {
    2.34 @@ -110,10 +131,13 @@ static void tap_update_blkif_status(blki
    2.35  	if (blkif->be->dev->state != XenbusStateConnected)
    2.36  		return;
    2.37  
    2.38 -	blkif->xenblkd = kthread_run(tap_blkif_schedule, blkif,
    2.39 -				     "xvd %d",
    2.40 -				     blkif->domid);
    2.41 +	err = blktap_name(blkif, name);
    2.42 +	if (err) {
    2.43 +		xenbus_dev_error(blkif->be->dev, err, "get blktap dev name");
    2.44 +		return;
    2.45 +	}
    2.46  
    2.47 +	blkif->xenblkd = kthread_run(tap_blkif_schedule, blkif, name);
    2.48  	if (IS_ERR(blkif->xenblkd)) {
    2.49  		err = PTR_ERR(blkif->xenblkd);
    2.50  		blkif->xenblkd = NULL;