WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [RFC][PATCH 07/13] Kemari: add Kemari support to python

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [RFC][PATCH 07/13] Kemari: add Kemari support to python
From: Yoshiaki Tamura <tamura.yoshiaki@xxxxxxxxxxxxx>
Date: Fri, 06 Mar 2009 15:46:30 +0900
Cc: ospk-vm@xxxxxxxxxxxxx, Ian Pratt <ian.pratt@xxxxxxxxxx>, ian.jackson@xxxxxxxxxxxxx, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Thu, 05 Mar 2009 23:01:15 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49B0B8DC.5000606@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <49B0B8DC.5000606@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)
This patch implements python code for supporting Kemari.  It provides --kemari
option and notifies it to the destination.  If --kemari is specified,
xc_kemari_save is called instead of xc_save on the sender, and
xc_kemari_restore is called instead of xc_restore on the receiver.

Signed-off-by: Yoshisato Yanagisawa <yanagisawa.yoshisato@xxxxxxxxxxxxx>
Signed-off-by: Yoshi Tamura <tamura.yoshiaki@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendAPI.py        |    3 -
 tools/python/xen/xend/XendCheckpoint.py |   81 ++++++++++++++++++++++++++++----
 tools/python/xen/xend/XendDomain.py     |    6 +-
 tools/python/xen/xm/migrate.py          |   10 +++
 4 files changed, 85 insertions(+), 15 deletions(-)

diff -r 19201eebab16 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Thu Sep 25 13:33:50 2008 +0100
+++ b/tools/python/xen/xend/XendAPI.py  Wed Mar 04 17:04:23 2009 +0900
@@ -1780,9 +1780,10 @@
         port = other_config.get("port", 0)
         node = other_config.get("node", -1)
         ssl = other_config.get("ssl", None)
+        kemari = other_config.get("kemari", None)

         xendom.domain_migrate(xeninfo.getDomid(), destination_url,
-                              bool(live), port, node, ssl)
+                              bool(live), port, node, ssl, kemari)
         return xen_api_success_void()

     def VM_save(self, _, vm_ref, dest, checkpoint):
diff -r 19201eebab16 tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py   Thu Sep 25 13:33:50 2008 +0100
+++ b/tools/python/xen/xend/XendCheckpoint.py   Wed Mar 04 17:04:23 2009 +0900
@@ -28,7 +28,9 @@
 QEMU_SIGNATURE = "QemuDeviceModelRecord"
 dm_batch = 512
 XC_SAVE = "xc_save"
+XC_KEMARI_SAVE = "xc_kemari_save"
 XC_RESTORE = "xc_restore"
+XC_KEMARI_RESTORE = "xc_kemari_restore"


 sizeof_int = calcsize("i")
@@ -64,11 +66,38 @@
               list.insert (i+1, value)
     return

+def get_dev_info(info, n):
+    i = 0
+    while i < len(info):
+        if (info[i][0] == n):
+            return [n, info[i][1]]
+        i = i + 1
+    return [n, '']

-def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1):
+def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1, 
kemari=False):
     write_exact(fd, SIGNATURE, "could not write guest state file: signature")

     sxprep = dominfo.sxpr()
+
+    # Add kemari option if enabled.
+    if kemari:
+        sxprep.append(['kemari', kemari])
+        pv_devlist = []
+        pv_devs = dominfo.getDeviceSxprs('vbd')
+        for x in pv_devs:
+            devinfo = []
+            for n in ['event-channel', 'ring-ref']:
+                devinfo.append(get_dev_info(x[1], n))
+            pv_devlist.append([x[0], devinfo])
+        pv_devs = dominfo.getDeviceSxprs('vif')
+        for x in pv_devs:
+            devinfo = []
+            for n in ['event-channel', 'tx-ring-ref', 'rx-ring-ref',
+                'request-rx-copy', 'feature-rx-notify', 'feature-sg',
+                'feature-gso-tcpv4']:
+                devinfo.append(get_dev_info(x[1], n))
+            pv_devlist.append([x[0], devinfo])
+        sxprep.append(['kemari-device-info', pv_devlist])

     if node > -1:
         insert_after(sxprep,'vcpus',['node', str(node)])
@@ -97,7 +126,16 @@
         # enabled. Passing "0" simply uses the defaults compiled into
         # libxenguest; see the comments and/or code in xc_linux_save() for
         # more information.
-        cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(fd),
+        if kemari:
+            if not hvm:
+                raise XendError("You can only use kemari on HVM domain")
+
+            cmd = [xen.util.auxbin.pathTo(XC_KEMARI_SAVE), str(fd),
+               str(dominfo.getDomid()), "0", "0",
+               str(int(live) | (int(hvm) << 2)) ]
+            log.debug("[xc_save]: %s", string.join(cmd))
+        else:
+            cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(fd),
                str(dominfo.getDomid()), "0", "0",
                str(int(live) | (int(hvm) << 2)) ]
         log.debug("[xc_save]: %s", string.join(cmd))
@@ -125,7 +163,7 @@
         forkHelper(cmd, fd, saveInputHandler, False)

         # put qemu device model state
-        if os.path.exists("/var/lib/xen/qemu-save.%d" % dominfo.getDomid()):
+        if not kemari and os.path.exists("/var/lib/xen/qemu-save.%d" %
dominfo.getDomid()):
             write_exact(fd, QEMU_SIGNATURE, "could not write qemu signature")
             qemu_fd = os.open("/var/lib/xen/qemu-save.%d" % dominfo.getDomid(),
                               os.O_RDONLY)
