[Devel] [PATCH] files-reg: Prepare for sysfs entries mode change

Cyrill Gorcunov gorcunov at virtuozzo.com
Tue Jan 16 01:51:31 MSK 2018


The kernel virtualize access to proc/sys/ entries in
lightweight way -- if entry is opened from inside of
veX then it's not allowed to be written.

Still we're dumping files in ve0 environment so the
mode for such files may no match on restore, because
restore itself is running inside veX.

 | (00.701122)    111: Error (criu/files-reg.c:1976): File proc/sys/vm/overcommit_kbytes has bad mode 0100444 (expect 0100644)
 | (00.701496)    334: Error (criu/cr-restore.c:1353): 111 exited, status=1

so i think we can simply skip such testing inside ve criu
instance since it's kernel specific.

Simply print out a warning for refernce and continue

 | (00.827328)    111: Error (criu/files-reg.c:1977): File proc/sys/vm/overcommit_kbytes has bad mode 0100444 (expect 0100644)
 | (00.827332)    111: Warn  (criu/files-reg.c:1985):      Expecting in VE environment. Ignore.

https://jira.sw.ru/browse/PSBM-80585

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/files-reg.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 27e4cf48d..0cc6a5e19 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -48,6 +48,7 @@
 #include "plugin.h"
 
 #define ATOP_ACCT_FILE "tmp/atop.d/atop.acct"
+#define PROCFS_SYSDIR	"proc/sys/"
 
 int setfsuid(uid_t fsuid);
 int setfsgid(gid_t fsuid);
@@ -1974,7 +1975,16 @@ int open_path(struct file_desc *d,
 				pr_err("File %s has bad mode 0%o (expect 0%o)\n",
 				       rfi->path, (int)st.st_mode,
 				       rfi->rfe->mode);
-				return -1;
+				/*
+				 * When we're restoring proc/sysfs entry the
+				 * file modes are virtualized by kernel and
+				 * 'write' bit is dropped when opening inside
+				 * veX. So don't fail in such case.
+				 */
+				if (!strncmp(rfi->path, PROCFS_SYSDIR, strlen(PROCFS_SYSDIR))) {
+					pr_warn("\tExpecting in VE environment. Ignore.\n");
+				} else
+					return -1;
 			}
 		}
 
-- 
2.14.3



More information about the Devel mailing list