ia64/xen-unstable

changeset 6615:a1de77c1486c

Enable 'live' migration from a tools pov; prior to this the 'live' flag was
being ignored by xend/xc_linux_save.

Signed-off-by: Steven Hand <steven@xensource.com>
author shand@ubuntu.eng.hq.xensource.com
date Fri Sep 02 17:36:29 2005 -0800 (2005-09-02)
parents 0c0d929e787c
children ce018d2730c0 62af59588060
files tools/libxc/xc_linux_save.c tools/libxc/xenguest.h tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/xcutils/xc_save.c
line diff
     1.1 --- a/tools/libxc/xc_linux_save.c	Fri Sep 02 17:55:24 2005 +0000
     1.2 +++ b/tools/libxc/xc_linux_save.c	Fri Sep 02 17:36:29 2005 -0800
     1.3 @@ -21,6 +21,24 @@
     1.4  
     1.5  #define MAX_MBIT_RATE 500
     1.6  
     1.7 +
     1.8 +/*
     1.9 +** Default values for important tuning parameters. Can override by passing
    1.10 +** non-zero replacement values to xc_linux_save().  
    1.11 +**
    1.12 +** XXX SMH: should consider if want to be able to override MAX_MBIT_RATE too. 
    1.13 +** 
    1.14 +*/
    1.15 +#define DEF_MAX_ITERS   29   /* limit us to 30 times round loop */ 
    1.16 +#define DEF_MAX_FACTOR   3   /* never send more than 3x nr_pfns */
    1.17 +
    1.18 +
    1.19 +
    1.20 +/* Flags to control behaviour of xc_linux_save */
    1.21 +#define XCFLAGS_LIVE      1
    1.22 +#define XCFLAGS_DEBUG     2
    1.23 +
    1.24 +
    1.25  #define DEBUG 0
    1.26  
    1.27  #if 1
    1.28 @@ -320,18 +338,18 @@ static int suspend_and_state(int xc_hand
    1.29                               xc_dominfo_t *info,
    1.30                               vcpu_guest_context_t *ctxt)
    1.31  {
    1.32 -    int i=0;
    1.33 +    int i = 0;
    1.34      char ans[30];
    1.35  
    1.36      printf("suspend\n");
    1.37      fflush(stdout);
    1.38      if (fgets(ans, sizeof(ans), stdin) == NULL) {
    1.39 -	ERR("failed reading suspend reply");
    1.40 -	return -1;
    1.41 +        ERR("failed reading suspend reply");
    1.42 +        return -1;
    1.43      }
    1.44      if (strncmp(ans, "done\n", 5)) {
    1.45 -	ERR("suspend reply incorrect: %s", ans);
    1.46 -	return -1;
    1.47 +        ERR("suspend reply incorrect: %s", ans);
    1.48 +        return -1;
    1.49      }
    1.50  
    1.51  retry:
    1.52 @@ -377,20 +395,17 @@ retry:
    1.53      return -1;
    1.54  }
    1.55  
    1.56 -int xc_linux_save(int xc_handle, int io_fd, u32 dom)
    1.57 +int xc_linux_save(int xc_handle, int io_fd, u32 dom, u32 max_iters, 
    1.58 +                  u32 max_factor, u32 flags)
    1.59  {
    1.60      xc_dominfo_t info;
    1.61  
    1.62      int rc = 1, i, j, k, last_iter, iter = 0;
    1.63      unsigned long mfn;
    1.64 -    int live =  0; // (ioctxt->flags & XCFLAGS_LIVE);
    1.65 -    int debug = 0; // (ioctxt->flags & XCFLAGS_DEBUG);
    1.66 +    int live  = (flags & XCFLAGS_LIVE); 
    1.67 +    int debug = (flags & XCFLAGS_DEBUG); 
    1.68      int sent_last_iter, skip_this_iter;
    1.69  
    1.70 -    /* Important tuning parameters */
    1.71 -    int max_iters  = 29; /* limit us to 30 times round loop */
    1.72 -    int max_factor = 3;  /* never send more than 3x nr_pfns */
    1.73 -
    1.74      /* The new domain's shared-info frame number. */
    1.75      unsigned long shared_info_frame;
    1.76      
    1.77 @@ -442,8 +457,16 @@ int xc_linux_save(int xc_handle, int io_
    1.78  
    1.79      MBIT_RATE = START_MBIT_RATE;
    1.80  
    1.81 -    DPRINTF("xc_linux_save start %d\n", dom);
    1.82 -    
    1.83 +
    1.84 +    /* If no explicit control parameters given, use defaults */
    1.85 +    if(!max_iters) 
    1.86 +        max_iters = DEF_MAX_ITERS; 
    1.87 +    if(!max_factor) 
    1.88 +        max_factor = DEF_MAX_FACTOR; 
    1.89 +
    1.90 +
    1.91 +    DPRINTF("xc_linux_save start DOM%u live=%s\n", dom, live?"true":"false"); 
    1.92 +
    1.93      if (mlock(&ctxt, sizeof(ctxt))) {
    1.94          ERR("Unable to mlock ctxt");
    1.95          return 1;
     2.1 --- a/tools/libxc/xenguest.h	Fri Sep 02 17:55:24 2005 +0000
     2.2 +++ b/tools/libxc/xenguest.h	Fri Sep 02 17:36:29 2005 -0800
     2.3 @@ -6,13 +6,12 @@
     2.4   * Copyright (c) 2003-2004, K A Fraser.
     2.5   */
     2.6  
     2.7 -#ifndef XENBUILD_H
     2.8 -#define XENBUILD_H
     2.9 +#ifndef XENGUEST_H
    2.10 +#define XENGUEST_H
    2.11  
    2.12 -#define XCFLAGS_VERBOSE   1
    2.13 -#define XCFLAGS_LIVE      2
    2.14 -#define XCFLAGS_DEBUG     4
    2.15 -#define XCFLAGS_CONFIGURE 8
    2.16 +#define XCFLAGS_LIVE      1
    2.17 +#define XCFLAGS_DEBUG     2
    2.18 +
    2.19  
    2.20  /**
    2.21   * This function will save a domain running Linux.
    2.22 @@ -22,7 +21,8 @@
    2.23   * @parm dom the id of the domain
    2.24   * @return 0 on success, -1 on failure
    2.25   */
    2.26 -int xc_linux_save(int xc_handle, int fd, uint32_t dom);
    2.27 +int xc_linux_save(int xc_handle, int fd, uint32_t dom, uint32_t max_iters, 
    2.28 +                  uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */);
    2.29  
    2.30  /**
    2.31   * This function will restore a saved domain running Linux.
    2.32 @@ -35,8 +35,9 @@ int xc_linux_save(int xc_handle, int fd,
    2.33   * @parm store_mfn returned with the mfn of the store page
    2.34   * @return 0 on success, -1 on failure
    2.35   */
    2.36 -int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, unsigned long nr_pfns,
    2.37 -		     unsigned int store_evtchn, unsigned long *store_mfn);
    2.38 +int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, 
    2.39 +                     unsigned long nr_pfns, unsigned int store_evtchn, 
    2.40 +                     unsigned long *store_mfn);
    2.41  
    2.42  int xc_linux_build(int xc_handle,
    2.43                     uint32_t domid,
    2.44 @@ -65,4 +66,4 @@ int xc_vmx_build(int xc_handle,
    2.45                   unsigned int store_evtchn,
    2.46                   unsigned long *store_mfn);
    2.47  
    2.48 -#endif
    2.49 +#endif // XENGUEST_H
     3.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Fri Sep 02 17:55:24 2005 +0000
     3.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Fri Sep 02 17:36:29 2005 -0800
     3.3 @@ -34,7 +34,7 @@ def read_exact(fd, size, errmsg):
     3.4          raise XendError(errmsg)
     3.5      return buf
     3.6  
     3.7 -def save(xd, fd, dominfo):
     3.8 +def save(xd, fd, dominfo, live):
     3.9      write_exact(fd, SIGNATURE, "could not write guest state file: signature")
    3.10  
    3.11      config = sxp.to_string(dominfo.sxpr())
    3.12 @@ -42,8 +42,13 @@ def save(xd, fd, dominfo):
    3.13                  "could not write guest state file: config len")
    3.14      write_exact(fd, config, "could not write guest state file: config")
    3.15  
    3.16 +    # xc_save takes three customization parameters: maxit, max_f, and flags
    3.17 +    # the last controls whether or not save is 'live', while the first two
    3.18 +    # further customize behaviour when 'live' save is enabled. Passing "0"
    3.19 +    # simply uses the defaults compiled into libxenguest; see the comments 
    3.20 +    # and/or code in xc_linux_save() for more information. 
    3.21      cmd = [PATH_XC_SAVE, str(xc.handle()), str(fd),
    3.22 -           str(dominfo.id)]
    3.23 +           str(dominfo.id), "0", "0", str(live) ]
    3.24      log.info("[xc_save] " + join(cmd))
    3.25      child = xPopen3(cmd, True, -1, [fd, xc.handle()])
    3.26      
     4.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Sep 02 17:55:24 2005 +0000
     4.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Sep 02 17:36:29 2005 -0800
     4.3 @@ -542,7 +542,7 @@ class XendDomain:
     4.4              dominfo.name = "tmp-" + dominfo.name
     4.5  
     4.6          try:
     4.7 -            XendCheckpoint.save(self, sock.fileno(), dominfo)
     4.8 +            XendCheckpoint.save(self, sock.fileno(), dominfo, live)
     4.9          except:
    4.10              if dst == "localhost":
    4.11                  dominfo.name = string.replace(dominfo.name, "tmp-", "", 1)
    4.12 @@ -563,7 +563,8 @@ class XendDomain:
    4.13  
    4.14              fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
    4.15  
    4.16 -            return XendCheckpoint.save(self, fd, dominfo)
    4.17 +            # For now we don't support 'live checkpoint' 
    4.18 +            return XendCheckpoint.save(self, fd, dominfo, False)
    4.19  
    4.20          except OSError, ex:
    4.21              raise XendError("can't write guest state file %s: %s" %
     5.1 --- a/tools/xcutils/xc_save.c	Fri Sep 02 17:55:24 2005 +0000
     5.2 +++ b/tools/xcutils/xc_save.c	Fri Sep 02 17:36:29 2005 -0800
     5.3 @@ -17,14 +17,17 @@
     5.4  int
     5.5  main(int argc, char **argv)
     5.6  {
     5.7 -    unsigned int xc_fd, io_fd, domid;
     5.8 +    unsigned int xc_fd, io_fd, domid, maxit, max_f, flags; 
     5.9  
    5.10 -    if (argc != 4)
    5.11 -	errx(1, "usage: %s xcfd iofd domid", argv[0]);
    5.12 +    if (argc != 7)
    5.13 +	errx(1, "usage: %s xcfd iofd domid maxit maxf flags", argv[0]);
    5.14  
    5.15      xc_fd = atoi(argv[1]);
    5.16      io_fd = atoi(argv[2]);
    5.17      domid = atoi(argv[3]);
    5.18 +    maxit = atoi(argv[4]);
    5.19 +    max_f = atoi(argv[5]);
    5.20 +    flags = atoi(argv[6]);
    5.21  
    5.22 -    return xc_linux_save(xc_fd, io_fd, domid);
    5.23 +    return xc_linux_save(xc_fd, io_fd, domid, maxit, max_f, flags);
    5.24  }