[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC Patch v2 16/16] remus: implement colo mode



Add a new option --colo to the command remus. We will ignore the
options: --time, -i, --no-net when --colo is specified. In colo
mode, we will write new signature "GuestColoRestore". If the xen-tool
in secondary machine does not support colo, it will reject this
signature, and the command remus will fail.

Signed-off-by: Ye Wei <wei.ye1987@xxxxxxxxx>
Signed-off-by: Jiang Yunhong <yunhong.jiang@xxxxxxxxx>
Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx>
---
 tools/python/xen/remus/image.py |    8 ++++++--
 tools/python/xen/remus/save.py  |    7 +++++--
 tools/remus/remus               |   20 +++++++++++++++++---
 3 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/tools/python/xen/remus/image.py b/tools/python/xen/remus/image.py
index b79d1e5..6bae8f4 100644
--- a/tools/python/xen/remus/image.py
+++ b/tools/python/xen/remus/image.py
@@ -5,6 +5,7 @@ import logging, struct
 import vm
 
 SIGNATURE = 'LinuxGuestRecord'
+COLO_SIGNATURE = "GuestColoRestore"
 LONGLEN = struct.calcsize('L')
 INTLEN = struct.calcsize('i')
 PAGE_SIZE = 4096
@@ -189,9 +190,12 @@ def parseheader(header):
     "parses a header sexpression"
     return vm.parsedominfo(vm.strtosxpr(header))
 
-def makeheader(dominfo):
+def makeheader(dominfo, colo):
     "create an image header from a VM dominfo sxpr"
-    items = [SIGNATURE]
+    if colo:
+        items = [COLO_SIGNATURE]
+    else:
+        items = [SIGNATURE]
     sxpr = vm.sxprtostr(dominfo)
     items.append(struct.pack('!i', len(sxpr)))
     items.append(sxpr)
diff --git a/tools/python/xen/remus/save.py b/tools/python/xen/remus/save.py
index 81e05b9..45be172 100644
--- a/tools/python/xen/remus/save.py
+++ b/tools/python/xen/remus/save.py
@@ -133,7 +133,8 @@ class Keepalive(object):
 
 class Saver(object):
     def __init__(self, domid, fd, suspendcb=None, resumecb=None,
-                 checkpointcb=None, setupcb=None, interval=0, flags=0):
+                 checkpointcb=None, setupcb=None, interval=0, flags=0,
+                 colo=False):
         """Create a Saver object for taking guest checkpoints.
         domid:        name, number or UUID of a running domain
         fd:           a stream to which checkpoint data will be written.
@@ -143,6 +144,7 @@ class Saver(object):
                       True to take another checkpoint, or False to stop.
         flags:        Remus flags to be passed to xc_domain_save
         setupcb:      callback invoked to configure network for colo
+        colo:         use colo mode
         """
         self.fd = fd
         self.suspendcb = suspendcb
@@ -151,6 +153,7 @@ class Saver(object):
         self.interval = interval
         self.flags = flags
         self.setupcb = setupcb
+        self.colo = colo
 
         self.vm = vm.VM(domid)
 
@@ -159,7 +162,7 @@ class Saver(object):
     def start(self):
         vm.getshadowmem(self.vm)
 
-        hdr = image.makeheader(self.vm.dominfo)
+        hdr = image.makeheader(self.vm.dominfo, self.colo)
         self.fd.write(hdr)
         self.fd.flush()
 
diff --git a/tools/remus/remus b/tools/remus/remus
index 7be7fdd..592c8cc 100644
--- a/tools/remus/remus
+++ b/tools/remus/remus
@@ -18,6 +18,7 @@ class CfgException(Exception): pass
 class Cfg(object):
 
     REMUS_FLAGS_COMPRESSION = 1
+    REMUS_FLAGS_COLO = 2
 
     def __init__(self):
         # must be set
@@ -30,6 +31,7 @@ class Cfg(object):
         self.netbuffer = True
         self.flags = self.REMUS_FLAGS_COMPRESSION
         self.timer = False
+        self.colo = False
 
         parser = optparse.OptionParser()
         parser.usage = '%prog [options] domain [destination]'
@@ -46,6 +48,8 @@ class Cfg(object):
                           help='run without checkpoint compression')
         parser.add_option('', '--timer', dest='timer', action='store_true',
                           help='force pause at checkpoint interval 
(experimental)')
+        parser.add_option('', '--colo', dest='colo', action='store_true',
+                          help='use colo checkpointing (experimental)')
         self.parser = parser
 
     def usage(self):
@@ -66,6 +70,12 @@ class Cfg(object):
             self.flags &= ~self.REMUS_FLAGS_COMPRESSION
         if opts.timer:
             self.timer = True
+        if opts.colo:
+            self.interval = 0
+            self.netbuffer = False
+            self.timer = True
+            self.colo = True
+            self.flags |= self.REMUS_FLAGS_COLO
 
         if not args:
             raise CfgException('Missing domain')
@@ -123,8 +133,12 @@ def run(cfg):
     if not cfg.nullremus:
         for disk in dom.disks:
             try:
-                bufs.append(ReplicatedDisk(disk))
-                disk.init('r')
+                rdisk = ReplicatedDisk(disk)
+                bufs.append(rdisk)
+                if cfg.colo:
+                    rdisk.init('c')
+                else:
+                    rdisk.init('r')
             except ReplicatedDiskException, e:
                 print e
                 continue
@@ -208,7 +222,7 @@ def run(cfg):
     rc = 0
 
     checkpointer = save.Saver(cfg.domid, fd, postsuspend, preresume, commit,
-                              setup, interval, cfg.flags)
+                              setup, interval, cfg.flags, cfg.colo)
 
     try:
         checkpointer.start()
-- 
1.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.