[lxc-devel] [lxd/master] Disregard block devices in /dev subdirectories

erikmack on Github lxc-bot at linuxcontainers.org
Wed Feb 3 04:25:23 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 859 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160203/48441156/attachment.bin>
-------------- next part --------------
From 1eb02a9ca48b5eb7fa2b87789d15f03fccaa26e1 Mon Sep 17 00:00:00 2001
From: Erik Mackdanz <erikmack at gmail.com>
Date: Tue, 2 Feb 2016 22:08:03 -0600
Subject: [PATCH] Disregard block devices in /dev subdirectories

... instead of failing the action entirely.

My root disk is mounted on /dev/mapper/root, note the unexpected
subdirectory.  Without the continue clause, 'lxc init' fails with the
"Disk is missing /sys/class/block entry" error since there is no
/sys/class/block/mapper/root.  Also 'lxc list' fails silently (displays
a table with a header but no containers).

Since a device node with the same major:minor is also at /dev/dm-0, it's
valid to simply ignore the identical node at /dev/mapper/root

Signed-off by: Erik Mackdanz <stasibear at gentoo.org>
---
 lxd/container_lxc.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index fa0dd31..89345c9 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -3509,8 +3509,13 @@ func (c *containerLXC) getDiskLimits() (map[string]deviceBlockLimit, error) {
 
 		for _, block := range blocks {
 			dev := strings.TrimPrefix(block, "/dev/")
+
+			if strings.Contains(dev,"/") {
+			   continue
+			}
+
 			if !shared.PathExists(fmt.Sprintf("/sys/class/block/%s/dev", dev)) {
-				return nil, fmt.Errorf("Disk is missing /sys/class/block entry")
+				return nil, fmt.Errorf("Disk %s is missing /sys/class/block entry", dev)
 			}
 
 			block, err := ioutil.ReadFile(fmt.Sprintf("/sys/class/block/%s/dev", dev))


More information about the lxc-devel mailing list