Revision 95b5edcd

b/blockdev.c
488 488
	    break;
489 489
	case MEDIA_CDROM:
490 490
            bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
491
            dinfo->media_cd = 1;
491 492
	    break;
492 493
	}
493 494
        break;
b/blockdev.h
33 33
    int bus;
34 34
    int unit;
35 35
    int auto_del;               /* see blockdev_mark_auto_del() */
36
    int media_cd;
36 37
    QemuOpts *opts;
37 38
    char serial[BLOCK_SERIAL_STRLEN + 1];
38 39
    QTAILQ_ENTRY(DriveInfo) next;
b/hw/ide/core.c
1731 1731
        ide_init1(bus, i);
1732 1732
        if (dinfo) {
1733 1733
            if (ide_init_drive(&bus->ifs[i], dinfo->bdrv,
1734
                               bdrv_get_type_hint(dinfo->bdrv) == BDRV_TYPE_CDROM ? IDE_CD : IDE_HD,
1735
                               NULL,
1734
                               dinfo->media_cd ? IDE_CD : IDE_HD, NULL,
1736 1735
                               *dinfo->serial ? dinfo->serial : NULL) < 0) {
1737 1736
                error_report("Can't set up IDE drive %s", dinfo->id);
1738 1737
                exit(1);
b/hw/ide/qdev.c
98 98
{
99 99
    DeviceState *dev;
100 100

  
101
    dev = qdev_create(&bus->qbus,
102
                      bdrv_get_type_hint(drive->bdrv) == BDRV_TYPE_CDROM
103
                      ? "ide-cd" : "ide-hd");
101
    dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd");
104 102
    qdev_prop_set_uint32(dev, "unit", unit);
105 103
    qdev_prop_set_drive_nofail(dev, "drive", drive->bdrv);
106 104
    qdev_init_nofail(dev);
......
165 163

  
166 164
static int ide_drive_initfn(IDEDevice *dev)
167 165
{
168
    return ide_dev_initfn(dev,
169
                          bdrv_get_type_hint(dev->conf.bs) == BDRV_TYPE_CDROM
170
                          ? IDE_CD : IDE_HD);
166
    DriveInfo *dinfo = drive_get_by_blockdev(dev->conf.bs);
167

  
168
    return ide_dev_initfn(dev, dinfo->media_cd ? IDE_CD : IDE_HD);
171 169
}
172 170

  
173 171
#define DEFINE_IDE_DEV_PROPERTIES()                     \
b/hw/scsi-disk.c
1295 1295
static int scsi_disk_initfn(SCSIDevice *dev)
1296 1296
{
1297 1297
    SCSIDriveKind kind;
1298
    DriveInfo *dinfo;
1298 1299

  
1299 1300
    if (!dev->conf.bs) {
1300 1301
        kind = SCSI_HD;         /* will die in scsi_initfn() */
1301 1302
    } else {
1302
        kind = bdrv_get_type_hint(dev->conf.bs) == BDRV_TYPE_CDROM
1303
            ? SCSI_CD : SCSI_HD;
1303
        dinfo = drive_get_by_blockdev(dev->conf.bs);
1304
        kind = dinfo->media_cd ? SCSI_CD : SCSI_HD;
1304 1305
    }
1305 1306

  
1306 1307
    return scsi_initfn(dev, kind);
b/hw/xen_devconfig.c
96 96
{
97 97
    char fe[256], be[256];
98 98
    int vdev = 202 * 256 + 16 * disk->unit;
99
    int cdrom = disk->bdrv->type == BDRV_TYPE_CDROM;
99
    int cdrom = disk->media_cd;
100 100
    const char *devtype = cdrom ? "cdrom" : "disk";
101 101
    const char *mode    = cdrom ? "r"     : "w";
102 102

  

Also available in: Unified diff