net/ip: print fd link of the image we fail to restore from

Submitted by Pavel Tikhomirov on Aug. 7, 2018, 12:52 p.m.

Details

Message ID 20180807125202.4376-1-ptikhomirov@virtuozzo.com
State New
Series "net/ip: print fd link of the image we fail to restore from"
Headers show

Commit Message

Pavel Tikhomirov Aug. 7, 2018, 12:52 p.m.
https://travis-ci.org/criupatchwork/criu/jobs/412519099

Patch hide | download patch | download mbox

========================= Run zdtm/static/env00 in ns ==========================
Start test
./env00 --pidfile=env00.pid --outfile=env00.out --envname=ENV_00_TEST
Run criu dump
Run criu restore
Fail RESTORE failed: Error(0): Unknown
=[log]=> dump/zdtm/static/env00/85/1/restore.log
------------------------ grep Error ------------------------
(00.000075) Version: 3.10 (gitid 49f7e07)
(00.000143) Running on travis-job-8a974ebb-7c8c-4133-9e93-c9f803cae02c Linux 4.4.0-51-generic #72~14.04.1-Ubuntu SMP Thu Nov 24 19:22:30 UTC 2016 x86_64
profiling:/home/travis/build/criupatchwork/criu/criu/cr-dump.gcda:Merge mismatch for function 45
Magic mismatch (1 elems, 666f7270 magic)
     1: Error (criu/util.c:834): exited, status=255
     1: Error (criu/net.c:1730): IP tool failed on addr restore
     1: Error (criu/util.c:1535): Can't wait or bad status: errno=0, status=65280
(00.000143) Error (criu/mount.c:3273): mnt: Can't remove the directory /tmp/.criu.mntns.WR0uSi: No such file or directory
(00.000143) Error (criu/cr-restore.c:2308): Restoring FAILED.
------------------------ ERROR OVER ------------------------

These "ip addr restore < some_ip_addr_dump.img" fails because wrong
magic in image, it is 0x666f7270 but should be 0x47361222, may be we
somehow gave the wrong file to ip util?

Moreover we have same error with same wrong magic for other series:
https://travis-ci.org/criupatchwork/criu/jobs/409952785, but for me it
does not reproduce in 4 runs in travis, so add more info about the
image.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 criu/net.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/criu/net.c b/criu/net.c
index cbd03dd0a..d8944bc43 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -1726,8 +1726,14 @@  static int run_ip_tool(char *arg1, char *arg2, char *arg3, char *arg4, int fdin,
 	ret = cr_system(fdin, fdout, -1, ip_tool_cmd,
 				(char *[]) { "ip", arg1, arg2, arg3, arg4, NULL }, flags);
 	if (ret) {
-		if (!(flags & CRS_CAN_FAIL))
+		if (!(flags & CRS_CAN_FAIL)) {
+			char buf[PATH_MAX];
+
 			pr_err("IP tool failed on %s %s %s %s\n", arg1, arg2, arg3 ? : "\0", arg4 ? : "\0");
+			if (!strcmp(arg2, "restore")
+			    && read_fd_link(fdin, buf, sizeof(buf)) >= 0)
+				pr_err("failed restore from image %s\n", buf);
+		}
 		return -1;
 	}
 

Comments

Dmitry Safonov Aug. 7, 2018, 1:58 p.m.
2018-08-07 13:52 GMT+01:00 Pavel Tikhomirov <ptikhomirov@virtuozzo.com>:
[..]
>                         pr_err("IP tool failed on %s %s %s %s\n", arg1, arg2, arg3 ? : "\0", arg4 ? : "\0");

Minor nit:
"\0" is a string with *two* null-terminates, so you could use just "".
BTW, I believe, printf() is smart enough to not dereference null-ptr
from %s. But that force comes with the price of "(null)" printed, IIRC.
If it's ok - this code line is prettier :)
Pavel Tikhomirov Aug. 8, 2018, 9:19 a.m.
> These "ip addr restore < some_ip_addr_dump.img" fails because wrong
> magic in image, it is 0x666f7270 but should be 0x47361222, may be we
> somehow gave the wrong file to ip util?
> 

Finally I got reproduce on my own travis test 
https://travis-ci.org/Snorch/criu/jobs/413103226 :

========================= Run zdtm/static/env00 in ns 
==========================
Start test
./env00 --pidfile=env00.pid --outfile=env00.out --envname=ENV_00_TEST
Run criu dump
Run criu restore
Fail RESTORE failed: Error(0): Unknown
=[log]=> dump/zdtm/static/env00/85/1/restore.log
------------------------ grep Error ------------------------
(00.000031) Version: 3.10 (gitid c3ba917)
(00.000048) Running on travis-job-9486da43-0fa9-41cf-b230-af61bff5f2ac 
Linux 4.4.0-51-generic #72~14.04.1-Ubuntu SMP Thu Nov 24 19:22:30 UTC 
2016 x86_64
profiling:/home/travis/build/Snorch/criu/criu/sk-unix.gcda:Merge 
mismatch for function 26
Magic mismatch (1 elems, 666f7270 magic)
      1: Error (criu/util.c:834): exited, status=255
      1: Error (criu/net.c:1732): IP tool failed on addr restore
      1: Error (criu/net.c:1735): failed restore from image 
/home/travis/build/Snorch/criu/test/dump/zdtm/static/env00/85/1/ifaddr-9.img
      1: Error (criu/util.c:1535): Can't wait or bad status: errno=0, 
status=65280
(00.000048) Error (criu/mount.c:3273): mnt: Can't remove the directory 
/tmp/.criu.mntns.EsrXyB: No such file or directory
(00.000048) Error (criu/cr-restore.c:2308): Restoring FAILED.
------------------------ ERROR OVER ------------------------
################# Test zdtm/static/env00 FAIL at CRIU restore 
##################

The image file is right ifaddr-9.img, but why it has wrong magic, may be 
we did something wrong on dump? Will try adding more debug.