[lxc-devel] [PATCH 1/2] don't hang on some errors in do_restore
Stéphane Graber
stgraber at ubuntu.com
Mon Apr 6 16:07:36 UTC 2015
On Sat, Apr 04, 2015 at 01:53:24AM +0000, Serge Hallyn wrote:
> Quoting Tycho Andersen (tycho.andersen at canonical.com):
> > Instead, the parent always writes a status to the pipe.
> >
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
>
> Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
This patch won't apply to current master, can you send a rebase version?
>
> > ---
> > src/lxc/lxccontainer.c | 21 ++++++++++++++++++---
> > 1 file changed, 18 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> > index b310a0f..88cdf55 100644
> > --- a/src/lxc/lxccontainer.c
> > +++ b/src/lxc/lxccontainer.c
> > @@ -3926,13 +3926,14 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
> > pid_t pid;
> > char pidfile[L_tmpnam];
> > struct lxc_handler *handler;
> > + int status;
> >
> > if (!tmpnam(pidfile))
> > - exit(1);
> > + goto out;
> >
> > handler = lxc_init(c->name, c->lxc_conf, c->config_path);
> > if (!handler)
> > - exit(1);
> > + goto out;
> >
> > if (!cgroup_init(handler)) {
> > ERROR("failed initing cgroups");
> > @@ -3957,6 +3958,9 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
> > struct criu_opts os;
> > struct lxc_rootfs *rootfs;
> >
> > + close(pipe);
> > + pipe = -1;
> > +
> > if (unshare(CLONE_NEWNS))
> > goto out_fini_handler;
> >
> > @@ -3994,7 +3998,7 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
> > rmdir(rootfs->mount);
> > goto out_fini_handler;
> > } else {
> > - int status, ret;
> > + int ret;
> > char title[2048];
> >
> > pid_t w = waitpid(pid, &status, 0);
> > @@ -4005,6 +4009,7 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
> >
> > ret = write(pipe, &status, sizeof(status));
> > close(pipe);
> > + pipe = -1;
> >
> > if (sizeof(status) != ret) {
> > perror("write");
> > @@ -4056,6 +4061,16 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
> >
> > out_fini_handler:
> > lxc_fini(c->name, handler);
> > +
> > +out:
> > + if (pipe >= 0) {
> > + status = 1;
> > + if (write(pipe, &status, sizeof(status)) != sizeof(status)) {
> > + SYSERROR("writing status failed");
> > + }
> > + close(pipe);
> > + }
> > +
> > exit(1);
> > }
> >
> > --
> > 2.1.4
> >
> > _______________________________________________
> > lxc-devel mailing list
> > lxc-devel at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150406/1aa62bb0/attachment.sig>
More information about the lxc-devel
mailing list