@@ -138,7 +176,7 @@
             os.close(qemu_fd)
             os.remove("/var/lib/xen/qemu-save.%d" % dominfo.getDomid())

-        if checkpoint:
+        if checkpoint or kemari:
             dominfo.resumeDomain()
         else:
             dominfo.destroy()
@@ -184,6 +222,16 @@
         raise XendError("not a valid guest state file: config parse")

     vmconfig = p.get_val()
+
+    # Checks kemari is enabled or not.
+    # Since Xen do not know kemari option, this option will not be migrated.
+    is_kemari = False
+    kemari_device_info = []
+    for v in vmconfig:
+        if v[0] == 'kemari' and v[1]:
+            is_kemari = True
+        if v[0] == 'kemari-device-info' and v[1]:
+            kemari_device_info = v[1]

     if not relocating:
         domconfig = XendConfig(sxp_obj = vmconfig)
@@ -258,7 +306,15 @@
         shadow_cur = xc.shadow_mem_control(dominfo.getDomid(), shadow / 1024)
         dominfo.info['shadow_memory'] = shadow_cur

-        cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE),
+        # Use Kemari restore.  Switching mechanism between normal migration
+        # and Kemari migration will be implemented lator.
+        #
+        if is_kemari:
+            cmd = map(str, [xen.util.auxbin.pathTo(XC_KEMARI_RESTORE),
+                        fd, dominfo.getDomid(),
+                        store_port, console_port, int(is_hvm), pae, apic])
+        else:
+            cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE),
                         fd, dominfo.getDomid(),
                         store_port, console_port, int(is_hvm), pae, apic])
         log.debug("[xc_restore]: %s", string.join(cmd))
@@ -266,6 +322,8 @@
         handler = RestoreInputHandler()

         forkHelper(cmd, fd, handler.handler, True)
+        if is_kemari:
+            os.close(fd)

         # We don't want to pass this fd to any other children -- we
         # might need to recover the disk space that backs it.
@@ -285,7 +343,7 @@
         # get qemu state and create a tmp file for dm restore
         # Even PV guests may have QEMU stat, but its not currently
         # used so only bother with HVM currently.
-        if is_hvm:
+        if is_hvm and not is_kemari:
             qemu_signature = read_exact(fd, len(QEMU_SIGNATURE),
                                         "invalid device model signature read")
             if qemu_signature != QEMU_SIGNATURE:
@@ -303,8 +361,10 @@
             os.close(qemu_fd)
             restore_image.setCpuid()

-
-        os.read(fd, 1)           # Wait for source to close connection
+        if is_kemari:
+            restore_image.setCpuid()
+        else:
+            os.read(fd, 1)           # Wait for source to close connection

         dominfo.completeRestore(handler.store_mfn, handler.console_mfn)

@@ -322,7 +382,10 @@
             lock = False;

         try:
-            dominfo.waitForDevices() # Wait for backends to set up
+            if is_kemari:
+                dominfo.waitForAttachedDevices(kemari_device_info)
+            else:
+                dominfo.waitForDevices() # Wait for backends to set up
         except Exception, exn:
             log.exception(exn)

diff -r 19201eebab16 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Thu Sep 25 13:33:50 2008 +0100
+++ b/tools/python/xen/xend/XendDomain.py       Wed Mar 04 17:04:23 2009 +0900
@@ -1267,7 +1267,7 @@

         return val

-    def domain_migrate(self, domid, dst, live=False, port=0, node=-1, 
ssl=None):
+    def domain_migrate(self, domid, dst, live=False, port=0, node=-1, ssl=None,
kemari=None):
         """Start domain migration.

         @param domid: Domain ID or Name
@@ -1332,7 +1332,7 @@

             try:
                 XendCheckpoint.save(p2cwrite, dominfo, True, live, dst,
-                                    node=node)
+                                    node=node, kemari=kemari)
             finally:
                 sock.shutdown()
                 sock.close()
@@ -1358,7 +1358,7 @@

             try:
                 XendCheckpoint.save(sock.fileno(), dominfo, True, live,
-                                    dst, node=node)
+                                    dst, node=node, kemari=kemari)
             finally:
                 sock.close()

diff -r 19201eebab16 tools/python/xen/xm/migrate.py
--- a/tools/python/xen/xm/migrate.py    Thu Sep 25 13:33:50 2008 +0100
+++ b/tools/python/xen/xm/migrate.py    Wed Mar 04 17:04:25 2009 +0900
@@ -51,6 +51,10 @@
           fn=set_true, default=None,
           use="Use ssl connection for migration.")

+gopts.opt('kemari', short='k',
+          fn=set_true, default=None,
+          use="Use kemari migration.")
+
 def help():
     return str(gopts)

@@ -70,7 +74,8 @@
         other_config = {
             "port":     opts.vals.port,
             "node":     opts.vals.node,
-            "ssl":      opts.vals.ssl
+            "ssl":      opts.vals.ssl,
+            "kemari":   opts.vals.kemari
             }
         server.xenapi.VM.migrate(vm_ref, dst, bool(opts.vals.live),
                                  other_config)
@@ -78,4 +83,5 @@
         server.xend.domain.migrate(dom, dst, opts.vals.live,
                                    opts.vals.port,
                                    opts.vals.node,
-                                   opts.vals.ssl)
+                                   opts.vals.ssl,
+                                   opts.vals.kemari)




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>