ia64/xen-unstable

changeset 2700:cc42f35f9597

bitkeeper revision 1.1159.116.4 (4177df97ZOvl759Lo38Gv7CY081ZCA)

Add resource control parameter to migrate.
author mjw@wray-m-3.hpl.hp.com
date Thu Oct 21 16:11:03 2004 +0000 (2004-10-21)
parents 7b0448e9f11d
children 29318d5c9f47
files tools/libxc/xc_io.h 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/libxc/xc_io.h	Thu Oct 21 16:07:17 2004 +0000
     1.2 +++ b/tools/libxc/xc_io.h	Thu Oct 21 16:11:03 2004 +0000
     1.3 @@ -8,6 +8,7 @@
     1.4  typedef struct XcIOContext {
     1.5      u32 domain;
     1.6      unsigned flags;
     1.7 +    int resource;
     1.8      IOStream *io;
     1.9      IOStream *info;
    1.10      IOStream *err;
     2.1 --- a/tools/python/xen/xend/XendClient.py	Thu Oct 21 16:07:17 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendClient.py	Thu Oct 21 16:11:03 2004 +0000
     2.3 @@ -244,11 +244,12 @@ class Xend:
     2.4                               {'op'      : 'save',
     2.5                                'file'    : filename })
     2.6  
     2.7 -    def xend_domain_migrate(self, id, dst, live=0):
     2.8 +    def xend_domain_migrate(self, id, dst, live=0, resource=0):
     2.9          return self.xendPost(self.domainurl(id),
    2.10                               {'op'         : 'migrate',
    2.11                                'destination': dst,
    2.12 -                              'live'       : live })
    2.13 +                              'live'       : live,
    2.14 +                              'resource'   : resource })
    2.15  
    2.16      def xend_domain_pincpu(self, id, cpu):
    2.17          return self.xendPost(self.domainurl(id),
     3.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Oct 21 16:07:17 2004 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Oct 21 16:11:03 2004 +0000
     3.3 @@ -594,7 +594,7 @@ class XendDomain:
     3.4          self.refresh_schedule()
     3.5          return val
     3.6  
     3.7 -    def domain_migrate(self, id, dst, live):
     3.8 +    def domain_migrate(self, id, dst, live=0, resource=0):
     3.9          """Start domain migration.
    3.10  
    3.11          @param id: domain id
    3.12 @@ -604,7 +604,7 @@ class XendDomain:
    3.13          # Don't forget to cancel restart for it.
    3.14          dominfo = self.domain_lookup(id)
    3.15          xmigrate = XendMigrate.instance()
    3.16 -        val = xmigrate.migrate_begin(dominfo, dst, live=live)
    3.17 +        val = xmigrate.migrate_begin(dominfo, dst, live=live, resource=resource)
    3.18          return val
    3.19  
    3.20      def domain_save(self, id, dst, progress=0):
     4.1 --- a/tools/python/xen/xend/XendMigrate.py	Thu Oct 21 16:07:17 2004 +0000
     4.2 +++ b/tools/python/xen/xend/XendMigrate.py	Thu Oct 21 16:11:03 2004 +0000
     4.3 @@ -260,7 +260,7 @@ class XendMigrateInfo(XfrdInfo):
     4.4      """Representation of a migrate in-progress and its interaction with xfrd.
     4.5      """
     4.6  
     4.7 -    def __init__(self, xid, dominfo, host, port, live):
     4.8 +    def __init__(self, xid, dominfo, host, port, live=0, resource=0):
     4.9          XfrdInfo.__init__(self)
    4.10          self.xid = xid
    4.11          self.dominfo = dominfo
    4.12 @@ -271,13 +271,15 @@ class XendMigrateInfo(XfrdInfo):
    4.13          self.dst_port = port
    4.14          self.dst_dom = None
    4.15          self.live = live
    4.16 +        self.resource = resource
    4.17          self.start = 0
    4.18          
    4.19      def sxpr(self):
    4.20          sxpr = ['migrate',
    4.21                  ['id',    self.xid   ],
    4.22                  ['state', self.state ],
    4.23 -                ['live',  self.live  ] ]
    4.24 +                ['live',  self.live  ],
    4.25 +                ['resource', self.resource] ]
    4.26          sxpr_src = ['src', ['host', self.src_host], ['domain', self.src_dom] ]
    4.27          sxpr.append(sxpr_src)
    4.28          sxpr_dst = ['dst', ['host', self.dst_host] ]
    4.29 @@ -300,7 +302,8 @@ class XendMigrateInfo(XfrdInfo):
    4.30                        vmconfig,
    4.31                        self.dst_host,
    4.32                        self.dst_port,
    4.33 -                      self.live ])
    4.34 +                      self.live,
    4.35 +                      self.resource ])
    4.36          
    4.37  ##     def xfr_vm_suspend(self, xfrd, val):
    4.38  ##         def cbok(val):
    4.39 @@ -490,7 +493,7 @@ class XendMigrate:
    4.40          reactor.connectTCP('localhost', XFRD_PORT, xcf)
    4.41          return info.deferred
    4.42      
    4.43 -    def migrate_begin(self, dominfo, host, port=XFRD_PORT, live=0):
    4.44 +    def migrate_begin(self, dominfo, host, port=XFRD_PORT, live=0, resource=0):
    4.45          """Begin to migrate a domain to another host.
    4.46  
    4.47          @param dominfo:  domain info
    4.48 @@ -499,7 +502,7 @@ class XendMigrate:
    4.49          @return: deferred
    4.50          """
    4.51          xid = self.nextid()
    4.52 -        info = XendMigrateInfo(xid, dominfo, host, port, live)
    4.53 +        info = XendMigrateInfo(xid, dominfo, host, port, live, resource)
    4.54          return self.session_begin(info)
    4.55  
    4.56      def save_begin(self, dominfo, file):
     5.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Thu Oct 21 16:07:17 2004 +0000
     5.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Thu Oct 21 16:11:03 2004 +0000
     5.3 @@ -81,7 +81,8 @@ class SrvDomain(SrvDir):
     5.4          fn = FormFn(self.xd.domain_migrate,
     5.5                      [['dom', 'str'],
     5.6                       ['destination', 'str'],
     5.7 -                     ['live', 'int']])
     5.8 +                     ['live', 'int'],
     5.9 +                     ['resource', 'int']])
    5.10          deferred = fn(req.args, {'dom': self.dom.id})
    5.11          print 'op_migrate>', deferred
    5.12          deferred.addCallback(self._op_migrate_cb, req)
     6.1 --- a/tools/python/xen/xm/migrate.py	Thu Oct 21 16:07:17 2004 +0000
     6.2 +++ b/tools/python/xen/xm/migrate.py	Thu Oct 21 16:11:03 2004 +0000
     6.3 @@ -26,6 +26,10 @@ gopts.opt('live', short='l',
     6.4            fn=set_true, default=0,
     6.5            use="Use live migration.")
     6.6  
     6.7 +gopts.opt('resource', short='r',
     6.8 +          fn=set_int, default=0,
     6.9 +          use="Set level of resource usage for migration.")
    6.10 +
    6.11  def help(argv):
    6.12      gopts.argv = argv
    6.13      gopts.usage()
    6.14 @@ -42,5 +46,5 @@ def main(argv):
    6.15      dst = args[1]
    6.16      if dom in [DOM0_NAME, DOM0_ID]:
    6.17          opts.err('Cannot migrate ' + dom)
    6.18 -    server.xend_domain_migrate(dom, dst, opts.vals.live)
    6.19 +    server.xend_domain_migrate(dom, dst, opts.vals.live, opts.vals.resource)
    6.20          
     7.1 --- a/tools/xfrd/xen_domain.c	Thu Oct 21 16:07:17 2004 +0000
     7.2 +++ b/tools/xfrd/xen_domain.c	Thu Oct 21 16:11:03 2004 +0000
     7.3 @@ -60,7 +60,7 @@ void xcfini(void){
     7.4  int xen_domain_snd(Conn *xend, IOStream *io,
     7.5                     uint32_t dom,
     7.6                     char *vmconfig, int vmconfig_n,
     7.7 -                   int live){
     7.8 +                   int live, int resource){
     7.9      int err = 0;
    7.10  #ifdef _XEN_XFR_STUB_
    7.11      char buf[1024];
    7.12 @@ -99,6 +99,7 @@ int xen_domain_snd(Conn *xend, IOStream 
    7.13      if(live){
    7.14          ioctxt->flags |= XCFLAGS_LIVE;
    7.15      }
    7.16 +    ioctxt->resource = resource;
    7.17      err = xc_linux_save(xcinit(), ioctxt);
    7.18  #endif   
    7.19      dprintf("< err=%d\n", err);
     8.1 --- a/tools/xfrd/xen_domain.h	Thu Oct 21 16:07:17 2004 +0000
     8.2 +++ b/tools/xfrd/xen_domain.h	Thu Oct 21 16:11:03 2004 +0000
     8.3 @@ -10,7 +10,7 @@
     8.4  extern int xen_domain_snd(Conn *xend, IOStream *io,
     8.5                            uint32_t dom,
     8.6                            char *vmconfig, int vmconfig_n,
     8.7 -                          int live);
     8.8 +                          int live, int resource);
     8.9  extern int xen_domain_rcv(IOStream *io,
    8.10                            uint32_t *dom,
    8.11                            char **vmconfig, int *vmconfig_n,
     9.1 --- a/tools/xfrd/xfrd.c	Thu Oct 21 16:07:17 2004 +0000
     9.2 +++ b/tools/xfrd/xfrd.c	Thu Oct 21 16:11:03 2004 +0000
     9.3 @@ -96,7 +96,7 @@ receiver:
     9.4  Sxpr oxfr_configure; // (xfr.configure <vmid> <vmconfig>)
     9.5  Sxpr oxfr_err;       // (xfr.err <code>)
     9.6  Sxpr oxfr_hello;     // (xfr.hello <major> <minor>)
     9.7 -Sxpr oxfr_migrate;   // (xfr.migrate <vmid> <vmconfig> <host> <port> <live>)
     9.8 +Sxpr oxfr_migrate;   // (xfr.migrate <vmid> <vmconfig> <host> <port> <live> <resource>)
     9.9  Sxpr oxfr_migrate_ok;// (xfr.migrate.ok <value>)
    9.10  Sxpr oxfr_progress;  // (xfr.progress <percent> <rate: kb/s>)
    9.11  Sxpr oxfr_restore;   // (xfr.restore <file>)
    9.12 @@ -241,6 +241,7 @@ typedef struct XfrState {
    9.13      char *xfr_host;
    9.14      uint32_t vmid_new;
    9.15      int live;
    9.16 +    int resource;
    9.17  } XfrState;
    9.18  
    9.19  /** Get the name of a transfer state.
    9.20 @@ -623,7 +624,7 @@ int xfr_send_state(XfrState *state, Conn
    9.21      err = xen_domain_snd(xend, peer->out,
    9.22                           state->vmid,
    9.23                           state->vmconfig, state->vmconfig_n,
    9.24 -                         state->live);
    9.25 +                         state->live, state->resource);
    9.26      dprintf(">*** Sent domain %u\n", state->vmid);
    9.27      if(err) goto exit;
    9.28      // Sending the domain suspends it, and there's no way back.
    9.29 @@ -771,7 +772,7 @@ int xfr_save(Args *args, XfrState *state
    9.30      err = xen_domain_snd(xend, io,
    9.31                           state->vmid,
    9.32                           state->vmconfig, state->vmconfig_n,
    9.33 -                         0);
    9.34 +                         0, 0);
    9.35      if(err){
    9.36          err = xfr_error(xend, err);
    9.37      } else {
    9.38 @@ -926,6 +927,8 @@ int xfrd_service(Args *args, int peersoc
    9.39          if(err) goto exit;
    9.40          err = intof(sxpr_childN(sxpr, n++, ONONE), &state->live);
    9.41          if(err) goto exit;
    9.42 +        err = intof(sxpr_childN(sxpr, n++, ONONE), &state->resource);
    9.43 +        if(err) goto exit;
    9.44          err = xfr_send(args, state, conn, addr, port);
    9.45  
    9.46      } else if(sxpr_elementp(sxpr, oxfr_save)){