diff options
author | Markus Armbruster <armbru@redhat.com> | 2011-09-06 18:58:46 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-09-12 15:17:20 +0200 |
commit | f107639a6ff0c8d02f6a2dfdfce3a9d9f1e2eb27 (patch) | |
tree | 0c5368f533034b7e1adbd02be5dcff6367cf3a94 /hw | |
parent | fdec4404ddfaf9e121bef84eac1303a8a0e47d75 (diff) |
block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked(). Implement for IDE
and SCSI CD-ROMs.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ide/core.c | 6 | ||||
-rw-r--r-- | hw/scsi-disk.c | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c index b33f84e1af..0403ad24c2 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -1795,8 +1795,14 @@ void ide_bus_reset(IDEBus *bus) bus->dma->ops->reset(bus->dma); } +static bool ide_cd_is_medium_locked(void *opaque) +{ + return ((IDEState *)opaque)->tray_locked; +} + static const BlockDevOps ide_cd_block_ops = { .change_media_cb = ide_cd_change_cb, + .is_medium_locked = ide_cd_is_medium_locked, }; int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind, diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 65783a73e6..42682d0865 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1165,6 +1165,15 @@ static void scsi_destroy(SCSIDevice *dev) blockdev_mark_auto_del(s->qdev.conf.bs); } +static bool scsi_cd_is_medium_locked(void *opaque) +{ + return ((SCSIDiskState *)opaque)->tray_locked; +} + +static const BlockDevOps scsi_cd_block_ops = { + .is_medium_locked = scsi_cd_is_medium_locked, +}; + static int scsi_initfn(SCSIDevice *dev, uint8_t scsi_type) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); @@ -1199,6 +1208,7 @@ static int scsi_initfn(SCSIDevice *dev, uint8_t scsi_type) } if (scsi_type == TYPE_ROM) { + bdrv_set_dev_ops(s->bs, &scsi_cd_block_ops, s); s->qdev.blocksize = 2048; } else if (scsi_type == TYPE_DISK) { s->qdev.blocksize = s->qdev.conf.logical_block_size; |