[CRIU] [PATCH 01/18] zdtm: Test descriptor sent over unix and kept open
Andrei Vagin
avagin at virtuozzo.com
Tue Aug 8 04:04:39 MSK 2017
Do you support a case when a socket is queued to the same socket?
[root at fc24 criu]# git diff
diff --git a/test/zdtm/static/scm00.c b/test/zdtm/static/scm00.c
index de626d9c9..39a91a8ae 100644
--- a/test/zdtm/static/scm00.c
+++ b/test/zdtm/static/scm00.c
@@ -84,6 +84,10 @@ int main(int argc, char **argv)
exit(1);
}
+ if (send_fd(sk[0], sk[0]) < 0) {
+ pr_perror("Can't send descriptor");
+ exit(1);
+ }
if (send_fd(sk[0], p[0]) < 0) {
pr_perror("Can't send descriptor");
exit(1);
@@ -115,6 +119,11 @@ int main(int argc, char **argv)
fail("Can't recv pipe back (%d)", p[0]);
goto out;
}
+ rfd = recv_fd(sk[1]);
+ if (rfd < 0) {
+ fail("Can't recv pipe back (%d)", p[0]);
+ goto out;
+ }
#ifdef SEND_BOTH
test_msg("Recv 2nd end\n");
diff --git a/test/zdtm/static/scm01.desc b/test/zdtm/static/scm01.desc
index ded89879a..95e9e8a16 100644
--- a/test/zdtm/static/scm01.desc
+++ b/test/zdtm/static/scm01.desc
@@ -1 +1 @@
-{'flags': 'crfail'}
+{'flags': ''}
[root at fc24 criu]# python test/zdtm.py run -t zdtm/static/scm01
=== Run 1/1 ================ zdtm/static/scm01
========================== Run zdtm/static/scm01 in h ==========================
Start test
./scm01 --pidfile=scm01.pid --outfile=scm01.out
Run criu dump
=[log]=> dump/zdtm/static/scm01/24/1/dump.log
------------------------ grep Error ------------------------
(00.005867) Searching for socket aa2b (family 1.0)
(00.005872) Searching for socket aa2a (family 1.0)
(00.005888) No filter for socket
(00.005953) 25 fdinfo 10: pos: 0 flags: 2/0
(00.005965) Error (criu/sk-queue.c:110): Can't dump send 5 (unix/epoll) fd
(00.005983) ----------------------------------------
(00.006013) Error (criu/cr-dump.c:1430): Dump files (pid: 24) failed with -1
(00.007023) 24 was stopped
(00.007283) Unlock network
(00.007298) Unfreezing tasks into 1
(00.007306) Unseizing 24 into 1
(00.007329) Error (criu/cr-dump.c:1800): Dumping FAILED.
------------------------ ERROR OVER ------------------------
################### Test zdtm/static/scm01 FAIL at CRIU dump ###################
Send the 9 signal to 24
Wait for zdtm/static/scm01(24) to die for 0.100000
##################################### FAIL #####################################
On Mon, Jul 10, 2017 at 12:37:50PM +0300, Pavel Emelyanov wrote:
>
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
> ---
> test/zdtm/static/Makefile | 2 ++
> test/zdtm/static/scm00.c | 26 +++++++++++++++++++++-----
> test/zdtm/static/scm01.c | 1 +
> test/zdtm/static/scm01.desc | 1 +
> 4 files changed, 25 insertions(+), 5 deletions(-)
> create mode 120000 test/zdtm/static/scm01.c
> create mode 100644 test/zdtm/static/scm01.desc
>
> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
> index 6947e05..661ff7f 100644
> --- a/test/zdtm/static/Makefile
> +++ b/test/zdtm/static/Makefile
> @@ -154,6 +154,7 @@ TST_NOFILE := \
> remap_dead_pid \
> remap_dead_pid_root \
> scm00 \
> + scm01 \
> aio00 \
> aio01 \
> fd \
> @@ -442,6 +443,7 @@ socket-tcp-closed-last-ack: CFLAGS += -D ZDTM_TCP_LAST_ACK
> mnt_ext_manual: CFLAGS += -D ZDTM_EXTMAP_MANUAL
> sigpending: LDLIBS += -lrt
> vdso01: LDLIBS += -lrt
> +scm01: CFLAGS += -DKEEP_SENT_FD
> mntns_link_remap: CFLAGS += -DZDTM_LINK_REMAP
> mntns_shared_bind02: CFLAGS += -DSHARED_BIND02
> mntns_root_bind02: CFLAGS += -DROOT_BIND02
> diff --git a/test/zdtm/static/scm00.c b/test/zdtm/static/scm00.c
> index 6f0c7b7..39c1473 100644
> --- a/test/zdtm/static/scm00.c
> +++ b/test/zdtm/static/scm00.c
> @@ -68,7 +68,7 @@ static int recv_fd(int via)
>
> int main(int argc, char **argv)
> {
> - int sk[2], p[2];
> + int sk[2], p[2], rfd;
> #define MSG "HELLO"
> char buf[8]; /* bigger than the MSG to check boundaries */
>
> @@ -89,6 +89,7 @@ int main(int argc, char **argv)
> exit(1);
> }
>
> +#ifndef KEEP_SENT_FD
> close(p[0]);
>
> /* Swap pipe ends to make scm recv put pipe into different place */
> @@ -96,22 +97,29 @@ int main(int argc, char **argv)
> close(p[1]);
> p[1] = p[0];
> p[0] = -1;
> +#endif
>
> test_daemon();
> test_waitsig();
>
> - p[0] = recv_fd(sk[1]);
> - if (p[0] < 0) {
> + rfd = recv_fd(sk[1]);
> + if (rfd < 0) {
> fail("Can't recv pipe back (%d)", p[0]);
> goto out;
> }
> -
> +#ifdef KEEP_SENT_FD
> + if (rfd == p[0]) {
> + fail("Original descriptor not kept");
> + goto out;
> + }
> +again:
> +#endif
> if (write(p[1], MSG, sizeof(MSG)) != sizeof(MSG)) {
> fail("Pipe write-broken");
> goto out;
> }
>
> - if (read(p[0], buf, sizeof(buf)) != sizeof(MSG)) {
> + if (read(rfd, buf, sizeof(buf)) != sizeof(MSG)) {
> fail("Pipe read-broken");
> goto out;
> }
> @@ -122,6 +130,14 @@ int main(int argc, char **argv)
> goto out;
> }
>
> +#ifdef KEEP_SENT_FD
> + if (rfd != p[0]) {
> + test_msg("Check kept\n");
> + rfd = p[0];
> + goto again;
> + }
> +#endif
> +
> pass();
> out:
> return 0;
> diff --git a/test/zdtm/static/scm01.c b/test/zdtm/static/scm01.c
> new file mode 120000
> index 0000000..4cab0ed
> --- /dev/null
> +++ b/test/zdtm/static/scm01.c
> @@ -0,0 +1 @@
> +scm00.c
> \ No newline at end of file
> diff --git a/test/zdtm/static/scm01.desc b/test/zdtm/static/scm01.desc
> new file mode 100644
> index 0000000..ded8987
> --- /dev/null
> +++ b/test/zdtm/static/scm01.desc
> @@ -0,0 +1 @@
> +{'flags': 'crfail'}
> --
> 2.1.4
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list