[lxc-devel] [lxd/master] allow wildcard in usb vendorid

Catramen on Github lxc-bot at linuxcontainers.org
Thu Nov 15 06:53:27 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 409 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181115/ffba0c95/attachment.bin>
-------------- next part --------------
From ab9fa74bd7c98c1b6dcc3aade5b700df42ade9ca Mon Sep 17 00:00:00 2001
From: Jingkui Wang <wjkcow at umich.edu>
Date: Wed, 14 Nov 2018 23:35:46 -0500
Subject: [PATCH] allow wildcard in usb vendorid

Sometimes I just want a stupid way to pass in everything.

Signed-off-by: Jingkui Wang <jkwang at google.com>
---
 doc/containers.md    | 2 +-
 lxd/container_lxc.go | 6 +++---
 lxd/devices.go       | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/containers.md b/doc/containers.md
index 211c50febb..1e61c33586 100644
--- a/doc/containers.md
+++ b/doc/containers.md
@@ -406,7 +406,7 @@ The following properties exist:
 
 Key         | Type      | Default           | Required  | Description
 :--         | :--       | :--               | :--       | :--
-vendorid    | string    | -                 | yes       | The vendor id of the USB device.
+vendorid    | string    | -                 | yes       | The vendor id of the USB device. Use '*' to specify all devices.
 productid   | string    | -                 | no        | The product id of the USB device.
 uid         | int       | 0                 | no        | UID of the device owner in the container
 gid         | int       | 0                 | no        | GID of the device owner in the container
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 9819bda540..9b1d5b1e78 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2091,7 +2091,7 @@ func (c *containerLXC) startCommon() (string, error) {
 			}
 
 			for _, usb := range usbs {
-				if usb.vendor != m["vendorid"] || (m["productid"] != "" && usb.product != m["productid"]) {
+				if m["vendorid"] != "*" && (usb.vendor != m["vendorid"] || (m["productid"] != "" && usb.product != m["productid"])) {
 					continue
 				}
 
@@ -4484,7 +4484,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 
 				/* if the device isn't present, we don't need to remove it */
 				for _, usb := range usbs {
-					if usb.vendor != m["vendorid"] || (m["productid"] != "" && usb.product != m["productid"]) {
+					if m["vendorid"] != "*" && (usb.vendor != m["vendorid"] || (m["productid"] != "" && usb.product != m["productid"])) {
 						continue
 					}
 
@@ -4620,7 +4620,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 				}
 
 				for _, usb := range usbs {
-					if usb.vendor != m["vendorid"] || (m["productid"] != "" && usb.product != m["productid"]) {
+					if m["vendorid"] != "*" && (usb.vendor != m["vendorid"] || (m["productid"] != "" && usb.product != m["productid"])) {
 						continue
 					}
 
diff --git a/lxd/devices.go b/lxd/devices.go
index c0ae53dc4e..1cff47bd69 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -852,7 +852,7 @@ func deviceUSBEvent(s *state.State, usb usbDevice) {
 				continue
 			}
 
-			if m["vendorid"] != usb.vendor || (m["productid"] != "" && m["productid"] != usb.product) {
+			if m["vendorid"] != "*" && (m["vendorid"] != usb.vendor || (m["productid"] != "" && m["productid"] != usb.product)) {
 				continue
 			}
 


More information about the lxc-devel mailing list