<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">2017-02-28 23:25 GMT+00: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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Mar 01, 2017 at 04:32:50AM +0100, <a href="mailto:rbruno@gsd.inesc-id.pt">rbruno@gsd.inesc-id.pt</a> wrote:<br>
&gt; Hi Andrei,<br>
&gt;<br>
&gt; here goes a patch to fix the negative returns issue.<br>
&gt;<br>
&gt; Let me know if you prefer to receive this in another format. If you see<br>
&gt; any problem with the resolution of the problem, let me know.<br>
&gt;<br>
&gt; ---<br>
&gt;  criu/fdstore.c          |  5 +++++<br>
&gt;  criu/files-reg.c        |  6 +++++-<br>
&gt;  criu/image.c            | 11 +++++++++--<br>
&gt;  criu/img-remote-proto.c |  2 +-<br>
&gt;  criu/img-remote.c       |  5 +++++<br>
&gt;  5 files changed, 25 insertions(+), 4 deletions(-)<br>
&gt;<br>
&gt; diff --git a/criu/fdstore.c b/criu/fdstore.c<br>
&gt; index d9bed4d..bddd2ab 100644<br>
&gt; --- a/criu/fdstore.c<br>
&gt; +++ b/criu/fdstore.c<br>
&gt; @@ -100,6 +100,11 @@ int fdstore_get(int id)<br>
&gt;       int sk = get_service_fd(FDSTORE_SK_OFF)<wbr>;<br>
&gt;       int fd;<br>
&gt;<br>
&gt; +     if (sk &lt; 0) {<br>
&gt; +             pr_err(&quot;Unable get service fd&quot;);<br>
&gt; +             return -1;<br>
&gt; +     }<br>
&gt; +<br>
&gt;       mutex_lock(&amp;desc-&gt;lock);<br>
&gt;       if (setsockopt(sk, SOL_SOCKET, SO_PEEK_OFF, &amp;id, sizeof(id))) {<br>
&gt;               mutex_unlock(&amp;desc-&gt;lock);<br>
&gt; diff --git a/criu/files-reg.c b/criu/files-reg.c<br>
&gt; index 3b93bb9..bc2c330 100644<br>
&gt; --- a/criu/files-reg.c<br>
&gt; +++ b/criu/files-reg.c<br>
&gt; @@ -134,7 +134,11 @@ static int mkreg_ghost(char *path, u32 mode, struct<br>
&gt; ghost_file *gf, struct cr_im<br>
<br>
Applying: Fixed negative returns issues introduced by remote images code.<br>
fatal: corrupt patch at line 30<br>
<br>
Looks like the previous two lines was the one line in an original patch.<br>
<br>
How do you send patches? I recomend to use git send-email.<br>
<a href="https://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/" rel="noreferrer" target="_blank">https://www.freedesktop.org/<wbr>wiki/Software/PulseAudio/<wbr>HowToUseGitSendEmail/</a><br>
<br></blockquote><div><br></div><div>Hmm... Which lines are repeated?</div><div><br></div><div>I use:</div><div>git commit </div><div>git format-patch -1 HEAD <br></div><div>(copy to email, send)</div><div><br></div><div>However, git send-email seems very cool :-)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt;       if (gfd &lt; 0)<br>
&gt;               return -1;<br>
&gt;<br>
&gt; -     ret = copy_file(img_raw_fd(img), gfd, 0);<br>
&gt; +     int rfd = img_raw_fd(img);<br>
&gt; +     if (rfd &lt; 0)<br>
&gt; +             return -1;<br>
&gt; +<br>
&gt; +     ret = copy_file(rfd, gfd, 0);<br>
&gt;       if (ret &lt; 0)<br>
&gt;               unlink(path);<br>
&gt;       close(gfd);<br>
&gt; diff --git a/criu/image.c b/criu/image.c<br>
&gt; index 57d3c7b..7bf52d9 100644<br>
&gt; --- a/criu/image.c<br>
&gt; +++ b/criu/image.c<br>
&gt; @@ -333,8 +333,15 @@ int do_open_remote_image(int dfd, char *path, int flags)<br>
&gt;        * change to previous working dir and back to correctly open the image<br>
&gt;        * proxy and cache sockets. */<br>
&gt;       int save = dirfd(opendir(&quot;.&quot;));<br>
&gt; -     if (fchdir(get_service_fd(IMG_FD_<wbr>OFF)) &lt; 0) {<br>
&gt; -             pr_debug(&quot;fchdir to dfd failed!\n&quot;);<br>
&gt; +     int service_fd = get_service_fd(IMG_FD_OFF);<br>
&gt; +<br>
&gt; +     if (service_fd &lt; 0) {<br>
&gt; +             pr_err(&quot;Unable to get service fd.\n&quot;);<br>
&gt; +             return -1;<br>
&gt; +     }<br>
&gt; +<br>
&gt; +     if (fchdir(service_fd) &lt; 0) {<br>
&gt; +             pr_perror(&quot;fchdir to dfd failed&quot;);<br>
&gt;               return -1;<br>
&gt;       }<br>
&gt;<br>
&gt; diff --git a/criu/img-remote-proto.c b/criu/img-remote-proto.c<br>
&gt; index c05b921..34074f2 100644<br>
&gt; --- a/criu/img-remote-proto.c<br>
&gt; +++ b/criu/img-remote-proto.c<br>
&gt; @@ -593,7 +593,6 @@ void *accept_local_image_<wbr>connections(void *port)<br>
&gt;               if (cli_fd &lt; 0) {<br>
&gt;                       if (!finished)<br>
&gt;                               pr_err(&quot;Unable to accept local image connection&quot;);<br>
&gt; -                     close(cli_fd);<br>
&gt;                       return NULL;<br>
&gt;               }<br>
&gt;<br>
&gt; @@ -624,6 +623,7 @@ void *accept_local_image_<wbr>connections(void *port)<br>
&gt;               int fd = open_proc_rw(PROC_GEN, LAST_PID_PATH);<br>
&gt;               if (fd &lt; 0) {<br>
&gt;                       pr_perror(&quot;Can&#39;t open %s&quot;, LAST_PID_PATH);<br>
&gt; +                     return NULL;<br>
&gt;               }<br>
&gt;<br>
&gt;               if (flock(fd, LOCK_EX)) {<br>
&gt; diff --git a/criu/img-remote.c b/criu/img-remote.c<br>
&gt; index 337cb4a..7dbde0e 100644<br>
&gt; --- a/criu/img-remote.c<br>
&gt; +++ b/criu/img-remote.c<br>
&gt; @@ -127,6 +127,11 @@ int skip_remote_bytes(int fd, unsigned long len)<br>
&gt;       int n = 0;<br>
&gt;       unsigned long curr = 0;<br>
&gt;<br>
&gt; +     if (fd &lt; 0) {<br>
&gt; +             pr_perror(&quot;Invalid fd: %d&quot;, fd);<br>
&gt; +             return -1;<br>
&gt; +     }<br>
&gt; +<br>
&gt;       for (; curr &lt; len; ) {<br>
&gt;               n = read(fd, buf, min(len - curr, (unsigned long)4096));<br>
&gt;               if (n == 0) {<br>
<span class="gmail-HOEnZb"><font color="#888888">&gt; --<br>
&gt; 1.9.1<br>
&gt;<br>
&gt;<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></div>