direct-io.hg

changeset 2270:3974feb63b14

bitkeeper revision 1.1159.38.5 (41235bac45keyRYBSLnIxXITxalrzg)

Add 'live' parameter to migrate.
author mjw@wray-m-3.hpl.hp.com
date Wed Aug 18 13:37:48 2004 +0000 (2004-08-18)
parents dbbb42e06417
children 703b333dc90c
files tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendMigrate.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xm/migrate.py tools/xfrd/xen_domain.c tools/xfrd/xen_domain.h tools/xfrd/xfrd.c
line diff
     1.1 --- a/tools/python/xen/xend/XendClient.py	Wed Aug 18 13:36:27 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendClient.py	Wed Aug 18 13:37:48 2004 +0000
     1.3 @@ -480,10 +480,11 @@ class Xend:
     1.4                               {'op'      : 'save',
     1.5                                'file'    : filename })
     1.6  
     1.7 -    def xend_domain_migrate(self, id, dst):
     1.8 +    def xend_domain_migrate(self, id, dst, live=0):
     1.9          return self.xendPost(self.domainurl(id),
    1.10 -                             {'op'      : 'migrate',
    1.11 -                              'destination': dst })
    1.12 +                             {'op'         : 'migrate',
    1.13 +                              'destination': dst,
    1.14 +                              'live'       : live })
    1.15  
    1.16      def xend_domain_pincpu(self, id, cpu):
    1.17          return self.xendPost(self.domainurl(id),
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Aug 18 13:36:27 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Wed Aug 18 13:37:48 2004 +0000
     2.3 @@ -586,7 +586,7 @@ class XendDomain:
     2.4          self.refresh_schedule()
     2.5          return val
     2.6  
     2.7 -    def domain_migrate(self, id, dst):
     2.8 +    def domain_migrate(self, id, dst, live):
     2.9          """Start domain migration.
    2.10  
    2.11          @param id: domain id
    2.12 @@ -597,7 +597,7 @@ class XendDomain:
    2.13          print 'domain_migrate>', id, dst
    2.14          dominfo = self.domain_lookup(id)
    2.15          xmigrate = XendMigrate.instance()
    2.16 -        val = xmigrate.migrate_begin(dominfo.id, dst)
    2.17 +        val = xmigrate.migrate_begin(dominfo.id, dst, live=live)
    2.18          print 'domain_migrate<', val
    2.19          return val
    2.20  
     3.1 --- a/tools/python/xen/xend/XendMigrate.py	Wed Aug 18 13:36:27 2004 +0000
     3.2 +++ b/tools/python/xen/xend/XendMigrate.py	Wed Aug 18 13:37:48 2004 +0000
     3.3 @@ -259,7 +259,7 @@ class XendMigrateInfo(XfrdInfo):
     3.4      """Representation of a migrate in-progress and its interaction with xfrd.
     3.5      """
     3.6  
     3.7 -    def __init__(self, xid, dom, host, port):
     3.8 +    def __init__(self, xid, dom, host, port, live):
     3.9          XfrdInfo.__init__(self)
    3.10          self.xid = xid
    3.11          self.state = 'begin'
    3.12 @@ -268,10 +268,14 @@ class XendMigrateInfo(XfrdInfo):
    3.13          self.dst_host = host
    3.14          self.dst_port = port
    3.15          self.dst_dom = None
    3.16 +        self.live = live
    3.17          self.start = 0
    3.18          
    3.19      def sxpr(self):
    3.20 -        sxpr = ['migrate', ['id', self.xid], ['state', self.state] ]
    3.21 +        sxpr = ['migrate',
    3.22 +                ['id',    self.xid   ],
    3.23 +                ['state', self.state ],
    3.24 +                ['live',  self.live  ] ]
    3.25          sxpr_src = ['src', ['host', self.src_host], ['domain', self.src_dom] ]
    3.26          sxpr.append(sxpr_src)
    3.27          sxpr_dst = ['dst', ['host', self.dst_host] ]
    3.28 @@ -289,7 +293,8 @@ class XendMigrateInfo(XfrdInfo):
    3.29                        self.src_dom,
    3.30                        vmconfig,
    3.31                        self.dst_host,
    3.32 -                      self.dst_port])
    3.33 +                      self.dst_port,
    3.34 +                      self.live ])
    3.35          
    3.36      def xfr_migrate_ok(self, xfrd, val):
    3.37          dom = int(sxp.child0(val))
    3.38 @@ -410,7 +415,7 @@ class XendMigrate:
    3.39          reactor.connectTCP('localhost', XFRD_PORT, xcf)
    3.40          return info
    3.41      
    3.42 -    def migrate_begin(self, dom, host, port=XFRD_PORT):
    3.43 +    def migrate_begin(self, dom, host, port=XFRD_PORT, live=0):
    3.44          """Begin to migrate a domain to another host.
    3.45  
    3.46          @param dom:  domain
    3.47 @@ -421,7 +426,7 @@ class XendMigrate:
    3.48          # Check dom for existence, not migrating already.
    3.49          # Subscribe to migrate notifications (for updating).
    3.50          xid = self.nextid()
    3.51 -        info = XendMigrateInfo(xid, dom, host, port)
    3.52 +        info = XendMigrateInfo(xid, dom, host, port, live)
    3.53          self.session_begin(info)
    3.54          return info.deferred
    3.55  
     4.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Wed Aug 18 13:36:27 2004 +0000
     4.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Wed Aug 18 13:37:48 2004 +0000
     4.3 @@ -80,7 +80,8 @@ class SrvDomain(SrvDir):
     4.4      def op_migrate(self, op, req):
     4.5          fn = FormFn(self.xd.domain_migrate,
     4.6                      [['dom', 'str'],
     4.7 -                     ['destination', 'str']])
     4.8 +                     ['destination', 'str'],
     4.9 +                     ['live', 'int']])
    4.10          deferred = fn(req.args, {'dom': self.dom.id})
    4.11          print 'op_migrate>', deferred
    4.12          deferred.addCallback(self._op_migrate_cb, req)
    4.13 @@ -244,4 +245,5 @@ class SrvDomain(SrvDir):
    4.14          req.write('<form method="post" action="%s">' % url)
    4.15          req.write('<br><input type="submit" name="op" value="migrate">')
    4.16          req.write(' To host: <input type="text" name="destination">')
    4.17 +        req.write('<input type="checkbox" name="live" value="1">Live')
    4.18          req.write('</form>')
     5.1 --- a/tools/python/xen/xm/migrate.py	Wed Aug 18 13:36:27 2004 +0000
     5.2 +++ b/tools/python/xen/xm/migrate.py	Wed Aug 18 13:37:48 2004 +0000
     5.3 @@ -22,6 +22,10 @@ gopts.opt('help', short='h',
     5.4           fn=set_true, default=0,
     5.5           use="Print this help.")
     5.6  
     5.7 +gopts.opt('live', short='l',
     5.8 +          fn=set_true, default=0,
     5.9 +          use="Use live migration.")
    5.10 +
    5.11  def help(argv):
    5.12      gopts.argv = argv
    5.13      gopts.usage()
    5.14 @@ -38,5 +42,5 @@ def main(argv):
    5.15      dst = args[1]
    5.16      if dom in [DOM0_NAME, DOM0_ID]:
    5.17          opts.err('Cannot migrate ' + dom)
    5.18 -    server.xend_domain_migrate(dom, dst)
    5.19 +    server.xend_domain_migrate(dom, dst, opts.vals.live)
    5.20          
     6.1 --- a/tools/xfrd/xen_domain.c	Wed Aug 18 13:36:27 2004 +0000
     6.2 +++ b/tools/xfrd/xen_domain.c	Wed Aug 18 13:37:48 2004 +0000
     6.3 @@ -53,7 +53,10 @@ void xcfini(void){
     6.4   * At some point during this the domain is suspended, and then there's no way back.
     6.5   * Even if something later goes wrong we can't restart the domain.
     6.6   */
     6.7 -int xen_domain_snd(Conn *xend, IOStream *io, uint32_t dom, char *vmconfig, int vmconfig_n){
     6.8 +int xen_domain_snd(Conn *xend, IOStream *io,
     6.9 +                   uint32_t dom,
    6.10 +                   char *vmconfig, int vmconfig_n,
    6.11 +                   int live){
    6.12      int err = 0;
    6.13  #ifdef _XEN_XFR_STUB_
    6.14      char buf[1024];
    6.15 @@ -89,7 +92,9 @@ int xen_domain_snd(Conn *xend, IOStream 
    6.16      ioctxt->suspend = domain_suspend;
    6.17      ioctxt->vmconfig = vmconfig;
    6.18      ioctxt->vmconfig_n = vmconfig_n;
    6.19 -
    6.20 +    if(live){
    6.21 +        ioctxt->flags |= XCFLAGS_LIVE;
    6.22 +    }
    6.23      err = xc_linux_save(xcinit(), ioctxt);
    6.24  #endif   
    6.25      dprintf("< err=%d\n", err);
     7.1 --- a/tools/xfrd/xen_domain.h	Wed Aug 18 13:36:27 2004 +0000
     7.2 +++ b/tools/xfrd/xen_domain.h	Wed Aug 18 13:37:48 2004 +0000
     7.3 @@ -7,7 +7,10 @@
     7.4  /** Define to use stubs. Undefine to use Xen ops. */
     7.5  //#define _XEN_XFR_STUB_
     7.6  
     7.7 -extern int xen_domain_snd(Conn *xend, IOStream *io, uint32_t dom, char *vmconfig, int vmconfig_n);
     7.8 +extern int xen_domain_snd(Conn *xend, IOStream *io,
     7.9 +                          uint32_t dom,
    7.10 +                          char *vmconfig, int vmconfig_n,
    7.11 +                          int live);
    7.12  extern int xen_domain_rcv(IOStream *io, uint32_t *dom, char **vmconfig, int *vmconfig_n);
    7.13  
    7.14  
     8.1 --- a/tools/xfrd/xfrd.c	Wed Aug 18 13:36:27 2004 +0000
     8.2 +++ b/tools/xfrd/xfrd.c	Wed Aug 18 13:37:48 2004 +0000
     8.3 @@ -81,7 +81,7 @@ receiver:
     8.4          (xfr.hello <major> <minor>)
     8.5          (xfr.err <code> <reason>)
     8.6  
     8.7 -        xend->xfrd (xfr.migrate  <domain> <vmconfig> <host> <port>)
     8.8 +        xend->xfrd (xfr.migrate  <domain> <vmconfig> <host> <port> <live>)
     8.9                     (xfr.save <domain> <vmconfig> <file>)
    8.10          xfrd->xend (xfr.suspend <domain>)
    8.11          xfrd->xend (xfr.progress <percent> <rate: kb/s>)
    8.12 @@ -95,7 +95,7 @@ receiver:
    8.13  Sxpr oxfr_configure; // (xfr.configure <vmid> <vmconfig>)
    8.14  Sxpr oxfr_err;       // (xfr.err <code>)
    8.15  Sxpr oxfr_hello;     // (xfr.hello <major> <minor>)
    8.16 -Sxpr oxfr_migrate;   // (xfr.migrate <vmid> <vmconfig> <host> <port>)
    8.17 +Sxpr oxfr_migrate;   // (xfr.migrate <vmid> <vmconfig> <host> <port> <live>)
    8.18  Sxpr oxfr_migrate_ok;// (xfr.migrate.ok <value>)
    8.19  Sxpr oxfr_progress;  // (xfr.progress <percent> <rate: kb/s>)
    8.20  Sxpr oxfr_save;      // (xfr.save <vmid> <vmconfig> <file>)
    8.21 @@ -235,6 +235,7 @@ typedef struct XfrState {
    8.22      unsigned long xfr_port;
    8.23      char *xfr_host;
    8.24      uint32_t vmid_new;
    8.25 +    int live;
    8.26  } XfrState;
    8.27  
    8.28  /** Get the name of a transfer state.
    8.29 @@ -607,7 +608,9 @@ int xfr_send_state(XfrState *state, Conn
    8.30      if(err) goto exit;
    8.31      dprintf(">*** Sending domain %u\n", state->vmid);
    8.32      err = xen_domain_snd(xend, peer->out,
    8.33 -                         state->vmid, state->vmconfig, state->vmconfig_n);
    8.34 +                         state->vmid,
    8.35 +                         state->vmconfig, state->vmconfig_n,
    8.36 +                         state->live);
    8.37      dprintf(">*** Sent domain %u\n", state->vmid);
    8.38      if(err) goto exit;
    8.39      // Sending the domain suspends it, and there's no way back.
    8.40 @@ -752,7 +755,10 @@ int xfr_save(Args *args, XfrState *state
    8.41          err = -EINVAL;
    8.42          goto exit;
    8.43      }
    8.44 -    err = xen_domain_snd(xend, io, state->vmid, state->vmconfig, state->vmconfig_n);
    8.45 +    err = xen_domain_snd(xend, io,
    8.46 +                         state->vmid,
    8.47 +                         state->vmconfig, state->vmconfig_n,
    8.48 +                         0);
    8.49      if(err){
    8.50          err = xfr_error(xend, err);
    8.51      } else {
    8.52 @@ -852,6 +858,8 @@ int xfrd_service(Args *args, int peersoc
    8.53          if(err) goto exit;
    8.54          err = portof(sxpr_childN(sxpr, n++, ONONE), &port);
    8.55          if(err) goto exit;
    8.56 +        err = intof(sxpr_childN(sxpr, n++, ONONE), &state->live);
    8.57 +        if(err) goto exit;
    8.58          err = xfr_send(args, state, conn, addr, port);
    8.59  
    8.60      } else if(sxpr_elementp(sxpr, oxfr_save)){