October 23, 20241 yr So I followed some steps I found here from a post a few years old which instructed me to make this entry in my XML file: <controller type='scsi' index='0' model='virtio-scsi'/> <hostdev mode='subsystem' type='scsi'> <source> <adapter name='scsi_host2'/> <address type='scsi' bus='0' target='0' unit='0'/> </source> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </hostdev> my optical drive is coming up like this: [7:0:0:0] cd/dvd HL-DT-ST BDDVDRW UH12NS40 1.00 /dev/sr0 So I changed the entry for 'scsi_host2' to 'scsi_host7' WHen I tried to save this, it said another device was already assigned to scsi index 0, so I had to change the index to 4. AFter making those adjustments, the drive appears in Debian but I'm not able to read it. Goobox appears to see it, but then promptly locks up the entire VM which you can see in here: And here you can see that disc manager sees the drive: FInally here's my full XML file... Any help is greatly appreciated! <?xml version='1.0' encoding='UTF-8'?> <domain type='kvm'> <name>Debian</name> <uuid>b66a5edb-7f8e-ba7e-dba7-efe5eefa7719</uuid> <metadata> <vmtemplate xmlns="unraid" name="Debian" icon="debian.png" os="debian"/> </metadata> <memory unit='KiB'>2097152</memory> <currentMemory unit='KiB'>2097152</currentMemory> <memoryBacking> <nosharepages/> </memoryBacking> <vcpu placement='static'>3</vcpu> <cputune> <vcpupin vcpu='0' cpuset='0'/> <vcpupin vcpu='1' cpuset='5'/> <vcpupin vcpu='2' cpuset='2'/> </cputune> <os> <type arch='x86_64' machine='pc-q35-7.2'>hvm</type> <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd</loader> <nvram>/etc/libvirt/qemu/nvram/b66a5edb-7f8e-ba7e-dba7-efe5eefa7719_VARS-pure-efi.fd</nvram> </os> <features> <acpi/> <apic/> </features> <cpu mode='host-passthrough' check='none' migratable='on'> <topology sockets='1' dies='1' cores='3' threads='1'/> <cache mode='passthrough'/> </cpu> <clock offset='utc'> <timer name='rtc' tickpolicy='catchup'/> <timer name='pit' tickpolicy='delay'/> <timer name='hpet' present='no'/> </clock> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/local/sbin/qemu</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='writeback'/> <source file='/mnt/user/domains/Debian/vdisk1.img'/> <target dev='hdc' bus='virtio'/> <serial>vdisk1</serial> <boot order='1'/> <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/mnt/user/isos/debian-12.7.0-amd64-netinst.iso'/> <target dev='hda' bus='sata'/> <readonly/> <boot order='2'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <controller type='sata' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> </controller> <controller type='pci' index='0' model='pcie-root'/> <controller type='pci' index='1' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='1' port='0x8'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> </controller> <controller type='pci' index='2' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='2' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='pci' index='3' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='3' port='0xa'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='pci' index='4' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='4' port='0xb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/> </controller> <controller type='pci' index='5' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='5' port='0xc'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/> </controller> <controller type='pci' index='6' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='6' port='0xd'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/> </controller> <controller type='pci' index='7' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='7' port='0xe'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/> </controller> <controller type='pci' index='8' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='8' port='0xf'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/> </controller> <controller type='pci' index='9' model='pcie-to-pci-bridge'> <model name='pcie-pci-bridge'/> <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> </controller> <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </controller> <controller type='scsi' index='0' model='lsilogic'> <address type='pci' domain='0x0000' bus='0x09' slot='0x01' function='0x0'/> </controller> <controller type='scsi' index='1' model='lsilogic'> <address type='pci' domain='0x0000' bus='0x09' slot='0x02' function='0x0'/> </controller> <controller type='scsi' index='2' model='lsilogic'> <address type='pci' domain='0x0000' bus='0x09' slot='0x03' function='0x0'/> </controller> <controller type='scsi' index='3' model='virtio-scsi'> <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/> </controller> <controller type='scsi' index='4' model='virtio-scsi'> <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> </controller> <controller type='usb' index='0' model='ich9-ehci1'> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/> </controller> <controller type='usb' index='0' model='ich9-uhci1'> <master startport='0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/> </controller> <controller type='usb' index='0' model='ich9-uhci2'> <master startport='2'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/> </controller> <controller type='usb' index='0' model='ich9-uhci3'> <master startport='4'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/> </controller> <interface type='bridge'> <mac address='52:54:00:5d:40:d9'/> <source bridge='br0'/> <model type='virtio-net'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> <serial type='pty'> <target type='isa-serial' port='0'> <model name='isa-serial'/> </target> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <channel type='unix'> <target type='virtio' name='org.qemu.guest_agent.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> <input type='tablet' bus='usb'> <address type='usb' bus='0' port='1'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' keymap='en-us'> <listen type='address' address='0.0.0.0'/> </graphics> <audio id='1' type='none'/> <video> <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/> </video> <hostdev mode='subsystem' type='scsi' managed='no'> <source> <adapter name='scsi_host7'/> <address bus='0' target='0' unit='0'/> </source> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </hostdev> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> </memballoon> </devices> </domain> Edited October 23, 20241 yr by slydog75
October 23, 20241 yr I Usual go after a usb atapi and pass disk drive by usb: https://a.co/d/5Muk902 your fighitng the linux disk mounts, /dev/sr0 and /dev/sg1 etc are all neeeded to pass a physical disk drive It may be easier to pas it while mounted... lets review: The reason your DVD drive appears as both /dev/sr0 and /dev/sg0 is because: /dev/sr0 refers to the standard block device interface used by most CD/DVD drives. It’s what most operating systems will use to read and write to the disc in a block-based manner (e.g., for filesystems). /dev/sg0 is a generic SCSI device interface. It allows for raw access to the drive, often used for issuing low-level SCSI commands directly to the device (e.g., for things like ejecting the tray or reading drive-specific information). When passing a physical optical drive to a virtual machine (VM) in unRAID, it's important to pass the correct device. Normally, you would pass /dev/sr0, as that’s the block device that the VM expects to work with for reading discs. If the disc isn't being read in the VM, check the following: Verify the drive in the XML: Ensure you're passing the DVD drive as /dev/sr0 and not /dev/sg0. Here's the XML snippet for a DVD drive: <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <source dev='/dev/sr0'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </disk> Replace /dev/sr0 with the correct device path if it's different. The target dev='hdc' is common for CD/DVD drives. Depending on your VM setup, it may use a different target and bus. Next, Ensure proper permissions: Make sure unRAID (and KVM) has the necessary permissions to access /dev/sr0. You can check this by running: ls -l /dev/sr0 You might need to adjust the permissions or run chmod to ensure KVM has access to the device. Check the VM OS drivers: Make sure the guest OS (inside the VM) has the correct drivers for the optical drive. For example, Windows and Linux should automatically detect and support most DVD drives, but occasionally the guest OS might need additional drivers or configuration. Confirm the media: Ensure the DVD or CD media you're using is readable and functional. Try reading the disc directly from the unRAID host (outside the VM) to confirm that the physical media and the drive are working correctly. Test the drive directly on the host: Before passing the device to the VM, test if the host (unRAID) can read the disk by mounting it directly on the host system: mount /dev/sr0 /mnt/cdrom and use /mnt/cdrom pass via unraid vm web ui... If this fails, there could be a problem with the drive or media, and this issue would also propagate to the VM. QEMU/CDROM Passthrough issues: CD/DVD passthrough to VMs via QEMU/KVM can sometimes be problematic, especially if you're using a non-standard configuration. In some cases, enabling passthrough with the SCSI bus or using a virtual ISO drive instead of physical media might be more reliable. Either way you passing a part of the disk drive and this is why it failed...
October 24, 20241 yr Author Thanks @bmartino1.. So, first,I modded the permissions and this is what I have now: brw-rw-rw- 1 root cdrom 11, 0 Oct 24 08:48 /dev/sr0 As far as the drive functioning, I know it does as it works fine with MakeMKV in a docker (I'm just trying to move away from running applications like that in a docker).. Finally, I tried adding your XML entries regarding the DVD drive snippet but get this error: Quote unsupported configuration: Invalid address type 'pci' for the disk 'hdc' with the bus type 'ide' Edited October 24, 20241 yr by slydog75 formatting
October 24, 20241 yr Author A further update.. with nothing or a CD-ROm in the drive, everything is fine until i try to read it.. I can even use disc manager to eject the tray.. but with a CD rom the whole OS locks up as soon as i try to read it.. WIth a BluRay disc in, the whole Os locks up within a a few seconds without even trying to read the drive.
October 24, 20241 yr Intresting. I have done this in the past, but as i said i've moved to usb pass the sata disk drive for easer use in unraid. I would still higly recommend the usb atapi device.... Apologies, you may have fixed the xml already... Was looking at proxmox and how they did it. on unraid they chaged how the address is read in there xml... as this is qemu virtio in a debain linux. you may also need to install some extra packages. sudo apt update sudo apt install udftools libbluray2 sudo apt install libaacs0 libbluray2 sudo modprobe sr_mod Other XML: <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <source dev='/dev/sr0'/> <target dev='hda' bus='sata'/> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> Try scsi / virtio: replace sata... other wises, this sounds like QEMU/KVM I/O Handling so we add extra kvm/qemu data... xml: <disk type='block' device='cdrom'> <driver name='qemu' type='raw' cache='none' io='threads'/> <source dev='/dev/sr0'/> <target dev='hda' bus='sata'/> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> The cache='none' and io='threads' options might help by reducing the load on the VM and preventing it from locking up. *In machinthe box docker to vm we use cashe=unsafe.... as there might be a io handle errer with reading a drive... SO update you xml and install drivers. check again. No luck the let take a different approach: ? Don't add the disk drive to the xml and with the machine off / on use virsh terminal command to add the device: https://serverfault.com/questions/373372/how-to-connect-a-cdrom-device-to-a-kvm-qemu-domain-using-command-line-tools otherwsie you may need to look into seperating the port and use pcie iommu group to pass the disk see earlier form post:
October 24, 20241 yr Author Thanks again. I'll try these steps.. if they don't work I'll get the USB adapater.. in fact, I might have one lying around somewhere already.
October 24, 20241 yr Author Quote sudo virsh attach-disk Debian /dev/sr0 hdc --type cdrom error: Failed to attach disk error: internal error: unable to execute QEMU command 'blockdev-remove-medium': Device '/machine/peripheral/virtio-disk2/virtio-backend' is not removable Here's the error I get when trying to mount via the unRAID CLI... Going to start looking for my usb adapter.
October 24, 20241 yr 10 minutes ago, slydog75 said: Here's the error I get when trying to mount via the unRAID CLI... Going to start looking for my usb adapter. ok since we have now moved to termainl commands.: here are some other potentials... The machine may need to be off. chose 1: Sata: sudo virsh attach-disk Debian /dev/sr0 hda --type cdrom --mode readonly --driver qemu --targetbus sata SCSI: sudo virsh attach-disk Debian /dev/sr0 sda --type cdrom --mode readonly --driver qemu --targetbus scsi after above is ran Confirm Device Compatibility: After attaching, check the VM logs for any device compatibility issues: sudo virsh qemu-monitor-command Debian --hmp "info block" per error aditional options when vm is on: Use blockdev-add and blockdev-change-medium Use blockdev-add to add the media: sudo virsh qemu-monitor-command Debian --hmp "blockdev-add {'node-name': 'cdrom', 'driver': 'raw', 'file': {'driver': 'file', 'filename': '/dev/sr0'}}" Use blockdev-change-medium to eject or change media: sudo virsh qemu-monitor-command Debian --hmp "blockdev-change-medium cdrom ''" If that doesn't work the pas usb disk drive would be your best bet...
October 24, 20241 yr Author Here's what I get after running the SCSI line above.. libvirt-2-format: /dev/sr0 (raw, read-only) Attached to: scsi0-0-0 Removable device: not locked, tray closed Cache mode: writeback but nothing actually appears within debian, within the GUI or under blkid. Edited October 24, 20241 yr by slydog75
October 24, 20241 yr Solution Well, thats all I have. thanks for trying... coming back from ubuntu 7 days when one could easily pass a disk drive as a network share... That tells me that unraid sees the disk drive in its current state, but if its not in the vm at that point the mount failed. I don't know why linux made a mess of temp storage disk drives with dvd writer/blueray writer adaptions... /dev/sg vs /dev/sr and others... linux clearly want something more to do a passthrough. Not sure if this is a unraid thing or issue. This is why as mentioned earlier I recommend using the usb atapi device... go old usb passthrough. I wish you luck.
October 24, 20241 yr Author Well, that was stupid easy.. I plugged it in via USB, enabled passthru in the VM settings pg and it just worked. It will forever bug me that I didn't get working over SATA, but on the plus side I now have another SATA port open so I might make a cache array. Thanks for all your help! And good luck with your current situation, I made a small donation to your gofundme. Edited October 24, 20241 yr by slydog75
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.