<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">&lt;<a href="mailto:avagin@virtuozzo.com" target="_blank">avagin@virtuozzo.com</a>&gt;</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 &amp; 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>
&gt; Signed-off-by: Radostin Stoyanov &lt;<a href="mailto:rstoyanov1@gmail.com">rstoyanov1@gmail.com</a>&gt;<br>
&gt; ---<br>
&gt;  test/others/rpc/remote.py | 86 ++++++++++++++++++++++++++++++<wbr>+++++++++++++++++<br>
&gt;  test/others/rpc/run.sh    | 26 ++++++++++++++<br>
&gt;  2 files changed, 112 insertions(+)<br>
&gt;  create mode 100644 test/others/rpc/remote.py<br>
&gt; <br>
&gt; diff --git a/test/others/rpc/remote.py b/test/others/rpc/remote.py<br>
&gt; new file mode 100644<br>
&gt; index 00000000..96ce3e21<br>
&gt; --- /dev/null<br>
&gt; +++ b/test/others/rpc/remote.py<br>
&gt; @@ -0,0 +1,86 @@<br>
&gt; +#!/usr/bin/env python2<br>
&gt; +<br>
&gt; +import socket, os, imp, sys, errno, signal<br>
&gt; +import rpc_pb2 as rpc<br>
&gt; +import argparse<br>
&gt; +<br>
&gt; +MAX_MSG_SIZE = 1024<br>
&gt; +<br>
&gt; +parser = argparse.ArgumentParser(<wbr>description=&quot;Test --remote option using CRIU RPC&quot;)<br>
&gt; +parser.add_argument(&#39;socket&#39;, type = str, help = &quot;CRIU service socket&quot;)<br>
&gt; +parser.add_argument(&#39;dir&#39;, type = str, help = &quot;Directory where CRIU images should be placed&quot;)<br>
&gt; +parser.add_argument(&#39;pid&#39;, type = int, help = &quot;PID of process to be dumped&quot;)<br>
&gt; +<br>
&gt; +args = vars(parser.parse_args())<br>
&gt; +<br>
&gt; +# Connect to RPC socket<br>
&gt; +s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)<br>
&gt; +s.connect(args[&#39;socket&#39;])<br>
&gt; +<br>
&gt; +# Open images-dir<br>
&gt; +dir_fd = os.open(args[&#39;dir&#39;], os.O_DIRECTORY)<br>
&gt; +if dir_fd &lt; 0:<br>
&gt; +     print &quot;Failed to open dir %s&quot; % args[&#39;dir&#39;]<br>
&gt; +     sys.exit(-1)<br>
&gt; +<br>
&gt; +# Prepare dump request<br>
&gt; +req = rpc.criu_req()<br>
&gt; +req.type = rpc.DUMP<br>
&gt; +req.opts.remote      = True<br>
&gt; +req.opts.log_level = 4<br>
&gt; +req.opts.pid = args[&#39;pid&#39;]<br>
&gt; +req.opts.images_dir_fd       = dir_fd<br>
&gt; +<br>
&gt; +# Send dump request<br>
&gt; +s.send(req.SerializeToString(<wbr>))<br>
&gt; +<br>
&gt; +# Receive responce<br>
&gt; +resp = rpc.criu_resp()<br>
&gt; +resp.ParseFromString(s.recv(<wbr>MAX_MSG_SIZE))<br>
&gt; +<br>
&gt; +# Reconnect to RPC socket<br>
&gt; +s.close()<br>
&gt; +s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)<br>
&gt; +s.connect(args[&#39;socket&#39;])<br>
&gt; +<br>
&gt; +<br>
&gt; +if resp.type != rpc.DUMP:<br>
&gt; +     print &#39;Unexpected dump msg type&#39;<br>
&gt; +     sys.exit(-1)<br>
&gt; +else:<br>
&gt; +     if resp.success:<br>
&gt; +             print &#39;Dump Success&#39;<br>
&gt; +     else:<br>
&gt; +             print &#39;Dump Fail&#39;<br>
&gt; +             sys.exit(-1)<br>
&gt; +<br>
&gt; +req                  = rpc.criu_req()<br>
&gt; +req.type             = rpc.RESTORE<br>
&gt; +req.opts.remote      = True<br>
&gt; +req.opts.log_level = 4<br>
&gt; +req.opts.images_dir_fd       = dir_fd<br>
&gt; +<br>
&gt; +# Send restore request<br>
&gt; +s.send(req.SerializeToString(<wbr>))<br>
&gt; +<br>
&gt; +# Receive response<br>
&gt; +resp         = rpc.criu_resp()<br>
&gt; +resp.ParseFromString(s.recv(<wbr>MAX_MSG_SIZE))<br>
&gt; +<br>
&gt; +# Close RPC socket<br>
&gt; +s.close()<br>
&gt; +# Close fd of images dir<br>
&gt; +os.close(dir_fd)<br>
&gt; +<br>
&gt; +if resp.type != rpc.RESTORE:<br>
&gt; +     print &#39;Unexpected restore msg type&#39;<br>
&gt; +     sys.exit(-1)<br>
&gt; +else:<br>
&gt; +     if resp.success:<br>
&gt; +             print &#39;Restore success&#39;<br>
&gt; +             print &quot;PID of the restored program is %d\n&quot; % (resp.restore.pid)<br>
&gt; +             # Kill restored process<br>
&gt; +             os.kill(resp.restore.pid, signal.SIGTERM)<br>
&gt; +     else:<br>
&gt; +             print &#39;Restore fail&#39;<br>
&gt; +             sys.exit(-1)<br>
&gt; diff --git a/test/others/rpc/run.sh b/test/others/rpc/run.sh<br>
&gt; index ed99addb..5364cc90 100755<br>
&gt; --- a/test/others/rpc/run.sh<br>
&gt; +++ b/test/others/rpc/run.sh<br>
&gt; @@ -76,6 +76,31 @@ function test_errno {<br>
&gt;       setsid ./errno.py build/criu_service.socket build/imgs_errno &lt; /dev/null &amp;&gt;&gt; build/output_errno<br>
&gt;  }<br>
&gt;  <br>
&gt; +function test_remote {<br>
&gt; +     mkdir -p build/imgs_remote<br>
&gt; +<br>
&gt; +     title_print &quot;Run image-cache&quot;<br>
&gt; +     ${CRIU} image-cache -v4 -o dump-loop.log -D build/imgs_remote --port 9996 &amp;<br>
&gt; +     CACHE_PID=${!}<br>
&gt; +<br>
&gt; +     title_print &quot;Run image-proxy&quot;<br>
&gt; +     ${CRIU} image-proxy -v4 -o dump-loop.log -D build/imgs_remote --address localhost --port 9996 &amp;<br>
<br>
How do you wait when image-cache creates a listen socket?<br>
<br>
&gt; +     PROXY_PID=${!}<br>
&gt; +<br>
&gt; +     title_print &quot;Run loop.sh&quot;<br>
&gt; +     setsid ./loop.sh &lt; /dev/null &amp;&gt; build/loop.log &amp;<br>
&gt; +     LOOP_PID=${!}<br>
&gt; +     echo &quot;Start loop with pid ${P}&quot;<br>
&gt; +<br>
&gt; +     title_print &quot;Run dump/restore with --remote test&quot;<br>
&gt; +     ./remote.py build/criu_service.socket build/imgs_remote $P &lt; /dev/null &amp;&gt;&gt; build/output_remote<br>
&gt; +<br>
&gt; +     # Clean up on failure<br>
&gt; +     kill -SIGTERM ${LOOP_PID}<br>
&gt; +     kill -SIGTERM ${CACHE_PID}<br>
&gt; +     kill -SIGTERM ${PROXT_PID}<br>
&gt; +}<br>
&gt; +<br>
&gt;  trap &#39;echo &quot;FAIL&quot;; stop_server&#39; EXIT<br>
&gt;  <br>
&gt;  start_server<br>
&gt; @@ -85,6 +110,7 @@ test_py<br>
&gt;  test_restore_loop<br>
&gt;  test_ps<br>
&gt;  test_errno<br>
&gt; +test_remote<br>
&gt;  <br>
&gt;  stop_server<br>
<span class="HOEnZb"><font color="#888888">&gt;  <br>
&gt; -- <br>
&gt; 2.14.3<br>
&gt; <br>
&gt; ______________________________<wbr>_________________<br>
&gt; CRIU mailing list<br>
&gt; <a href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br>
&gt; <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>