[Devel] [PATCH v3 3/9] pass parameters to open
Glauber Costa
glommer at openvz.org
Mon Apr 29 22:16:25 PDT 2013
Upstream containers running on kernels that support user namespaces would
benefit from being able to have early access to the container configuration.
This is because we would like user namespaces support to be either enabled or
disabled, and a lot of the actions we take can be potentially affected by this
configuration switch.
We do that by bundling it into vz_open, where we traditionally are setting all
the namespace related flags (based solely on the presence of it in the system).
The open handler in hooks_vz technically does not need to be modified. But I am
doing it out of consistency.
Signed-off-by: Glauber Costa <glommer at openvz.org>
---
include/env.h | 6 +++---
src/lib/env.c | 7 ++++---
src/lib/hooks_ct.c | 2 +-
src/lib/hooks_vz.c | 2 +-
src/vzctl-actions.c | 2 +-
5 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/include/env.h b/include/env.h
index 1628bbf..06729f6 100644
--- a/include/env.h
+++ b/include/env.h
@@ -50,7 +50,7 @@ enum {
* @param veid CT ID.
* @return handler or NULL on error.
*/
-vps_handler *vz_open(envid_t veid);
+vps_handler *vz_open(envid_t veid, vps_param *param);
/** Close CT handler.
*
@@ -125,6 +125,6 @@ int exec_container_init(struct arg_start *arg,
struct env_create_param3 *create_param);
int set_personality32();
-int vz_do_open(vps_handler *h);
-int ct_do_open(vps_handler *h);
+int vz_do_open(vps_handler *h, vps_param *param);
+int ct_do_open(vps_handler *h, vps_param *param);
#endif
diff --git a/src/lib/env.c b/src/lib/env.c
index 7e9a923..898bfc8 100644
--- a/src/lib/env.c
+++ b/src/lib/env.c
@@ -72,9 +72,10 @@ static int reset_std()
/** Allocate and initialize CT handler.
*
* @param veid CT ID.
+ * @param param CT parameters.
* @return handler or NULL on error.
*/
-vps_handler *vz_open(envid_t veid)
+vps_handler *vz_open(envid_t veid, vps_param *param)
{
vps_handler *h = NULL;
int ret = -1;
@@ -88,7 +89,7 @@ vps_handler *vz_open(envid_t veid)
#ifdef VZ_KERNEL_SUPPORTED
/* Find out if we are under OpenVZ or upstream kernel */
if (stat_file("/proc/vz"))
- ret = vz_do_open(h);
+ ret = vz_do_open(h, param);
else
#endif
{
@@ -96,7 +97,7 @@ vps_handler *vz_open(envid_t veid)
"non-OpenVZ kernel");
h->vzfd = -1;
#ifdef HAVE_UPSTREAM
- ret = ct_do_open(h);
+ ret = ct_do_open(h, param);
#else
logger(-1, 0, "No suitable kernel support compiled in");
#endif
diff --git a/src/lib/hooks_ct.c b/src/lib/hooks_ct.c
index 3cfb6e9..f24d91e 100644
--- a/src/lib/hooks_ct.c
+++ b/src/lib/hooks_ct.c
@@ -572,7 +572,7 @@ static int ct_setcontext(envid_t veid)
return 0;
}
-int ct_do_open(vps_handler *h)
+int ct_do_open(vps_handler *h, vps_param *param)
{
int ret;
char path[STR_SIZE];
diff --git a/src/lib/hooks_vz.c b/src/lib/hooks_vz.c
index afbcd0f..50770c0 100644
--- a/src/lib/hooks_vz.c
+++ b/src/lib/hooks_vz.c
@@ -466,7 +466,7 @@ static int vz_veth_ctl(vps_handler *h, envid_t veid, int op, veth_dev *dev)
return ret;
}
-int vz_do_open(vps_handler *h)
+int vz_do_open(vps_handler *h, vps_param *param)
{
if ((h->vzfd = open(VZCTLDEV, O_RDWR)) < 0) {
logger(-1, errno, "Unable to open %s", VZCTLDEV);
diff --git a/src/vzctl-actions.c b/src/vzctl-actions.c
index e0cd261..4627043 100644
--- a/src/vzctl-actions.c
+++ b/src/vzctl-actions.c
@@ -1471,7 +1471,7 @@ int run_action(envid_t veid, act_t action, vps_param *g_p, vps_param *vps_p,
int ret = 0, lock_id = -1;
struct sigaction act;
- if ((h = vz_open(veid)) == NULL) {
+ if ((h = vz_open(veid, g_p)) == NULL) {
/* Accept to run "set --save --force" on any kernel,
* otherwise error out if initialization failed
*/
--
1.7.11.7
More information about the Devel
mailing list