From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shriram Rajagopalan Subject: Re: [PATCH 1 of 3] remus: remove dead code and unused modules Date: Thu, 23 Jun 2011 09:08:56 -0400 Message-ID: References: <866B66C6-1A2B-4B87-AFA5-491B6E9EB686@cs.ubc.ca> Reply-To: rshriram@cs.ubc.ca Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0851369239==" Return-path: In-Reply-To: <866B66C6-1A2B-4B87-AFA5-491B6E9EB686@cs.ubc.ca> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Brendan Cully Cc: xen-devel@lists.xensource.com, ian.jackson@eu.citrix.com List-Id: xen-devel@lists.xenproject.org --===============0851369239== Content-Type: multipart/alternative; boundary=0016e6db5bd6fb7ddc04a660cb92 --0016e6db5bd6fb7ddc04a660cb92 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jun 22, 2011 at 6:30 PM, Brendan Cully wrote: > Some of this code is indeed obsolete or otherwise not useful, but a lot of > it (like CheckpointingFile) is, I think, useful for people who might want to > hack on Remus. Specifically, I agree with removing vdi.py and with your > change to tools/remus/remus, I am neutral on tapdisk.py, and I would prefer > to keep the rest. > Please specify what goes into "a lot of it" and "rest" On 2011-06-22, at 6:37 AM, Shriram Rajagopalan wrote: > > > # HG changeset patch > > # User Shriram Rajagopalan > > # Date 1308683501 25200 > > # Node ID ca4a8d0d504344a84f64bc7e939f8910baac236e > > # Parent c31e9249893d309655a8e739ba2ecb07d2c0148b > > remus: remove dead code and unused modules > > > > remove unused modules (profile, tapdisk, vdi) and > > unused thread classes/qdisc classes from the python code > > base. > > > > Signed-off-by: Shriram Rajagopalan > > > > diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/profile.py > > --- a/tools/python/xen/remus/profile.py Sat Jun 18 20:52:07 2011 > -0700 > > +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 > > @@ -1,56 +0,0 @@ > > -"""Simple profiling module > > -""" > > - > > -import time > > - > > -class ProfileBlock(object): > > - """A section of code to be profiled""" > > - def __init__(self, name): > > - self.name = name > > - > > - def enter(self): > > - print "PROF: entered %s at %f" % (self.name, time.time()) > > - > > - def exit(self): > > - print "PROF: exited %s at %f" % (self.name, time.time()) > > - > > -class NullProfiler(object): > > - def enter(self, name): > > - pass > > - > > - def exit(self, name=None): > > - pass > > - > > -class Profiler(object): > > - def __init__(self): > > - self.blocks = {} > > - self.running = [] > > - > > - def enter(self, name): > > - try: > > - block = self.blocks[name] > > - except KeyError: > > - block = ProfileBlock(name) > > - self.blocks[name] = block > > - > > - block.enter() > > - self.running.append(block) > > - > > - def exit(self, name=None): > > - if name is not None: > > - block = None > > - while self.running: > > - tmp = self.running.pop() > > - if tmp.name == name: > > - block = tmp > > - break > > - tmp.exit() > > - if not block: > > - raise KeyError('block %s not running' % name) > > - else: > > - try: > > - block = self.running.pop() > > - except IndexError: > > - raise KeyError('no block running') > > - > > - block.exit() > > diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/qdisc.py > > --- a/tools/python/xen/remus/qdisc.py Sat Jun 18 20:52:07 2011 -0700 > > +++ b/tools/python/xen/remus/qdisc.py Tue Jun 21 12:11:41 2011 -0700 > > @@ -109,43 +109,6 @@ > > qdisc_kinds['prio'] = PrioQdisc > > qdisc_kinds['pfifo_fast'] = PrioQdisc > > > > -class CfifoQdisc(Qdisc): > > - fmt = 'II' > > - > > - def __init__(self, qdict): > > - super(CfifoQdisc, self).__init__(qdict) > > - > > - if qdict.get('options'): > > - self.unpack(qdict['options']) > > - else: > > - self.epoch = 0 > > - self.vmid = 0 > > - > > - def pack(self): > > - return struct.pack(self.fmt, self.epoch, self.vmid) > > - > > - def unpack(self, opts): > > - self.epoch, self.vmid = struct.unpack(self.fmt, opts) > > - > > - def parse(self, opts): > > - args = list(opts) > > - try: > > - while args: > > - arg = args.pop(0) > > - if arg == 'epoch': > > - self.epoch = int(args.pop(0)) > > - continue > > - if arg.lower() == 'vmid': > > - self.vmid = int(args.pop(0)) > > - continue > > - except Exception, inst: > > - raise QdiscException(str(inst)) > > - > > - def optstr(self): > > - return 'epoch %d vmID %d' % (self.epoch, self.vmid) > > - > > -qdisc_kinds['cfifo'] = CfifoQdisc > > - > > TC_PLUG_CHECKPOINT = 0 > > TC_PLUG_RELEASE = 1 > > > > diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/save.py > > --- a/tools/python/xen/remus/save.py Sat Jun 18 20:52:07 2011 -0700 > > +++ b/tools/python/xen/remus/save.py Tue Jun 21 12:11:41 2011 -0700 > > @@ -1,8 +1,7 @@ > > #!/usr/bin/env python > > > > -import os, select, socket, threading, time, signal, xmlrpclib > > +import os, socket, xmlrpclib > > > > -from xen.xend.XendClient import server > > from xen.xend.xenstore.xswatch import xswatch > > > > import xen.lowlevel.xc > > @@ -13,10 +12,6 @@ > > > > import vm, image > > > > -XCFLAGS_LIVE = 1 > > - > > -xcsave = '/usr/lib/xen/bin/xc_save' > > - > > class _proxy(object): > > "proxy simulates an object without inheritance" > > def __init__(self, obj): > > @@ -30,58 +25,6 @@ > > > > class CheckpointError(Exception): pass > > > > -class CheckpointingFile(_proxy): > > - """Tee writes into separate file objects for each round. > > - This is necessary because xc_save gets a single file descriptor > > - for the duration of checkpointing. > > - """ > > - def __init__(self, path): > > - self.path = path > > - > > - self.round = 0 > > - self.rfd, self.wfd = os.pipe() > > - self.fd = file(path, 'wb') > > - > > - # this pipe is used to notify the writer thread of checkpoints > > - self.cprfd, self.cpwfd = os.pipe() > > - > > - super(CheckpointingFile, self).__init__(self.fd) > > - > > - wt = threading.Thread(target=self._wrthread, > name='disk-write-thread') > > - wt.setDaemon(True) > > - wt.start() > > - self.wt = wt > > - > > - def fileno(self): > > - return self.wfd > > - > > - def close(self): > > - os.close(self.wfd) > > - # closing wfd should signal writer to stop > > - self.wt.join() > > - os.close(self.rfd) > > - os.close(self.cprfd) > > - os.close(self.cpwfd) > > - self.fd.close() > > - self.wt = None > > - > > - def checkpoint(self): > > - os.write(self.cpwfd, '1') > > - > > - def _wrthread(self): > > - while True: > > - r, o, e = select.select((self.rfd, self.cprfd), (), ()) > > - if self.rfd in r: > > - data = os.read(self.rfd, 256 * 1024) > > - if not data: > > - break > > - self.fd.write(data) > > - if self.cprfd in r: > > - junk = os.read(self.cprfd, 1) > > - self.round += 1 > > - self.fd = file('%s.%d' % (self.path, self.round), 'wb') > > - self.proxy(self.fd) > > - > > class MigrationSocket(_proxy): > > def __init__(self, address): > > sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > @@ -101,36 +44,6 @@ > > fd = os.fdopen(filedesc, 'w+') > > super(NullSocket, self).__init__(fd) > > > > -class Keepalive(object): > > - "Call a keepalive method at intervals" > > - def __init__(self, method, interval=0.1): > > - self.keepalive = method > > - self.interval = interval > > - > > - self.thread = None > > - self.running = False > > - > > - def start(self): > > - if not self.interval: > > - return > > - self.thread = threading.Thread(target=self.run, > name='keepalive-thread') > > - self.thread.setDaemon(True) > > - self.running = True > > - self.thread.start() > > - > > - def stop(self): > > - if not self.thread: > > - return > > - self.running = False > > - self.thread.join() > > - self.thread = None > > - > > - def run(self): > > - while self.running: > > - self.keepalive() > > - time.sleep(self.interval) > > - self.keepalive(stop=True) > > - > > class Saver(object): > > def __init__(self, domid, fd, suspendcb=None, resumecb=None, > > checkpointcb=None, interval=0, flags=0): > > @@ -177,10 +90,5 @@ > > pass > > > > def _resume(self): > > - """low-overhead version of XendDomainInfo.resumeDomain""" > > - # TODO: currently assumes SUSPEND_CANCEL is available > > - if True: > > xc.domain_resume(self.vm.domid, 1) > > xsutil.ResumeDomain(self.vm.domid) > > - else: > > - server.xend.domain.resumeDomain(self.vm.domid) > > diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/tapdisk.py > > --- a/tools/python/xen/remus/tapdisk.py Sat Jun 18 20:52:07 2011 > -0700 > > +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 > > @@ -1,4 +0,0 @@ > > -import blkdev > > - > > -class TapDisk(BlkDev): > > - pass > > diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/vdi.py > > --- a/tools/python/xen/remus/vdi.py Sat Jun 18 20:52:07 2011 -0700 > > +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 > > @@ -1,121 +0,0 @@ > > -#code to play with vdis and snapshots > > - > > -import os > > - > > -def run(cmd): > > - fd = os.popen(cmd) > > - res = [l for l in fd if l.rstrip()] > > - return not fd.close(), res > > - > > - > > -_blockstore = '/blockstore.dat' > > - > > -def set_blockstore(blockstore): > > - global _blockstore > > - __blockstore = blockstore > > - > > - > > -class SnapShot: > > - def __init__(self, vdi, block, index): > > - self.__vdi = vdi > > - self.__block = block > > - self.__index = index > > - > > - #TODO add snapshot date and radix > > - > > - def __str__(self): > > - return '%d %d %d' % (self.__vdi.id(), self.__block, > self.__index) > > - > > - def vdi(self): > > - return self.__vdi > > - > > - def block(self): > > - return self.__block > > - > > - def index(self): > > - return self.__index > > - > > - def match(self, block, index): > > - return self.__block == block and self.__index == index > > - > > - > > -class VDIException(Exception): > > - pass > > - > > - > > -class VDI: > > - def __init__(self, id, name): > > - self.__id = id > > - self.__name = name > > - > > - def __str__(self): > > - return 'vdi: %d %s' % (self.__id, self.__name) > > - > > - def id(self): > > - return self.__id > > - > > - def name(self): > > - return self.__name > > - > > - def list_snapshots(self): > > - res, ls = run('vdi_snap_list %s %d' % (_blockstore, self.__id)) > > - if res: > > - return [SnapShot(self, int(l[0]), int(l[1])) for l in > [l.split() for l in ls[1:]]] > > - else: > > - raise VDIException("Error reading snapshot list") > > - > > - def snapshot(self): > > - res, ls = run('vdi_checkpoint %s %d' % (_blockstore, self.__id)) > > - if res: > > - _, block, idx = ls[0].split() > > - return SnapShot(self, int(block), int(idx)) > > - else: > > - raise VDIException("Error taking vdi snapshot") > > - > > - > > -def create(name, snap): > > - res, _ = run('vdi_create %s %s %d %d' > > - % (_blockstore, name, snap.block(), snap.index())) > > - if res: > > - return lookup_by_name(name) > > - else: > > - raise VDIException('Unable to create vdi from snapshot') > > - > > - > > -def fill(name, img_file): > > - res, _ = run('vdi_create %s %s' % (_blockstore, name)) > > - > > - if res: > > - vdi = lookup_by_name(name) > > - res, _ = run('vdi_fill %d %s' % (vdi.id(), img_file)) > > - if res: > > - return vdi > > - raise VDIException('Unable to create vdi from disk img file') > > - > > - > > -def list_vdis(): > > - vdis = [] > > - res, lines = run('vdi_list %s' % _blockstore) > > - if res: > > - for l in lines: > > - r = l.split() > > - vdis.append(VDI(int(r[0]), r[1])) > > - return vdis > > - else: > > - raise VDIException("Error doing vdi list") > > - > > - > > -def lookup_by_id(id): > > - vdis = list_vdis() > > - for v in vdis: > > - if v.id() == id: > > - return v > > - raise VDIException("No match from vdi id") > > - > > - > > -def lookup_by_name(name): > > - vdis = list_vdis() > > - for v in vdis: > > - if v.name() == name: > > - return v > > - raise VDIException("No match for vdi name") > > diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/vm.py > > --- a/tools/python/xen/remus/vm.py Sat Jun 18 20:52:07 2011 -0700 > > +++ b/tools/python/xen/remus/vm.py Tue Jun 21 12:11:41 2011 -0700 > > @@ -143,10 +143,6 @@ > > > > return [blkdev.parse(disk) for disk in disks] > > > > -def fromxend(domid): > > - "create a VM object from xend information" > > - return VM(domid) > > - > > def getshadowmem(vm): > > "Balloon down domain0 to create free memory for shadow paging." > > maxmem = int(vm.dom['maxmem']) > > diff -r c31e9249893d -r ca4a8d0d5043 tools/remus/remus > > --- a/tools/remus/remus Sat Jun 18 20:52:07 2011 -0700 > > +++ b/tools/remus/remus Tue Jun 21 12:11:41 2011 -0700 > > @@ -86,12 +86,9 @@ > > # I am not sure what the best way to die is. xm destroy is > another option, > > # or we could attempt to trigger some instant reboot. > > print "dying..." > > - print util.runcmd(['sudo', 'ifdown', 'eth2']) > > - # dangling imq0 handle on vif locks up the system > > for buf in bufs: > > buf.uninstall() > > print util.runcmd(['sudo', 'xm', 'destroy', cfg.domid]) > > - print util.runcmd(['sudo', 'ifup', 'eth2']) > > > > def getcommand(): > > """Get a command to execute while running. > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com > > http://lists.xensource.com/xen-devel > > > > --0016e6db5bd6fb7ddc04a660cb92 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Wed, Jun 22, 2011 at 6:30 PM, Brendan Cully <= span dir=3D"ltr"><brendan@cs.ubc.ca= > wrote:
Some of this code is indeed obsolete or otherwise not useful, but a lot of = it (like CheckpointingFile) is, I think, useful for people who might want t= o hack on Remus. Specifically, I agree with removing vdi.py and with your c= hange to tools/remus/remus, I am neutral on tapdisk.py, and I would prefer = to keep the rest.

