/* Create a vbd. */
int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, unsigned major,
- unsigned minor, int readonly);
+ unsigned minor, int readonly, int cdrom);
void vbd_free(struct vbd *vbd);
unsigned long long vbd_size(struct vbd *vbd);
}
int vbd_create(blkif_t *blkif, blkif_vdev_t handle, unsigned major,
- unsigned minor, int readonly)
+ unsigned minor, int readonly, int cdrom)
{
struct vbd *vbd;
struct block_device *bdev;
return -ENOENT;
}
- if (vbd->bdev->bd_disk->flags & GENHD_FL_CD)
+ if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom)
vbd->type |= VDISK_CDROM;
if (vbd->bdev->bd_disk->flags & GENHD_FL_REMOVABLE)
vbd->type |= VDISK_REMOVABLE;
struct backend_info *be
= container_of(watch, struct backend_info, backend_watch);
struct xenbus_device *dev = be->dev;
+ int cdrom = 0;
+ char *device_type;
DPRINTK("");
return;
}
+ device_type = xenbus_read(XBT_NIL, dev->otherend, "device-type", NULL);
+ if (!IS_ERR(device_type)) {
+ cdrom = strcmp(device_type, "cdrom") == 0;
+ kfree(device_type);
+ }
+
if (be->major == 0 && be->minor == 0) {
/* Front end dir is a number, which is used as the handle. */
be->minor = minor;
err = vbd_create(be->blkif, handle, major, minor,
- (NULL == strchr(be->mode, 'w')));
+ (NULL == strchr(be->mode, 'w')), cdrom);
if (err) {
be->major = be->minor = 0;
xenbus_dev_fatal(dev, err, "creating vbd structure");