USB device wont follow default mode after device is removed and re-inserted

Passing through usb device does not follow default mode value (0660) after plugged out and plugged in.
Client version: 3.15
Server version: 3.15

Steps to reproduce:

lxc config device add neverland usb:01 usb vendorid=\<vid> productid=\<pid>
In Container: ls -la /dev/bus/usb/00x/00y
crw-rw----. 1 root root 189, 4 Aug 7 19:01 /dev/bus/usb/00x/00y
#Plug out the usb device and plug back in.
In Container: ls -la /dev/bus/usb/00x/00y
crw-------. 1 root root 189, 4 Aug 7 19:02 /dev/bus/usb/00x/00y

It can be resolved by remove/detach the device from the container and insert the mode argument, i.e.

lxc config device add neverland usb:01 usb vendorid=\<vid> productid=\<pid> mode=0600

Then, ls -la /dev/bus/usb/00x/00y will result:

crw-rw----. 1 root root 189, 4 Aug 7 19:01 /dev/bus/usb/00x/00y

(same mode result even after the device is plugged out and plugged back in later)

1 Like

@tomp can you take care of that issue as you look at porting this to the new device code?
Obviously not something we can really add tests for, but should be easy to address.

@stgraber sure will do.

@abcdef I am currently re-working the devices in LXD to be managed via their own Go package to better isolate them from the core of LXD. As part of this each device type needs to be checked its still working, so I will make sure to address this issue when I move onto USB shortly.

1 Like

This issue is fixed in this pull request: https://github.com/lxc/lxd/pull/6085