atapi: implement eject requests
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
025ccaa7f9
commit
2df0a3a308
@ -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;
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user