[CRIU] [PATCH 5/5] crit: Add dump for semaphores

Cyrill Gorcunov gorcunov at openvz.org
Thu Dec 10 02:07:06 PST 2015


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 pycriu/images/images.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pycriu/images/images.py b/pycriu/images/images.py
index dcc8dea26d9a..01d64d8b79f2 100644
--- a/pycriu/images/images.py
+++ b/pycriu/images/images.py
@@ -274,7 +274,17 @@ class ipc_sem_set_handler:
 		return s.tolist()
 
 	def dump(self, extra, f, pb):
-		raise Exception("Not yet implemented")
+		entry = pb2dict.pb2dict(pb)
+		size = sizeof_u16 * entry['nsems']
+		rounded = round_up(size, sizeof_u64)
+		s = array.array('H')
+		if s.itemsize != sizeof_u16:
+			raise Exception("Array size mismatch")
+		s.fromlist(extra)
+		if len(s) != entry['nsems']:
+			raise Exception("Number of semaphores mismatch")
+		s.tofile(f)
+		f.write('\0' * (rounded - size))
 
 class ipc_msg_queue_handler:
 	def load(self, f, pb):
-- 
2.5.0



More information about the CRIU mailing list