ia64/xen-unstable

changeset 2162:920e29e2986d

bitkeeper revision 1.1159.1.31 (4118d1e3hysYQeJp5YNlLFvX8SMWFg)

Merge ssh://xenbk@gandalf.hpl.hp.com//var/bk/xeno-unstable.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Tue Aug 10 13:47:15 2004 +0000 (2004-08-10)
parents fcc4a1183476 4af7ef741f16
children 02a135451216
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/xfrd/xen_domain.c
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Aug 10 12:55:49 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Aug 10 13:47:15 2004 +0000
     1.3 @@ -413,10 +413,7 @@ class XendDomain:
     1.4  
     1.5      def domain_exists(self, name):
     1.6          name = str(name)
     1.7 -        if self.domain_by_name.get(name) or self.domain_by_id.get(name):
     1.8 -            return 1
     1.9 -        else:
    1.10 -            return 0
    1.11 +        return self.domain_by_name.get(name) or self.domain_by_id.get(name):
    1.12  
    1.13      def domain_unpause(self, id):
    1.14          """Unpause domain execution.
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 10 12:55:49 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 10 13:47:15 2004 +0000
     2.3 @@ -295,15 +295,20 @@ def vm_restore(src, progress=0):
     2.4      raises   VmError for invalid configuration
     2.5      """
     2.6      vm = XendDomainInfo()
     2.7 +    vm.restore = 1
     2.8      ostype = "linux" #todo Set from somewhere (store in the src?).
     2.9      restorefn = getattr(xc, "%s_restore" % ostype)
    2.10      d = restorefn(state_file=src, progress=progress)
    2.11      dom = int(d['dom'])
    2.12      if dom < 0:
    2.13          raise VmError('restore failed')
    2.14 -    vmconfig = sxp.from_string(d['vmconfig'])
    2.15 -    vm.config = sxp.child_value(vmconfig, 'config')
    2.16 -    deferred = vm.dom_configure(dom)
    2.17 +    try:
    2.18 +        vmconfig = sxp.from_string(d['vmconfig'])
    2.19 +        vm.config = sxp.child_value(vmconfig, 'config')
    2.20 +    except Exception, ex:
    2.21 +        raise VmError('config error: ' + str(ex))
    2.22 +    deferred = vm.dom_construct(dom)
    2.23 +    vm.restore = 0
    2.24      def vifs_cb(val, vm):
    2.25          vif_up(vm.ipaddrs)
    2.26      deferred.addCallback(vifs_cb, vm)
    2.27 @@ -354,6 +359,7 @@ class XendDomainInfo:
    2.28  
    2.29      def __init__(self):
    2.30          self.recreate = 0
    2.31 +        self.restore = 0
    2.32          self.config = None
    2.33          self.id = None
    2.34          self.dom = None
    2.35 @@ -463,7 +469,11 @@ class XendDomainInfo:
    2.36              raise VmError('invalid vm name')
    2.37          # See comment in XendDomain constructor.
    2.38          xd = get_component('xen.xend.XendDomain')
    2.39 -        if xd.domain_exists(name):
    2.40 +        dominfo = xd.domain_exists(name)
    2.41 +        # When creating or rebooting, a domain with my name should not exist.
    2.42 +        # When restoring, a domain with my name will exist, but it should have
    2.43 +        # my domain id.
    2.44 +        if dominfo and (not self.dom or dominfo.dom != self.dom)
    2.45              raise VmError('vm name clash: ' + name)
    2.46          
    2.47      def construct(self, config):
    2.48 @@ -688,7 +698,12 @@ class XendDomainInfo:
    2.49      def init_domain(self):
    2.50          """Initialize the domain memory.
    2.51          """
    2.52 -        if self.recreate: return
    2.53 +        if self.recreate:
    2.54 +            return
    2.55 +        if self.start_time is None:
    2.56 +            self.start_time = time.time()
    2.57 +        if self.restore:
    2.58 +            return
    2.59          memory = self.memory
    2.60          name = self.name
    2.61          cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
    2.62 @@ -700,13 +715,10 @@ class XendDomainInfo:
    2.63          log.debug('init_domain> Created domain=%d name=%s memory=%d', dom, name, memory)
    2.64          self.setdom(dom)
    2.65  
    2.66 -        if self.start_time is None:
    2.67 -            self.start_time = time.time()
    2.68 -
    2.69      def build_domain(self, ostype, kernel, ramdisk, cmdline, vifs_n):
    2.70          """Build the domain boot image.
    2.71          """
    2.72 -        if self.recreate: return
    2.73 +        if self.recreate or self.restore: return
    2.74          if len(cmdline) >= 256:
    2.75              log.warning('kernel cmdline too long, domain %d', self.dom)
    2.76          dom = self.dom
    2.77 @@ -918,8 +930,8 @@ class XendDomainInfo:
    2.78          d.addCallback(_vm_configure1, self)
    2.79          return d
    2.80  
    2.81 -    def dom_configure(self, dom):
    2.82 -        """Configure a vm for an existing domain.
    2.83 +    def dom_construct(self, dom):
    2.84 +        """Construct a vm for an existing domain.
    2.85  
    2.86          @param dom:    domain id
    2.87          @return: deferred
    2.88 @@ -931,7 +943,7 @@ class XendDomainInfo:
    2.89              self.setdom(dom)
    2.90              self.name = d['name']
    2.91              self.memory = d['memory']/1024
    2.92 -            deferred = self.configure()
    2.93 +            deferred = self.construct()
    2.94              def cberr(err):
    2.95                  self.destroy()
    2.96                  return err
     3.1 --- a/tools/xfrd/xen_domain.c	Tue Aug 10 12:55:49 2004 +0000
     3.2 +++ b/tools/xfrd/xen_domain.c	Tue Aug 10 13:47:15 2004 +0000
     3.3 @@ -81,13 +81,14 @@ int xen_domain_snd(Conn *xend, IOStream 
     3.4    exit:
     3.5  #else 
     3.6      XcIOContext _ioctxt = {}, *ioctxt = &_ioctxt;
     3.7 -    dprintf("> dom=%d\n", dom);
     3.8      ioctxt->domain = dom;
     3.9      ioctxt->io = io;
    3.10      ioctxt->info = iostdout;
    3.11      ioctxt->err = iostderr;
    3.12      ioctxt->data = xend;
    3.13      ioctxt->suspend = domain_suspend;
    3.14 +    ioctxt->vmconfig = vmconfig;
    3.15 +    ioctxt->vmconfig_n = vmconfig_n;
    3.16  
    3.17      err = xc_linux_save(xcinit(), ioctxt);
    3.18  #endif