[vfio-users] optical eject issue

leesteken at pm.me leesteken at pm.me
Sat May 23 06:29:30 UTC 2020


On Saturday, May 23, 2020 7:12 AM, Roger Lawhorn <rll at twc.com> 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?

QEMU creates a virtual motherboard, I add a virtual SCSI controller, to which I add a virtual optical drive that takes ISOs.
This virtual SCSI controller requires a driver for Windows, but in my experience it always detects ISO changes immediately:
/usr/bin/kvm \
  ...
  -device 'virtio-scsi-pci,id=scsihw0,bus=pci.0,addr=0x5' \
  -drive 'file=/spool/storage/proxmox/template/iso/virtio-win-0.1.171.iso,if=none,id=drive-scsi1,media=cdrom,aio=threads' \
  -device 'scsi-cd,bus=scsihw0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi1,id=scsi1,bootindex=100' \
  ...

> I am adding a physical optical drive.

I did not realize. Apologies for proposing an alternative that does not relate to your problem.

I used to pass a physical drive like that and don't remember such problems, but I could never play DVDs or burn ISOs to discs.
Therefore, nowadays, I pass-through a physical SATA controller (to a Linux VM) that has only the physical drive connected:
/usr/bin/kvm \
  ...
  -device 'vfio-pci,host=0000:0d:00.2,id=hostpci2,bus=pci.0,addr=0x1b' \
  ...

But this does also not help you with your issue, sorry.

> I launch qemu using a script.
> The script is passed the number of cpus to let qemu have ($1).
> The ISO I setup as a cdrom shows up as drive D:
> The physical optical drive shows up as drive F:
>
> Like I said, the ejection issues really suck.
>
> Here is my script:
> #!/bin/bash
> cd /media/dad/QEMU-SSD/qemu-wd
> export QEMU_AUDIO_DRV=pa
> export QEMU_AUDIO_TIMER_PERIOD=200
> export QEMU_PA_SERVER=/run/user/1000/pulse/native
>
> taskset -p -c 0-7 `pidof lightdm | cut -d' ' -f2`
> taskset -c 8-23 qemu4.0-system-x86_64 -machine type=q35,accel=kvm -cpu
> EPYC \
> -chardev stdio,id=seabios -device
> isa-debugcon,iobase=0x402,chardev=seabios \
> -smp $1,sockets=1,cores=$1 \
> -bios /usr/share/seabios/bios.bin \
> -m 16G \
> -vga none \
> -soundhw hda \
> -mem-prealloc \
> -rtc clock=host,base=localtime \
> -device
> ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \
> -device
> vfio-pci,host=0d:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on \
> -device vfio-pci,host=0d:00.1,bus=root.1,addr=00.1,multifunction=on \
> -device vfio-pci,host=0e:00.0,bus=root.1,addr=00.2,multifunction=on \
> -device virtio-scsi-pci,id=scsi \
> -drive
> id=disk0,if=virtio,cache=none,format=raw,file=/media/dad/QEMU-SSD/qemu-wd/windows10.img
> \
> -drive
> file=/media/dad/QEMU-SSD/qemu-wd/'Win10_1909_English_x64.iso',id=isocd,format=raw,if=none
> -device scsi-cd,drive=isocd \
> -netdev type=tap,id=net0,ifname=tap0 \
> -device virtio-net-pci,netdev=net0,mac=00:16:3e:00:01:01 \
> -usb -device usb-host,vendorid=0x046d,productid=0xc534 \
> -usb -device usb-host,vendorid=0x05ac,productid=0x12aa \
> -usb -device usb-host,vendorid=0x21c4,productid=0x0cd1 \
> -cdrom /dev/sr0 \
> -boot menu=on \
> -boot order=c
> exit 0
>
[snip]

Unfortunately, I cannot test this because my host no longer has an optical drive. (Because it is passed-through to a VM.)
Maybe the following would work (after installing virtio SCSI drivers for Windows)?
  -device 'virtio-scsi-pci,id=scsihw0,bus=pci.0,addr=0x5' \
  -drive 'file=/dev/sr0,if=none,id=drive-scsi1,media=cdrom,aio=threads' \
  -device 'scsi-cd,bus=scsihw0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi1,id=scsi1'

kind regards, Arjen





More information about the vfio-users mailing list