aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xcutils
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-15 19:04:43 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-15 19:04:43 +0100
commitd0ed0b289c9d86f395e3e242c964447e1bfa775e (patch)
treee9d21822ff41b54b8eb8f768dd18a7f5b4ea422b /tools/xcutils
parent835d343163ca88a2d58d96680a43b865f143b33c (diff)
downloadxen-d0ed0b289c9d86f395e3e242c964447e1bfa775e.tar.gz
xen-d0ed0b289c9d86f395e3e242c964447e1bfa775e.tar.bz2
xen-d0ed0b289c9d86f395e3e242c964447e1bfa775e.zip
[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>
Diffstat (limited to 'tools/xcutils')
-rw-r--r--tools/xcutils/xc_restore.c23
-rw-r--r--tools/xcutils/xc_save.c28
2 files changed, 33 insertions, 18 deletions
diff --git a/tools/xcutils/xc_restore.c b/tools/xcutils/xc_restore.c
index c94dbd3bbe..c8b2b89331 100644
--- a/tools/xcutils/xc_restore.c
+++ b/tools/xcutils/xc_restore.c
@@ -12,6 +12,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <xenctrl.h>
#include <xenguest.h>
int
@@ -21,17 +22,20 @@ main(int argc, char **argv)
int ret;
unsigned long store_mfn, console_mfn;
- if (argc != 7)
+ if (argc != 6)
errx(1,
- "usage: %s xcfd iofd domid nr_pfns store_evtchn console_evtchn",
+ "usage: %s iofd domid nr_pfns store_evtchn console_evtchn",
argv[0]);
- xc_fd = atoi(argv[1]);
- io_fd = atoi(argv[2]);
- domid = atoi(argv[3]);
- nr_pfns = atoi(argv[4]);
- store_evtchn = atoi(argv[5]);
- console_evtchn = atoi(argv[6]);
+ xc_fd = xc_interface_open();
+ if (xc_fd < 0)
+ errx(1, "failed to open control interface");
+
+ io_fd = atoi(argv[1]);
+ domid = atoi(argv[2]);
+ nr_pfns = atoi(argv[3]);
+ store_evtchn = atoi(argv[4]);
+ console_evtchn = atoi(argv[5]);
ret = xc_linux_restore(xc_fd, io_fd, domid, nr_pfns, store_evtchn,
&store_mfn, console_evtchn, &console_mfn);
@@ -40,5 +44,8 @@ main(int argc, char **argv)
printf("console-mfn %li\n", console_mfn);
fflush(stdout);
}
+
+ xc_interface_close(xc_fd);
+
return ret;
}
diff --git a/tools/xcutils/xc_save.c b/tools/xcutils/xc_save.c
index 44c4701379..c9be3454d4 100644
--- a/tools/xcutils/xc_save.c
+++ b/tools/xcutils/xc_save.c
@@ -13,9 +13,9 @@
#include <string.h>
#include <stdio.h>
+#include <xenctrl.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.
@@ -36,16 +36,24 @@ int
main(int argc, char **argv)
{
unsigned int xc_fd, io_fd, domid, maxit, max_f, flags;
+ int ret;
+
+ if (argc != 6)
+ errx(1, "usage: %s iofd domid maxit maxf flags", argv[0]);
+
+ xc_fd = xc_interface_open();
+ if (xc_fd < 0)
+ errx(1, "failed to open control interface");
+
+ io_fd = atoi(argv[1]);
+ domid = atoi(argv[2]);
+ maxit = atoi(argv[3]);
+ max_f = atoi(argv[4]);
+ flags = atoi(argv[5]);
- if (argc != 7)
- errx(1, "usage: %s xcfd iofd domid maxit maxf flags", argv[0]);
+ ret = xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags, &suspend);
- xc_fd = atoi(argv[1]);
- io_fd = atoi(argv[2]);
- domid = atoi(argv[3]);
- maxit = atoi(argv[4]);
- max_f = atoi(argv[5]);
- flags = atoi(argv[6]);
+ xc_interface_close(xc_fd);
- return xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags, &suspend);
+ return ret;
}