[CRIU] [PATCH] page-server: allow to execute page-server in the background
Andrey Vagin
avagin at openvz.org
Mon May 20 03:43:58 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.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
crtools.c | 8 +++++++-
include/page-xfer.h | 2 +-
page-xfer.c | 5 ++++-
test/zdtm.sh | 2 +-
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/crtools.c b/crtools.c
index 769cade..07138a6 100644
--- a/crtools.c
+++ b/crtools.c
@@ -67,6 +67,7 @@ int main(int argc, char *argv[])
int opt, idx;
int log_inited = 0;
int log_level = 0;
+ bool daemon_mode = false;
BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
@@ -116,6 +117,7 @@ int main(int argc, char *argv[])
{ "prev-images-dir", required_argument, 0, 53},
{ "ms", no_argument, 0, 54},
{ "track-mem", no_argument, 0, 55},
+ { "daemon", no_argument, 0, 56},
{ },
};
@@ -271,6 +273,9 @@ int main(int argc, char *argv[])
case 54:
opts.check_ms_kernel = true;
break;
+ case 56:
+ daemon_mode = true;
+ break;
case 'V':
pr_msg("Version: %s\n", version);
return 0;
@@ -346,7 +351,7 @@ int main(int argc, char *argv[])
}
if (!strcmp(argv[optind], "page-server"))
- return cr_page_server();
+ return cr_page_server(daemon_mode);
pr_msg("Unknown command \"%s\"\n", argv[optind]);
usage:
@@ -415,6 +420,7 @@ usage:
"Page server options\n"
" --address ADDR address of page server\n"
" --port PORT port of page server\n"
+" --daemon 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..7a93068 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;
@@ -233,6 +233,9 @@ out:
if (ask < 0)
return -1;
+ if (daemon_mode)
+ daemon(0, 0);
+
pr_info("Accepted connection from %s:%u\n",
inet_ntoa(caddr.sin_addr),
(int)ntohs(caddr.sin_port));
diff --git a/test/zdtm.sh b/test/zdtm.sh
index ace17b6..a82bf97 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
PS_PID=$!
opts="--page-server --address 127.0.0.1 --port $PS_PORT"
fi
--
1.8.2
More information about the CRIU
mailing list