[lxc-devel] [lxc/master] Migration fixes
tych0 on Github
lxc-bot at linuxcontainers.org
Fri Aug 26 21:02:52 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160826/7b8474b4/attachment.bin>
-------------- next part --------------
From 1f56665557fb75898cb9cbf550063cc8259cf9ad Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Fri, 26 Aug 2016 16:13:06 -0400
Subject: [PATCH 1/2] remove extra 'ret'
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
src/lxc/criu.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/lxc/criu.c b/src/lxc/criu.c
index c20c00a..5a48c72 100644
--- a/src/lxc/criu.c
+++ b/src/lxc/criu.c
@@ -749,8 +749,6 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
ERROR("criu process exited %d, output:\n%s\n", WEXITSTATUS(status), buf);
goto out_fini_handler;
} else {
- int ret;
-
ret = snprintf(buf, sizeof(buf), "/proc/self/task/%lu/children", (unsigned long)syscall(__NR_gettid));
if (ret < 0 || ret >= sizeof(buf)) {
ERROR("snprintf'd too many characters: %d", ret);
From f3886023c18ce703cb05425d33d8c4e3ca441a3f Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Fri, 26 Aug 2016 16:29:45 -0400
Subject: [PATCH 2/2] c/r: write status only after trying to parse the pid
Previously, we write a "success" status but tried to parse the pid. This
meant that we wouldn't notice a successful restore but failure to parse the
pid, which was a little strange.
We still don't know the child pid, so we will end up with a restored
process tree and a running container, but at least in this case the API
will return false indicating that something failed.
We could kill(-1, 9) in this case, but since liblxc runs as root sometimes
(e.g. LXD), that would be a Very Bad Thing.
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
src/lxc/criu.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/lxc/criu.c b/src/lxc/criu.c
index 5a48c72..71c9b9c 100644
--- a/src/lxc/criu.c
+++ b/src/lxc/criu.c
@@ -723,15 +723,6 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
goto out_fini_handler;
}
- ret = write(status_pipe, &status, sizeof(status));
- close(status_pipe);
- status_pipe = -1;
-
- if (sizeof(status) != ret) {
- SYSERROR("failed to write all of status");
- goto out_fini_handler;
- }
-
if (WIFEXITED(status)) {
char buf[4096];
@@ -780,6 +771,15 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
close(pipes[0]);
+ ret = write(status_pipe, &status, sizeof(status));
+ close(status_pipe);
+ status_pipe = -1;
+
+ if (sizeof(status) != ret) {
+ SYSERROR("failed to write all of status");
+ goto out_fini_handler;
+ }
+
/*
* See comment in lxcapi_start; we don't care if these
* fail because it's just a beauty thing. We just
@@ -805,7 +805,12 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
out:
if (status_pipe >= 0) {
- status = 1;
+ /* ensure getting here was a failure, e.g. if we failed to
+ * parse the child pid or something, even after a successful
+ * restore
+ */
+ if (!status)
+ status = 1;
if (write(status_pipe, &status, sizeof(status)) != sizeof(status)) {
SYSERROR("writing status failed");
}
More information about the lxc-devel
mailing list