diff options
author | emellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com> | 2006-01-10 14:23:56 +0000 |
---|---|---|
committer | emellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com> | 2006-01-10 14:23:56 +0000 |
commit | 3a7a9bda1b677c86944bc5707fb6d6a1a56b88a4 (patch) | |
tree | 2ff059928179bb53b001163a2f56c8e6c9928544 /tools/xcutils | |
parent | 1676162e17e90f35b2c2b03c5b6a06eb8dc35c0b (diff) | |
download | xen-3a7a9bda1b677c86944bc5707fb6d6a1a56b88a4.tar.gz xen-3a7a9bda1b677c86944bc5707fb6d6a1a56b88a4.tar.bz2 xen-3a7a9bda1b677c86944bc5707fb6d6a1a56b88a4.zip |
Extend the xc_linux_save interface to take a callback function for handling the
suspend, and push the printf("suspend") out of xc_linux_save and into xc_save.
This means that xc_linux_save can be used without the xc_save wrapper if
desired.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/xcutils')
-rw-r--r-- | tools/xcutils/xc_save.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/xcutils/xc_save.c b/tools/xcutils/xc_save.c index eac8d1ad2b..44c4701379 100644 --- a/tools/xcutils/xc_save.c +++ b/tools/xcutils/xc_save.c @@ -10,10 +10,28 @@ #include <err.h> #include <stdlib.h> #include <stdint.h> +#include <string.h> #include <stdio.h> #include <xenguest.h> + +/** + * Issue a suspend request through stdout, and receive the acknowledgement + * from stdin. This is handled by XendCheckpoint in the Python layer. + */ +static int suspend(int domid) +{ + char ans[30]; + + printf("suspend\n"); + fflush(stdout); + + return (fgets(ans, sizeof(ans), stdin) != NULL && + !strncmp(ans, "done\n", 5)); +} + + int main(int argc, char **argv) { @@ -29,5 +47,5 @@ main(int argc, char **argv) max_f = atoi(argv[5]); flags = atoi(argv[6]); - return xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags); + return xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags, &suspend); } |