ia64/xen-unstable

changeset 5155:10992a804a2a

bitkeeper revision 1.1550.1.4 (4294b3735gOYxynlbg6ebX3oag6sHQ)

relocate.py, SrvDomain.py, XendDomain.py:
Support vm relocation using XendCheckpoint.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed May 25 17:18:43 2005 +0000 (2005-05-25)
parents 6e81b0f58356
children ce83bd80b6bd
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/relocate.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Wed May 25 17:18:14 2005 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Wed May 25 17:18:43 2005 +0000
     1.3 @@ -14,6 +14,7 @@ import time
     1.4  
     1.5  import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
     1.6  
     1.7 +from xen.xend.server import relocate
     1.8  import sxp
     1.9  import XendRoot; xroot = XendRoot.instance()
    1.10  import XendCheckpoint
    1.11 @@ -510,6 +511,11 @@ class XendDomain:
    1.12          # Need a cancel too?
    1.13          # Don't forget to cancel restart for it.
    1.14          dominfo = self.domain_lookup(id)
    1.15 +
    1.16 +        port = xroot.get_xend_relocation_port()
    1.17 +        sock = relocate.setupRelocation(dst, port)
    1.18 +
    1.19 +        XendCheckpoint.save(self, sock.fileno(), dominfo)
    1.20          return None
    1.21  
    1.22      def domain_save(self, id, dst, progress=False):
     2.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Wed May 25 17:18:14 2005 +0000
     2.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Wed May 25 17:18:43 2005 +0000
     2.3 @@ -75,15 +75,7 @@ class SrvDomain(SrvDir):
     2.4                       ['destination', 'str'],
     2.5                       ['live',        'int'],
     2.6                       ['resource',    'int']])
     2.7 -        info = fn(req.args, {'dom': self.dom.id})
     2.8 -        #req.setResponseCode(http.ACCEPTED)
     2.9 -        host = info.dst_host
    2.10 -        port = info.dst_port
    2.11 -        dom  = info.dst_dom
    2.12 -        url = "http://%s:%d/xend/domain/%d" % (host, port, dom)
    2.13 -        req.setHeader("Location", url)
    2.14 -        print 'do_migrate> url=', url
    2.15 -        return url
    2.16 +        return fn(req.args, {'dom': self.dom.id})
    2.17  
    2.18      def op_pincpu(self, op, req):
    2.19          fn = FormFn(self.xd.domain_pincpu,
     3.1 --- a/tools/python/xen/xend/server/relocate.py	Wed May 25 17:18:14 2005 +0000
     3.2 +++ b/tools/python/xen/xend/server/relocate.py	Wed May 25 17:18:43 2005 +0000
     3.3 @@ -1,3 +1,5 @@
     3.4 +
     3.5 +import socket
     3.6  import sys
     3.7  import StringIO
     3.8  
     3.9 @@ -123,3 +125,15 @@ def listenRelocation():
    3.10          port = xroot.get_xend_relocation_port()
    3.11          interface = xroot.get_xend_relocation_address()
    3.12          reactor.listenTCP(port, factory, interface=interface)
    3.13 +
    3.14 +def setupRelocation(dst, port):
    3.15 +    try:
    3.16 +        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    3.17 +        sock.connect((dst, port))
    3.18 +    except socket.error, err:
    3.19 +        raise XendError("can't connect: %s" % err[1])
    3.20 +
    3.21 +    sock.send("receive\n")
    3.22 +    print sock.recv(80)
    3.23 +
    3.24 +    return sock