[CRIU] [PATCH] page-server: allow to execute page-server in the background (v2)
Andrey Vagin
avagin at openvz.org
Mon May 20 06:53:25 EDT 2013
page-server creates a listen socket and only then goes into the
background, so we can be sure, that page-server is ready for work after
detaching.
v2: call daemon() in a proper place and reuse the option -d
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
crtools.c | 3 ++-
include/page-xfer.h | 2 +-
page-xfer.c | 5 ++++-
test/zdtm.sh | 2 +-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/crtools.c b/crtools.c
index 769cade..ef1ce41 100644
--- a/crtools.c
+++ b/crtools.c
@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
}
if (!strcmp(argv[optind], "page-server"))
- return cr_page_server();
+ return cr_page_server(opts.restore_detach);
pr_msg("Unknown command \"%s\"\n", argv[optind]);
usage:
@@ -415,6 +415,7 @@ usage:
"Page server options\n"
" --address ADDR address of page server\n"
" --port PORT port of page server\n"
+" -d run in the background\n"
"\n"
"Show options:\n"
" -f|--file FILE show contents of a checkpoint file\n"
diff --git a/include/page-xfer.h b/include/page-xfer.h
index a6960c1..67a59ec 100644
--- a/include/page-xfer.h
+++ b/include/page-xfer.h
@@ -1,6 +1,6 @@
#ifndef __CR_PAGE_XFER__H__
#define __CR_PAGE_XFER__H__
-int cr_page_server(void);
+int cr_page_server(bool daemon_mode);
/*
* page_xfer -- transfer pages into image file.
diff --git a/page-xfer.c b/page-xfer.c
index 8864e94..93b5815 100644
--- a/page-xfer.c
+++ b/page-xfer.c
@@ -195,7 +195,7 @@ static int page_server_serve(int sk)
return ret;
}
-int cr_page_server(void)
+int cr_page_server(bool daemon_mode)
{
int sk, ask = -1;
struct sockaddr_in caddr;
@@ -223,6 +223,9 @@ int cr_page_server(void)
goto out;
}
+ if (daemon_mode)
+ daemon(0, 0);
+
ask = accept(sk, (struct sockaddr *)&caddr, &clen);
if (ask < 0)
pr_perror("Can't accept connection to server");
diff --git a/test/zdtm.sh b/test/zdtm.sh
index ace17b6..f4ca882 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -349,7 +349,7 @@ EOF
mkdir -p $ddump
if [ $PAGE_SERVER -eq 1 ]; then
- $CRTOOLS page-server -D $ddump -o page_server.log -v 4 --port $PS_PORT &
+ $CRTOOLS page-server -D $ddump -o page_server.log -v 4 --port $PS_PORT -d
PS_PID=$!
opts="--page-server --address 127.0.0.1 --port $PS_PORT"
fi
--
1.8.2
More information about the CRIU
mailing list