[CRIU] [PATCH 1/6] p.haul: change fs receiver interface
Nikita Spiridonov
nspiridonov at odin.com
Mon Dec 14 02:15:26 PST 2015
Change fs receiver interface, now receiver object has start_receive
and stop_receive methods instead of start/join (derived from
threading.Thread). With this changes receiver can incapsulate
several fs receiving threads.
This change is needed to handle multiple disks in ploop fs hauler.
Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
phaul/fs_haul_ploop.py | 24 +++++++++++++++++-------
phaul/service.py | 4 ++--
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/phaul/fs_haul_ploop.py b/phaul/fs_haul_ploop.py
index abfb052..728a029 100644
--- a/phaul/fs_haul_ploop.py
+++ b/phaul/fs_haul_ploop.py
@@ -38,7 +38,7 @@ class p_haul_fs:
return True
-class p_haul_fs_receiver(threading.Thread):
+class p_haul_fs_receiver:
def __init__(self, fname_path, fs_sk):
"""Initialize ploop disk receiver
@@ -46,14 +46,24 @@ class p_haul_fs_receiver(threading.Thread):
and socket.
"""
+ self.__delta_receiver = delta_receiver(fname_path, fs_sk)
+
+ def start_receive(self):
+ self.__delta_receiver.start()
+
+ def stop_receive(self):
+ self.__delta_receiver.join()
+
+
+class delta_receiver(threading.Thread):
+ def __init__(self, delta_path, delta_fd):
+ """Initialize ploop single active delta receiver"""
threading.Thread.__init__(self)
- self.__fname_path = fname_path
- self.__fs_sk = fs_sk
+ self.__path = delta_path
+ self.__fd = delta_fd
def run(self):
try:
- logging.info("Started fs receiver")
- libploop.ploopcopy_receiver(self.__fname_path,
- self.__fs_sk.fileno())
+ libploop.ploopcopy_receiver(self.__path, self.__fd)
except:
- logging.exception("Exception in p_haul_fs_receiver")
+ logging.exception("Exception in %s delta receiver", self.__path)
diff --git a/phaul/service.py b/phaul/service.py
index b5ce48f..577278e 100644
--- a/phaul/service.py
+++ b/phaul/service.py
@@ -33,7 +33,7 @@ class phaul_service:
# Stop fs receiver if it is running
if self.__fs_receiver:
- self.__fs_receiver.join()
+ self.__fs_receiver.stop_receive()
if self.img:
logging.info("Closing images")
@@ -51,7 +51,7 @@ class phaul_service:
# Create and start fs receiver if current p.haul module provide it
self.__fs_receiver = self.htype.get_fs_receiver(self._fs_sk)
if self.__fs_receiver:
- self.__fs_receiver.start()
+ self.__fs_receiver.start_receive()
def rpc_set_options(self, opts):
self.criu_connection.set_options(opts)
--
1.7.1
More information about the CRIU
mailing list