[CRIU] [PATCH 7/8] Added --mix-pre-dump option for zdtm suite

Abhishek Dubey dubeyabhishek777 at gmail.com
Thu Oct 3 17:09:24 MSK 2019


Mixing splice and read modes of pre-dump results
in 4 pre-dump combination sequences. This patch
implements zdtm check, for the following
sequences:
    1) splice mode --> splice mode
    2) read mode   --> read mode
    3) splice mode --> read mode
    4) read mode   --> splice mode

New option --mix-pre-dump is added for zdtm suite
only, to test integrity of mixing pre-dump modes.

Signed-off-by: Abhishek Dubey <dubeyabhishek777 at gmail.com>
---
 Documentation/criu.txt |  4 ++++
 test/zdtm.py           | 61 +++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 55 insertions(+), 10 deletions(-)

diff --git a/Documentation/criu.txt b/Documentation/criu.txt
index 2729bc9..1f7e31e 100644
--- a/Documentation/criu.txt
+++ b/Documentation/criu.txt
@@ -162,6 +162,10 @@ In addition, *page-server* options may be specified.
     syscall. The 'read' mode incurs reduced frozen time and reduced
     memory pressure as compared to 'splice' mode. Default is 'splice' mode.
 
+    It is safe to inter-mix SPLICE and READ modes of pre-dump.
+    (Travis test with --mix-pre-dump option checks the integrity of
+     inter-mixing READ and SPLICE modes of pre-dump).
+
 *dump*
 ~~~~~~
 Performs a checkpoint procedure.
diff --git a/test/zdtm.py b/test/zdtm.py
index 7fdb8a3..56ca275 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -1021,6 +1021,7 @@ class criu:
         self.__criu_bin = opts['criu_bin']
         self.__crit_bin = opts['crit_bin']
         self.__pre_dump_mode = opts['pre_dump_mode']
+        self.__mix_pre_dump = bool(opts['mix_pre_dump'])
 
     def fini(self):
         if self.__lazy_migrate:
@@ -1279,6 +1280,13 @@ class criu:
             a_opts += ['--empty-ns', 'net']
         if self.__pre_dump_mode:
             a_opts += ["--pre-dump-mode", "%s" % self.__pre_dump_mode]
+        if self.__mix_pre_dump and action == "pre-dump":
+            if(predump_cnt % 2):
+                print("Mix-mode selected: %s" % pre_dump1)
+                a_opts += ["--pre-dump-mode", pre_dump1]
+            else:
+                print("Mix-mode selected: %s" % pre_dump2)
+                a_opts += ["--pre-dump-mode", pre_dump2]
 
         nowait = False
         if self.__lazy_migrate and action == "dump":
@@ -1428,6 +1436,39 @@ def iter_parm(opt, dflt):
     return (range(0, int(x[0])), float(x[1]))
 
 
+def dmp(cr_api, test, opts, case):
+    global predump_cnt
+    global pre_dump1, pre_dump2
+
+    predump_cnt = 0
+
+    if opts['mix_pre_dump']:
+        if case == 1:
+            pre_dump1="splice"
+            pre_dump2="splice"
+        elif case == 2:
+            pre_dump1="read"
+            pre_dump2="read"
+        elif case == 3:
+            pre_dump1="splice"
+            pre_dump2="read"
+        elif case == 4:
+            pre_dump1="read"
+            pre_dump2="splice"
+
+    pres = iter_parm(opts['pre'], 0)
+    for p in pres[0]:
+        if opts['snaps']:
+            cr_api.dump("dump", opts=["--leave-running", "--track-mem"])
+        else:
+            if opts['mix_pre_dump']:
+                predump_cnt += 1
+            cr_api.dump("pre-dump")
+            try_run_hook(test, ["--post-pre-dump"])
+            test.pre_dump_notify()
+        time.sleep(pres[1])
+
+
 def cr(cr_api, test, opts):
     if opts['nocr']:
         return
@@ -1436,15 +1477,12 @@ def cr(cr_api, test, opts):
 
     iters = iter_parm(opts['iters'], 1)
     for i in iters[0]:
-        pres = iter_parm(opts['pre'], 0)
-        for p in pres[0]:
-            if opts['snaps']:
-                cr_api.dump("dump", opts=["--leave-running", "--track-mem"])
-            else:
-                cr_api.dump("pre-dump")
-                try_run_hook(test, ["--post-pre-dump"])
-                test.pre_dump_notify()
-            time.sleep(pres[1])
+        if opts['mix_pre_dump']:
+            for case in range(1,5):
+                print("===== mix-pre-dump case %d =====" % (case))
+                dmp(cr_api, test, opts, case)
+        else:
+            dmp(cr_api, test, opts, 0)
 
         sbs('pre-dump')
 
@@ -1868,7 +1906,7 @@ class Launcher:
               'sat', 'script', 'rpc', 'lazy_pages', 'join_ns', 'dedup', 'sbs',
               'freezecg', 'user', 'dry_run', 'noauto_dedup',
               'remote_lazy_pages', 'show_stats', 'lazy_migrate', 'remote',
-              'tls', 'criu_bin', 'crit_bin', 'pre_dump_mode')
+              'tls', 'criu_bin', 'crit_bin', 'pre_dump_mode', 'mix_pre_dump')
         arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
 
         if self.__use_log:
@@ -2519,6 +2557,9 @@ rp.add_argument("--pre-dump-mode",
                 help="Use splice or read mode of pre-dumping",
                 choices=['splice', 'read'],
                 default='splice')
+rp.add_argument("--mix-pre-dump",
+                help="mixing splice/read pre-dump modes",
+                action='store_true')
 
 lp = sp.add_parser("list", help="List tests")
 lp.set_defaults(action=list_tests)
-- 
2.7.4



More information about the CRIU mailing list