diff --git a/0069-rootfs-support-use-host-rootfs-as-container-rootfs.patch b/0069-rootfs-support-use-host-rootfs-as-container-rootfs.patch new file mode 100644 index 0000000000000000000000000000000000000000..2bb91d0624dd45c9f60608ad18d038a083c7b652 --- /dev/null +++ b/0069-rootfs-support-use-host-rootfs-as-container-rootfs.patch @@ -0,0 +1,41 @@ +From 25a47f44f377e20b2939679f7df79c333627c97a Mon Sep 17 00:00:00 2001 +From: lifeng68 +Date: Wed, 24 Jun 2020 17:07:50 +0800 +Subject: [PATCH] rootfs: support use host rootfs / as container rootfs + +Signed-off-by: lifeng68 +--- + 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 + diff --git a/lxc.spec b/lxc.spec index 62c04072730e9d871240fadc3b27e5adcb8bfd88..3acb0605df81eb353b9b44040afdfb3dad67f911 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 2020052701 +%global _release 2020062401 %global debug_package %{nil} 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 Patch9066: 0067-set-normal-ret-value-when-populate-exist-device-successfully.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: pkgconfig(libseccomp) diff --git a/series.conf b/series.conf index f5d846b17db72e898b9717f15215910a31179dcb..a45ea58eeabcd6bc78a5aa661e12a0c9555f35d7 100644 --- a/series.conf +++ b/series.conf @@ -66,3 +66,4 @@ 0066-lxc-fix-tests-build-error.patch 0067-set-normal-ret-value-when-populate-exist-device-successfully.patch 0068-lxc-config-default-cgroup-pattern-to-lxc-n.patch +0069-rootfs-support-use-host-rootfs-as-container-rootfs.patch