lxc/0078-Run-pre-start-hook-before-chroot.patch

71 lines
2.0 KiB
Diff
Raw Normal View History

2019-12-25 15:57:42 +08:00
From 59ee57ce2c6b7d8b3054a2c52657b6667faf868c Mon Sep 17 00:00:00 2001
2019-09-30 11:03:07 -04:00
From: LiFeng <lifeng68@huawei.com>
Date: Wed, 3 Apr 2019 23:36:04 -0400
2019-12-25 15:57:42 +08:00
Subject: [PATCH 078/131] Run pre-start hook before chroot
2019-09-30 11:03:07 -04:00
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
src/lxc/conf.c | 7 +++++++
src/lxc/start.c | 6 ++++++
src/lxc/sync.h | 2 ++
3 files changed, 15 insertions(+)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
2019-12-25 15:57:42 +08:00
index 58fc059c..a9421c5f 100644
2019-09-30 11:03:07 -04:00
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -82,6 +82,7 @@
#include "loop.h"
#include "path.h"
#include "utils.h"
+#include "sync.h"
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
@@ -4186,6 +4187,12 @@ int lxc_setup(struct lxc_handler *handler)
goto on_error;
}
+ /* Ask father to run start host hooks and wait for him to finish. */
+ if (lxc_sync_barrier_parent(handler, LXC_SYNC_START_HOST_HOOK)) {
+ ERROR("Failed to sync parent to start host hook");
+ goto on_error;
+ }
+
ret = lxc_setup_rootfs_switch_root(&lxc_conf->rootfs);
if (ret < 0) {
ERROR("Failed to pivot root into rootfs");
diff --git a/src/lxc/start.c b/src/lxc/start.c
2019-12-25 15:57:42 +08:00
index ae92c133..10f922d0 100644
2019-09-30 11:03:07 -04:00
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -2204,6 +2204,12 @@ static int lxc_spawn(struct lxc_handler *handler)
goto out_delete_net;
}
+ /* Tell the child to continue its initialization. We'll get
+ * LXC_SYNC_CGROUP when it is ready for us to setup cgroups.
+ */
+ if (lxc_sync_barrier_child(handler, LXC_SYNC_POST_START_HOST_HOOK))
+ goto out_delete_net;
+
/* Tell the child to complete its initialization and wait for it to exec
* or return an error. (The child will never return
* LXC_SYNC_READY_START+1. It will either close the sync pipe, causing
diff --git a/src/lxc/sync.h b/src/lxc/sync.h
2019-12-25 15:57:42 +08:00
index 5c0fb343..787911dd 100644
2019-09-30 11:03:07 -04:00
--- a/src/lxc/sync.h
+++ b/src/lxc/sync.h
@@ -31,6 +31,8 @@ enum {
LXC_SYNC_POST_CONFIGURE,
LXC_SYNC_CGROUP,
LXC_SYNC_CGROUP_UNSHARE,
+ LXC_SYNC_START_HOST_HOOK,
+ LXC_SYNC_POST_START_HOST_HOOK,
LXC_SYNC_CGROUP_LIMITS,
LXC_SYNC_READY_START,
LXC_SYNC_RESTART,
--
2019-12-25 15:57:42 +08:00
2.23.0
2019-09-30 11:03:07 -04:00