<div dir="ltr">Hi Andrei and Radostin,<div><br></div><div>in our last iteration, I sent to Andei a patch to rework the cache-proxy code to be single threaded.</div><div><br></div><div>Is it possible to merge that patch into CRIU dev?</div><div><br></div><div>I think it would be easy this way because we would be then working on small code changes to fix bugs related to tests failing.</div><div><br></div><div>I would be able to help fixing the implementation.</div><div><br></div><div>best,</div><div>rodrigo</div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-10 2:10 GMT+01:00 Andrei Vagin <span dir="ltr"><<a href="mailto:avagin@virtuozzo.com" target="_blank">avagin@virtuozzo.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Radostin,<br>
<br>
Should we run this test in scripts/travis/travis-tests?<br>
<br>
Rodrigo has patches, which reworks image proxy & cache to a single<br>
thread model. These patches are mostly ready to be merged, but need<br>
some work.<br>
<br>
Would it be interesting for you to finish criu --remote, that we could<br>
merge it into the master branch?<br>
<br>
For that, all tests have to pass, and image and cache have to<br>
be single-thread processes.<br>
<br>
There is one inline comment.<br>
<br>
On Mon, Feb 12, 2018 at 10:54:05AM +0000, Radostin Stoyanov wrote:<br>
> Signed-off-by: Radostin Stoyanov <<a href="mailto:rstoyanov1@gmail.com">rstoyanov1@gmail.com</a>><br>
> ---<br>
> test/others/rpc/remote.py | 86 ++++++++++++++++++++++++++++++<wbr>+++++++++++++++++<br>
> test/others/rpc/run.sh | 26 ++++++++++++++<br>
> 2 files changed, 112 insertions(+)<br>
> create mode 100644 test/others/rpc/remote.py<br>
> <br>
> diff --git a/test/others/rpc/remote.py b/test/others/rpc/remote.py<br>
> new file mode 100644<br>
> index 00000000..96ce3e21<br>
> --- /dev/null<br>
> +++ b/test/others/rpc/remote.py<br>
> @@ -0,0 +1,86 @@<br>
> +#!/usr/bin/env python2<br>
> +<br>
> +import socket, os, imp, sys, errno, signal<br>
> +import rpc_pb2 as rpc<br>
> +import argparse<br>
> +<br>
> +MAX_MSG_SIZE = 1024<br>
> +<br>
> +parser = argparse.ArgumentParser(<wbr>description="Test --remote option using CRIU RPC")<br>
> +parser.add_argument('socket', type = str, help = "CRIU service socket")<br>
> +parser.add_argument('dir', type = str, help = "Directory where CRIU images should be placed")<br>
> +parser.add_argument('pid', type = int, help = "PID of process to be dumped")<br>
> +<br>
> +args = vars(parser.parse_args())<br>
> +<br>
> +# Connect to RPC socket<br>
> +s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)<br>
> +s.connect(args['socket'])<br>
> +<br>
> +# Open images-dir<br>
> +dir_fd = os.open(args['dir'], os.O_DIRECTORY)<br>
> +if dir_fd < 0:<br>
> + print "Failed to open dir %s" % args['dir']<br>
> + sys.exit(-1)<br>
> +<br>
> +# Prepare dump request<br>
> +req = rpc.criu_req()<br>
> +req.type = rpc.DUMP<br>
> +req.opts.remote = True<br>
> +req.opts.log_level = 4<br>
> +req.opts.pid = args['pid']<br>
> +req.opts.images_dir_fd = dir_fd<br>
> +<br>
> +# Send dump request<br>
> +s.send(req.SerializeToString(<wbr>))<br>
> +<br>
> +# Receive responce<br>
> +resp = rpc.criu_resp()<br>
> +resp.ParseFromString(s.recv(<wbr>MAX_MSG_SIZE))<br>
> +<br>
> +# Reconnect to RPC socket<br>
> +s.close()<br>
> +s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)<br>
> +s.connect(args['socket'])<br>
> +<br>
> +<br>
> +if resp.type != rpc.DUMP:<br>
> + print 'Unexpected dump msg type'<br>
> + sys.exit(-1)<br>
> +else:<br>
> + if resp.success:<br>
> + print 'Dump Success'<br>
> + else:<br>
> + print 'Dump Fail'<br>
> + sys.exit(-1)<br>
> +<br>
> +req = rpc.criu_req()<br>
> +req.type = rpc.RESTORE<br>
> +req.opts.remote = True<br>
> +req.opts.log_level = 4<br>
> +req.opts.images_dir_fd = dir_fd<br>
> +<br>
> +# Send restore request<br>
> +s.send(req.SerializeToString(<wbr>))<br>
> +<br>
> +# Receive response<br>
> +resp = rpc.criu_resp()<br>
> +resp.ParseFromString(s.recv(<wbr>MAX_MSG_SIZE))<br>
> +<br>
> +# Close RPC socket<br>
> +s.close()<br>
> +# Close fd of images dir<br>
> +os.close(dir_fd)<br>
> +<br>
> +if resp.type != rpc.RESTORE:<br>
> + print 'Unexpected restore msg type'<br>
> + sys.exit(-1)<br>
> +else:<br>
> + if resp.success:<br>
> + print 'Restore success'<br>
> + print "PID of the restored program is %d\n" % (resp.restore.pid)<br>
> + # Kill restored process<br>
> + os.kill(resp.restore.pid, signal.SIGTERM)<br>
> + else:<br>
> + print 'Restore fail'<br>
> + sys.exit(-1)<br>
> diff --git a/test/others/rpc/run.sh b/test/others/rpc/run.sh<br>
> index ed99addb..5364cc90 100755<br>
> --- a/test/others/rpc/run.sh<br>
> +++ b/test/others/rpc/run.sh<br>
> @@ -76,6 +76,31 @@ function test_errno {<br>
> setsid ./errno.py build/criu_service.socket build/imgs_errno < /dev/null &>> build/output_errno<br>
> }<br>
> <br>
> +function test_remote {<br>
> + mkdir -p build/imgs_remote<br>
> +<br>
> + title_print "Run image-cache"<br>
> + ${CRIU} image-cache -v4 -o dump-loop.log -D build/imgs_remote --port 9996 &<br>
> + CACHE_PID=${!}<br>
> +<br>
> + title_print "Run image-proxy"<br>
> + ${CRIU} image-proxy -v4 -o dump-loop.log -D build/imgs_remote --address localhost --port 9996 &<br>
<br>
How do you wait when image-cache creates a listen socket?<br>
<br>
> + PROXY_PID=${!}<br>
> +<br>
> + title_print "Run loop.sh"<br>
> + setsid ./loop.sh < /dev/null &> build/loop.log &<br>
> + LOOP_PID=${!}<br>
> + echo "Start loop with pid ${P}"<br>
> +<br>
> + title_print "Run dump/restore with --remote test"<br>
> + ./remote.py build/criu_service.socket build/imgs_remote $P < /dev/null &>> build/output_remote<br>
> +<br>
> + # Clean up on failure<br>
> + kill -SIGTERM ${LOOP_PID}<br>
> + kill -SIGTERM ${CACHE_PID}<br>
> + kill -SIGTERM ${PROXT_PID}<br>
> +}<br>
> +<br>
> trap 'echo "FAIL"; stop_server' EXIT<br>
> <br>
> start_server<br>
> @@ -85,6 +110,7 @@ test_py<br>
> test_restore_loop<br>
> test_ps<br>
> test_errno<br>
> +test_remote<br>
> <br>
> stop_server<br>
<span class="HOEnZb"><font color="#888888">> <br>
> -- <br>
> 2.14.3<br>
> <br>
> ______________________________<wbr>_________________<br>
> CRIU mailing list<br>
> <a href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br>
> <a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/<wbr>mailman/listinfo/criu</a><br>
</font></span></blockquote></div><br></div>