我桌上有一个硬件开发工具包,通过USB连接到我的Windows笔记本电脑上。开发工具包允许您通过USB闪存芯片。我想使用usbip将此设备公开到我的服务器环境中。
在我的Windows电脑上,我运行一个带有USBIP服务器的virtualbox。我已经绑定了硬件开发工具包。服务器正在监听端口3240,该端口由虚拟盒转发到主机(笔记本电脑)端口7023
使用SSH我登录到我的服务器。我已经设置了一个SSH远程隧道,以便服务器上的3240端口将请求发送到笔记本电脑上的7023端口。
概要
USBIP服务器端口3240—虚拟机-->笔记本电脑端口7023在服务器上,此操作正常:

sudo /usr/lib/linux-tools-4.4.0-66/usbip --tcp-port 3240 attach -r 127.0.0.1 -b 1-2
dinne@vidar:~$ lsusb
Bus 005 Device 002: ID 04f2:b39a Chicony Electronics Co., Ltd

现在在服务器上我有一些Docker容器在运行。这些容器有一个开发环境,我可以用它为hw dev工具包编译程序。我想将编译后的应用程序闪存到开发工具包中。
每个用户在服务器上都有自己的开发容器和本地安装的开发工具包。所以我想避免使用usbip将虚拟USB设备直接连接到服务器上。相反,如果用户可以在Docker容器中运行usbip,这将是理想的选择。
在Docker容器里我试过:
sudo usbip --tcp-port 3240 list -r 192.168.96.101

Exportable USB devices
======================
 - 192.168.96.101
        1-2: Chicony Electronics Co., Ltd : unknown product (04f2:b39a)
           : /sys/devices/pci0000:00/0000:00:06.0/usb1/1-2
           : Miscellaneous Device / ? / Interface Association (ef/02/01)

sudo usbip --debug --tcp-port 3240 attach -r 192.168.96.101 -b 1-2

usbip: info: using port 3250 ("3250")
usbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/src/usbip_network.c:40:[usbip_setup_port_number] parsing port arg '3250'
usbip: info: using port 3250 ("3250")
usbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/src/usbip.c:141:[run_command] running command: `attach'
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:242:[usbip_vhci_driver_open] available ports: 7
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 0 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 1 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 2 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 3 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 4 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 5 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 6 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:71:[parse_status] port 7 status 4 speed 0 devid 0
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:72:[parse_status] socket 0 lbusid 0000000000000000
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:105:[parse_status] exit
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:311:[usbip_vhci_attach_device2] writing: 0 3 65539 2
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:316:[usbip_vhci_attach_device2] attach attribute path: /sys/devices/platform/vhci_hcd/attach
usbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c:17:[write_sysfs_attribute] error opening attribute /sys/devices/platform/vhci_hcd/attach
libusbip: debug: /build/linux-tools-SJqEHJ/linux-tools-3.16.7-ckt20/drivers/staging/usbip/userspace/libsrc/vhci_driver.c:320:[usbip_vhci_attach_device2] write_sysfs_attribute failed
usbip: error: import device
usbip: error: query

open(“/sys/devices/platform/vhcci_hcd/attach”,O_WRONLY)似乎出现故障。
sudo -- sh -c "ls -al /sys/devices/platform/vhci_hcd/"
drwxr-xr-x  4 root root    0 Mar 21 22:00 .
drwxr-xr-x 19 root root    0 Mar 21 21:21 ..
--w-------  1 root root 4096 Mar 21 22:00 attach
--w-------  1 root root 4096 Mar 21 22:00 detach
lrwxrwxrwx  1 root root    0 Mar 21 22:00 driver -> ../../../bus/platform/drivers/vhci_hcd
-rw-r--r--  1 root root 4096 Mar 21 22:00 driver_override
-r--r--r--  1 root root 4096 Mar 21 22:00 modalias
drwxr-xr-x  2 root root    0 Mar 21 22:00 power
-r--r--r--  1 root root 4096 Mar 21 21:21 status
lrwxrwxrwx  1 root root    0 Mar 21 22:00 subsystem -> ../../../bus/platform
-rw-r--r--  1 root root 4096 Mar 21 21:21 uevent
drwxr-xr-x  5 root root    0 Mar 21 22:00 usb5
-rw-r--r--  1 root root 4096 Mar 21 22:00 usbip_debug

如何让USBIP客户端在Docker容器中工作?

最佳答案

如果我用特权管理docker的话,它看起来很管用。

10-06 06:33