<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"><<a href="mailto:avagin@virtuozzo.com" target="_blank">avagin@virtuozzo.com</a>></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>
> Hi Andrei,<br>
><br>
> here goes a patch to fix the negative returns issue.<br>
><br>
> Let me know if you prefer to receive this in another format. If you see<br>
> any problem with the resolution of the problem, let me know.<br>
><br>
> ---<br>
> criu/fdstore.c | 5 +++++<br>
> criu/files-reg.c | 6 +++++-<br>
> criu/image.c | 11 +++++++++--<br>
> criu/img-remote-proto.c | 2 +-<br>
> criu/img-remote.c | 5 +++++<br>
> 5 files changed, 25 insertions(+), 4 deletions(-)<br>
><br>
> diff --git a/criu/fdstore.c b/criu/fdstore.c<br>
> index d9bed4d..bddd2ab 100644<br>
> --- a/criu/fdstore.c<br>
> +++ b/criu/fdstore.c<br>
> @@ -100,6 +100,11 @@ int fdstore_get(int id)<br>
> int sk = get_service_fd(FDSTORE_SK_OFF)<wbr>;<br>
> int fd;<br>
><br>
> + if (sk < 0) {<br>
> + pr_err("Unable get service fd");<br>
> + return -1;<br>
> + }<br>
> +<br>
> mutex_lock(&desc->lock);<br>
> if (setsockopt(sk, SOL_SOCKET, SO_PEEK_OFF, &id, sizeof(id))) {<br>
> mutex_unlock(&desc->lock);<br>
> diff --git a/criu/files-reg.c b/criu/files-reg.c<br>
> index 3b93bb9..bc2c330 100644<br>
> --- a/criu/files-reg.c<br>
> +++ b/criu/files-reg.c<br>
> @@ -134,7 +134,11 @@ static int mkreg_ghost(char *path, u32 mode, struct<br>
> 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">
> if (gfd < 0)<br>
> return -1;<br>
><br>
> - ret = copy_file(img_raw_fd(img), gfd, 0);<br>
> + int rfd = img_raw_fd(img);<br>
> + if (rfd < 0)<br>
> + return -1;<br>
> +<br>
> + ret = copy_file(rfd, gfd, 0);<br>
> if (ret < 0)<br>
> unlink(path);<br>
> close(gfd);<br>
> diff --git a/criu/image.c b/criu/image.c<br>
> index 57d3c7b..7bf52d9 100644<br>
> --- a/criu/image.c<br>
> +++ b/criu/image.c<br>
> @@ -333,8 +333,15 @@ int do_open_remote_image(int dfd, char *path, int flags)<br>
> * change to previous working dir and back to correctly open the image<br>
> * proxy and cache sockets. */<br>
> int save = dirfd(opendir("."));<br>
> - if (fchdir(get_service_fd(IMG_FD_<wbr>OFF)) < 0) {<br>
> - pr_debug("fchdir to dfd failed!\n");<br>
> + int service_fd = get_service_fd(IMG_FD_OFF);<br>
> +<br>
> + if (service_fd < 0) {<br>
> + pr_err("Unable to get service fd.\n");<br>
> + return -1;<br>
> + }<br>
> +<br>
> + if (fchdir(service_fd) < 0) {<br>
> + pr_perror("fchdir to dfd failed");<br>
> return -1;<br>
> }<br>
><br>
> diff --git a/criu/img-remote-proto.c b/criu/img-remote-proto.c<br>
> index c05b921..34074f2 100644<br>
> --- a/criu/img-remote-proto.c<br>
> +++ b/criu/img-remote-proto.c<br>
> @@ -593,7 +593,6 @@ void *accept_local_image_<wbr>connections(void *port)<br>
> if (cli_fd < 0) {<br>
> if (!finished)<br>
> pr_err("Unable to accept local image connection");<br>
> - close(cli_fd);<br>
> return NULL;<br>
> }<br>
><br>
> @@ -624,6 +623,7 @@ void *accept_local_image_<wbr>connections(void *port)<br>
> int fd = open_proc_rw(PROC_GEN, LAST_PID_PATH);<br>
> if (fd < 0) {<br>
> pr_perror("Can't open %s", LAST_PID_PATH);<br>
> + return NULL;<br>
> }<br>
><br>
> if (flock(fd, LOCK_EX)) {<br>
> diff --git a/criu/img-remote.c b/criu/img-remote.c<br>
> index 337cb4a..7dbde0e 100644<br>
> --- a/criu/img-remote.c<br>
> +++ b/criu/img-remote.c<br>
> @@ -127,6 +127,11 @@ int skip_remote_bytes(int fd, unsigned long len)<br>
> int n = 0;<br>
> unsigned long curr = 0;<br>
><br>
> + if (fd < 0) {<br>
> + pr_perror("Invalid fd: %d", fd);<br>
> + return -1;<br>
> + }<br>
> +<br>
> for (; curr < len; ) {<br>
> n = read(fd, buf, min(len - curr, (unsigned long)4096));<br>
> if (n == 0) {<br>
<span class="gmail-HOEnZb"><font color="#888888">> --<br>
> 1.9.1<br>
><br>
><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></div>