[CRIU] [PATCH] p.haul: remove obsoleted p_haul_cgroup.py

Nikita Spiridonov nspiridonov at odin.com
Mon Oct 12 12:03:58 PDT 2015


p_haul_cgroup.py no longer needed, remove it.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 phaul/p_haul_cgroup.py |   80 ------------------------------------------------
 phaul/p_haul_lxc.py    |   20 ++----------
 phaul/p_haul_vz.py     |   14 +-------
 3 files changed, 5 insertions(+), 109 deletions(-)
 delete mode 100644 phaul/p_haul_cgroup.py

diff --git a/phaul/p_haul_cgroup.py b/phaul/p_haul_cgroup.py
deleted file mode 100644
index 92e13a4..0000000
--- a/phaul/p_haul_cgroup.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#
-# CGroups manipulations for p.haul.
-#
-# FIXME Isn't it nicer to do it via libcgroup?
-#
-
-import os
-import logging
-
-cg_root_dir = "/sys/fs/cgroup"
-cg_tasks_file = "tasks"
-
-def cg_line_parse(ln):
-	items = ln.split(":")
-	#
-	# If two controllers are merged tigether, we see
-	# their names comma-separated in proc. The problem
-	# is that the respective directory name in sysfsis
-	# (!) IS NOT THE SAME, controller names can go
-	# reversed.
-	#
-	# That said, we just use the first name component,
-	# in sysfs there would the respective symlink
-	#
-	cname = items[1].split(",")[0]
-	cdir = items[2]
-
-	return cname, cdir
-
-def dump_hier(pid, img):
-	logging.info("\tSave CG for %d into %s", pid, img)
-	fd = open(img, "w")
-	cg = open("/proc/%d/cgroup" % pid)
-	for ln in cg:
-		cg_controller, cg_dir = cg_line_parse(ln)
-		if not cg_controller.startswith("name="):
-			fd.write("%s%s" % (cg_controller, cg_dir))
-
-	cg.close()
-	fd.close()
-
-#
-# The cpuset controller is unusable before at least one
-# cpu and memory node is set there. For restore it's OK
-# to copy parent masks into it, at the end we'll apply
-# "real" CT config
-#
-
-def cpuset_copy_parent(path, c):
-	c = "cpuset.%s" % c
-	ppath = os.path.dirname(path)
-	pfd = open(os.path.join(ppath, c))
-	cfd = open(os.path.join(path, c), "w")
-	cfd.write(pfd.read())
-	cfd.close()
-	pfd.close()
-
-def cpuset_allow_all(path):
-	cpuset_copy_parent(path, "cpus")
-	cpuset_copy_parent(path, "mems")
-
-def restore_one_controller(pid, ln):
-	cg_path = os.path.join(cg_root_dir, ln.strip())
-	logging.info("[%s]", cg_path)
-	if not os.access(cg_path, os.F_OK):
-		os.makedirs(cg_path)
-	if ln.startswith("cpuset"):
-		cpuset_allow_all(cg_path)
-
-	tf = open(os.path.join(cg_path, cg_tasks_file), "w")
-	tf.write("%d" % pid)
-	tf.close()
-
-def restore_hier(pid, img):
-	logging.info("\tCreate hier for %d from %s", pid, img)
-	fd = open(img)
-	for ln in fd:
-		restore_one_controller(pid, ln)
-	fd.close()
-	pass
diff --git a/phaul/p_haul_lxc.py b/phaul/p_haul_lxc.py
index 47e9353..01db59a 100644
--- a/phaul/p_haul_lxc.py
+++ b/phaul/p_haul_lxc.py
@@ -5,7 +5,6 @@
 import os
 import shutil
 import logging
-import p_haul_cgroup
 import p_haul_module
 import util
 import fs_haul_shared
@@ -15,7 +14,6 @@ from subprocess import Popen, PIPE
 name = "lxc"
 lxc_dir = "/var/lib/lxc/"
 lxc_rootfs_dir = "/usr/lib64/lxc/rootfs"
-cg_image_name = "lxccg.img"
 
 class p_haul_type:
 	def __init__(self, name):
@@ -107,33 +105,21 @@ class p_haul_type:
 		return os.path.join(lxc_dir, self._ctname, "config")
 
 	#
-	# Meta-images for LXC -- container config and info about CGroups
+	# Meta-images for LXC -- container config
 	#
 	def get_meta_images(self, dir):
-		cg_img = os.path.join(dir, cg_image_name)
-		p_haul_cgroup.dump_hier(self.root_task_pid(), cg_img)
 		cfg_name = self.__ct_config()
-		return [ (cfg_name, "config"),
-			 (cg_img, cg_image_name) ]
+		return [(cfg_name, "config")]
 
 	def put_meta_images(self, dir):
 		logging.info("Putting config file into %s", lxc_dir)
-
 		shutil.copy(os.path.join(dir, "config"), self.__ct_config())
 
-		# Keep this name, we'll need one in prepare_ct()
-		self.cg_img = os.path.join(dir, cg_image_name)
-
 	def final_restore(self, img, connection):
 		p_haul_module.final_restore(self, img, connection)
 
-	#
-	# Create cgroup hierarchy and put root task into it
-	# Hierarchy is unlimited, we will apply config limitations
-	# in ->restored->__apply_cg_config later
-	#
 	def prepare_ct(self, pid):
-		p_haul_cgroup.restore_hier(pid, self.cg_img)
+		pass
 
 	def mount(self):
 		nroot = self.__ct_root()
diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index 7710cde..d8b7667 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -6,7 +6,6 @@ import os
 import subprocess
 import shlex
 import logging
-import p_haul_cgroup
 import p_haul_module
 import util
 import fs_haul_shared
@@ -16,7 +15,6 @@ import pycriu.rpc
 name = "vz"
 vz_global_conf = "/etc/vz/vz.conf"
 vz_conf_dir = "/etc/vz/conf/"
-cg_image_name = "ovzcg.img"
 vzctl_bin = "vzctl"
 
 class p_haul_type:
@@ -124,25 +122,18 @@ class p_haul_type:
 		return "%s.conf" % self._ctid
 
 	#
-	# Meta-images for OVZ -- container config and info about CGroups
+	# Meta-images for OVZ -- container config
 	#
 	def get_meta_images(self, path):
-		cg_img = os.path.join(path, cg_image_name)
-		p_haul_cgroup.dump_hier(self.root_task_pid(), cg_img)
 		cfg_name = self.__ct_config()
-		return [ (os.path.join(vz_conf_dir, cfg_name), cfg_name), \
-			 (cg_img, cg_image_name) ]
+		return [(os.path.join(vz_conf_dir, cfg_name), cfg_name)]
 
 	def put_meta_images(self, path):
 		logging.info("Putting config file into %s", vz_conf_dir)
-
 		self.__load_ct_config(path)
 		with open(os.path.join(vz_conf_dir, self.__ct_config()), "w") as ofd:
 			ofd.write(self._cfg)
 
-		# Keep this name, we'll need one in prepare_ct()
-		self.cg_img = os.path.join(path, cg_image_name)
-
 	def __setup_restore_extra_args(self, path, img, connection):
 		"""Create temporary file with extra arguments for criu restore"""
 		extra_args = [
@@ -184,7 +175,6 @@ class p_haul_type:
 		"""
 
 		self.__cg_set_veid()
-		p_haul_cgroup.restore_hier(pid, self.cg_img)
 
 	def mount(self):
 		logging.info("Mounting CT root to %s", self._ct_root)
-- 
1.7.1



More information about the CRIU mailing list