[CRIU] [PATCH] uffd.c: create lazy-pages socket in image directory

Adrian Reber adrian at lisas.de
Fri Jan 13 02:47:18 PST 2017


From: Adrian Reber <areber at redhat.com>

runc uses the work-dir and image-dir option to control where
criu is running. This means that criu chdir()-s to work-dir
and the lazy-pages socket cannot be found as it is in the image
directory.

I think there was a problem with too long socket names which make it
impossible to include the full path. Therefore this change tries to
fchdir() to the image directory before accessing the lazy-pages socket
and chdir()-s back to the work-dir after that.

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 criu/uffd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/criu/uffd.c b/criu/uffd.c
index 516b800..fcedb65 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -247,12 +247,16 @@ int prepare_lazy_pages_socket(void)
 		return -1;
 
 	len = offsetof(struct sockaddr_un, sun_path) + strlen(sun.sun_path);
+	/* change to image dir in case work dir has changed */
+	fchdir(criu_get_image_dir());
 	if (connect(new_fd, (struct sockaddr *) &sun, len) < 0) {
 		pr_perror("connect to %s failed", sun.sun_path);
 		close(new_fd);
+		chdir(opts.work_dir);
 		return -1;
 	}
 
+	chdir(opts.work_dir);
 	return 0;
 }
 
-- 
1.8.3.1



More information about the CRIU mailing list