[lxc-devel] [lxd/master] Fixes some issues with unix inotify

tomponline on Github lxc-bot at linuxcontainers.org
Thu Aug 22 17:06:47 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 691 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190822/98c454a4/attachment.bin>
-------------- next part --------------
From e835e10beb16eb9dee00131e1cecad22ee7abac6 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 22 Aug 2019 18:02:20 +0100
Subject: [PATCH 1/2] container/lxc: Fixes inotify dynamic hotplug on container
 start when device exists

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/container_lxc.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 95397799eb..b72f37384f 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2696,7 +2696,7 @@ func (c *containerLXC) startCommon() (string, []func() error, error) {
 				}
 				srcPath = shared.HostPath(srcPath)
 
-				err = deviceInotifyAddClosestLivingAncestor(c.state, srcPath)
+				err = deviceInotifyAddClosestLivingAncestor(c.state, filepath.Dir(srcPath))
 				if err != nil {
 					logger.Errorf("Failed to add \"%s\" to inotify targets", srcPath)
 					return "", postStartHooks, err

From 9ab849025e779562eca3d1f80e3b76b537a5b74f Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 22 Aug 2019 18:03:06 +0100
Subject: [PATCH 2/2] devices: Fixes dynamic hotplug of unix devices when they
 exist on startup

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/devices.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/devices.go b/lxd/devices.go
index 730764f5a6..6331214a9b 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -1087,11 +1087,11 @@ func deviceInotifyDirRescan(s *state.State) {
 			}
 
 			// and add its nearest existing ancestor.
-			err = deviceInotifyAddClosestLivingAncestor(s, cleanDevPath)
+			err = deviceInotifyAddClosestLivingAncestor(s, filepath.Dir(cleanDevPath))
 			if err != nil {
-				logger.Errorf("Failed to add \"%s\" to inotify targets: %s", cleanDevPath, err)
+				logger.Errorf("Failed to add \"%s\" to inotify targets: %s", filepath.Dir(cleanDevPath), err)
 			} else {
-				logger.Debugf("Added \"%s\" to inotify targets", cleanDevPath)
+				logger.Debugf("Added \"%s\" to inotify targets", filepath.Dir(cleanDevPath))
 			}
 		}
 	}


More information about the lxc-devel mailing list