direct-io.hg

changeset 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 d20e1835c24b
children ec03b24a2d83
files tools/python/xen/xend/XendCheckpoint.py tools/xcutils/xc_restore.c tools/xcutils/xc_save.c
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Tue Aug 15 18:20:03 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Tue Aug 15 19:04:43 2006 +0100
     1.3 @@ -78,7 +78,7 @@ def save(fd, dominfo, network, live, dst
     1.4          # enabled. Passing "0" simply uses the defaults compiled into
     1.5          # libxenguest; see the comments and/or code in xc_linux_save() for
     1.6          # more information.
     1.7 -        cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(xc.handle()), str(fd),
     1.8 +        cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(fd),
     1.9                 str(dominfo.getDomid()), "0", "0", str(int(live)) ]
    1.10          log.debug("[xc_save]: %s", string.join(cmd))
    1.11  
    1.12 @@ -150,7 +150,7 @@ def restore(xd, fd):
    1.13          balloon.free(xc.pages_to_kib(nr_pfns))
    1.14  
    1.15          cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE),
    1.16 -                        xc.handle(), fd, dominfo.getDomid(), nr_pfns,
    1.17 +                        fd, dominfo.getDomid(), nr_pfns,
    1.18                          store_port, console_port])
    1.19          log.debug("[xc_restore]: %s", string.join(cmd))
    1.20  
     2.1 --- a/tools/xcutils/xc_restore.c	Tue Aug 15 18:20:03 2006 +0100
     2.2 +++ b/tools/xcutils/xc_restore.c	Tue Aug 15 19:04:43 2006 +0100
     2.3 @@ -12,6 +12,7 @@
     2.4  #include <stdint.h>
     2.5  #include <stdio.h>
     2.6  
     2.7 +#include <xenctrl.h>
     2.8  #include <xenguest.h>
     2.9  
    2.10  int
    2.11 @@ -21,17 +22,20 @@ main(int argc, char **argv)
    2.12      int ret;
    2.13      unsigned long store_mfn, console_mfn;
    2.14  
    2.15 -    if (argc != 7)
    2.16 +    if (argc != 6)
    2.17  	errx(1,
    2.18 -	     "usage: %s xcfd iofd domid nr_pfns store_evtchn console_evtchn",
    2.19 +	     "usage: %s iofd domid nr_pfns store_evtchn console_evtchn",
    2.20  	     argv[0]);
    2.21  
    2.22 -    xc_fd = atoi(argv[1]);
    2.23 -    io_fd = atoi(argv[2]);
    2.24 -    domid = atoi(argv[3]);
    2.25 -    nr_pfns = atoi(argv[4]);
    2.26 -    store_evtchn = atoi(argv[5]);
    2.27 -    console_evtchn = atoi(argv[6]);
    2.28 +    xc_fd = xc_interface_open();
    2.29 +    if (xc_fd < 0)
    2.30 +        errx(1, "failed to open control interface");
    2.31 +
    2.32 +    io_fd = atoi(argv[1]);
    2.33 +    domid = atoi(argv[2]);
    2.34 +    nr_pfns = atoi(argv[3]);
    2.35 +    store_evtchn = atoi(argv[4]);
    2.36 +    console_evtchn = atoi(argv[5]);
    2.37  
    2.38      ret = xc_linux_restore(xc_fd, io_fd, domid, nr_pfns, store_evtchn,
    2.39  			   &store_mfn, console_evtchn, &console_mfn);
    2.40 @@ -40,5 +44,8 @@ main(int argc, char **argv)
    2.41  	printf("console-mfn %li\n", console_mfn);
    2.42  	fflush(stdout);
    2.43      }
    2.44 +
    2.45 +    xc_interface_close(xc_fd);
    2.46 +
    2.47      return ret;
    2.48  }
     3.1 --- a/tools/xcutils/xc_save.c	Tue Aug 15 18:20:03 2006 +0100
     3.2 +++ b/tools/xcutils/xc_save.c	Tue Aug 15 19:04:43 2006 +0100
     3.3 @@ -13,9 +13,9 @@
     3.4  #include <string.h>
     3.5  #include <stdio.h>
     3.6  
     3.7 +#include <xenctrl.h>
     3.8  #include <xenguest.h>
     3.9  
    3.10 -
    3.11  /**
    3.12   * Issue a suspend request through stdout, and receive the acknowledgement
    3.13   * from stdin.  This is handled by XendCheckpoint in the Python layer.
    3.14 @@ -36,16 +36,24 @@ int
    3.15  main(int argc, char **argv)
    3.16  {
    3.17      unsigned int xc_fd, io_fd, domid, maxit, max_f, flags; 
    3.18 +    int ret;
    3.19  
    3.20 -    if (argc != 7)
    3.21 -	errx(1, "usage: %s xcfd iofd domid maxit maxf flags", argv[0]);
    3.22 +    if (argc != 6)
    3.23 +	errx(1, "usage: %s iofd domid maxit maxf flags", argv[0]);
    3.24 +
    3.25 +    xc_fd = xc_interface_open();
    3.26 +    if (xc_fd < 0)
    3.27 +        errx(1, "failed to open control interface");
    3.28  
    3.29 -    xc_fd = atoi(argv[1]);
    3.30 -    io_fd = atoi(argv[2]);
    3.31 -    domid = atoi(argv[3]);
    3.32 -    maxit = atoi(argv[4]);
    3.33 -    max_f = atoi(argv[5]);
    3.34 -    flags = atoi(argv[6]);
    3.35 +    io_fd = atoi(argv[1]);
    3.36 +    domid = atoi(argv[2]);
    3.37 +    maxit = atoi(argv[3]);
    3.38 +    max_f = atoi(argv[4]);
    3.39 +    flags = atoi(argv[5]);
    3.40  
    3.41 -    return xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags, &suspend);
    3.42 +    ret = xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags, &suspend);
    3.43 +
    3.44 +    xc_interface_close(xc_fd);
    3.45 +
    3.46 +    return ret;
    3.47  }