qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Do you have a use for a tester of virtio-scsi with CD d


From: Thomas Schmitt
Subject: Re: [Qemu-devel] Do you have a use for a tester of virtio-scsi with CD drives ?
Date: Thu, 03 Nov 2011 10:15:08 +0100

Hi,

first i want to thank Paolo for his patience.

> So if you specified "-drive if=scsi" *and* "-cdrom", you'd get two non-empty
> drives.

Indeed. With
   -drive file=/dev/sr0,if=scsi,media=cdrom -cdrom /dvdbuffer/pseudo_drive
i get two drives with media:

  0  -dev '/dev/sr0' rwrw-- :  'QEMU    ' 'QEMU DVD-ROM' 
  1  -dev '/dev/sr1' rwrw-- :  'QEMU    ' 'QEMU CD-ROM' 

/dev/sr0 is from hw/ide/atapi.c:cmd_mode_sense()
  MODE SENSE
  5a 00 2a 00 00 00 00 00 1c 00 
  From drive: 28b
  00 22 70 00 00 00 00 00 2a 12 3b 00 71 60 2b 00 02 c0 00 02
  02 00 02 c0 00 00 00 00 

/dev/sr1 indeed differs in behavior
  MODE SENSE
  5a 00 2a 00 00 00 00 00 2d 00 
  From drive: 45b
  00 24 00 80 00 00 00 08 00 23 05 40 00 00 08 00 2a 14 3b 00
  7f ff 2f 00 22 60 00 02 08 00 0b 00 00 00 0b 00 0b 00 00 00
  00 00 00 00 00 

Which gives me something to work on. libburn does not take into
respect the Block Descriptor of 8 bytes which sits between
Mode Data Header and mode page.
So it misinterpets the result and demands the wrong Allocation
Length.

This error is explainable by my reading of MMC-5 which prescribes
in table 653:
  "Block Descriptor Length = 0"
MMC-1 on the other hand has in Annex B.4.1 :
  "The Mode Parameter Block Descriptor does not apply to ATAPI
   devices, and the Block Descriptor Length in the Mode
   Parameter Header shall be set to 0."

My thanks to qemu and the developers of its SCSI CD-ROM for showing
me this misconception in libburn.

------------------------------------------------------------------------

If i do only -drive file=/dev/sr0,if=scsi,medium=cdrom i get
one empty drive, obviously from hw/ide/atapi.c:cmd_mode_sense():

  MODE SENSE
  5a 00 2a 00 00 00 00 00 1c 00 
  From drive: 28b
  00 22 70 00 00 00 00 00 2a 12 3b 00 71 60 29 00 02 c0 00 02
  02 00 02 c0 00 00 00 00 

So i mistook the default DVD-ROM drive, which has no source data and
thus is empty, for the CD-ROM drive which i expected from -drive if=scsi
which would not be empty, but does not show up at all.

The question remains, why the CD-ROM drive is missing if i do -drive
but not -cdrom.

------------------------------------------------------------------------

I will repeat my experiments with
   -drive file=/dev/sg2,if=scsi,media=cdrom -cdrom /dvdbuffer/pseudo_drive

Maybe the presence of -cdrom cures the problems i had with passthrough.
(The bug in libburn is not to blame for that. The passthrough drive did not
 deliver a block descriptor.)

------------------------------------------------------------------------

> Yeah, looks like all the
> 
>         case MODE_PAGE_R_W_ERROR: /* error recovery */
>             cpu_to_ube16(&buf[0], 16 + 6);
> should have "- 2" instead of "+ 6".

I came to the same conclusion.


The implementation of MODE SENSE(6) in hw/ide/atapi.c:cmd_mode_sense()
is wrong.

SPC-1, table 239 prescribes only 4 bytes of Mode Parameter Header,
with only one byte of Mode Data Length.

cmd_mode_sense() prepends 8 bytes unconditionally. Suitable only
for MODE SENSE(10).

Obviously nobody ever really needed a correct MODE SENSE(6) with
the emulated IDE CD-ROM of qemu.
MMC-1 allows MODE SENSE(6), MMC-3 implicitely assumes MODE SENSE(10) only,
MMC-5 prescribes to use MODE SENSE(10).

MMC-2 has a list of required ATAPI commands. MODE SENSE(10) is listed.
MODE SENSE(6) is not listed.


I compared this with the SCSI counterpart of cmd_mode_sense():
hw/scsi-disk.c:scsi_disk_emulate_mode_sense()

It distinguishes between MODE_SENSE, which gets 4 bytes of header,
and MODE_SENSE_10, which gets 8. This looks correct.

------------------------------------------------------------------------

Have a nice day :)

Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]