diff mbox

[1/5] scsi-disk: removable hard disks support START/STOP

Message ID 1342448756-7582-2-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini July 16, 2012, 2:25 p.m. UTC
Support for START/STOP UNIT right now is limited to CD-ROMs.  This is wrong,
since removable hard disks (in the real world: SD card readers) also support
it in pretty much the same way.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi-disk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Blue Swirl July 23, 2012, 4:44 p.m. UTC | #1
On Mon, Jul 16, 2012 at 2:25 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Support for START/STOP UNIT right now is limited to CD-ROMs.  This is wrong,
> since removable hard disks (in the real world: SD card readers) also support
> it in pretty much the same way.

I remember vaguely tuning a set of large SCSI hard disks
(non-removable) so that they all didn't start immediately at the same
time (which could have burned out the PSU) but only with START UNIT
command. I think Linux or maybe even the BIOS started the drives
(nicely in sequence) before accessing the drive.

>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/scsi-disk.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index bcec66b..42bae3b 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -1251,7 +1251,7 @@ static int scsi_disk_emulate_start_stop(SCSIDiskReq *r)
>      bool start = req->cmd.buf[4] & 1;
>      bool loej = req->cmd.buf[4] & 2; /* load on start, eject on !start */
>
> -    if (s->qdev.type == TYPE_ROM && loej) {
> +    if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) && loej) {
>          if (!start && !s->tray_open && s->tray_locked) {
>              scsi_check_condition(r,
>                                   bdrv_is_inserted(s->qdev.conf.bs)
> --
> 1.7.10.4
>
>
>
Paolo Bonzini July 23, 2012, 4:50 p.m. UTC | #2
Il 23/07/2012 18:44, Blue Swirl ha scritto:
>> > Support for START/STOP UNIT right now is limited to CD-ROMs.  This is wrong,
>> > since removable hard disks (in the real world: SD card readers) also support
>> > it in pretty much the same way.
> I remember vaguely tuning a set of large SCSI hard disks
> (non-removable) so that they all didn't start immediately at the same
> time (which could have burned out the PSU) but only with START UNIT
> command. I think Linux or maybe even the BIOS started the drives
> (nicely in sequence) before accessing the drive.

Yes, all disks do start/stop.  Removable disks support load and eject in
addition.  I'll fix the commit message.

Paolo
diff mbox

Patch

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index bcec66b..42bae3b 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1251,7 +1251,7 @@  static int scsi_disk_emulate_start_stop(SCSIDiskReq *r)
     bool start = req->cmd.buf[4] & 1;
     bool loej = req->cmd.buf[4] & 2; /* load on start, eject on !start */
 
-    if (s->qdev.type == TYPE_ROM && loej) {
+    if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) && loej) {
         if (!start && !s->tray_open && s->tray_locked) {
             scsi_check_condition(r,
                                  bdrv_is_inserted(s->qdev.conf.bs)