qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
@ 2013-05-16 15:34 Pavel Hrdina
  2013-05-16 15:42 ` Eric Blake
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Hrdina @ 2013-05-16 15:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, pbonzini, phrdina

Tray statuses should be also reseted. Some guests may lock the tray
and after reset before any kernel is loaded the tray should be unlocked.

Also if you reset the real computer the tray is closed. We should
do the same in qemu.

This fix is already commited for IDE CD.
Check the commit a7f3d65b65b8c86a5ff0c0abcfefb45e2ec6fe4c.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 hw/scsi/scsi-disk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index c8d2a99..02733dc 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1984,6 +1984,9 @@ static void scsi_disk_reset(DeviceState *dev)
         nb_sectors--;
     }
     s->qdev.max_lba = nb_sectors;
+    /* reset tray statuses */
+    s->tray_locked = 0;
+    s->tray_open = 0;
 }
 
 static void scsi_destroy(SCSIDevice *dev)
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-16 15:34 [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset Pavel Hrdina
@ 2013-05-16 15:42 ` Eric Blake
  2013-05-16 15:48   ` Pavel Hrdina
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Blake @ 2013-05-16 15:42 UTC (permalink / raw)
  To: Pavel Hrdina; +Cc: kwolf, pbonzini, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]

On 05/16/2013 09:34 AM, Pavel Hrdina wrote:
> Tray statuses should be also reseted. Some guests may lock the tray

s/reseted/reset/

> and after reset before any kernel is loaded the tray should be unlocked.
> 
> Also if you reset the real computer the tray is closed. We should
> do the same in qemu.

Is that OS-independent hardware behavior, or is tray closing on boot
merely a side effect observed on bare metal but caused by installed
software (BIOS or OS code)?  At any rate, being consistent with IDE
doesn't hurt.

> 
> This fix is already commited for IDE CD.

s/commited/committed/

> Check the commit a7f3d65b65b8c86a5ff0c0abcfefb45e2ec6fe4c.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  hw/scsi/scsi-disk.c | 3 +++
>  1 file changed, 3 insertions(+)

assuming the maintainer can touch up the commit message, feel free to add:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-16 15:42 ` Eric Blake
@ 2013-05-16 15:48   ` Pavel Hrdina
  2013-05-16 16:11     ` Paolo Bonzini
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Hrdina @ 2013-05-16 15:48 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, pbonzini, qemu-devel

On 16.5.2013 17:42, Eric Blake wrote:
> On 05/16/2013 09:34 AM, Pavel Hrdina wrote:
>> Tray statuses should be also reseted. Some guests may lock the tray
>
> s/reseted/reset/
>
>> and after reset before any kernel is loaded the tray should be unlocked.
>>
>> Also if you reset the real computer the tray is closed. We should
>> do the same in qemu.
>
> Is that OS-independent hardware behavior, or is tray closing on boot
> merely a side effect observed on bare metal but caused by installed
> software (BIOS or OS code)?  At any rate, being consistent with IDE
> doesn't hurt.
>

 From what I just tested it is the OS-independent HW behavior.

Tested on desktop:
1. Turn off the computer.
2. Turn on the computer and after few second open the CD-ROM tray before 
any OS system is loaded and holding the power button turn the computer 
off again. The CD-ROM tray should stay opened.
3. Turn on the computer and the CD-ROM tray is automatically closed.

Next time I'll mention this test in the commit message.

>>
>> This fix is already commited for IDE CD.
>
> s/commited/committed/
>
>> Check the commit a7f3d65b65b8c86a5ff0c0abcfefb45e2ec6fe4c.
>>
>> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>> ---
>>   hw/scsi/scsi-disk.c | 3 +++
>>   1 file changed, 3 insertions(+)
>
> assuming the maintainer can touch up the commit message, feel free to add:
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-16 15:48   ` Pavel Hrdina
@ 2013-05-16 16:11     ` Paolo Bonzini
  2013-05-17 11:57       ` Pavel Hrdina
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2013-05-16 16:11 UTC (permalink / raw)
  To: Pavel Hrdina; +Cc: kwolf, qemu-devel

Il 16/05/2013 17:48, Pavel Hrdina ha scritto:
> 
> From what I just tested it is the OS-independent HW behavior.
> 
> Tested on desktop:
> 1. Turn off the computer.
> 2. Turn on the computer and after few second open the CD-ROM tray before
> any OS system is loaded and holding the power button turn the computer
> off again. The CD-ROM tray should stay opened.
> 3. Turn on the computer and the CD-ROM tray is automatically closed.

When?  Compared to the BIOS splash screen, for example.

> Next time I'll mention this test in the commit message.

It could mean it is done in the firmware.

What happens when you suspend the QEMU machine to RAM?  I believe the
tray should remain open or, if closed, should remain locked.  Can you
try the same test on bare-metal (hint: boot to emergency mode to bypass
anything that udev can do with locking the tray, then use sg_prevent to
toggle the state).

Paolo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-16 16:11     ` Paolo Bonzini
@ 2013-05-17 11:57       ` Pavel Hrdina
  2013-05-17 12:02         ` Paolo Bonzini
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Hrdina @ 2013-05-17 11:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kwolf, qemu-devel

