diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-11-11 17:26:37 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-11-11 17:26:37 -0600 |
commit | 74d33d5ce4d70125fa7ff476145276a44372e9d5 (patch) | |
tree | af5d7b7a0ced95035e89592b233845010d310c7b /hw | |
parent | 0abe905d29f556128c5fb2ea8d93e982e94aaa67 (diff) | |
parent | ca716364f045da710ddef7fc6420bd6760e45b56 (diff) |
Merge remote-tracking branch 'kwolf/block-stable' into staging
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ide/atapi.c | 11 | ||||
-rw-r--r-- | hw/ide/core.c | 13 | ||||
-rw-r--r-- | hw/pc.c | 4 | ||||
-rw-r--r-- | hw/scsi-disk.c | 24 |
4 files changed, 43 insertions, 9 deletions
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 90b6729692..1fed359ab1 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -516,9 +516,14 @@ static unsigned int event_status_media(IDEState *s, /* Event notification descriptor */ event_code = MEC_NO_CHANGE; - if (media_status != MS_TRAY_OPEN && s->events.new_media) { - event_code = MEC_NEW_MEDIA; - s->events.new_media = false; + if (media_status != MS_TRAY_OPEN) { + if (s->events.new_media) { + event_code = MEC_NEW_MEDIA; + s->events.new_media = false; + } else if (s->events.eject_request) { + event_code = MEC_EJECT_REQUESTED; + s->events.eject_request = false; + } } buf[4] = event_code; diff --git a/hw/ide/core.c b/hw/ide/core.c index 9a2fd30607..93a1a689c4 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -804,6 +804,18 @@ static void ide_cd_change_cb(void *opaque, bool load) */ s->cdrom_changed = 1; s->events.new_media = true; + s->events.eject_request = false; + ide_set_irq(s->bus); +} + +static void ide_cd_eject_request_cb(void *opaque, bool force) +{ + IDEState *s = opaque; + + s->events.eject_request = true; + if (force) { + s->tray_locked = false; + } ide_set_irq(s->bus); } @@ -1811,6 +1823,7 @@ static bool ide_cd_is_medium_locked(void *opaque) static const BlockDevOps ide_cd_block_ops = { .change_media_cb = ide_cd_change_cb, + .eject_request_cb = ide_cd_eject_request_cb, .is_tray_open = ide_cd_is_tray_open, .is_medium_locked = ide_cd_is_medium_locked, }; @@ -335,7 +335,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, ISADevice *s) { int val, nb, nb_heads, max_track, last_sect, i; - FDriveType fd_type[2]; + FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE }; BlockDriverState *fd[MAX_FD]; static pc_cmos_init_late_arg arg; @@ -385,8 +385,6 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, bdrv_get_floppy_geometry_hint(fd[i], &nb_heads, &max_track, &last_sect, FDRIVE_DRV_NONE, &fd_type[i]); - } else { - fd_type[i] = FDRIVE_DRV_NONE; } } } diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 1c04872af7..62f538f4f8 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -65,6 +65,7 @@ struct SCSIDiskState uint32_t removable; bool media_changed; bool media_event; + bool eject_request; QEMUBH *bh; char *version; char *serial; @@ -671,9 +672,14 @@ static int scsi_event_status_media(SCSIDiskState *s, uint8_t *outbuf) /* Event notification descriptor */ event_code = MEC_NO_CHANGE; - if (media_status != MS_TRAY_OPEN && s->media_event) { - event_code = MEC_NEW_MEDIA; - s->media_event = false; + if (media_status != MS_TRAY_OPEN) { + if (s->media_event) { + event_code = MEC_NEW_MEDIA; + s->media_event = false; + } else if (s->eject_request) { + event_code = MEC_EJECT_REQUESTED; + s->eject_request = false; + } } outbuf[0] = event_code; @@ -1470,6 +1476,17 @@ static void scsi_cd_change_media_cb(void *opaque, bool load) s->tray_open = !load; s->qdev.unit_attention = SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM); s->media_event = true; + s->eject_request = false; +} + +static void scsi_cd_eject_request_cb(void *opaque, bool force) +{ + SCSIDiskState *s = opaque; + + s->eject_request = true; + if (force) { + s->tray_locked = false; + } } static bool scsi_cd_is_tray_open(void *opaque) @@ -1484,6 +1501,7 @@ static bool scsi_cd_is_medium_locked(void *opaque) static const BlockDevOps scsi_cd_block_ops = { .change_media_cb = scsi_cd_change_media_cb, + .eject_request_cb = scsi_cd_eject_request_cb, .is_tray_open = scsi_cd_is_tray_open, .is_medium_locked = scsi_cd_is_medium_locked, }; |