[CRIU] [PATCH 4/4] fi: Test that ghosts are removed if restore fails

Pavel Emelyanov xemul at parallels.com
Thu Sep 24 08:08:24 PDT 2015


This is again 2 steps:

First, the unlink_fstat00 is marked with .fault file, criu
is asked to fail the restore soon after root task is born
and is ready to fork kids.

Correctly failed restore is then if no ghost files is left.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-restore.c                               |  7 ++++++-
 include/fault-injection.h                  |  1 +
 test/zdtm.sh                               |  1 +
 test/zdtm/live/static/unlink_fstat00.fault | 14 ++++++++++++++
 4 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100755 test/zdtm/live/static/unlink_fstat00.fault

diff --git a/cr-restore.c b/cr-restore.c
index b8b4473..31bd3f9 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -76,7 +76,7 @@
 #include "security.h"
 #include "lsm.h"
 #include "seccomp.h"
-
+#include "fault-injection.h"
 #include "parasite-syscall.h"
 
 #include "protobuf.h"
@@ -1532,6 +1532,11 @@ static int restore_task_with_children(void *_arg)
 	if (prepare_sigactions() < 0)
 		goto err_fini_mnt;
 
+	if (fault_injected(FI_RESTORE_ROOT_ONLY)) {
+		pr_info("fault: Restore root task failure!\n");
+		BUG();
+	}
+
 	if (create_children_and_session())
 		goto err_fini_mnt;
 
diff --git a/include/fault-injection.h b/include/fault-injection.h
index 0f91967..989f654 100644
--- a/include/fault-injection.h
+++ b/include/fault-injection.h
@@ -5,6 +5,7 @@
 enum faults {
 	FI_NONE = 0,
 	FI_DUMP_EARLY,
+	FI_RESTORE_ROOT_ONLY,
 	FI_MAX,
 };
 
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 75bc439..b81290f 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -212,6 +212,7 @@ generate_test_list()
 		ns/static/apparmor
 		static/different_creds
 		finj/static/env00
+		finj/static/unlink_fstat00
 	"
 
 	TEST_CR_KERNEL="
diff --git a/test/zdtm/live/static/unlink_fstat00.fault b/test/zdtm/live/static/unlink_fstat00.fault
new file mode 100755
index 0000000..941fa96
--- /dev/null
+++ b/test/zdtm/live/static/unlink_fstat00.fault
@@ -0,0 +1,14 @@
+#!/bin/bash
+#fault:2
+if [ "$1" != "restore" ]; then
+	echo "Unexpected CRIU fail @$1"
+	exit 1
+fi
+
+if find -name 'unlink_fstat00*ghost'; then
+	echo "Dangling ghost file"
+	exit 1
+fi
+
+echo "Looks OK"
+exit 0
-- 
1.9.3




More information about the CRIU mailing list