[Devel] [PATCH 3/8] vzctl: transfer vps_res in env_stop

Andrey Vagin avagin at openvz.org
Wed May 15 09:10:48 PDT 2013


It will be used to unlink a state file

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/types.h    |  3 ++-
 src/lib/env.c      | 18 +++++++++---------
 src/lib/hooks_ct.c |  4 ++--
 src/lib/hooks_vz.c |  2 +-
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/include/types.h b/include/types.h
index 79e22ca..150b756 100644
--- a/include/types.h
+++ b/include/types.h
@@ -90,6 +90,7 @@ struct dev_res;
 struct cpu_param;
 struct veth_dev;
 struct meminfo_param;
+struct vps_res;
 
 /** CT handler.
  */
@@ -99,7 +100,7 @@ typedef struct vps_handler {
 	int can_join_pidns; /* can't enter otherwise */
 	int (*is_run)(struct vps_handler *h, envid_t veid);
 	int (*enter)(struct vps_handler *h, envid_t veid, const char *root, int flags);
-	int (*destroy)(struct vps_handler *h, envid_t veid);
+	int (*destroy)(struct vps_handler *h, envid_t veid, const struct vps_res *res);
 	int (*env_create)(struct arg_start *arg);
 	int (*setlimits)(struct vps_handler *h, envid_t, struct ub_struct *ub);
 	int (*setcpus)(struct vps_handler *h, envid_t, struct cpu_param *cpu);
diff --git a/src/lib/env.c b/src/lib/env.c
index 7e9a923..1cf94a1 100644
--- a/src/lib/env.c
+++ b/src/lib/env.c
@@ -45,7 +45,7 @@
 #include "image.h"
 #include "readelf.h"
 
-static int env_stop(vps_handler *h, envid_t veid, const char *root,
+static int env_stop(vps_handler *h, envid_t veid, const vps_res *res,
 		int stop_mode);
 
 /*
@@ -687,7 +687,7 @@ err:
 	}
 	if (ret) {
 		if (vps_is_run(h, veid))
-			env_stop(h, veid, res->fs.root, M_KILL);
+			env_stop(h, veid, res, M_KILL);
 		/* restore original quota values */
 		if (!ploop)
 			vps_set_quota(veid, &res->dq);
@@ -738,7 +738,7 @@ int vps_start(vps_handler *h, envid_t veid, vps_param *param,
 	return ret;
 }
 
-static int real_env_stop(vps_handler *h, envid_t veid, const char *vps_root,
+static int real_env_stop(vps_handler *h, envid_t veid, const vps_res *res,
 	int stop_mode)
 {
 	int ret;
@@ -746,7 +746,7 @@ static int real_env_stop(vps_handler *h, envid_t veid, const char *vps_root,
 	if ((ret = h->setcontext(veid)))
 		return ret;
 	close_fds(1, h->vzfd, -1);
-	ret = h->enter(h, veid, vps_root, 0);
+	ret = h->enter(h, veid, res->fs.root, 0);
 	if (ret == VZ_VE_NOT_RUNNING)
 		/* Ignore "VE not running" error here */
 		return 0;
@@ -809,7 +809,7 @@ static int wait_child(int pid, int ignore_kill)
 	return ret;
 }
 
-static int env_stop(vps_handler *h, envid_t veid, const char *root,
+static int env_stop(vps_handler *h, envid_t veid, const vps_res *res,
 		int stop_mode)
 {
 	int i, pid, ret, tout = 0;
@@ -832,7 +832,7 @@ static int env_stop(vps_handler *h, envid_t veid, const char *root,
 		ret = VZ_RESOURCE_ERROR;
 		goto out;
 	} else if (pid == 0) {
-		ret = real_env_stop(h, veid, root, stop_mode);
+		ret = real_env_stop(h, veid, res, stop_mode);
 		exit(ret);
 	}
 	if (wait_child(pid, 0)) /* reboot/halt failed, retry with kill */
@@ -848,7 +848,7 @@ static int env_stop(vps_handler *h, envid_t veid, const char *root,
 
 kill_vps:
 	logger(0, 0, "Killing container ...");
-	ret = h->destroy(h, veid);
+	ret = h->destroy(h, veid, res);
 	if (!is_vz_kernel(h))
 		goto wait;
 
@@ -858,7 +858,7 @@ kill_vps:
 		goto out;
 
 	} else if (pid == 0) {
-		ret = real_env_stop(h, veid, root, M_KILL);
+		ret = real_env_stop(h, veid, res, M_KILL);
 		exit(ret);
 	}
 	ret = wait_child(pid, 1);
@@ -924,7 +924,7 @@ int vps_stop(vps_handler *h, envid_t veid, vps_param *param, int stop_mode,
 	if (is_vz_kernel(h))
 		get_vps_ip(h, veid, &param->del_res.net.ip);
 
-	if ((ret = env_stop(h, veid, res->fs.root, stop_mode)))
+	if ((ret = env_stop(h, veid, res, stop_mode)))
 		goto end;
 
 	mod_cleanup(h, veid, action, param);
diff --git a/src/lib/hooks_ct.c b/src/lib/hooks_ct.c
index 184c26a..0d4e439 100644
--- a/src/lib/hooks_ct.c
+++ b/src/lib/hooks_ct.c
@@ -75,7 +75,7 @@ static int ct_is_run(vps_handler *h, envid_t veid)
 	return container_is_running(veid);
 }
 
-static int ct_destroy(vps_handler *h, envid_t veid)
+static int ct_destroy(vps_handler *h, envid_t veid, const vps_res *res)
 {
 	char ctpath[STR_SIZE];
 	int ret;
@@ -269,7 +269,7 @@ int ct_env_create(struct arg_start *arg)
 	char ctpath[STR_SIZE];
 
 	/* non-fatal */
-	if ((ret = ct_destroy(arg->h, arg->veid)))
+	if ((ret = ct_destroy(arg->h, arg->veid, arg->res)))
 		logger(0, 0, "Could not properly cleanup container: %s",
 			container_error(ret));
 
diff --git a/src/lib/hooks_vz.c b/src/lib/hooks_vz.c
index afbcd0f..9f3c401 100644
--- a/src/lib/hooks_vz.c
+++ b/src/lib/hooks_vz.c
@@ -94,7 +94,7 @@ static int vz_enter(vps_handler *h, envid_t veid, const char *root, int flags)
 	return ret;
 }
 
-static int vz_destroy(vps_handler *h, envid_t veid)
+static int vz_destroy(vps_handler *h, envid_t veid, const vps_res *res)
 {
 	/* Destroys automatically after reboot */
 	return 0;
-- 
1.8.2




More information about the Devel mailing list