[CRIU] [PATCH 3/3] net: Dont print error in rule save

Pavel Emelyanov xemul at parallels.com
Thu Nov 12 01:15:03 PST 2015


This thing is new and can be absent in ip tool, which is OK
and is handled by net.c code itself.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 include/util.h | 2 ++
 net.c          | 5 +++--
 util.c         | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/util.h b/include/util.h
index 3f7718a..2af6798 100644
--- a/include/util.h
+++ b/include/util.h
@@ -172,6 +172,8 @@ extern int is_anon_link_type(char *link, char *type);
 extern void *shmalloc(size_t bytes);
 extern void shfree_last(void *ptr);
 
+#define CRS_CAN_FAIL	0x1 /* cmd can validly exit with non zero code */
+
 extern int cr_system(int in, int out, int err, char *cmd, char *const argv[], unsigned flags);
 extern int cr_system_userns(int in, int out, int err, char *cmd,
 				char *const argv[], unsigned flags, int userns_pid);
diff --git a/net.c b/net.c
index f85a13c..cca5ef8 100644
--- a/net.c
+++ b/net.c
@@ -602,7 +602,8 @@ static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout,
 	ret = cr_system(fdin, fdout, -1, ip_tool_cmd,
 				(char *[]) { "ip", arg1, arg2, arg3, NULL }, flags);
 	if (ret) {
-		pr_err("IP tool failed on %s %s\n", arg1, arg2);
+		if (!(flags & CRS_CAN_FAIL))
+			pr_err("IP tool failed on %s %s\n", arg1, arg2);
 		return -1;
 	}
 
@@ -663,7 +664,7 @@ static inline int dump_rule(struct cr_imgset *fds)
 	if (!path)
 		return -1;
 
-	if (run_ip_tool("rule", "save", NULL, -1, img_raw_fd(img), 0)) {
+	if (run_ip_tool("rule", "save", NULL, -1, img_raw_fd(img), CRS_CAN_FAIL)) {
 		pr_warn("Check if \"ip rule save\" is supported!\n");
 		unlinkat(get_service_fd(IMG_FD_OFF), path, 0);
 	}
diff --git a/util.c b/util.c
index 69b3102..c8dfaa3 100644
--- a/util.c
+++ b/util.c
@@ -592,7 +592,7 @@ out_chld:
 		}
 
 		if (WIFEXITED(status)) {
-			if (WEXITSTATUS(status))
+			if (!(flags & CRS_CAN_FAIL) && WEXITSTATUS(status))
 				pr_err("exited, status=%d\n", WEXITSTATUS(status));
 			break;
 		} else if (WIFSIGNALED(status)) {
-- 
1.9.3




More information about the CRIU mailing list