rootfs: support use host rootfs / as container roofs
Signed-off-by: lifeng68 <lifeng68@huawei.com>
This commit is contained in:
parent
063e981382
commit
9364d2f6e3
@ -0,0 +1,41 @@
|
|||||||
|
From 25a47f44f377e20b2939679f7df79c333627c97a Mon Sep 17 00:00:00 2001
|
||||||
|
From: lifeng68 <lifeng68@huawei.com>
|
||||||
|
Date: Wed, 24 Jun 2020 17:07:50 +0800
|
||||||
|
Subject: [PATCH] rootfs: support use host rootfs / as container rootfs
|
||||||
|
|
||||||
|
Signed-off-by: lifeng68 <lifeng68@huawei.com>
|
||||||
|
---
|
||||||
|
src/lxc/conf.c | 10 +++++++++-
|
||||||
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
|
||||||
|
index 6890da12..0744c19b 100644
|
||||||
|
--- a/src/lxc/conf.c
|
||||||
|
+++ b/src/lxc/conf.c
|
||||||
|
@@ -1367,7 +1367,7 @@ static int lxc_mount_rootfs(struct lxc_conf *conf)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct lxc_storage *bdev;
|
||||||
|
- const struct lxc_rootfs *rootfs = &conf->rootfs;
|
||||||
|
+ struct lxc_rootfs *rootfs = &conf->rootfs;
|
||||||
|
|
||||||
|
#ifdef HAVE_ISULAD
|
||||||
|
unsigned long flags, mntflags, pflags;
|
||||||
|
@@ -1378,6 +1378,14 @@ static int lxc_mount_rootfs(struct lxc_conf *conf)
|
||||||
|
ret = mount("", "/", NULL, MS_SLAVE | MS_REC, 0);
|
||||||
|
if (ret < 0)
|
||||||
|
return log_error_errno(-1, errno, "Failed to remount \"/\" MS_REC | MS_SLAVE");
|
||||||
|
+#ifdef HAVE_ISULAD
|
||||||
|
+ if (!access(rootfs->mount, F_OK)) {
|
||||||
|
+ rootfs->path = safe_strdup("/");
|
||||||
|
+ if (mount("/", rootfs->mount, NULL, MS_BIND, 0)) {
|
||||||
|
+ return log_error_errno(-1, errno, "Failed to mount \"/\" to %s", rootfs->mount);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
3
lxc.spec
3
lxc.spec
@ -1,4 +1,4 @@
|
|||||||
%global _release 2020052701
|
%global _release 2020062401
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
|
|
||||||
Name: lxc
|
Name: lxc
|
||||||
@ -76,6 +76,7 @@ Patch9064: 0065-lxc-disable-terminal-stdout-stderr-pipe-O_NONBLOCK.patch
|
|||||||
Patch9065: 0066-lxc-fix-tests-build-error.patch
|
Patch9065: 0066-lxc-fix-tests-build-error.patch
|
||||||
Patch9066: 0067-set-normal-ret-value-when-populate-exist-device-successfully.patch
|
Patch9066: 0067-set-normal-ret-value-when-populate-exist-device-successfully.patch
|
||||||
Patch9067: 0068-lxc-config-default-cgroup-pattern-to-lxc-n.patch
|
Patch9067: 0068-lxc-config-default-cgroup-pattern-to-lxc-n.patch
|
||||||
|
Patch9068: 0069-rootfs-support-use-host-rootfs-as-container-rootfs.patch
|
||||||
|
|
||||||
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
|
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
|
||||||
BuildRequires: pkgconfig(libseccomp)
|
BuildRequires: pkgconfig(libseccomp)
|
||||||
|
|||||||
@ -66,3 +66,4 @@
|
|||||||
0066-lxc-fix-tests-build-error.patch
|
0066-lxc-fix-tests-build-error.patch
|
||||||
0067-set-normal-ret-value-when-populate-exist-device-successfully.patch
|
0067-set-normal-ret-value-when-populate-exist-device-successfully.patch
|
||||||
0068-lxc-config-default-cgroup-pattern-to-lxc-n.patch
|
0068-lxc-config-default-cgroup-pattern-to-lxc-n.patch
|
||||||
|
0069-rootfs-support-use-host-rootfs-as-container-rootfs.patch
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user