From: Luiz Capitulino <lcapitulino@redhat.com>
To: aliguori@us.ibm.com
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/5] block: Don't call bdrv_eject() if the tray state didn't change
Date: Thu, 23 Feb 2012 12:42:52 -0200 [thread overview]
Message-ID: <1330008174-26084-4-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1330008174-26084-1-git-send-email-lcapitulino@redhat.com>
It's not needed. Besides we can then assume that bdrv_eject() is
only called when there's a tray state change, which is useful to
the DEVICE_TRAY_MOVED event (going to be added in a future
commit).
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
---
hw/ide/atapi.c | 7 +++++--
hw/scsi-disk.c | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 0adb27b..5919cf5 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -883,8 +883,11 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);
return;
}
- bdrv_eject(s->bs, !start);
- s->tray_open = !start;
+
+ if (s->tray_open != !start) {
+ bdrv_eject(s->bs, !start);
+ s->tray_open = !start;
+ }
}
ide_atapi_cmd_ok(s);
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a5d2fd1..091ecdc 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1050,8 +1050,11 @@ static int scsi_disk_emulate_start_stop(SCSIDiskReq *r)
: SENSE_CODE(NOT_READY_REMOVAL_PREVENTED));
return -1;
}
- bdrv_eject(s->qdev.conf.bs, !start);
- s->tray_open = !start;
+
+ if (s->tray_open != !start) {
+ bdrv_eject(s->qdev.conf.bs, !start);
+ s->tray_open = !start;
+ }
}
return 0;
}
--
1.7.9.111.gf3fb0.dirty
next prev parent reply other threads:[~2012-02-23 14:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-23 14:42 [Qemu-devel] [PULL 0/5]: QMP queue Luiz Capitulino
2012-02-23 14:42 ` [Qemu-devel] [PATCH 1/5] block: Rename bdrv_mon_event() & BlockMonEventAction Luiz Capitulino
2012-02-23 14:42 ` [Qemu-devel] [PATCH 2/5] block: bdrv_eject(): Make eject_flag a real bool Luiz Capitulino
2012-02-23 14:42 ` Luiz Capitulino [this message]
2012-02-23 14:42 ` [Qemu-devel] [PATCH 4/5] ide: drop ide_tray_state_post_load() Luiz Capitulino
2012-02-23 14:42 ` [Qemu-devel] [PATCH 5/5] qmp: add DEVICE_TRAY_MOVED event Luiz Capitulino
2012-02-24 16:35 ` [Qemu-devel] [PULL 0/5]: QMP queue Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2012-02-17 19:21 [Qemu-devel] [PATCH v3 0/5]: QMP: add DEVICE_TRAY_MOVED event Luiz Capitulino
2012-02-17 19:21 ` [Qemu-devel] [PATCH 3/5] block: Don't call bdrv_eject() if the tray state didn't change Luiz Capitulino
2012-02-20 8:16 ` Markus Armbruster
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=1330008174-26084-4-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.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).