On 16.5.2013 18:11, Paolo Bonzini wrote:
> Il 16/05/2013 17:48, Pavel Hrdina ha scritto:
>>
>>  From what I just tested it is the OS-independent HW behavior.
>>
>> Tested on desktop:
>> 1. Turn off the computer.
>> 2. Turn on the computer and after few second open the CD-ROM tray before
>> any OS system is loaded and holding the power button turn the computer
>> off again. The CD-ROM tray should stay opened.
>> 3. Turn on the computer and the CD-ROM tray is automatically closed.
>
> When?  Compared to the BIOS splash screen, for example.

Immediately after the computer is turned on. On HP Z400 workstation it 
means before the monitor is turned on.

>
>> Next time I'll mention this test in the commit message.
>
> It could mean it is done in the firmware.
>
> What happens when you suspend the QEMU machine to RAM?  I believe the
> tray should remain open or, if closed, should remain locked.  Can you
> try the same test on bare-metal (hint: boot to emergency mode to bypass
> anything that udev can do with locking the tray, then use sg_prevent to
> toggle the state).
>
> Paolo
>

I've booted to init 1, then ejected the CD-ROM tray and run the 
pm-suspend. The computer has suspended successfully. And again 
immediately after the computer is turned on before the screen is turned 
on the CD-ROM tray is closed.

I don't have SCSI CD-ROM device to use the sg_prevent.

Pavel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-17 11:57       ` Pavel Hrdina
@ 2013-05-17 12:02         ` Paolo Bonzini
  2013-05-17 12:11           ` Pavel Hrdina
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2013-05-17 12:02 UTC (permalink / raw)
  To: Pavel Hrdina; +Cc: kwolf, qemu-devel

Il 17/05/2013 13:57, Pavel Hrdina ha scritto:
>>
>> What happens when you suspend the QEMU machine to RAM?  I believe the
>> tray should remain open or, if closed, should remain locked.  Can you
>> try the same test on bare-metal (hint: boot to emergency mode to bypass
>> anything that udev can do with locking the tray, then use sg_prevent to
>> toggle the state).
> 
> I've booted to init 1, then ejected the CD-ROM tray and run the
> pm-suspend. The computer has suspended successfully. And again
> immediately after the computer is turned on before the screen is turned
> on the CD-ROM tray is closed.

Ok, these are good signs. :)

> I don't have SCSI CD-ROM device to use the sg_prevent.

All CD-ROMs ultimately speak SCSI (via ATAPI).  You don't have /dev/sr0?

Paolo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-17 12:02         ` Paolo Bonzini
@ 2013-05-17 12:11           ` Pavel Hrdina
  2013-05-17 12:15             ` Paolo Bonzini
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Hrdina @ 2013-05-17 12:11 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kwolf, qemu-devel

On 17.5.2013 14:02, Paolo Bonzini wrote:
> Il 17/05/2013 13:57, Pavel Hrdina ha scritto:
>>>
>>> What happens when you suspend the QEMU machine to RAM?  I believe the
>>> tray should remain open or, if closed, should remain locked.  Can you
>>> try the same test on bare-metal (hint: boot to emergency mode to bypass
>>> anything that udev can do with locking the tray, then use sg_prevent to
>>> toggle the state).
>>
>> I've booted to init 1, then ejected the CD-ROM tray and run the
>> pm-suspend. The computer has suspended successfully. And again
>> immediately after the computer is turned on before the screen is turned
>> on the CD-ROM tray is closed.
>
> Ok, these are good signs. :)
>
>> I don't have SCSI CD-ROM device to use the sg_prevent.
>
> All CD-ROMs ultimately speak SCSI (via ATAPI).  You don't have /dev/sr0?
>
> Paolo
>

