[lxc-devel] [lxd/master] Fix LXD forkmount with liblxc 3.1

stgraber on Github lxc-bot at linuxcontainers.org
Mon Dec 17 04:52:35 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181217/31c290a8/attachment.bin>
-------------- next part --------------
From d18d1be0979fa30bf3f6f43f1f383bd2cbaf937f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 16 Dec 2018 23:49:10 -0500
Subject: [PATCH 1/2] lxd/forkmount: Fix version detection
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/main_forkmount.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxd/main_forkmount.go b/lxd/main_forkmount.go
index d324bbdcef..1360b7de72 100644
--- a/lxd/main_forkmount.go
+++ b/lxd/main_forkmount.go
@@ -14,6 +14,7 @@ import (
 #include <libgen.h>
 #include <limits.h>
 #include <lxc/lxccontainer.h>
+#include <lxc/version.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>

From b9968b09eb2f771129c6881f58074a30cc32bf6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 16 Dec 2018 23:49:57 -0500
Subject: [PATCH 2/2] lxd/containers: Handle projects in forkmount
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 852c4618dd..2e2ececb0a 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -6410,12 +6410,13 @@ func (c *containerLXC) insertMount(source, target, fstype string, flags int) err
 	}
 
 	if lxc.HasApiExtension("mount_injection") {
+		cname := projectPrefix(c.Project(), c.Name())
 		configPath := filepath.Join(c.LogPath(), "lxc.conf")
 		if fstype == "" {
 			fstype = "none"
 		}
 
-		_, err := shared.RunCommand(c.state.OS.ExecPath, "forkmount", "lxc-mount", c.Name(), c.state.OS.LxcPath, configPath, source, target, fstype, fmt.Sprintf("%d", flags))
+		_, err := shared.RunCommand(c.state.OS.ExecPath, "forkmount", "lxc-mount", cname, c.state.OS.LxcPath, configPath, source, target, fstype, fmt.Sprintf("%d", flags))
 		if err != nil {
 			return err
 		}
@@ -6474,12 +6475,12 @@ func (c *containerLXC) removeMount(mount string) error {
 
 	if lxc.HasApiExtension("mount_injection") {
 		configPath := filepath.Join(c.LogPath(), "lxc.conf")
-		_, err := shared.RunCommand(c.state.OS.ExecPath, "forkmount", "lxc-umount", c.Name(), c.state.OS.LxcPath, configPath, mount)
+		cname := projectPrefix(c.Project(), c.Name())
+		_, err := shared.RunCommand(c.state.OS.ExecPath, "forkmount", "lxc-umount", cname, c.state.OS.LxcPath, configPath, mount)
 		if err != nil {
 			return err
 		}
 	} else {
-
 		// Remove the mount from the container
 		pidStr := fmt.Sprintf("%d", pid)
 		out, err := shared.RunCommand(c.state.OS.ExecPath, "forkmount", "lxd-umount", pidStr, mount)


More information about the lxc-devel mailing list