[CRIU] [PATCH 1/3] criu/lazy-pages: fix socket creation with relative images-dir

Mike Rapoport rppt at linux.vnet.ibm.com
Sun Aug 7 07:22:51 PDT 2016


The UNIX sockets do not like relative paths. Assuming both lazy-pages
daemon and restore use the same opts.work_dir, their working directory full
path will be the same.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/uffd.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index 871989c..aecc042 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -120,16 +120,22 @@ static void lpi_hash_fini(void)
 
 static int prepare_sock_addr(struct sockaddr_un *saddr)
 {
+	char cwd[PATH_MAX];
 	int len;
 
+	if (!getcwd(cwd, PATH_MAX)) {
+		pr_perror("Cannot get CWD\n");
+		return -1;
+	}
+
 	memset(saddr, 0, sizeof(struct sockaddr_un));
 
 	saddr->sun_family = AF_UNIX;
 	len = snprintf(saddr->sun_path, sizeof(saddr->sun_path),
-		       "%s/%s", opts.work_dir, LAZY_PAGES_SOCK_NAME);
+		       "%s/%s", cwd, LAZY_PAGES_SOCK_NAME);
 	if (len >= sizeof(saddr->sun_path)) {
 		pr_err("Wrong UNIX socket name: %s/%s\n",
-		       opts.work_dir, LAZY_PAGES_SOCK_NAME);
+		       cwd, LAZY_PAGES_SOCK_NAME);
 		return -1;
 	}
 
-- 
1.9.1



More information about the CRIU mailing list