remote: Check if socket exist before dump/restore

Submitted by Radostin Stoyanov on Sept. 24, 2018, 4:51 p.m.

Details

Message ID 20180924165151.27891-1-rstoyanov1@gmail.com
State New
Series "remote: Check if socket exist before dump/restore"
Headers show

Commit Message

Radostin Stoyanov Sept. 24, 2018, 4:51 p.m.
When running `criu dump` with --remote before image-proxy was started
the following errors occur.

 # criu dump -t 24159 -j --remote
 Error (criu/img-remote.c:209): Unable to connect to local socket: img-proxy.sock: No such file or directory
 Error (criu/img-remote.c:1150): Unable to open snapshot id push connection
 Error (criu/cr-dump.c:1764): Failed to push image namespace.
 Error (criu/stats.c:76): BUG at criu/stats.c:76
 Aborted

And similar error will be shown on restore:

 # criu restore -j --remote
 Error (criu/img-remote.c:209): Unable to connect to local socket: img-cache.sock: No such file or directory
 Error (criu/img-remote.c:1003): Error opening local connection for parent:null
 Error (criu/img-remote.c:209): Unable to connect to local socket: img-cache.sock: No such file or directory
 Error (criu/img-remote.c:1003): Error opening local connection for parent:null
 Error (criu/img-remote.c:1193): Error, could not find current snapshot id (.) fd
 Error (criu/img-remote.c:1216): Error, could not find snapshot id for idx -1
 Error (criu/util.c:725): Can't read link of fd -404: No such file or directory
 Error (criu/protobuf.c:75): Unexpected EOF on (null)

With this change the above messages will be replaced with:

 # criu dump -t 24159 -j --remote
 Error (criu/crtools.c:234): Can't access img-proxy.sock: No such file or directory

 # criu restore -j --remote
 Error (criu/crtools.c:255): Can't access img-cache.sock: No such file or directory

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 criu/crtools.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/crtools.c b/criu/crtools.c
index 64d298de..cbe4be08 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -230,6 +230,11 @@  int main(int argc, char *argv[], char *envp[])
 		pr_info("Will do snapshot from %s\n", opts.img_parent);
 
 	if (!strcmp(argv[optind], "dump")) {
+		if (opts.remote && euidaccess(DEFAULT_PROXY_SOCKET, R_OK|W_OK)) {
+			pr_perror("Can't access %s", DEFAULT_PROXY_SOCKET);
+			return 1;
+		}
+
 		if (!opts.tree_id)
 			goto opt_pid_missing;
 		return cr_dump_tasks(opts.tree_id);
@@ -246,6 +251,11 @@  int main(int argc, char *argv[], char *envp[])
 		if (opts.tree_id)
 			pr_warn("Using -t with criu restore is obsoleted\n");
 
+		if (opts.remote && euidaccess(DEFAULT_CACHE_SOCKET, R_OK|W_OK)) {
+			pr_perror("Can't access %s", DEFAULT_CACHE_SOCKET);
+			return 1;
+		}
+
 		ret = cr_restore_tasks();
 		if (ret == 0 && opts.exec_cmd) {
 			close_pid_proc();