[lxc-devel] [lxcfs/master] Fix lxcfs mount handling with newer lxc
stgraber on Github
lxc-bot at linuxcontainers.org
Sat Mar 19 03:26:02 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160319/ae672535/attachment.bin>
-------------- next part --------------
From 77171c86c5a542c35912d937e4a50a75d2328ab4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 18 Mar 2016 23:23:17 -0400
Subject: [PATCH] Fix lxcfs mount handling with newer lxc
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>
---
share/lxc.mount.hook.in | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/share/lxc.mount.hook.in b/share/lxc.mount.hook.in
index 9ef1b91..89e06b0 100755
--- a/share/lxc.mount.hook.in
+++ b/share/lxc.mount.hook.in
@@ -28,18 +28,36 @@ fi
# /sys/fs/cgroup files
if [ -d "${LXC_ROOTFS_MOUNT}/sys/fs/cgroup" ]; then
if [ -d @LXCFSTARGETDIR@/cgroup ]; then
- for entry in @LXCFSTARGETDIR@/cgroup/*; do
+ # Cleanup existing mounts
+ for entry in ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/*; do
DEST=$(basename $entry)
- if [ "$DEST" = "name=systemd" ]; then
- DEST="systemd"
+
+ if [ "${DEST}" = "cgmanager" ]; then
+ continue
fi
- if mountpoint -q ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/$DEST; then
+ if [ ! -d "${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST}" ]; then
continue
fi
- if [ ! -d ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/$DEST ]; then
- mkdir ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/$DEST
+ while grep "${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST}" /proc/self/mountinfo; do
+ grep "${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST}" /proc/self/mountinfo | cut -d' ' -f5 | while read line; do
+ mountpoint -q ${line} && umount -l ${line} || true
+ done
+ done
+
+ rm -Rf ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST}
+ done
+
+ # Mount the new entries
+ for entry in @LXCFSTARGETDIR@/cgroup/*; do
+ DEST=$(basename $entry)
+ if [ "$DEST" = "name=systemd" ]; then
+ DEST="systemd"
+ fi
+
+ if [ ! -d ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST} ]; then
+ mkdir ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST}
fi
mount -n --bind $entry ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/$DEST
More information about the lxc-devel
mailing list