[CRIU] [PATCH 08/11] p.haul: add start and stop functions to htype

Nikita Spiridonov nspiridonov at virtuozzo.com
Mon Mar 21 09:35:23 PDT 2016


Add to htype start and stop functions needed for migration in restart
mode. Implement start and stop functions for Virtuozzo module.

Signed-off-by: Nikita Spiridonov <nspiridonov at virtuozzo.com>
---
 phaul/p_haul_docker.py |    6 ++++++
 phaul/p_haul_lxc.py    |   12 +++++++++---
 phaul/p_haul_pid.py    |    6 ++++++
 phaul/p_haul_vz.py     |   26 ++++++++++++++++++++++++--
 4 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/phaul/p_haul_docker.py b/phaul/p_haul_docker.py
index e957103..626ebd0 100644
--- a/phaul/p_haul_docker.py
+++ b/phaul/p_haul_docker.py
@@ -66,6 +66,12 @@ class p_haul_type:
 	def umount(self):
 		pass
 
+	def start(self):
+		pass
+
+	def stop(self, umount):
+		pass
+
 	def get_fs(self, fdfs=None):
 		# use rsync for rootfs and configuration directories
 		return fs_haul_subtree.p_haul_fs([self._ct_rootfs, self._ct_config_dir])
diff --git a/phaul/p_haul_lxc.py b/phaul/p_haul_lxc.py
index 4b3d789..5303574 100644
--- a/phaul/p_haul_lxc.py
+++ b/phaul/p_haul_lxc.py
@@ -133,6 +133,15 @@ class p_haul_type:
 		self._fs_mounted = True
 		return nroot
 
+	def umount(self):
+		pass
+
+	def start(self):
+		pass
+
+	def stop(self, umount):
+		pass
+
 	def get_fs(self, fdfs=None):
 		return fs_haul_shared.p_haul_fs()
 
@@ -155,9 +164,6 @@ class p_haul_type:
 	def can_migrate_tcp(self):
 		return True
 
-	def umount(self):
-		pass
-
 	def veths(self):
 		#
 		# Caller wants to see list of tuples with [0] being name
diff --git a/phaul/p_haul_pid.py b/phaul/p_haul_pid.py
index 75dfd26..061a766 100644
--- a/phaul/p_haul_pid.py
+++ b/phaul/p_haul_pid.py
@@ -45,6 +45,12 @@ class p_haul_type:
 	def umount(self):
 		pass
 
+	def start(self):
+		pass
+
+	def stop(self, umount):
+		pass
+
 	# Get driver for FS migration
 	def get_fs(self, fdfs=None):
 		return fs_haul_shared.p_haul_fs()
diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index 70838af..a7dedae 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -191,7 +191,7 @@ class p_haul_type:
 
 	def mount(self):
 		logging.info("Mounting CT root to %s", self._ct_root)
-		logging.info("Starting vzctl mount")
+		logging.info("Running vzctl mount")
 		proc = subprocess.Popen(
 			[vzctl_bin, "--skiplock", "mount", self._ctid],
 			stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -203,7 +203,7 @@ class p_haul_type:
 	def umount(self):
 		if self._fs_mounted:
 			logging.info("Umounting CT root")
-			logging.info("Starting vzctl umount")
+			logging.info("Running vzctl umount")
 			proc = subprocess.Popen(
 				[vzctl_bin, "--skiplock", "umount", self._ctid],
 				stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -211,6 +211,28 @@ class p_haul_type:
 			logging.info(proc_output)
 			self._fs_mounted = False
 
+	def start(self):
+		logging.info("Starting CT")
+		logging.info("Running vzctl start")
+		proc = subprocess.Popen(
+			[vzctl_bin, "--skiplock", "start", self._ctid],
+			stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+		proc_output = proc.communicate()[0]
+		logging.info(proc_output)
+		self._fs_mounted = True
+
+	def stop(self, umount):
+		logging.info("Stopping CT")
+		logging.info("Running vzctl stop")
+		args = [vzctl_bin, "--skiplock", "stop", self._ctid]
+		if not umount:
+			args.append("--skip-umount")
+		proc = subprocess.Popen(
+			args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+		proc_output = proc.communicate()[0]
+		logging.info(proc_output)
+		self._fs_mounted = not umount
+
 	def get_fs(self, fdfs=None):
 		deltas = self.__parse_fdfs_arg(fdfs)
 		return fs_haul_ploop.p_haul_fs(deltas)
-- 
1.7.1



More information about the CRIU mailing list