direct-io.hg

changeset 2203:86c685a1dda9

bitkeeper revision 1.1159.1.42 (411b8205n-7QEGvjIUl4GfoBiiNpcw)

Destroy domain earlier in migration to allow
migration to localhost.
author mjw@wray-m-3.hpl.hp.com
date Thu Aug 12 14:43:17 2004 +0000 (2004-08-12)
parents f9df1e9a2193
children 294fd489740a
files tools/python/xen/xend/XendMigrate.py tools/python/xen/xend/server/messages.py tools/xfrd/xfrd.c tools/xfrd/xfrd.h
line diff
     1.1 --- a/tools/python/xen/xend/XendMigrate.py	Thu Aug 12 11:15:06 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendMigrate.py	Thu Aug 12 14:43:17 2004 +0000
     1.3 @@ -1,5 +1,7 @@
     1.4  # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
     1.5  
     1.6 +import traceback
     1.7 +
     1.8  import errno
     1.9  import sys
    1.10  import socket
    1.11 @@ -156,6 +158,19 @@ class XfrdInfo:
    1.12          print 'xfr_progress>', val
    1.13          return None
    1.14  
    1.15 +    def xfr_vm_destroy(self, xfrd, val):
    1.16 +        print 'xfr_vm_destroy>', val
    1.17 +        try:
    1.18 +            vmid = sxp.child0(val)
    1.19 +            val = self.xd.domain_destroy(vmid)
    1.20 +            if vmid in self.paused:
    1.21 +                del self.paused[vmid]
    1.22 +            if vmid in self.suspended:
    1.23 +                del self.suspended[vmid]
    1.24 +        except:
    1.25 +            val = errno.EINVAL
    1.26 +        return ['xfr.err', val]
    1.27 +    
    1.28      def xfr_vm_pause(self, xfrd, val):
    1.29          print 'xfr_vm_pause>', val
    1.30          try:
    1.31 @@ -221,7 +236,9 @@ class XfrdInfo:
    1.32              d.addErrback(cberr)
    1.33              d.setTimeout(self.timeout)
    1.34              return d
    1.35 -        except:
    1.36 +        except Exception, err:
    1.37 +            print 'xfr_vm_suspend> Exception', err
    1.38 +            traceback.print_exc()
    1.39              val = errno.EINVAL
    1.40          return ['xfr.err', val]
    1.41  
    1.42 @@ -401,8 +418,6 @@ class XendMigrate:
    1.43          @param port: destination port
    1.44          @return: deferred
    1.45          """
    1.46 -        if host in ['localhost', '127.0.0.1']:
    1.47 -            raise XendError('cannot migrate to localhost')
    1.48          # Check dom for existence, not migrating already.
    1.49          # Subscribe to migrate notifications (for updating).
    1.50          xid = self.nextid()
     2.1 --- a/tools/python/xen/xend/server/messages.py	Thu Aug 12 11:15:06 2004 +0000
     2.2 +++ b/tools/python/xen/xend/server/messages.py	Thu Aug 12 14:43:17 2004 +0000
     2.3 @@ -1,5 +1,6 @@
     2.4  import sys
     2.5  import struct
     2.6 +import types
     2.7  
     2.8  from xen.lowlevel import xu
     2.9  
    2.10 @@ -230,19 +231,22 @@ def unpackMsg(ty, msg):
    2.11      @rtype: dict
    2.12      """
    2.13      args = msg.get_payload()
    2.14 -    mac = [0, 0, 0, 0, 0, 0]
    2.15 -    macs = []
    2.16 -    for (k, v) in args.items():
    2.17 -        if k.startswith('mac['):
    2.18 -            macs += k
    2.19 -            i = int(k[4:5])
    2.20 -            mac[i] = v
    2.21 -        else:
    2.22 -            pass
    2.23 -    if macs:
    2.24 -        args['mac'] = mac
    2.25 -        for k in macs:
    2.26 -            del args[k]
    2.27 +    if isinstance(args, types.StringType):
    2.28 +        args = { 'value': args }
    2.29 +    else:
    2.30 +        mac = [0, 0, 0, 0, 0, 0]
    2.31 +        macs = []
    2.32 +        for (k, v) in args.items():
    2.33 +            if k.startswith('mac['):
    2.34 +                macs += k
    2.35 +                i = int(k[4:5])
    2.36 +                mac[i] = v
    2.37 +            else:
    2.38 +                pass
    2.39 +        if macs:
    2.40 +            args['mac'] = mac
    2.41 +            for k in macs:
    2.42 +                del args[k]
    2.43      if DEBUG:
    2.44          msgid = msg.get_header()['id']
    2.45          print '<unpackMsg', msgid, ty, args
     3.1 --- a/tools/xfrd/xfrd.c	Thu Aug 12 11:15:06 2004 +0000
     3.2 +++ b/tools/xfrd/xfrd.c	Thu Aug 12 14:43:17 2004 +0000
     3.3 @@ -100,6 +100,7 @@ Sxpr oxfr_migrate_ok;// (xfr.migrate.ok 
     3.4  Sxpr oxfr_progress;  // (xfr.progress <percent> <rate: kb/s>)
     3.5  Sxpr oxfr_save;      // (xfr.save <vmid> <vmconfig> <file>)
     3.6  Sxpr oxfr_save_ok;   // (xfr.save.ok)
     3.7 +Sxpr oxfr_vm_destroy;// (xfr.vm.destroy <vmid>)
     3.8  Sxpr oxfr_vm_suspend;// (xfr.vm.suspend <vmid>)
     3.9  Sxpr oxfr_xfr;       // (xfr.xfr <vmid>)
    3.10  Sxpr oxfr_xfr_ok;    // (xfr.xfr.ok <vmid>)
    3.11 @@ -113,6 +114,7 @@ void xfr_init(void){
    3.12      oxfr_progress       = intern("xfr.progress");
    3.13      oxfr_save           = intern("xfr.save");
    3.14      oxfr_save_ok        = intern("xfr.save.ok");
    3.15 +    oxfr_vm_destroy     = intern("xfr.vm.destroy");
    3.16      oxfr_vm_suspend     = intern("xfr.vm.suspend");
    3.17      oxfr_xfr            = intern("xfr.xfr");
    3.18      oxfr_xfr_ok         = intern("xfr.xfr.ok");
    3.19 @@ -566,6 +568,28 @@ int xfr_vm_suspend(Conn *xend, uint32_t 
    3.20      return err;
    3.21  }
    3.22  
    3.23 +int xfr_send_destroy(Conn *conn, uint32_t vmid){
    3.24 +    int err = 0;
    3.25 +
    3.26 +    err = IOStream_print(conn->out, "(%s %d)",
    3.27 +                         atom_name(oxfr_vm_destroy), vmid);
    3.28 +    return (err < 0 ? err : 0);
    3.29 +}
    3.30 +
    3.31 +/** Destroy a vm on behalf of save/migrate.
    3.32 + */
    3.33 +int xfr_vm_destroy(Conn *xend, uint32_t vmid){
    3.34 +    int err = 0;
    3.35 +    dprintf("> vmid=%u\n", vmid);
    3.36 +    err = xfr_send_destroy(xend, vmid);
    3.37 +    if(err) goto exit;
    3.38 +    IOStream_flush(xend->out);
    3.39 +    err = xfr_response(xend);
    3.40 +  exit:
    3.41 +    dprintf("< err=%d\n", err);
    3.42 +    return err;
    3.43 +}
    3.44 +
    3.45  /** Get vm state. Send transfer message.
    3.46   *
    3.47   * @param peer connection
    3.48 @@ -584,6 +608,10 @@ int xfr_send_state(XfrState *state, Conn
    3.49      err = xen_domain_snd(xend, peer->out,
    3.50                           state->vmid, state->vmconfig, state->vmconfig_n);
    3.51      if(err) goto exit;
    3.52 +    // Sending the domain suspends it, and there's no way back.
    3.53 +    // So destroy it now. If anything goes wrong now it's too late.
    3.54 +    err = xfr_vm_destroy(xend, state->vmid);
    3.55 +    if(err) goto exit;
    3.56      IOStream_flush(peer->out);
    3.57      // Read the response from the peer.
    3.58      err = Conn_sxpr(peer, &sxpr);
     4.1 --- a/tools/xfrd/xfrd.h	Thu Aug 12 11:15:06 2004 +0000
     4.2 +++ b/tools/xfrd/xfrd.h	Thu Aug 12 14:43:17 2004 +0000
     4.3 @@ -13,4 +13,5 @@
     4.4  
     4.5  struct Conn;
     4.6  extern int xfr_vm_suspend(struct Conn *xend, uint32_t vmid);
     4.7 +extern int xfr_vm_destroy(struct Conn *xend, uint32_t vmid);
     4.8  #endif