Please specify what goes into "a lot of it"= and "rest"

On 2011-06-22, at 6:37 AM, Shriram Rajagopalan wrote:

> # HG changeset patch
> # User Shriram Rajagopalan <r= shriram@cs.ubc.ca>
> # Date 1308683501 25200
> # Node ID ca4a8d0d504344a84f64bc7e939f8910baac236e
> # Parent =A0c31e9249893d309655a8e739ba2ecb07d2c0148b
> remus: remove dead code and unused modules
>
> remove unused modules (profile, tapdisk, vdi) and
> unused thread classes/qdisc classes from the python code
> base.
>
> Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
>
> diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/profile.py=
> --- a/tools/python/xen/remus/profile.py =A0 =A0 =A0 Sat Jun 18 20:52:0= 7 2011 -0700
> +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
> @@ -1,56 +0,0 @@
> -"""Simple profiling module
> -"""
> -
> -import time
> -
> -class ProfileBlock(object):
> - =A0 =A0"""A section of code to be profiled""= ;"
> - =A0 =A0def __init__(self, name):
> - =A0 =A0 =A0 =A0self.n= ame =3D name
> -
> - =A0 =A0def enter(self):
> - =A0 =A0 =A0 =A0print "PROF: entered %s at %f" % (self.name, time.time())
> -
> - =A0 =A0def exit(self):
> - =A0 =A0 =A0 =A0print "PROF: exited %s at %f" % (self.name, time.time())
> -
> -class NullProfiler(object):
> - =A0 =A0def enter(self, name):
> - =A0 =A0 =A0 =A0pass
> -
> - =A0 =A0def exit(self, name=3DNone):
> - =A0 =A0 =A0 =A0pass
> -
> -class Profiler(object):
> - =A0 =A0def __init__(self):
> - =A0 =A0 =A0 =A0self.blocks =3D {}
> - =A0 =A0 =A0 =A0self.running =3D []
> -
> - =A0 =A0def enter(self, name):
> - =A0 =A0 =A0 =A0try:
> - =A0 =A0 =A0 =A0 =A0 =A0block =3D self.blocks[name]
> - =A0 =A0 =A0 =A0except KeyError:
> - =A0 =A0 =A0 =A0 =A0 =A0block =3D ProfileBlock(name)
> - =A0 =A0 =A0 =A0 =A0 =A0self.blocks[name] =3D block
> -
> - =A0 =A0 =A0 =A0block.enter()
> - =A0 =A0 =A0 =A0self.running.append(block)
> -
> - =A0 =A0def exit(self, name=3DNone):
> - =A0 =A0 =A0 =A0if name is not None:
> - =A0 =A0 =A0 =A0 =A0 =A0block =3D None
> - =A0 =A0 =A0 =A0 =A0 =A0while self.running:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmp =3D self.running.pop()
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if tmp.name =3D=3D name:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0block =3D tmp
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tmp.exit()
> - =A0 =A0 =A0 =A0 =A0 =A0if not block:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise KeyError('block %s not runn= ing' % name)
> - =A0 =A0 =A0 =A0else:
> - =A0 =A0 =A0 =A0 =A0 =A0try:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0block =3D self.running.pop()
> - =A0 =A0 =A0 =A0 =A0 =A0except IndexError:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise KeyError('no block running&= #39;)
> -
> - =A0 =A0 =A0 =A0block.exit()
> diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/qdisc.py > --- a/tools/python/xen/remus/qdisc.py Sat Jun 18 20:52:07 2011 -0700 > +++ b/tools/python/xen/remus/qdisc.py Tue Jun 21 12:11:41 2011 -0700 > @@ -109,43 +109,6 @@
> qdisc_kinds['prio'] =3D PrioQdisc
> qdisc_kinds['pfifo_fast'] =3D PrioQdisc
>
> -class CfifoQdisc(Qdisc):
> - =A0 =A0fmt =3D 'II'
> -
> - =A0 =A0def __init__(self, qdict):
> - =A0 =A0 =A0 =A0super(CfifoQdisc, self).__init__(qdict)
> -
> - =A0 =A0 =A0 =A0if qdict.get('options'):
> - =A0 =A0 =A0 =A0 =A0 =A0self.unpack(qdict['options'])
> - =A0 =A0 =A0 =A0else:
> - =A0 =A0 =A0 =A0 =A0 =A0self.epoch =3D 0
> - =A0 =A0 =A0 =A0 =A0 =A0self.vmid =3D 0
> -
> - =A0 =A0def pack(self):
> - =A0 =A0 =A0 =A0return struct.pack(self.fmt, self.epoch, self.vmid) > -
> - =A0 =A0def unpack(self, opts):
> - =A0 =A0 =A0 =A0self.epoch, self.vmid =3D struct.unpack(self.fmt, opt= s)
> -
> - =A0 =A0def parse(self, opts):
> - =A0 =A0 =A0 =A0args =3D list(opts)
> - =A0 =A0 =A0 =A0try:
> - =A0 =A0 =A0 =A0 =A0 =A0while args:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0arg =3D args.pop(0)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if arg =3D=3D 'epoch':
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.epoch =3D int(args.pop(0= ))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if arg.lower() =3D=3D 'vmid':=
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.vmid =3D int(args.pop(0)= )
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue
> - =A0 =A0 =A0 =A0except Exception, inst:
> - =A0 =A0 =A0 =A0 =A0 =A0raise QdiscException(str(inst))
> -
> - =A0 =A0def optstr(self):
> - =A0 =A0 =A0 =A0return 'epoch %d vmID %d' % (self.epoch, self= .vmid)
> -
> -qdisc_kinds['cfifo'] =3D CfifoQdisc
> -
> TC_PLUG_CHECKPOINT =3D 0
> TC_PLUG_RELEASE =3D 1
>
> diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/save.py > --- a/tools/python/xen/remus/save.py =A0Sat Jun 18 20:52:07 2011 -0700=
> +++ b/tools/python/xen/remus/save.py =A0Tue Jun 21 12:11:41 2011 -0700=
> @@ -1,8 +1,7 @@
> #!/usr/bin/env python
>
> -import os, select, socket, threading, time, signal, xmlrpclib
> +import os, socket, xmlrpclib
>
> -from xen.xend.XendClient import server
> from xen.xend.xenstore.xswatch import xswatch
>
> import xen.lowlevel.xc
> @@ -13,10 +12,6 @@
>
> import vm, image
>
> -XCFLAGS_LIVE =3D =A0 =A0 =A01
> -
> -xcsave =3D '/usr/lib/xen/bin/xc_save'
> -
> class _proxy(object):
> =A0 =A0 "proxy simulates an object without inheritance"
> =A0 =A0 def __init__(self, obj):
> @@ -30,58 +25,6 @@
>
> class CheckpointError(Exception): pass
>
> -class CheckpointingFile(_proxy):
> - =A0 =A0"""Tee writes into separate file objects for e= ach round.
> - =A0 =A0This is necessary because xc_save gets a single file descript= or
> - =A0 =A0for the duration of checkpointing.
> - =A0 =A0"""
> - =A0 =A0def __init__(self, path):
> - =A0 =A0 =A0 =A0self.path =3D path
> -
> - =A0 =A0 =A0 =A0self.round =3D 0
> - =A0 =A0 =A0 =A0self.rfd, self.wfd =3D os.pipe()
> - =A0 =A0 =A0 =A0self.fd =3D file(path, 'wb')
> -
> - =A0 =A0 =A0 =A0# this pipe is used to notify the writer thread of ch= eckpoints
> - =A0 =A0 =A0 =A0self.cprfd, self.cpwfd =3D os.pipe()
> -
> - =A0 =A0 =A0 =A0super(CheckpointingFile, self).__init__(self.fd)
> -
> - =A0 =A0 =A0 =A0wt =3D threading.Thread(target=3Dself._wrthread, name= =3D'disk-write-thread')
> - =A0 =A0 =A0 =A0wt.setDaemon(True)
> - =A0 =A0 =A0 =A0wt.start()
> - =A0 =A0 =A0 =A0self.wt =3D wt
> -
> - =A0 =A0def fileno(self):
> - =A0 =A0 =A0 =A0return self.wfd
> -
> - =A0 =A0def close(self):
> - =A0 =A0 =A0 =A0os.close(self.wfd)
> - =A0 =A0 =A0 =A0# closing wfd should signal writer to stop
> - =A0 =A0 =A0 =A0self.wt.join()
> - =A0 =A0 =A0 =A0os.close(self.rfd)
> - =A0 =A0 =A0 =A0os.close(self.cprfd)
> - =A0 =A0 =A0 =A0os.close(self.cpwfd)
> - =A0 =A0 =A0 =A0self.fd.close()
> - =A0 =A0 =A0 =A0self.wt =3D None
> -
> - =A0 =A0def checkpoint(self):
> - =A0 =A0 =A0 =A0os.write(self.cpwfd, '1')
> -
> - =A0 =A0def _wrthread(self):
> - =A0 =A0 =A0 =A0while True:
> - =A0 =A0 =A0 =A0 =A0 =A0r, o, e =3D select.select((self.rfd, self.cpr= fd), (), ())
> - =A0 =A0 =A0 =A0 =A0 =A0if self.rfd in r:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0data =3D os.read(self.rfd, 256 * 1024= )
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if not data:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.fd.write(data)
> - =A0 =A0 =A0 =A0 =A0 =A0if self.cprfd in r:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0junk =3D os.read(self.cprfd, 1)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.round +=3D 1
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.fd =3D file('%s.%d' % (s= elf.path, self.round), 'wb')
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.proxy(self.fd)
> -
> class MigrationSocket(_proxy):
> =A0 =A0 def __init__(self, address):
> =A0 =A0 =A0 =A0 sock =3D socket.socket(socket.AF_INET, socket.SOCK_STR= EAM)
> @@ -101,36 +44,6 @@
> =A0 =A0 =A0 =A0 fd =3D os.fdopen(filedesc, 'w+')
> =A0 =A0 =A0 =A0 super(NullSocket, self).__init__(fd)
>
> -class Keepalive(object):
> - =A0 =A0"Call a keepalive method at intervals"
> - =A0 =A0def __init__(self, method, interval=3D0.1):
> - =A0 =A0 =A0 =A0self.keepalive =3D method
> - =A0 =A0 =A0 =A0self.interval =3D interval
> -
> - =A0 =A0 =A0 =A0self.thread =3D None
> - =A0 =A0 =A0 =A0self.running =3D False
> -
> - =A0 =A0def start(self):
> - =A0 =A0 =A0 =A0if not self.interval:
> - =A0 =A0 =A0 =A0 =A0 =A0return
> - =A0 =A0 =A0 =A0self.thread =3D threading.Thread(target=3Dself.run, n= ame=3D'keepalive-thread')
> - =A0 =A0 =A0 =A0self.thread.setDaemon(True)
> - =A0 =A0 =A0 =A0self.running =3D True
> - =A0 =A0 =A0 =A0self.thread.start()
> -
> - =A0 =A0def stop(self):
> - =A0 =A0 =A0 =A0if not self.thread:
> - =A0 =A0 =A0 =A0 =A0 =A0return
> - =A0 =A0 =A0 =A0self.running =3D False
> - =A0 =A0 =A0 =A0self.thread.join()
> - =A0 =A0 =A0 =A0self.thread =3D None
> -
> - =A0 =A0def run(self):
> - =A0 =A0 =A0 =A0while self.running:
> - =A0 =A0 =A0 =A0 =A0 =A0self.keepalive()
> - =A0 =A0 =A0 =A0 =A0 =A0time.sleep(self.interval)
> - =A0 =A0 =A0 =A0self.keepalive(stop=3DTrue)
> -
> class Saver(object):
> =A0 =A0 def __init__(self, domid, fd, suspendcb=3DNone, resumecb=3DNon= e,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0checkpointcb=3DNone, interval=3D0, = flags=3D0):
> @@ -177,10 +90,5 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pass
>
> =A0 =A0 def _resume(self):
> - =A0 =A0 =A0 =A0"""low-overhead version of XendDomainI= nfo.resumeDomain"""
> - =A0 =A0 =A0 =A0# TODO: currently assumes SUSPEND_CANCEL is available=
> - =A0 =A0 =A0 =A0if True:
> =A0 =A0 =A0 =A0 =A0 =A0 xc.domain_resume(self.vm.domid, 1)
> =A0 =A0 =A0 =A0 =A0 =A0 xsutil.ResumeDomain(self.vm.domid)
> - =A0 =A0 =A0 =A0else:
> - =A0 =A0 =A0 =A0 =A0 =A0server.xend.domain.resumeDomain(self.vm.domid= )
> diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/tapdisk.py=
> --- a/tools/python/xen/remus/tapdisk.py =A0 =A0 =A0 Sat Jun 18 20:52:0= 7 2011 -0700
> +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
> @@ -1,4 +0,0 @@
> -import blkdev
> -
> -class TapDisk(BlkDev):
> - =A0 =A0pass
> diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/vdi.py
> --- a/tools/python/xen/remus/vdi.py =A0 Sat Jun 18 20:52:07 2011 -0700=
> +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
> @@ -1,121 +0,0 @@
> -#code to play with vdis and snapshots
> -
> -import os
> -
> -def run(cmd):
> - =A0 =A0fd =3D os.popen(cmd)
> - =A0 =A0res =3D [l for l in fd if l.rstrip()]
> - =A0 =A0return not fd.close(), res
> -
> -
> -_blockstore =3D '/blockstore.dat'
> -
> -def set_blockstore(blockstore):
> - =A0 =A0global _blockstore
> - =A0 =A0__blockstore =3D blockstore
> -
> -
> -class SnapShot:
> - =A0 =A0def __init__(self, vdi, block, index):
> - =A0 =A0 =A0 self.__vdi =3D vdi
> - =A0 =A0 =A0 self.__block =3D block
> - =A0 =A0 =A0 self.__index =3D index
> -
> - =A0 =A0 =A0 #TODO add snapshot date and radix
> -
> - =A0 =A0def __str__(self):
> - =A0 =A0 =A0 return '%d %d %d' % (self.__vdi.id(), self.__block, self.__index)
> -
> - =A0 =A0def vdi(self):
> - =A0 =A0 =A0 return self.__vdi
> -
> - =A0 =A0def block(self):
> - =A0 =A0 =A0 return self.__block
> -
> - =A0 =A0def index(self):
> - =A0 =A0 =A0 return self.__index
> -
> - =A0 =A0def match(self, block, index):
> - =A0 =A0 =A0 return self.__block =3D=3D block and self.__index =3D=3D= index
> -
> -
> -class VDIException(Exception):
> - =A0 =A0 =A0 pass
> -
> -
> -class VDI:
> - =A0 =A0def __init__(self, id, name):
> - =A0 =A0 =A0 self.__id =3D id
> - =A0 =A0 =A0 self.__name =3D name
> -
> - =A0 =A0def __str__(self):
> - =A0 =A0 =A0 return 'vdi: %d %s' % (self.__id, self.__name) > -
> - =A0 =A0def id(self):
> - =A0 =A0 =A0 return self.__id
> -
> - =A0 =A0def name(self):
> - =A0 =A0 =A0 return self.__name
> -
> - =A0 =A0def list_snapshots(self):
> - =A0 =A0 =A0 res, ls =3D run('vdi_snap_list %s %d' % (_blocks= tore, self.__id))
> - =A0 =A0 =A0 if res:
> - =A0 =A0 =A0 =A0 =A0 return [SnapShot(self, int(l[0]), int(l[1])) for= l in [l.split() for l in ls[1:]]]
> - =A0 =A0 =A0 else:
> - =A0 =A0 =A0 =A0 =A0 raise VDIException("Error reading snapshot = list")
> -
> - =A0 =A0def snapshot(self):
> - =A0 =A0 =A0 res, ls =3D run('vdi_checkpoint %s %d' % (_block= store, self.__id))
> - =A0 =A0 =A0 if res:
> - =A0 =A0 =A0 =A0 =A0 _, block, idx =3D ls[0].split()
> - =A0 =A0 =A0 =A0 =A0 return SnapShot(self, int(block), int(idx))
> - =A0 =A0 =A0 else:
> - =A0 =A0 =A0 =A0 =A0 raise VDIException("Error taking vdi snapsh= ot")
> -
> -
> -def create(name, snap):
> - =A0 =A0res, _ =3D run('vdi_create %s %s %d %d'
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0% (_blockstore, name, snap.block(), s= nap.index()))
> - =A0 =A0if res:
> - =A0 =A0 =A0 return lookup_by_name(name)
> - =A0 =A0else:
> - =A0 =A0 =A0 raise VDIException('Unable to create vdi from snapsh= ot')
> -
> -
> -def fill(name, img_file):
> - =A0 =A0res, _ =3D run('vdi_create %s %s' % (_blockstore, nam= e))
> -
> - =A0 =A0if res:
> - =A0 =A0 =A0 vdi =3D lookup_by_name(name)
> - =A0 =A0 =A0 res, _ =3D run('vdi_fill %d %s' % (vdi.id(), img_file))
> - =A0 =A0 =A0 if res:
> - =A0 =A0 =A0 =A0 =A0 return vdi
> - =A0 =A0raise VDIException('Unable to create vdi from disk img fi= le')
> -
> -
> -def list_vdis():
> - =A0 =A0vdis =3D []
> - =A0 =A0res, lines =3D run('vdi_list %s' % _blockstore)
> - =A0 =A0if res:
> - =A0 =A0 =A0 for l in lines:
> - =A0 =A0 =A0 =A0 =A0 r =3D l.split()
> - =A0 =A0 =A0 =A0 =A0 vdis.append(VDI(int(r[0]), r[1]))
> - =A0 =A0 =A0 return vdis
> - =A0 =A0else:
> - =A0 =A0 =A0 raise VDIException("Error doing vdi list")
> -
> -
> -def lookup_by_id(id):
> - =A0 =A0vdis =3D list_vdis()
> - =A0 =A0for v in vdis:
> - =A0 =A0 =A0 if v.id() = =3D=3D id:
> - =A0 =A0 =A0 =A0 =A0 return v
> - =A0 =A0raise VDIException("No match from vdi id")
> -
> -
> -def lookup_by_name(name):
> - =A0 =A0vdis =3D list_vdis()
> - =A0 =A0for v in vdis:
> - =A0 =A0 =A0 if v.name() =3D=3D name:
> - =A0 =A0 =A0 =A0 =A0 return v
> - =A0 =A0raise VDIException("No match for vdi name")
> diff -r c31e9249893d -r ca4a8d0d5043 tools/python/xen/remus/vm.py
> --- a/tools/python/xen/remus/vm.py =A0 =A0Sat Jun 18 20:52:07 2011 -07= 00
> +++ b/tools/python/xen/remus/vm.py =A0 =A0Tue Jun 21 12:11:41 2011 -07= 00
> @@ -143,10 +143,6 @@
>
> =A0 =A0 return [blkdev.parse(disk) for disk in disks]
>
> -def fromxend(domid):
> - =A0 =A0"create a VM object from xend information"
> - =A0 =A0return VM(domid)
> -
> def getshadowmem(vm):
> =A0 =A0 "Balloon down domain0 to create free memory for shadow pa= ging."
> =A0 =A0 maxmem =3D int(vm.dom['maxmem'])
> diff -r c31e9249893d -r ca4a8d0d5043 tools/remus/remus
> --- a/tools/remus/remus =A0 =A0 =A0 Sat Jun 18 20:52:07 2011 -0700
> +++ b/tools/remus/remus =A0 =A0 =A0 Tue Jun 21 12:11:41 2011 -0700
> @@ -86,12 +86,9 @@
> =A0 =A0 =A0 =A0 # I am not sure what the best way to die is. xm destro= y is another option,
> =A0 =A0 =A0 =A0 # or we could attempt to trigger some instant reboot.<= br> > =A0 =A0 =A0 =A0 print "dying..."
> - =A0 =A0 =A0 =A0print util.runcmd(['sudo', 'ifdown', = 'eth2'])
> - =A0 =A0 =A0 =A0# dangling imq0 handle on vif locks up the system
> =A0 =A0 =A0 =A0 for buf in bufs:
> =A0 =A0 =A0 =A0 =A0 =A0 buf.uninstall()
> =A0 =A0 =A0 =A0 print util.runcmd(['sudo', 'xm', '= destroy', cfg.domid])
> - =A0 =A0 =A0 =A0print util.runcmd(['sudo', 'ifup', &#= 39;eth2'])
>
> =A0 =A0 def getcommand():
> =A0 =A0 =A0 =A0 """Get a command to execute while runni= ng.
>
> _______________________________________________
> Xen-devel mailing list
>
Xen-devel@lists.xenso= urce.com
> htt= p://lists.xensource.com/xen-devel
>


--0016e6db5bd6fb7ddc04a660cb92-- --===============0851369239== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0851369239==--