[CRIU] [PATCH 8/9] libcriu: add cr_errno support

Ruslan Kuprieiev kupruser at gmail.com
Wed Dec 3 11:13:07 PST 2014


Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 lib/criu.c | 20 ++++++++------------
 lib/criu.h |  2 +-
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/lib/criu.c b/lib/criu.c
index ad419ba..18d2091 100644
--- a/lib/criu.c
+++ b/lib/criu.c
@@ -410,6 +410,8 @@ static int criu_connect(void)
 	return fd;
 }
 
+static int cr_errno;
+
 static int send_req_and_recv_resp_sk(int fd, CriuReq *req, CriuResp **resp)
 {
 	int ret = 0;
@@ -448,6 +450,8 @@ again:
 		}
 	}
 
+	cr_errno = (*resp)->cr_errno;
+
 exit:
 	return ret;
 }
@@ -475,8 +479,6 @@ int criu_check(void)
 	CriuReq req	= CRIU_REQ__INIT;
 	CriuResp *resp	= NULL;
 
-	saved_errno = 0;
-
 	req.type	= CRIU_REQ_TYPE__CHECK;
 
 	ret = send_req_and_recv_resp(&req, &resp);
@@ -489,7 +491,7 @@ exit:
 	if (resp)
 		criu_resp__free_unpacked(resp, NULL);
 
-	errno = saved_errno;
+	errno = cr_errno;
 
 	return ret;
 }
@@ -500,8 +502,6 @@ int criu_dump(void)
 	CriuReq req	= CRIU_REQ__INIT;
 	CriuResp *resp	= NULL;
 
-	saved_errno = 0;
-
 	req.type	= CRIU_REQ_TYPE__DUMP;
 	req.opts	= opts;
 
@@ -521,7 +521,7 @@ exit:
 	if (resp)
 		criu_resp__free_unpacked(resp, NULL);
 
-	errno = saved_errno;
+	errno = cr_errno;
 
 	return ret;
 }
@@ -532,8 +532,6 @@ int criu_dump_iters(int (*more)(criu_predump_info pi))
 	CriuReq req	= CRIU_REQ__INIT;
 	CriuResp *resp	= NULL;
 
-	saved_errno = 0;
-
 	req.type	= CRIU_REQ_TYPE__PRE_DUMP;
 	req.opts	= opts;
 
@@ -585,7 +583,7 @@ exit:
 	if (resp)
 		criu_resp__free_unpacked(resp, NULL);
 
-	errno = saved_errno;
+	errno = cr_errno;
 
 	return ret;
 }
@@ -596,8 +594,6 @@ int criu_restore(void)
 	CriuReq req	= CRIU_REQ__INIT;
 	CriuResp *resp	= NULL;
 
-	saved_errno = 0;
-
 	req.type	= CRIU_REQ_TYPE__RESTORE;
 	req.opts	= opts;
 
@@ -614,7 +610,7 @@ exit:
 	if (resp)
 		criu_resp__free_unpacked(resp, NULL);
 
-	errno = saved_errno;
+	errno = cr_errno;
 
 	return ret;
 }
diff --git a/lib/criu.h b/lib/criu.h
index 18f911e..8b6742f 100644
--- a/lib/criu.h
+++ b/lib/criu.h
@@ -76,7 +76,7 @@ int criu_notify_pid(criu_notify_arg_t na);
  *
  * >0            undefined            Success(criu_restore() only).
  *
- * -BADE         rpc err  (0 for now) RPC has returned fail.
+ * -BADE         rpc err (cr_errno)   RPC has returned fail.
  *
  * -ECONNREFUSED errno                Unable to connect to CRIU.
  *
-- 
1.9.3



More information about the CRIU mailing list