direct-io.hg

view tools/xcutils/xc_save.c @ 11133:bb37d167c82e

[XEND] xc_save/xc_restore open the libxc interface independently
of their parent. This is required now that the interface fd is
marked for close-on-exec.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Aug 15 19:04:43 2006 +0100 (2006-08-15)
parents a51fcb5de470
children 1e590ddb1277
line source
1 /*
2 * This file is subject to the terms and conditions of the GNU General
3 * Public License. See the file "COPYING" in the main directory of
4 * this archive for more details.
5 *
6 * Copyright (C) 2005 by Christian Limpach
7 *
8 */
10 #include <err.h>
11 #include <stdlib.h>
12 #include <stdint.h>
13 #include <string.h>
14 #include <stdio.h>
16 #include <xenctrl.h>
17 #include <xenguest.h>
19 /**
20 * Issue a suspend request through stdout, and receive the acknowledgement
21 * from stdin. This is handled by XendCheckpoint in the Python layer.
22 */
23 static int suspend(int domid)
24 {
25 char ans[30];
27 printf("suspend\n");
28 fflush(stdout);
30 return (fgets(ans, sizeof(ans), stdin) != NULL &&
31 !strncmp(ans, "done\n", 5));
32 }
35 int
36 main(int argc, char **argv)
37 {
38 unsigned int xc_fd, io_fd, domid, maxit, max_f, flags;
39 int ret;
41 if (argc != 6)
42 errx(1, "usage: %s iofd domid maxit maxf flags", argv[0]);
44 xc_fd = xc_interface_open();
45 if (xc_fd < 0)
46 errx(1, "failed to open control interface");
48 io_fd = atoi(argv[1]);
49 domid = atoi(argv[2]);
50 maxit = atoi(argv[3]);
51 max_f = atoi(argv[4]);
52 flags = atoi(argv[5]);
54 ret = xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags, &suspend);
56 xc_interface_close(xc_fd);
58 return ret;
59 }