Skip to content

Enable USB/IP drivers and configuration in kernel #164

@149segolte

Description

@149segolte

Currently, Podman on macOS and Windows lacks a direct mechanism to passthrough USB devices from the host to containers running within the Podman machine. I came across Docker's workaround for this using USB/IP protocol from their docs.

This process can be replicated in podman even easier by using podman machine ssh instead of creating a separate privileged container:

  • Layer usbip on the coreos base image:
$ podman machine ssh

# rpm-ostree install usbip
# systemctl reboot
  • Run USB/IP server on the host (like, jiegec/usbip on mac):
$ git clone https://github.com/jiegec/usbip
$ cd usbip
$ env RUST_LOG=info cargo run --release --example host
  • Try to connect a USB device inside podman:
$ podman machine ssh

# usbip
usage: usbip [--debug] [--log] [--tcp-port PORT] [version]
             [help] <command> <args>

  attach     Attach a remote USB device
  detach     Detach a remote USB device
  list       List exportable or local USB devices
  bind       Bind device to usbip-host.ko
  unbind     Unbind device from usbip-host.ko
  port       Show imported USB devices

# usbip list -r host.containers.internal
Exportable USB devices
======================
 - host.containers.internal
      1-1-2: Micron Technology, Inc. : unknown product (0634:5605)
           : /sys/bus/1/1/2
           : (Defined at Interface level) (00/00/00)
           :  0 - Mass Storage / SCSI / Bulk-Only (08/06/50)

# usbip attach -r host.containers.internal -b 1-1-2
libusbip: error: udev_device_new_from_subsystem_sysname failed
usbip: error: open vhci_driver
# usbip port
libusbip: error: udev_device_new_from_subsystem_sysname failed
usbip: error: open vhci_driver
usbip: error: list imported devices

It seems to work fine and detect the USB/IP device but fails at the last step due to missing drivers. I do not know how to enable kernel drivers in an CoreOS OCI image, but that is the last step to get this working, including these modules would provide a flexible way for USB device passthrough. And once this is working, the UX can later be improved by directing integrating usbip command into podman like SSH - podman machine usb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions