ia64/linux-2.6.18-xen.hg

changeset 521:e5f0712d7520

blkback: Set the VDISK_CDROM flag when a device is marked as being a
cdrom, even if the underlying device/file is not a physical cdrom.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
CC: Christian Limpach <christian.limpach@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 15 15:16:28 2008 +0100 (2008-04-15)
parents 906b14e26f2f
children bb12908b737a
files drivers/xen/blkback/common.h drivers/xen/blkback/vbd.c drivers/xen/blkback/xenbus.c
line diff
     1.1 --- a/drivers/xen/blkback/common.h	Tue Apr 15 15:15:26 2008 +0100
     1.2 +++ b/drivers/xen/blkback/common.h	Tue Apr 15 15:16:28 2008 +0100
     1.3 @@ -110,7 +110,7 @@ int blkif_map(blkif_t *blkif, unsigned l
     1.4  
     1.5  /* Create a vbd. */
     1.6  int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, unsigned major,
     1.7 -	       unsigned minor, int readonly);
     1.8 +	       unsigned minor, int readonly, int cdrom);
     1.9  void vbd_free(struct vbd *vbd);
    1.10  
    1.11  unsigned long long vbd_size(struct vbd *vbd);
     2.1 --- a/drivers/xen/blkback/vbd.c	Tue Apr 15 15:15:26 2008 +0100
     2.2 +++ b/drivers/xen/blkback/vbd.c	Tue Apr 15 15:16:28 2008 +0100
     2.3 @@ -51,7 +51,7 @@ unsigned long vbd_secsize(struct vbd *vb
     2.4  }
     2.5  
     2.6  int vbd_create(blkif_t *blkif, blkif_vdev_t handle, unsigned major,
     2.7 -	       unsigned minor, int readonly)
     2.8 +	       unsigned minor, int readonly, int cdrom)
     2.9  {
    2.10  	struct vbd *vbd;
    2.11  	struct block_device *bdev;
    2.12 @@ -81,7 +81,7 @@ int vbd_create(blkif_t *blkif, blkif_vde
    2.13  		return -ENOENT;
    2.14  	}
    2.15  
    2.16 -	if (vbd->bdev->bd_disk->flags & GENHD_FL_CD)
    2.17 +	if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom)
    2.18  		vbd->type |= VDISK_CDROM;
    2.19  	if (vbd->bdev->bd_disk->flags & GENHD_FL_REMOVABLE)
    2.20  		vbd->type |= VDISK_REMOVABLE;
     3.1 --- a/drivers/xen/blkback/xenbus.c	Tue Apr 15 15:15:26 2008 +0100
     3.2 +++ b/drivers/xen/blkback/xenbus.c	Tue Apr 15 15:16:28 2008 +0100
     3.3 @@ -270,6 +270,8 @@ static void backend_changed(struct xenbu
     3.4  	struct backend_info *be
     3.5  		= container_of(watch, struct backend_info, backend_watch);
     3.6  	struct xenbus_device *dev = be->dev;
     3.7 +	int cdrom = 0;
     3.8 +	char *device_type;
     3.9  
    3.10  	DPRINTK("");
    3.11  
    3.12 @@ -303,6 +305,12 @@ static void backend_changed(struct xenbu
    3.13  		return;
    3.14  	}
    3.15  
    3.16 +	device_type = xenbus_read(XBT_NIL, dev->otherend, "device-type", NULL);
    3.17 +	if (!IS_ERR(device_type)) {
    3.18 +		cdrom = strcmp(device_type, "cdrom") == 0;
    3.19 +		kfree(device_type);
    3.20 +	}
    3.21 +
    3.22  	if (be->major == 0 && be->minor == 0) {
    3.23  		/* Front end dir is a number, which is used as the handle. */
    3.24  
    3.25 @@ -313,7 +321,7 @@ static void backend_changed(struct xenbu
    3.26  		be->minor = minor;
    3.27  
    3.28  		err = vbd_create(be->blkif, handle, major, minor,
    3.29 -				 (NULL == strchr(be->mode, 'w')));
    3.30 +				 (NULL == strchr(be->mode, 'w')), cdrom);
    3.31  		if (err) {
    3.32  			be->major = be->minor = 0;
    3.33  			xenbus_dev_fatal(dev, err, "creating vbd structure");