[CRIU] [PATCH] restorer: Use of CR_RLIM_NLIMITS for resource allocation

Cyrill Gorcunov gorcunov at openvz.org
Tue Jul 2 08:29:26 EDT 2013


rhel6 has RLIM_NLIMITS defined to 15, while modern
kernels increased this value to 16 (this value
comes from glibc-headers-2.12-1.80.el6.x86_64
package) -- so use own definition for resource
array allocation thus even being compiled on
rhel6 criu would be able to proceed c/r.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-restore.c       | 2 +-
 include/restorer.h | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 2146da2..abe2afc 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1831,7 +1831,7 @@ static int prepare_rlimits(int pid, struct task_restore_core_args *ta)
 			break;
 
 		l = ta->nr_rlim;
-		if (l == RLIM_NLIMITS) {
+		if (l == ARRAY_SIZE(ta->rlims)) {
 			pr_err("Too many rlimits in image for %d\n", pid);
 			ret = -1;
 			break;
diff --git a/include/restorer.h b/include/restorer.h
index 8a796a5..d14ff40 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -23,6 +23,13 @@
 #include "protobuf/creds.pb-c.h"
 #include "protobuf/core.pb-c.h"
 
+#define CR_RLIM_NLIMITS 16
+
+static inline void builtin_check_nlimits(void)
+{
+	BUILD_BUG_ON(CR_RLIM_NLIMITS < RLIM_NLIMITS);
+}
+
 struct task_restore_core_args;
 struct thread_restore_args;
 
@@ -146,7 +153,7 @@ struct task_restore_core_args {
 	char				comm[TASK_COMM_LEN];
 
 	int				nr_rlim;
-	struct rlimit			rlims[RLIM_NLIMITS];
+	struct rlimit			rlims[CR_RLIM_NLIMITS];
 
 	struct rst_tcp_sock		*rst_tcp_socks;
 	int				rst_tcp_socks_size;
-- 
1.8.1.4



More information about the CRIU mailing list