Yes I have. If I run "sg_prevent /dev/sr0" the CD-ROM tray could be 
still opened. Even with "sg_prevent -p 3 /dev/sr0".

Pavel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-17 12:11           ` Pavel Hrdina
@ 2013-05-17 12:15             ` Paolo Bonzini
  2013-05-17 12:34               ` Pavel Hrdina
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2013-05-17 12:15 UTC (permalink / raw)
  To: Pavel Hrdina; +Cc: kwolf, qemu-devel

Il 17/05/2013 14:11, Pavel Hrdina ha scritto:
> On 17.5.2013 14:02, Paolo Bonzini wrote:
>> Il 17/05/2013 13:57, Pavel Hrdina ha scritto:
>>>>
>>>> What happens when you suspend the QEMU machine to RAM?  I believe the
>>>> tray should remain open or, if closed, should remain locked.  Can you
>>>> try the same test on bare-metal (hint: boot to emergency mode to bypass
>>>> anything that udev can do with locking the tray, then use sg_prevent to
>>>> toggle the state).
>>>
>>> I've booted to init 1, then ejected the CD-ROM tray and run the
>>> pm-suspend. The computer has suspended successfully. And again
>>> immediately after the computer is turned on before the screen is turned
>>> on the CD-ROM tray is closed.
>>
>> Ok, these are good signs. :)
>>
>>> I don't have SCSI CD-ROM device to use the sg_prevent.
>>
>> All CD-ROMs ultimately speak SCSI (via ATAPI).  You don't have /dev/sr0?
>>
>> Paolo
>>
> 
> Yes I have. If I run "sg_prevent /dev/sr0" the CD-ROM tray could be
> still opened. Even with "sg_prevent -p 3 /dev/sr0".

Try "init=/bin/sh".  Runlevel 1 might not be enough.

Also, you can try "echo 0 > /sys/block/sr0/event_poll_msecs"

Paolo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset
  2013-05-17 12:15             ` Paolo Bonzini
@ 2013-05-17 12:34               ` Pavel Hrdina
  0 siblings, 0 replies; 9+ messages in thread
From: Pavel Hrdina @ 2013-05-17 12:34 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kwolf, qemu-devel

On 17.5.2013 14:15, Paolo Bonzini wrote:
> Il 17/05/2013 14:11, Pavel Hrdina ha scritto:
>> On 17.5.2013 14:02, Paolo Bonzini wrote:
>>> Il 17/05/2013 13:57, Pavel Hrdina ha scritto:
>>>>>
>>>>> What happens when you suspend the QEMU machine to RAM?  I believe the
>>>>> tray should remain open or, if closed, should remain locked.  Can you
>>>>> try the same test on bare-metal (hint: boot to emergency mode to bypass
>>>>> anything that udev can do with locking the tray, then use sg_prevent to
>>>>> toggle the state).
>>>>
>>>> I've booted to init 1, then ejected the CD-ROM tray and run the
>>>> pm-suspend. The computer has suspended successfully. And again
>>>> immediately after the computer is turned on before the screen is turned
>>>> on the CD-ROM tray is closed.
>>>
>>> Ok, these are good signs. :)
>>>
>>>> I don't have SCSI CD-ROM device to use the sg_prevent.
>>>
>>> All CD-ROMs ultimately speak SCSI (via ATAPI).  You don't have /dev/sr0?
>>>
>>> Paolo
>>>
>>
>> Yes I have. If I run "sg_prevent /dev/sr0" the CD-ROM tray could be
>> still opened. Even with "sg_prevent -p 3 /dev/sr0".
>
> Try "init=/bin/sh".  Runlevel 1 might not be enough.

Still not preventing from opening.

>
> Also, you can try "echo 0 > /sys/block/sr0/event_poll_msecs"

There is no file event_poll_msecs in that directory.

Pavel

>
> Paolo
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-05-17 12:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-16 15:34 [Qemu-devel] [PATCH] scsi: reset cdrom tray statuses on scsi_disk_reset Pavel Hrdina
2013-05-16 15:42 ` Eric Blake
2013-05-16 15:48   ` Pavel Hrdina
2013-05-16 16:11     ` Paolo Bonzini
2013-05-17 11:57       ` Pavel Hrdina
2013-05-17 12:02         ` Paolo Bonzini
2013-05-17 12:11           ` Pavel Hrdina
2013-05-17 12:15             ` Paolo Bonzini
2013-05-17 12:34               ` Pavel Hrdina

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).