[vfio-users] optical eject issue

Samuel Holland samuel at sholland.org
Sat May 23 17:32:07 UTC 2020


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