[CRIU] [PATCH 5/8] vzctl: transfer vps_res in vps_chkpnt and vps_restore
Andrey Vagin
avagin at openvz.org
Wed May 15 12:10:50 EDT 2013
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
include/cpt.h | 2 +-
include/env.h | 2 +-
include/snapshot.h | 4 ++--
src/lib/cpt.c | 6 +++---
src/lib/hooks_vz.c | 2 +-
src/snapshot.c | 13 ++++++++-----
src/vzctl-actions.c | 6 +++---
7 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/include/cpt.h b/include/cpt.h
index 013dbbd..191162b 100644
--- a/include/cpt.h
+++ b/include/cpt.h
@@ -17,7 +17,7 @@
int cpt_cmd(vps_handler *h, envid_t veid, const char *root,
int action, int cmd, unsigned int ctx);
-int vps_chkpnt(vps_handler *h, envid_t veid, const fs_param *fs,
+int vps_chkpnt(vps_handler *h, envid_t veid, const vps_res *res,
int cmd, cpt_param *param);
int vps_restore(vps_handler *h, envid_t veid, struct vps_param *vps_p, int cmd,
cpt_param *param, skipFlags skip);
diff --git a/include/env.h b/include/env.h
index 1628bbf..6f7aaf5 100644
--- a/include/env.h
+++ b/include/env.h
@@ -34,7 +34,7 @@
-typedef int (*env_create_FN)(vps_handler *h, envid_t veid, int wait_p,
+typedef int (*env_create_FN)(vps_handler *h, envid_t veid, vps_res *res, int wait_p,
int old_wait_p, int err_p, void *data);
/** Stop modes.
diff --git a/include/snapshot.h b/include/snapshot.h
index f3feab4..9ac4e02 100644
--- a/include/snapshot.h
+++ b/include/snapshot.h
@@ -46,11 +46,11 @@ int vzctl_store_snapshot_tree(const char *fname, struct vzctl_snapshot_tree *tre
/* src/snapshot.c */
int is_snapshot_supported(const char *ve_private);
-int vzctl_env_create_snapshot(vps_handler *h, envid_t veid, const fs_param *fs,
+int vzctl_env_create_snapshot(vps_handler *h, envid_t veid, const vps_res *res,
const struct vzctl_snapshot_param *param);
int vzctl_env_switch_snapshot(vps_handler *h, envid_t veid, vps_param *g_p,
- const fs_param *fs, const char *guid);
+ const char *guid);
int vzctl_env_delete_snapshot(vps_handler *h, envid_t veid, const fs_param *fs,
const char *guid);
diff --git a/src/lib/cpt.c b/src/lib/cpt.c
index 362c646..5501d92 100644
--- a/src/lib/cpt.c
+++ b/src/lib/cpt.c
@@ -197,14 +197,14 @@ do { \
} \
} while (0)
-int vps_chkpnt(vps_handler *h, envid_t veid, const fs_param *fs,
+int vps_chkpnt(vps_handler *h, envid_t veid, const vps_res *res,
int cmd, cpt_param *param)
{
int dump_fd = -1;
char buf[PATH_LEN];
const char *dumpfile = NULL;
int cpt_fd, pid, ret;
- const char *root = fs->root;
+ const char *root = res->fs.root;
ret = VZ_CHKPNT_ERROR;
if (root == NULL) {
@@ -303,7 +303,7 @@ err:
return ret;
}
-static int restore_fn(vps_handler *h, envid_t veid, int wait_p,
+static int restore_fn(vps_handler *h, envid_t veid, vps_res *res, int wait_p,
int old_wait_p, int err_p, void *data)
{
int status, len, len1, ret;
diff --git a/src/lib/hooks_vz.c b/src/lib/hooks_vz.c
index 9f3c401..f358f59 100644
--- a/src/lib/hooks_vz.c
+++ b/src/lib/hooks_vz.c
@@ -255,7 +255,7 @@ static int vz_do_env_create(struct arg_start *arg)
if (fn == NULL) {
ret = _env_create(h, (void *)arg);
} else {
- ret = fn(h, veid, wait_p, old_wait_p, err_p, data);
+ ret = fn(h, veid, res, wait_p, old_wait_p, err_p, data);
}
env_err:
if (ret)
diff --git a/src/snapshot.c b/src/snapshot.c
index 675b2c8..3ea0ea9 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -59,7 +59,7 @@ int is_snapshot_supported(const char *ve_private)
}
int vzctl_env_create_snapshot(vps_handler *h, envid_t veid,
- const fs_param *fs,
+ const vps_res *res,
const struct vzctl_snapshot_param *param)
{
int ret, run = 0;
@@ -72,6 +72,7 @@ int vzctl_env_create_snapshot(vps_handler *h, envid_t veid,
struct ploop_merge_param merge_param = {};
struct ploop_disk_images_data *di = NULL;
struct vzctl_snapshot_tree *tree = NULL;
+ const fs_param *fs = &res->fs;
if (!is_snapshot_supported(fs->private))
return VZCTL_E_CREATE_SNAPSHOT;
@@ -121,7 +122,7 @@ int vzctl_env_create_snapshot(vps_handler *h, envid_t veid,
run = vps_is_run(h, veid);
/* 1 freeze */
if (run) {
- ret = vps_chkpnt(h, veid, fs, CMD_SUSPEND, &cpt);
+ ret = vps_chkpnt(h, veid, res, CMD_SUSPEND, &cpt);
if (ret)
goto err1;
}
@@ -137,7 +138,7 @@ int vzctl_env_create_snapshot(vps_handler *h, envid_t veid,
if (run) {
vzctl_get_snapshot_dumpfile(fs->private, guid, fname, sizeof(fname));
cpt.dumpfile = fname;
- ret = vps_chkpnt(h, veid, fs, CMD_DUMP, &cpt);
+ ret = vps_chkpnt(h, veid, res, CMD_DUMP, &cpt);
if (ret)
goto err2;
if (cpt_cmd(h, veid, fs->root, CMD_CHKPNT, CMD_RESUME, 0))
@@ -179,7 +180,7 @@ out:
}
int vzctl_env_switch_snapshot(vps_handler *h, envid_t veid,
- vps_param *g_p, const fs_param *fs, const char *guid)
+ vps_param *g_p, const char *guid)
{
int ret, run;
int flags = 0;
@@ -192,6 +193,8 @@ int vzctl_env_switch_snapshot(vps_handler *h, envid_t veid,
char dumpfile[PATH_MAX];
struct vzctl_snapshot_tree *tree = NULL;
struct ploop_disk_images_data *di = NULL;
+ const vps_res *res = &g_p->res;
+ const fs_param *fs = &res->fs;
if (!is_snapshot_supported(fs->private))
return VZCTL_E_SWITCH_SNAPSHOT;
@@ -237,7 +240,7 @@ int vzctl_env_switch_snapshot(vps_handler *h, envid_t veid,
flags = PLOOP_SNAP_SKIP_TOPDELTA_DESTROY;
if (ploop.get_top_delta_fname(di, topdelta_fname, sizeof(topdelta_fname)))
goto err1;
- ret = vps_chkpnt(h, veid, fs, CMD_SUSPEND, &cpt);
+ ret = vps_chkpnt(h, veid, res, CMD_SUSPEND, &cpt);
if (ret)
goto err1;
} else if (vps_is_mounted(fs->root, fs->private)) {
diff --git a/src/vzctl-actions.c b/src/vzctl-actions.c
index e0cd261..284c009 100644
--- a/src/vzctl-actions.c
+++ b/src/vzctl-actions.c
@@ -1297,7 +1297,7 @@ static int chkpnt(vps_handler *h, envid_t veid, vps_param *g_p, vps_param *cmd_p
return 0;
}
- ret = vps_chkpnt(h, veid, &g_p->res.fs, cmd, &cmd_p->res.cpt);
+ ret = vps_chkpnt(h, veid, &g_p->res, cmd, &cmd_p->res.cpt);
if (ret)
return ret;
if (cmd == CMD_CHKPNT || cmd == CMD_DUMP) {
@@ -1605,14 +1605,14 @@ int run_action(envid_t veid, act_t action, vps_param *g_p, vps_param *vps_p,
#ifdef HAVE_PLOOP
case ACTION_SNAPSHOT_CREATE:
ret = vzctl_env_create_snapshot(h, veid,
- &g_p->res.fs, &cmd_p->snap);
+ &g_p->res, &cmd_p->snap);
break;
case ACTION_SNAPSHOT_DELETE:
ret = vzctl_env_delete_snapshot(h, veid,
&g_p->res.fs, cmd_p->snap.guid);
break;
case ACTION_SNAPSHOT_SWITCH:
- ret = vzctl_env_switch_snapshot(h, veid, g_p, &g_p->res.fs,
+ ret = vzctl_env_switch_snapshot(h, veid, g_p,
cmd_p->snap.guid);
break;
case ACTION_SNAPSHOT_LIST:
--
1.8.2
More information about the CRIU
mailing list