[vfio-users] optical eject issue

Roger Lawhorn rll at twc.com
Sat May 23 22:43:21 UTC 2020


Well,

Got an error:
qemu4.0-system-x86_64: -device scsi-generic,drive=cd0: SG_GET_SCSI_ID 
ioctl failed

The drive itself is sata so I don't think it will accept scsi commands.



On 5/23/20 1:32 PM, Samuel Holland wrote:
> Hello,
>
> On 5/23/20 12:12 AM, Roger Lawhorn wrote:
>> ok, sorry, did a reply instead of a reply to all....
>>
>> I have used the -cdrom /dev/sr0 option.
>> When you say 'virtual' optical drive, are you talking about an iso or a physical
>> optical drive?
>> I am adding a physical optical drive.
> To pass through a physical optical drive, you need to use qemu's SCSI generic
> device, not a SCSI CD device. In this case, qemu will forward SCSI commands
> as-is instead of adding its own emulation layer on top. This means that an
> "eject" command will be handled by your physical drive, and not by qemu.
>
> For example, from one of my own qemu scripts:
>
>    -device virtio-scsi-pci,bus=pcie.0 \
>      -device scsi-hd,drive=hd0 \
>        -drive file=/dev/sdc,format=raw,id=hd0,if=none,unit=0 \
>      -device scsi-generic,drive=cd0 \
>        -drive file=/dev/sg2,format=raw,id=cd0,if=none,unit=1 \
>
> I've successfully used this arrangement to rip dozens of CD-ROMs using CUETools.
> Attempting to eject sometimes takes 3 or 4 tries, especially if the device is
> still in use, but it does eventually work. Another thing you can do is run
> `eject /dev/sr0` on the host, even while the VM is running, which always ejected
> immediately.
>
> Cheers,
> Samuel




More information about the vfio-users mailing list