[lxc-devel] [lxd/master] try to remove the usb bus dir after device disconnect
tych0 on Github
lxc-bot at linuxcontainers.org
Tue Aug 23 14:28:05 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 651 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160823/57a47ebc/attachment.bin>
-------------- next part --------------
From 9a2b1ba3a0ea9db93c345a228c52f9e3f633293e Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Tue, 23 Aug 2016 10:12:56 -0400
Subject: [PATCH] try to remove the usb bus dir after device disconnect
As the comment notes, it's okay to fail because there may be other USB
devices still connected.
Also, I need to find a USB device SWAG because I didn't bring one to this
conference and so I don't really have a way to test this, but I think this
will do it right :)
Closes #2306
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
lxd/container_lxc.go | 6 ++++++
lxd/devices.go | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 8982e88..67d0068 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2524,6 +2524,12 @@ func (c *containerLXC) Update(args containerArgs, userRequested bool) error {
if err != nil {
shared.Log.Error("failed to remove usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
}
+
+ /* ok to fail here, there may be other usb
+ * devices on this bus still left in the
+ * container
+ */
+ os.Remove(filepath.Dir(usb.path))
}
}
}
diff --git a/lxd/devices.go b/lxd/devices.go
index a846b9e..ab51902 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -507,6 +507,12 @@ func deviceUSBEvent(d *Daemon, usb usbDevice) {
shared.Log.Error("failed to remove usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
return
}
+
+ /* ok to fail here, there may be other usb
+ * devices on this bus still left in the
+ * container
+ */
+ os.Remove(filepath.Dir(usb.path))
} else {
shared.Log.Error("unknown action for usb device", log.Ctx{"usb": usb})
continue
More information about the lxc-devel
mailing list