[lxc-devel] [lxd/master] lxd/containers: Fix removing NVIDIA containers

stgraber on Github lxc-bot at linuxcontainers.org
Wed Jun 27 19:07:55 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180627/c9fafb2b/attachment.bin>
-------------- next part --------------
From 93c3132659ce5d150fb826f488174d20db5e3b5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 27 Jun 2018 15:06:42 -0400
Subject: [PATCH] lxd/containers: Fix removing NVIDIA containers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4683

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container.go     | 13 +++++++++++--
 lxd/container_lxc.go |  4 ----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lxd/container.go b/lxd/container.go
index 2143136d0..7079086d1 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -439,8 +439,17 @@ func containerValidDevices(db *db.Cluster, devices types.Devices, profile bool,
 				return fmt.Errorf("Missing vendorid for USB device.")
 			}
 		} else if m["type"] == "gpu" {
-			// Probably no checks needed, since we allow users to
-			// pass in all GPUs.
+			if m["pci"] != "" && !shared.PathExists(fmt.Sprintf("/sys/bus/pci/devices/%s", m["pci"])) {
+				return fmt.Errorf("Invalid PCI address (no device found): %s", m["pci"])
+			}
+
+			if m["pci"] != "" && (m["id"] != "" || m["productid"] != "" || m["vendorid"] != "") {
+				return fmt.Errorf("Cannot use id, productid or vendorid when pci is set")
+			}
+
+			if m["id"] != "" && (m["pci"] != "" || m["productid"] != "" || m["vendorid"] != "") {
+				return fmt.Errorf("Cannot use pci, productid or vendorid when id is set")
+			}
 		} else if m["type"] == "proxy" {
 			if m["listen"] == "" {
 				return fmt.Errorf("Proxy device entry is missing the required \"listen\" property.")
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 4284e3a55..93bd6aa41 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -4374,10 +4374,6 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 							nvidiaExists = true
 							break
 						}
-					} else if !allGpus {
-						errMsg := fmt.Errorf("Failed to detect correct \"/dev/nvidia\" path")
-						logger.Errorf("%s", errMsg)
-						return errMsg
 					}
 				}
 


More information about the lxc-devel mailing list