From 8841edf770762a6d469fd40b40d656c0b51cb6c1 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 10 Dec 2015 13:07:06 +0300 Subject: [PATCH] crit: Add dump for semaphores Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- 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 dcc8dea26..01d64d8b7 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):