From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PATCH 8/8] scsi-disk: implement eject requests
Date: Tue, 25 Oct 2011 12:53:40 +0200 [thread overview]
Message-ID: <1319540020-32484-9-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1319540020-32484-1-git-send-email-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi-disk.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index f407e2b..241a676 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,
};
--
1.7.6
next prev parent reply other threads:[~2011-10-25 10:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-25 10:53 [Qemu-devel] [PATCH 0/5] My remaining block/SCSI patches for 1.0 Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 1/8] scsi: do not call transfer_data after canceling a request Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 2/8] scsi-disk: bump SCSIRequest reference count until aio completion runs Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 3/8] scsi-generic: " Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 4/8] scsi: push request restart to SCSIDevice Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 5/8] scsi-disk: add scsi-block for device passthrough Paolo Bonzini
2011-10-28 17:04 ` Kevin Wolf
2011-10-25 10:53 ` [Qemu-devel] [PATCH 6/8] block: add eject request callback Paolo Bonzini
2011-10-28 17:21 ` Kevin Wolf
2011-10-29 7:46 ` Paolo Bonzini
2011-11-07 13:21 ` Markus Armbruster
2011-11-07 13:36 ` Paolo Bonzini
2011-11-07 13:49 ` Kevin Wolf
2011-11-07 13:56 ` Paolo Bonzini
2011-11-07 14:12 ` Kevin Wolf
2011-11-07 15:23 ` Markus Armbruster
2011-11-07 16:14 ` Paolo Bonzini
2011-11-07 16:50 ` [Qemu-devel] [PATCH 6/8 v2] " Paolo Bonzini
2011-11-08 13:18 ` Kevin Wolf
2011-10-25 10:53 ` [Qemu-devel] [PATCH 7/8] atapi: implement eject requests Paolo Bonzini
2011-10-25 10:53 ` Paolo Bonzini [this message]
2011-10-27 11:45 ` [Qemu-devel] ping Re: [PATCH 0/5] My remaining block/SCSI patches for 1.0 Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1319540020-32484-9-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).