Revision 95b5edcd hw/ide/qdev.c

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()                     \

Also available in: Unified diff