[CRIU] [PATCH] Fixed negative returns issues introduced by remote images code.
Andrei Vagin
avagin at virtuozzo.com
Wed Mar 1 16:15:53 PST 2017
On Wed, Mar 01, 2017 at 02:05:22PM +0000, Rodrigo Bruno wrote:
> Hi,
>
> 2017-02-28 23:25 GMT+00:00 Andrei Vagin <avagin at virtuozzo.com>:
>
> On Wed, Mar 01, 2017 at 04:32:50AM +0100, rbruno at gsd.inesc-id.pt wrote:
> > Hi Andrei,
> >
> > here goes a patch to fix the negative returns issue.
> >
> > Let me know if you prefer to receive this in another format. If you see
> > any problem with the resolution of the problem, let me know.
> >
> > ---
> > criu/fdstore.c | 5 +++++
> > criu/files-reg.c | 6 +++++-
> > criu/image.c | 11 +++++++++--
> > criu/img-remote-proto.c | 2 +-
> > criu/img-remote.c | 5 +++++
> > 5 files changed, 25 insertions(+), 4 deletions(-)
> >
> > diff --git a/criu/fdstore.c b/criu/fdstore.c
> > index d9bed4d..bddd2ab 100644
> > --- a/criu/fdstore.c
> > +++ b/criu/fdstore.c
> > @@ -100,6 +100,11 @@ int fdstore_get(int id)
> > int sk = get_service_fd(FDSTORE_SK_OFF);
> > int fd;
> >
> > + if (sk < 0) {
> > + pr_err("Unable get service fd");
> > + return -1;
> > + }
> > +
> > mutex_lock(&desc->lock);
> > if (setsockopt(sk, SOL_SOCKET, SO_PEEK_OFF, &id, sizeof(id))) {
> > mutex_unlock(&desc->lock);
> > diff --git a/criu/files-reg.c b/criu/files-reg.c
> > index 3b93bb9..bc2c330 100644
> > --- a/criu/files-reg.c
> > +++ b/criu/files-reg.c
> > @@ -134,7 +134,11 @@ static int mkreg_ghost(char *path, u32 mode, struct
> > ghost_file *gf, struct cr_im
>
> Applying: Fixed negative returns issues introduced by remote images code.
> fatal: corrupt patch at line 30
>
> Looks like the previous two lines was the one line in an original patch.
>
> How do you send patches? I recomend to use git send-email.
> https://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/
>
>
>
> Hmm... Which lines are repeated?
The line was splited
The message contains these two lines:
@@ -134,7 +134,11 @@ static int mkreg_ghost(char *path, u32 mode, struct
ghost_file *gf, struct cr_im
but actulally this is one line
@@ -134,7 +134,11 @@ static int mkreg_ghost(char *path, u32 mode, struct ghost_file *gf, struct cr_im
You can try to download this patch from the mailing list
https://patchwork.criu.org/api/1.0/series/1295/revisions/1/mbox/
and try to apply it with the "git am" tool
[root at fc24 criu]# curl https://patchwork.criu.org/api/1.0/series/1295/revisions/1/mbox/ > m
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3360 0 3360 0 0 17453 0 --:--:-- --:--:-- --:--:-- 17500
[root at fc24 criu]# git am m
Applying: Fixed negative returns issues introduced by remote images code.
fatal: corrupt patch at line 30
Patch failed at 0001 Fixed negative returns issues introduced by remote images code.
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
>
> I use:
> git commit
> git format-patch -1 HEAD
> (copy to email, send)
>
> However, git send-email seems very cool :-)
>
>
>
> > if (gfd < 0)
> > return -1;
> >
> > - ret = copy_file(img_raw_fd(img), gfd, 0);
> > + int rfd = img_raw_fd(img);
> > + if (rfd < 0)
> > + return -1;
> > +
> > + ret = copy_file(rfd, gfd, 0);
> > if (ret < 0)
> > unlink(path);
> > close(gfd);
> > diff --git a/criu/image.c b/criu/image.c
> > index 57d3c7b..7bf52d9 100644
> > --- a/criu/image.c
> > +++ b/criu/image.c
> > @@ -333,8 +333,15 @@ int do_open_remote_image(int dfd, char *path, int
> flags)
> > * change to previous working dir and back to correctly open the
> image
> > * proxy and cache sockets. */
> > int save = dirfd(opendir("."));
> > - if (fchdir(get_service_fd(IMG_FD_OFF)) < 0) {
> > - pr_debug("fchdir to dfd failed!\n");
> > + int service_fd = get_service_fd(IMG_FD_OFF);
> > +
> > + if (service_fd < 0) {
> > + pr_err("Unable to get service fd.\n");
> > + return -1;
> > + }
> > +
> > + if (fchdir(service_fd) < 0) {
> > + pr_perror("fchdir to dfd failed");
> > return -1;
> > }
> >
> > diff --git a/criu/img-remote-proto.c b/criu/img-remote-proto.c
> > index c05b921..34074f2 100644
> > --- a/criu/img-remote-proto.c
> > +++ b/criu/img-remote-proto.c
> > @@ -593,7 +593,6 @@ void *accept_local_image_connections(void *port)
> > if (cli_fd < 0) {
> > if (!finished)
> > pr_err("Unable to accept local image
> connection");
> > - close(cli_fd);
> > return NULL;
> > }
> >
> > @@ -624,6 +623,7 @@ void *accept_local_image_connections(void *port)
> > int fd = open_proc_rw(PROC_GEN, LAST_PID_PATH);
> > if (fd < 0) {
> > pr_perror("Can't open %s", LAST_PID_PATH);
> > + return NULL;
> > }
> >
> > if (flock(fd, LOCK_EX)) {
> > diff --git a/criu/img-remote.c b/criu/img-remote.c
> > index 337cb4a..7dbde0e 100644
> > --- a/criu/img-remote.c
> > +++ b/criu/img-remote.c
> > @@ -127,6 +127,11 @@ int skip_remote_bytes(int fd, unsigned long len)
> > int n = 0;
> > unsigned long curr = 0;
> >
> > + if (fd < 0) {
> > + pr_perror("Invalid fd: %d", fd);
> > + return -1;
> > + }
> > +
> > for (; curr < len; ) {
> > n = read(fd, buf, min(len - curr, (unsigned long)4096));
> > if (n == 0) {
> > --
> > 1.9.1
> >
> >
> >
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu
>
>
More information about the CRIU
mailing list