[lxc-devel] [lxd/master] better errors when sanity checking devices

tych0 on Github lxc-bot at linuxcontainers.org
Tue Jul 12 18:34:19 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 435 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160712/0135ffaa/attachment.bin>
-------------- next part --------------
From 0f708ae6e2e04ff5b1beb399bf41c7b6f9a192b3 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Tue, 12 Jul 2016 12:33:32 -0600
Subject: [PATCH] better errors when sanity checking devices

let's always include the path, so it's obvious which device is broken.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/container_lxc.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 7cde497..5d1503b 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -3536,10 +3536,10 @@ func (c *containerLXC) createUnixDevice(name string, m shared.Device) (string, e
 		// If no major and minor are set, use those from the device on the host
 		_, major, minor, err = deviceGetAttributes(srcPath)
 		if err != nil {
-			return "", fmt.Errorf("Failed to get device attributes: %s", err)
+			return "", fmt.Errorf("Failed to get device attributes for %s: %s", m["path"], err)
 		}
 	} else if m["major"] == "" || m["minor"] == "" {
-		return "", fmt.Errorf("Both major and minor must be supplied for devices")
+		return "", fmt.Errorf("Both major and minor must be supplied for device: %s", m["path"])
 	} else {
 		major, err = strconv.Atoi(m["major"])
 		if err != nil {


More information about the lxc-devel mailing list