[CRIU] [PATCH 2/5] p.haul: minor fixups for set_options functions

Nikita Spiridonov nspiridonov at odin.com
Fri Nov 20 08:49:00 PST 2015


Add set_options function to criu_conn to avoid code duplication
and use it from phaul_iter_worker and phaul_service; fix up
phaul_iter_worker.set_options a little furthermore.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 phaul/criu_api.py |   10 ++++------
 phaul/iters.py    |    7 +++----
 phaul/service.py  |    3 +--
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 2da304a..7c87d2d 100644
--- a/phaul/criu_api.py
+++ b/phaul/criu_api.py
@@ -38,6 +38,10 @@ class criu_conn:
 		self._last_req = -1
 		self._mem_fd = mem_sk.fileno()
 
+	def set_options(self, opts):
+		self.verb = opts["verbose"]
+		self._shell_job = opts["shell_job"]
+
 	def close(self):
 		self._cs.close()
 		self._swrk.wait()
@@ -45,9 +49,6 @@ class criu_conn:
 	def mem_sk_fileno(self):
 		return self._mem_fd
 
-	def verbose(self, level):
-		self.verb = level
-
 	def _recv_resp(self):
 		resp = pycriu.rpc.criu_resp()
 		resp.ParseFromString(self._cs.recv(1024))
@@ -81,9 +82,6 @@ class criu_conn:
 	def memory_tracking(self, value):
 		self._track_mem = value
 
-	def shell_job(self, value):
-		self._shell_job = value
-
 
 #
 # Helper to read CRIU-generated statistics
diff --git a/phaul/iters.py b/phaul/iters.py
index 0a7f451..8728e7e 100644
--- a/phaul/iters.py
+++ b/phaul/iters.py
@@ -53,14 +53,13 @@ class phaul_iter_worker:
 		return self.target_host
 
 	def set_options(self, opts):
+		self.__force = opts["force"]
+		self.__pre_dump = opts["pre_dump"]
 		self.target_host.set_options(opts)
-		self.criu_connection.verbose(opts["verbose"])
-		self.criu_connection.shell_job(opts["shell_job"])
+		self.criu_connection.set_options(opts)
 		self.img.set_options(opts)
 		self.htype.set_options(opts)
 		self.fs.set_options(opts)
-		self.__force = opts["force"]
-		self.__pre_dump = opts["pre_dump"]
 
 	def validate_cpu(self):
 		if self.__force:
diff --git a/phaul/service.py b/phaul/service.py
index a51834a..b5ce48f 100644
--- a/phaul/service.py
+++ b/phaul/service.py
@@ -54,8 +54,7 @@ class phaul_service:
 			self.__fs_receiver.start()
 
 	def rpc_set_options(self, opts):
-		self.criu_connection.verbose(opts["verbose"])
-		self.criu_connection.shell_job(opts["shell_job"])
+		self.criu_connection.set_options(opts)
 		self.img.set_options(opts)
 		self.htype.set_options(opts)
 
-- 
1.7.1



More information about the CRIU mailing list