Mounting DVD RW device in incus container

Hi,

I am trying to setup a fedora container to run K3B. The software itself
runs great but I am having difficulties mounting the DVD RW device
in the container.

This is the information I get from the DVD RW device on the host:

udevadm info --query=env /dev/sr0 

Yields this result:

EVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/host0/target0:0:0/0:0:0:0/block/sr0
DEVNAME=/dev/sr0
DEVTYPE=disk
DISKSEQ=16
MAJOR=11
MINOR=0
SUBSYSTEM=block
USEC_INITIALIZED=8951945717
ID_CDROM=1
SYSTEMD_MOUNT_DEVICE_BOUND=1
ID_CDROM_CD_R=1
ID_CDROM_CD_RW=1
ID_CDROM_DVD=1
ID_CDROM_DVD_R=1
ID_CDROM_DVD_RAM=1
ID_CDROM_MRW=1
ID_CDROM_MRW_W=1
ID_CDROM_DVD_R_DL_SEQ=1
ID_CDROM_DVD_R_DL_JR=1
ID_CDROM_DVD_PLUS_R_DL=1
ID_CDROM_DVD_PLUS_R=1
ID_CDROM_DVD_PLUS_RW=1
ID_CDROM_DVD_RW_SEQ=1
ID_CDROM_DVD_RW_RO=1
ID_CDROM_CD=1
ID_CDROM_RW_REMOVABLE=1
ID_CDROM_DVD_RW=1
ID_CDROM_DVD_R_DL=1
SYSTEMD_READY=0
ID_BUS=usb
ID_MODEL=DVDRAM_GP57EB40
ID_MODEL_ENC=DVDRAM\x20GP57EB40\x20
ID_MODEL_ID=1887
ID_SERIAL=HL-DT-ST_DVDRAM_GP57EB40_K0DL2383936-0:0
ID_SERIAL_SHORT=K0DL2383936
ID_VENDOR=HL-DT-ST
ID_VENDOR_ENC=HL-DT-ST
ID_VENDOR_ID=0e8d
ID_REVISION=RF01
ID_TYPE=cd
ID_INSTANCE=0:0
ID_USB_MODEL=DVDRAM_GP57EB40
ID_USB_MODEL_ENC=DVDRAM\x20GP57EB40\x20
ID_USB_MODEL_ID=1887
ID_USB_SERIAL=HL-DT-ST_DVDRAM_GP57EB40_K0DL2383936-0:0
ID_USB_SERIAL_SHORT=K0DL2383936
ID_USB_VENDOR=HL-DT-ST
ID_USB_VENDOR_ENC=HL-DT-ST
ID_USB_VENDOR_ID=0e8d
ID_USB_REVISION=RF01
ID_USB_TYPE=cd
ID_USB_INSTANCE=0:0
ID_USB_INTERFACES=:080250:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usb-storage
ID_PATH=pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_1_0-scsi-0_0_0_0
ID_FOR_SEAT=block-pci-0000_00_14_0-usb-0_1_1_0-scsi-0_0_0_0
DEVLINKS=/dev/cdrom /dev/disk/by-path/pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0 /dev/disk/by-id/usb-HL-DT-ST_DVDRAM_GP57EB40_K0DL2383936-0:0 /dev/disk/by-diskseq/16
TAGS=:uaccess:seat:systemd:

I have tried mounting the device using the following container config:

dvd:                                                                                                                                                                                                                                  
   required: "false"
   source: /dev/sr0
   type: unix-block

This configuration sort of works, but is not recognized by K3B as a cdrom/dvd drive. This
is the output from the same udevadm as above, but from within the container:

DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/host0/target0:0:0/0:0:0:0/block/sr0
DEVNAME=/dev/sr0
DEVTYPE=disk
DISKSEQ=16
MAJOR=11
MINOR=0
SUBSYSTEM=block

I suppose it is the lack of information tags such as ID_CDROM=1 which prevents
K3B from properly identifying the device.

I am using incus 6.0.1.

Any ideas on how to make this work?

Maybe try passing DVD player as a USB device. Like here with a phone. First, find a vendorid and productid. Then pass that device to the container:

lsusb
incus config device add <container_name> <any_device_name> usb vendorid=<vid> productid=<pid>

For example:

incus config device add k3b dvd usb vendorid=18d1 productid=4ee7

Thank you for the suggestion @qkiel ! The DVD writer properly shows up as a USB
device, as shown in lsusb when run from within the container:

Bus 003 Device 002: ID 0e8d:1887 MediaTek Inc. Slim Portable DVD Writer

However, now I do not have a /dev/sr0 device and K3B does not recognize it as a DVD Writer.

Any ideas on how to simulate the /dev/sr0 device, somehow?

I also tried changing the device type to “unix-hotplug”, unfortunately it does not seem to add the device under /dev. I have verified that the systemd-udev service is active and running but it
does not seem to do anything.

Wrong of me! I re-plugged the USB connector which made the /dev/cdrom node
appear in the container!