[Devel] [PATCH 2/2] vz7: Take into account if plain zdtm test in progress
Cyrill Gorcunov
gorcunov at gmail.com
Mon Feb 20 09:49:50 PST 2017
We use ZDTM_RUN env variable to detect if we're running
under plain test load, not container. It's needed to
not do
- unlimiting/limiting beancounters on dump
- enter/exit specific VE on restore
- switch ve on binfmt mounting (which
is virtualized on our kernel)
Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
criu/cr-dump.c | 6 ++++++
criu/cr-restore.c | 3 +++
criu/crtools.c | 8 ++++++++
criu/include/cr_options.h | 2 ++
criu/mount.c | 7 +++++++
5 files changed, 26 insertions(+)
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 6a3597d..3136b9c 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -214,6 +214,9 @@ static void __maybe_unused ve_bc_read(pid_t pid, bc_set_t *bc_set)
char path[PATH_MAX];
int i;
+ if (vz_zdtm_run)
+ return;
+
if (IS_ERR_OR_NULL(veid)) {
pr_err("ubc: Can't fetch VEID of a dumpee %d\n", pid);
return;
@@ -271,6 +274,9 @@ static void __maybe_unused ve_bc_unlimit(bc_set_t *bc_set)
{
int i, j;
+ if (vz_zdtm_run)
+ return;
+
if (!(bc_set->status & VE_BC_STATUS_READ))
return;
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index c3db8bd..ee5846b 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1649,6 +1649,9 @@ static int join_ve(pid_t pid, bool veX)
char buf[PATH_MAX];
char *veid;
+ if (vz_zdtm_run)
+ return 0;
+
if (!may_join_ve) {
if (access(ve0_tasks_path, F_OK)) {
pr_warn_once("ve: Can't access %s, non VZ kernel?\n",
diff --git a/criu/crtools.c b/criu/crtools.c
index ebaf758..787a66d 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -58,6 +58,8 @@
struct cr_options opts;
+bool vz_zdtm_run = false;
+
void init_opts(void)
{
memset(&opts, 0, sizeof(opts));
@@ -77,6 +79,12 @@ void init_opts(void)
opts.ghost_limit = DEFAULT_GHOST_LIMIT;
opts.timeout = DEFAULT_TIMEOUT;
opts.empty_ns = 0;
+
+ /*
+ * When running tests, skip anything
+ * related to container specifics.
+ */
+ vz_zdtm_run = getenv("ZDTM_RUN") ? true : false;
}
static int parse_join_ns(const char *ptr)
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index c2f4b10..b688959 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -123,4 +123,6 @@ extern struct cr_options opts;
extern void init_opts(void);
+extern bool vz_zdtm_run;
+
#endif /* __CR_OPTIONS_H__ */
diff --git a/criu/mount.c b/criu/mount.c
index b3fde9e..16c1928 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1347,6 +1347,9 @@ static __maybe_unused int mount_cr_time_mount(struct ns_id *ns, unsigned int *s_
char buf[PATH_MAX];
char *veid;
+ if (vz_zdtm_run)
+ goto do_mount_no_switch;
+
snprintf(buf, PATH_MAX, "/sys/fs/cgroup/ve/tasks");
ret = ve0_fd = open(buf, O_WRONLY);
if (ret < 0) {
@@ -1380,6 +1383,7 @@ static __maybe_unused int mount_cr_time_mount(struct ns_id *ns, unsigned int *s_
goto out;
}
+do_mount_no_switch:
ret = mount(source, target, type, 0, NULL);
if (ret < 0) {
exit_code = -errno;
@@ -1395,6 +1399,9 @@ static __maybe_unused int mount_cr_time_mount(struct ns_id *ns, unsigned int *s_
}
restore_ns:
+ if (vz_zdtm_run)
+ return ret < 0 ? 0 : exit_code;
+
ret = restore_ns(mnt_fd, &mnt_ns_desc);
out:
if (len > 0 && write(ve0_fd, buf, len) != len) {
--
2.7.4
More information about the Devel
mailing list