[CRIU] [PATCH] crit: Fix ipc load/dump for io.BytesIO input/output
Pavel Emelyanov
xemul at parallels.com
Thu Dec 10 11:08:17 PST 2015
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: Pavel Emelyanov <xemul at parallels.com>
---
pycriu/images/images.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pycriu/images/images.py b/pycriu/images/images.py
index 01d64d8..d4e883f 100644
--- a/pycriu/images/images.py
+++ b/pycriu/images/images.py
@@ -269,7 +269,7 @@ class ipc_sem_set_handler:
s = array.array('H')
if s.itemsize != sizeof_u16:
raise Exception("Array size mismatch")
- s.fromfile(f, entry['nsems'])
+ s.fromstring(f.read(size))
f.seek(rounded - size, 1)
return s.tolist()
@@ -283,7 +283,7 @@ class ipc_sem_set_handler:
s.fromlist(extra)
if len(s) != entry['nsems']:
raise Exception("Number of semaphores mismatch")
- s.tofile(f)
+ f.write(s.tostring())
f.write('\0' * (rounded - size))
class ipc_msg_queue_handler:
--
1.9.3
More information about the CRIU
mailing list