[lxc-devel] [lxd/master] container_lxc: check whether disk device exists

brauner on Github lxc-bot at linuxcontainers.org
Tue Jun 27 22:27:18 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 489 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170627/a70cbcf4/attachment.bin>
-------------- next part --------------
From 1ff86640f45f5737a220e28b4558964d41e7034a Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 28 Jun 2017 00:20:54 +0200
Subject: [PATCH] container_lxc: check whether disk device exists

We should check whether the disk device exists under the containers disk device
entries and only then try to forkumount.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/container_lxc.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index a44660b0d..3e104185d 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -6299,6 +6299,11 @@ func (c *containerLXC) removeDiskDevice(name string, m types.Device) error {
 	devName := fmt.Sprintf("disk.%s", strings.Replace(tgtPath, "/", "-", -1))
 	devPath := filepath.Join(c.DevicesPath(), devName)
 
+	// The dsk device doesn't exist and cannot be mounted.
+	if !shared.PathExists(devPath) {
+		return nil
+	}
+
 	// Remove the bind-mount from the container
 	if c.FileExists(tgtPath) == nil {
 		err := c.removeMount(m["path"])


More information about the lxc-devel mailing list