Commit 1b87ae8f authored by Pavel Emelyanov's avatar Pavel Emelyanov

crit: Fix ipc load/dump for io.BytesIO input/output

There are loads and dumps method in pycriu.images that work with
strings, instead of open()-ed files. For simplicity strings are
turned into streams with io.BytesIO and the files are then pushed
into regular load/dump methods.

The problem is that array.array object doesn't work with io object
in .fromfile/.tofile methods, so we have to read/write the data
from them explicitly and use .fromstring/.tostring for arrays.

With this the crit test finally passes :D
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 8841edf7
...@@ -269,7 +269,7 @@ class ipc_sem_set_handler: ...@@ -269,7 +269,7 @@ class ipc_sem_set_handler:
s = array.array('H') s = array.array('H')
if s.itemsize != sizeof_u16: if s.itemsize != sizeof_u16:
raise Exception("Array size mismatch") raise Exception("Array size mismatch")
s.fromfile(f, entry['nsems']) s.fromstring(f.read(size))
f.seek(rounded - size, 1) f.seek(rounded - size, 1)
return s.tolist() return s.tolist()
...@@ -283,7 +283,7 @@ class ipc_sem_set_handler: ...@@ -283,7 +283,7 @@ class ipc_sem_set_handler:
s.fromlist(extra) s.fromlist(extra)
if len(s) != entry['nsems']: if len(s) != entry['nsems']:
raise Exception("Number of semaphores mismatch") raise Exception("Number of semaphores mismatch")
s.tofile(f) f.write(s.tostring())
f.write('\0' * (rounded - size)) f.write('\0' * (rounded - size))
class ipc_msg_queue_handler: class ipc_msg_queue_handler:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment