71 lines
2.0 KiB
Diff
71 lines
2.0 KiB
Diff
|
|
From ca1c7f86ddadd194c2347e2ccd6b216f1403e273 Mon Sep 17 00:00:00 2001
|
||
|
|
From: LiFeng <lifeng68@huawei.com>
|
||
|
|
Date: Wed, 3 Apr 2019 23:36:04 -0400
|
||
|
|
Subject: [PATCH 078/122] Run pre-start hook before chroot
|
||
|
|
|
||
|
|
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
|
||
|
|
index 58fc059..a9421c5 100644
|
||
|
|
--- 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
|
||
|
|
index ae92c13..10f922d 100644
|
||
|
|
--- 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
|
||
|
|
index 5c0fb34..787911d 100644
|
||
|
|
--- 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,
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|