Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uevent-based matching for `unix-char` and `unix-block` #1750

Open
jsimonetti opened this issue Mar 12, 2016 · 12 comments

Comments

@jsimonetti
Copy link
Contributor

commented Mar 12, 2016

It appears possible (for example with this library https://github.com/jessta/udev) to add udev device hotplug monitoring to lxd.

Allowing one to add devices similar to udev rules:
lxc config device add ct1 udev subsystem="usb" attrs.idVendor="10c4" attrs.idProduct="ea60" group="serial" mode="0666" path=/dev/ttyUSB0

And have this particular device auto mounted inside ct1 as /dev/ttyUSB0 at insert time would sound like a dream come true and one of the last hurdles I have to take to fully containerise all my current systems.

@stgraber

This comment has been minimized.

Copy link
Member

commented Mar 12, 2016

Yeah, we already have a uevent handler so we could do something like that, however we need to make sure the design is somewhat generic at the API level.

@stgraber stgraber added this to the later milestone Mar 12, 2016
@stgraber stgraber modified the milestones: later, soon Apr 25, 2016
@stgraber stgraber changed the title add hotplugging support for devices Add support for USB devices Apr 25, 2016
@stgraber stgraber added API Easy and removed Easy labels Apr 25, 2016
@stgraber

This comment has been minimized.

Copy link
Member

commented Jul 27, 2016

So I think there are two different cases, one is to dynamically pass unix-char/unix-block devices as they appear/disappear on the host.

The other case is to pass raw USB devices. I'm re-titling this bug to make it clear that it's about the former.

@stgraber stgraber changed the title Add support for USB devices Add support for dynamic unix-char/unix-block devices as result of hardware event Jul 27, 2016
@stgraber stgraber changed the title Add support for dynamic unix-char/unix-block devices as result of hardware event Add support for dynamic unix-char/unix-block devices with hardware hotplug Jul 27, 2016
@stgraber stgraber modified the milestones: soon, later Sep 13, 2016
@pavlodvornikov

This comment has been minimized.

Copy link

commented Oct 12, 2017

Is there any activity on this feature ?

@stgraber

This comment has been minimized.

Copy link
Member

commented Oct 12, 2017

Nope, it's not been a priority for us so far. We'd certainly be happy to review a branch that implements this though.

@pavlodvornikov

This comment has been minimized.

Copy link

commented Oct 12, 2017

I am trying to use usb-hotplug-with-lxd-containers to connect to usb serial device from lxc container with no luck. The main problem that mentioned device apeears in container as raw usb device. I cant get serial interface to this device.

root@test:~# modprobe usbserial vendor=0x0403 product=0x6001
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.10.0-19-generic/modules.dep.bin'
modprobe: FATAL: Module usbserial not found in directory /lib/modules/4.10.0-19-generic
@stgraber

This comment has been minimized.

Copy link
Member

commented Oct 12, 2017

Indeed, the USB passthrough is for libusb devices which serial USB ports aren't.

You can manually pass such devices using the "unix-char" device type. For hotplug, for now you'd need to use a custom udev rule on your host. Or contribute to LXD and add that particular feature.

@stgraber

This comment has been minimized.

Copy link
Member

commented Nov 4, 2017

Just to update this issue on what I think should be done here. I think we need a new unix-hotplug device type which would allow for /dev entries related to a device filter to be added to the container as they become available.

At its most basic, we'd be looking at:

lxc config device add c1 usb-console unix-hotplug vendorid=067b productid=2303 required=true

This would then add any device node associated with this particular device to the container.
The options are the same as the usb device type but rather than passing /dev/bus/usb/... entries, we'd be looking at the udev database to track down any device nodes under /dev which are tied to that particular device.

More filters may be added later to deal with other types of device.

Other than having to track down those devices (likely through udev), the difficulty will also be to properly clean them up when they're disconnected. We want to make sure that a container can start with the devices pre-connected, or can have the devices connected later and then have them disconnected at any point with everything being cleaned up properly.

@stgraber stgraber changed the title Add support for dynamic unix-char/unix-block devices with hardware hotplug New unix-hotplug device type (dynamically passes unix devices) Nov 4, 2017
@Catramen

This comment has been minimized.

Copy link
Contributor

commented Mar 22, 2019

Should this be merged to 3995?

@stgraber

This comment has been minimized.

Copy link
Member

commented Mar 22, 2019

No, this is different and is why we split the issue in half in the first place.
See: #1750 (comment)

@nvertigo21

This comment has been minimized.

Copy link

commented Apr 15, 2019

I'd also like to see this feature. Passing a joystick through to a container for RetroPie but when the uevent changes on the host, I have to manually edit the container config.

@stgraber

This comment has been minimized.

Copy link
Member

commented Apr 15, 2019

Until then you can probably use a udev hook to run lxc config device add for you.

@splett2

This comment has been minimized.

Copy link

commented Sep 23, 2019

hi, lily and I would like to claim this issue for our group.

@stgraber stgraber changed the title New unix-hotplug device type (dynamically passes unix devices) Uevent-based matching for `unix-char` and `unix-block` Sep 23, 2019
@stgraber stgraber modified the milestones: later, soon Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
6 participants
You can’t perform that action at this time.