ia64/xen-unstable

changeset 5334:46ed74bb2921

bitkeeper revision 1.1662.1.3 (42a41e76cPOoyKvX4mmcf2J0DTpnpA)

Many files:
Cleanup domain id/name confusion.
XendDomain.py:
Cleanup domain id/name confusion, interface to xend db and domain_lookup.
Signed-off-by: Mike Wray <mike.wray@hp.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Jun 06 09:59:18 2005 +0000 (2005-06-06)
parents 9672db054b6d
children 7d8015b52943
files tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvConsole.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/SrvDomainDir.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/netif.py
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Fri Jun 03 16:17:30 2005 +0000
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Mon Jun 06 09:59:18 2005 +0000
     1.3 @@ -43,7 +43,7 @@ def save(xd, fd, dominfo):
     1.4      write_exact(fd, config, "could not write guest state file: config")
     1.5  
     1.6      cmd = [PATH_XC_SAVE, str(xc.handle()), str(fd),
     1.7 -           dominfo.id]
     1.8 +           str(dominfo.id)]
     1.9      log.info("[xc_save] " + join(cmd))
    1.10      child = xPopen3(cmd, True, -1, [fd, xc.handle()])
    1.11      
    1.12 @@ -109,7 +109,7 @@ def restore(xd, fd):
    1.13              "not a valid guest state file: pfn count out of range")
    1.14  
    1.15      cmd = [PATH_XC_RESTORE, str(xc.handle()), str(fd),
    1.16 -           dominfo.id, str(nr_pfns)]
    1.17 +           str(dominfo.id), str(nr_pfns)]
    1.18      log.info("[xc_restore] " + join(cmd))
    1.19      child = xPopen3(cmd, True, -1, [fd, xc.handle()])
    1.20      child.tochild.close()
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Jun 03 16:17:30 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Mon Jun 06 09:59:18 2005 +0000
     2.3 @@ -78,7 +78,7 @@ class XendDomain:
     2.4          domlist = xc.domain_getinfo()
     2.5          doms = {}
     2.6          for d in domlist:
     2.7 -            domid = str(d['dom'])
     2.8 +            domid = d['dom']
     2.9              doms[domid] = d
    2.10          return doms
    2.11  
    2.12 @@ -86,12 +86,8 @@ class XendDomain:
    2.13          """Get info about a single domain from xc.
    2.14          Returns None if not found.
    2.15  
    2.16 -        @param dom domain id
    2.17 +        @param dom domain id (int)
    2.18          """
    2.19 -        try:
    2.20 -            dom = int(dom)
    2.21 -        except ValueError:
    2.22 -            return None
    2.23          dominfo = xc.domain_getinfo(dom, 1)
    2.24          if dominfo == [] or dominfo[0]['dom'] != dom:
    2.25              dominfo = None
    2.26 @@ -104,13 +100,12 @@ class XendDomain:
    2.27          """
    2.28          doms = self.xen_domains()
    2.29          for config in self.db.fetchall("").values():
    2.30 -            domid = str(sxp.child_value(config, 'id'))
    2.31 +            domid = int(sxp.child_value(config, 'id'))
    2.32              if domid in doms:
    2.33                  try:
    2.34                      self._new_domain(config, doms[domid])
    2.35 -                    self.update_domain(domid)
    2.36                  except Exception, ex:
    2.37 -                    log.exception("Error recreating domain info: id=%s", domid)
    2.38 +                    log.exception("Error recreating domain info: id=%d", domid)
    2.39                      self._delete_domain(domid)
    2.40              else:
    2.41                  self._delete_domain(domid)
    2.42 @@ -121,7 +116,7 @@ class XendDomain:
    2.43  
    2.44          info	domain info
    2.45          """
    2.46 -        self.db.save(info.id, info.sxpr())
    2.47 +        self.db.save(str(info.id), info.sxpr())
    2.48  
    2.49      def close(self):
    2.50          pass
    2.51 @@ -135,6 +130,7 @@ class XendDomain:
    2.52          """
    2.53          dominfo = XendDomainInfo.recreate(savedinfo, info)
    2.54          self.domains[dominfo.id] = dominfo
    2.55 +        self.sync_domain(dominfo)
    2.56          return dominfo
    2.57  
    2.58      def _add_domain(self, info, notify=True):
    2.59 @@ -147,7 +143,7 @@ class XendDomain:
    2.60          for i, d in self.domains.items():
    2.61              if i != d.id:
    2.62                  del self.domains[i]
    2.63 -                self.db.delete(i)
    2.64 +                self.db.delete(str(i))
    2.65          if info.id in self.domains:
    2.66              notify = False
    2.67          self.domains[info.id] = info
    2.68 @@ -166,7 +162,7 @@ class XendDomain:
    2.69              del self.domains[id]
    2.70              if notify:
    2.71                  eserver.inject('xend.domain.died', [info.name, info.id])
    2.72 -            self.db.delete(id)
    2.73 +            self.db.delete(str(id))
    2.74  
    2.75      def reap(self):
    2.76          """Look for domains that have crashed or stopped.
    2.77 @@ -181,22 +177,21 @@ class XendDomain:
    2.78                              not(d['running'] or d['paused'] or d['blocked']))
    2.79              if dead:
    2.80                  casualties.append(d)
    2.81 -        destroyed = 0
    2.82          for d in casualties:
    2.83 -            id = str(d['dom'])
    2.84 +            id = d['dom']
    2.85              #print 'reap>', id
    2.86              dominfo = self.domains.get(id)
    2.87              name = (dominfo and dominfo.name) or '??'
    2.88              if dominfo and dominfo.is_terminated():
    2.89                  #print 'reap> already terminated:', id
    2.90                  continue
    2.91 -            log.debug('XendDomain>reap> domain died name=%s id=%s', name, id)
    2.92 +            log.debug('XendDomain>reap> domain died name=%s id=%d', name, id)
    2.93              if d['shutdown']:
    2.94                  reason = shutdown_reason(d['shutdown_reason'])
    2.95 -                log.debug('XendDomain>reap> shutdown name=%s id=%s reason=%s', name, id, reason)
    2.96 +                log.debug('XendDomain>reap> shutdown name=%s id=%d reason=%s', name, id, reason)
    2.97                  if reason in ['suspend']:
    2.98                      if dominfo and dominfo.is_terminated():
    2.99 -                        log.debug('XendDomain>reap> Suspended domain died id=%s', id)
   2.100 +                        log.debug('XendDomain>reap> Suspended domain died id=%d', id)
   2.101                      else:
   2.102                          eserver.inject('xend.domain.suspended', [name, id])
   2.103                          if dominfo:
   2.104 @@ -207,9 +202,8 @@ class XendDomain:
   2.105                      self.domain_restart_schedule(id, reason)
   2.106              else:
   2.107                 if xroot.get_enable_dump():
   2.108 -                   self.domain_dumpcore(int(id))
   2.109 +                   self.domain_dumpcore(id)
   2.110                 eserver.inject('xend.domain.exit', [name, id, 'crash']) 
   2.111 -            destroyed += 1
   2.112              self.final_domain_destroy(id)
   2.113  
   2.114      def refresh(self, cleanup=False):
   2.115 @@ -237,16 +231,7 @@ class XendDomain:
   2.116              scheduler.now(self.domain_restarts)
   2.117  
   2.118      def update_domain(self, id):
   2.119 -        """Update the saved info for a domain.
   2.120 -
   2.121 -        @param id: domain id
   2.122 -        """
   2.123 -        dominfo = self.domains.get(id)
   2.124 -        if dominfo:
   2.125 -            self.sync_domain(dominfo)
   2.126 -
   2.127 -    def refresh_domain(self, id):
   2.128 -        """Refresh information for a single domain.
   2.129 +        """Update information for a single domain.
   2.130  
   2.131          @param id: domain id
   2.132          """
   2.133 @@ -339,22 +324,30 @@ class XendDomain:
   2.134          @param id: domain id
   2.135          @return: domain object (or None)
   2.136          """
   2.137 -        id = str(id)
   2.138 -        self.refresh_domain(id)
   2.139 +        self.update_domain(id)
   2.140          return self.domains.get(id)
   2.141  
   2.142      def domain_lookup(self, id):
   2.143 -        name = str(id)
   2.144 -        dominfo = self.domains.get_by_name(name) or self.domains.get(id)
   2.145 +        dominfo = self.domains.get(id)
   2.146          if not dominfo:
   2.147              try:
   2.148                  info = self.xen_domain(id)
   2.149                  if info:
   2.150 -                    log.info("Creating entry for unknown domain: id=%s", name)
   2.151 +                    log.info("Creating entry for unknown domain: id=%d", id)
   2.152                      dominfo = XendDomainInfo.recreate(None, info, unknown=True)
   2.153                      self._add_domain(dominfo)
   2.154              except Exception, ex:
   2.155 -                log.exception("Error creating domain info: id=%s", name)
   2.156 +                log.exception("Error creating domain info: id=%d", id)
   2.157 +        return dominfo
   2.158 +
   2.159 +    def domain_lookup_by_name(self, name):
   2.160 +        dominfo = self.domains.get_by_name(name)
   2.161 +        if not dominfo:
   2.162 +            try:
   2.163 +                id = int(name)
   2.164 +                dominfo = self.domain_lookup(id)
   2.165 +            except ValueError:
   2.166 +                pass
   2.167          return dominfo
   2.168  
   2.169      def domain_unpause(self, id):
   2.170 @@ -365,7 +358,7 @@ class XendDomain:
   2.171          dominfo = self.domain_lookup(id)
   2.172          eserver.inject('xend.domain.unpause', [dominfo.name, dominfo.id])
   2.173          try:
   2.174 -            return xc.domain_unpause(dom=dominfo.dom)
   2.175 +            return xc.domain_unpause(dom=dominfo.id)
   2.176          except Exception, ex:
   2.177              raise XendError(str(ex))
   2.178      
   2.179 @@ -377,7 +370,7 @@ class XendDomain:
   2.180          dominfo = self.domain_lookup(id)
   2.181          eserver.inject('xend.domain.pause', [dominfo.name, dominfo.id])
   2.182          try:
   2.183 -            return xc.domain_pause(dom=dominfo.dom)
   2.184 +            return xc.domain_pause(dom=dominfo.id)
   2.185          except Exception, ex:
   2.186              raise XendError(str(ex))
   2.187      
   2.188 @@ -435,7 +428,7 @@ class XendDomain:
   2.189          @param id:     domain id
   2.190          @param reason: shutdown reason
   2.191          """
   2.192 -        log.debug('domain_restart_schedule> %s %s %d', id, reason, force)
   2.193 +        log.debug('domain_restart_schedule> %d %s %d', id, reason, force)
   2.194          dominfo = self.domain_lookup(id)
   2.195          if not dominfo:
   2.196              return
   2.197 @@ -483,7 +476,7 @@ class XendDomain:
   2.198          except:
   2.199              #todo
   2.200              try:
   2.201 -                val = xc.domain_destroy(dom=int(id))
   2.202 +                val = xc.domain_destroy(dom=id)
   2.203              except Exception, ex:
   2.204                  raise XendError(str(ex))
   2.205          return val       
   2.206 @@ -552,7 +545,7 @@ class XendDomain:
   2.207          """
   2.208          dominfo = self.domain_lookup(id)
   2.209          try:
   2.210 -            return xc.domain_pincpu(int(dominfo.id), vcpu, cpumap)
   2.211 +            return xc.domain_pincpu(dominfo.id, vcpu, cpumap)
   2.212          except Exception, ex:
   2.213              raise XendError(str(ex))
   2.214  
   2.215 @@ -561,7 +554,7 @@ class XendDomain:
   2.216          """
   2.217          dominfo = self.domain_lookup(id)
   2.218          try:
   2.219 -            return xc.bvtsched_domain_set(dom=dominfo.dom, mcuadv=mcuadv,
   2.220 +            return xc.bvtsched_domain_set(dom=dominfo.id, mcuadv=mcuadv,
   2.221                                            warpback=warpback, warpvalue=warpvalue, 
   2.222                                            warpl=warpl, warpu=warpu)
   2.223          except Exception, ex:
   2.224 @@ -572,7 +565,7 @@ class XendDomain:
   2.225          """
   2.226          dominfo = self.domain_lookup(id)
   2.227          try:
   2.228 -            return xc.bvtsched_domain_get(dominfo.dom)
   2.229 +            return xc.bvtsched_domain_get(dominfo.id)
   2.230          except Exception, ex:
   2.231              raise XendError(str(ex))
   2.232      
   2.233 @@ -580,18 +573,18 @@ class XendDomain:
   2.234      def domain_cpu_sedf_set(self, id, period, slice, latency, extratime, weight):
   2.235          """Set Simple EDF scheduler parameters for a domain.
   2.236          """
   2.237 -	dominfo = self.domain_lookup(id)
   2.238 +        dominfo = self.domain_lookup(id)
   2.239          try:
   2.240 -            return xc.sedf_domain_set(dominfo.dom, period, slice, latency, extratime, weight)
   2.241 +            return xc.sedf_domain_set(dominfo.id, period, slice, latency, extratime, weight)
   2.242          except Exception, ex:
   2.243              raise XendError(str(ex))
   2.244  
   2.245      def domain_cpu_sedf_get(self, id):
   2.246 -        """Get Atropos scheduler parameters for a domain.
   2.247 +        """Get Simple EDF scheduler parameters for a domain.
   2.248          """
   2.249          dominfo = self.domain_lookup(id)
   2.250          try:
   2.251 -            return xc.sedf_domain_get(dominfo.dom)
   2.252 +            return xc.sedf_domain_get(dominfo.id)
   2.253          except Exception, ex:
   2.254              raise XendError(str(ex))
   2.255  
   2.256 @@ -603,44 +596,44 @@ class XendDomain:
   2.257          """
   2.258          dominfo = self.domain_lookup(id)
   2.259          val = dominfo.device_create(devconfig)
   2.260 -        self.update_domain(dominfo.id)
   2.261 +        self.sync_domain(dominfo)
   2.262          return val
   2.263  
   2.264 -    def domain_device_configure(self, id, devconfig, idx):
   2.265 +    def domain_device_configure(self, id, devconfig, devid):
   2.266          """Configure an existing device for a domain.
   2.267  
   2.268          @param id:   domain id
   2.269          @param devconfig: device configuration
   2.270 -        @param idx:  device index
   2.271 +        @param devid:  device index
   2.272          @return: updated device configuration
   2.273          """
   2.274          dominfo = self.domain_lookup(id)
   2.275 -        val = dominfo.device_configure(devconfig, idx)
   2.276 -        self.update_domain(dominfo.id)
   2.277 +        val = dominfo.device_configure(devconfig, devid)
   2.278 +        self.sync_domain(dominfo)
   2.279          return val
   2.280      
   2.281 -    def domain_device_refresh(self, id, type, idx):
   2.282 +    def domain_device_refresh(self, id, type, devid):
   2.283          """Refresh a device.
   2.284  
   2.285          @param id:  domain id
   2.286 -        @param idx:  device index
   2.287 +        @param devid:  device index
   2.288          @param type: device type
   2.289          """
   2.290          dominfo = self.domain_lookup(id)
   2.291 -        val = dominfo.device_refresh(type, idx)
   2.292 -        self.update_domain(dominfo.id)
   2.293 +        val = dominfo.device_refresh(type, devid)
   2.294 +        self.sync_domain(dominfo)
   2.295          return val
   2.296  
   2.297 -    def domain_device_destroy(self, id, type, idx):
   2.298 +    def domain_device_destroy(self, id, type, devid):
   2.299          """Destroy a device.
   2.300  
   2.301          @param id:  domain id
   2.302 -        @param idx:  device index
   2.303 +        @param devid:  device index
   2.304          @param type: device type
   2.305          """
   2.306          dominfo = self.domain_lookup(id)
   2.307 -        val = dominfo.device_destroy(type, idx)
   2.308 -        self.update_domain(dominfo.id)
   2.309 +        val = dominfo.device_destroy(type, devid)
   2.310 +        self.sync_domain(dominfo)
   2.311          return val
   2.312  
   2.313      def domain_devtype_ls(self, id, type):
   2.314 @@ -653,16 +646,16 @@ class XendDomain:
   2.315          dominfo = self.domain_lookup(id)
   2.316          return dominfo.getDeviceSxprs(type)
   2.317  
   2.318 -    def domain_devtype_get(self, id, type, idx):
   2.319 +    def domain_devtype_get(self, id, type, devid):
   2.320          """Get a device from a domain.
   2.321  
   2.322          @param id:  domain
   2.323          @param type: device type
   2.324 -        @param idx:  device index
   2.325 +        @param devid:  device index
   2.326          @return: device object (or None)
   2.327          """
   2.328          dominfo = self.domain_lookup(id)
   2.329 -        return dominfo.getDeviceByIndex(type, idx)
   2.330 +        return dominfo.getDeviceByIndex(type, devid)
   2.331  
   2.332      def domain_vif_limit_set(self, id, vif, credit, period):
   2.333          """Limit the vif's transmission rate
   2.334 @@ -681,33 +674,33 @@ class XendDomain:
   2.335          """
   2.336          dominfo = self.domain_lookup(id)
   2.337          try:
   2.338 -            return xc.shadow_control(dominfo.dom, op)
   2.339 +            return xc.shadow_control(dominfo.id, op)
   2.340          except Exception, ex:
   2.341              raise XendError(str(ex))
   2.342  
   2.343      def domain_maxmem_set(self, id, mem):
   2.344          """Set the memory limit for a domain.
   2.345  
   2.346 -        @param dom: domain
   2.347 +        @param id: domain
   2.348          @param mem: memory limit (in MB)
   2.349          @return: 0 on success, -1 on error
   2.350          """
   2.351          dominfo = self.domain_lookup(id)
   2.352          maxmem = int(mem) * 1024
   2.353          try:
   2.354 -            return xc.domain_setmaxmem(dominfo.dom, maxmem_kb = maxmem)
   2.355 +            return xc.domain_setmaxmem(dominfo.id, maxmem_kb = maxmem)
   2.356          except Exception, ex:
   2.357              raise XendError(str(ex))
   2.358  
   2.359 -    def domain_mem_target_set(self, id, target):
   2.360 +    def domain_mem_target_set(self, id, mem):
   2.361          """Set the memory target for a domain.
   2.362  
   2.363          @param id: domain
   2.364 -        @param target: memory target (in MB)
   2.365 +        @param mem: memory target (in MB)
   2.366          @return: 0 on success, -1 on error
   2.367          """
   2.368          dominfo = self.domain_lookup(id)
   2.369 -        return dominfo.mem_target_set(target)
   2.370 +        return dominfo.mem_target_set(mem)
   2.371  
   2.372      def domain_dumpcore(self, id):
   2.373          """Save a core dump for a crashed domain.
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jun 03 16:17:30 2005 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Jun 06 09:59:18 2005 +0000
     3.3 @@ -86,7 +86,7 @@ STATE_VM_SUSPENDED  = "suspended"
     3.4  def domain_exists(name):
     3.5      # See comment in XendDomain constructor.
     3.6      xd = get_component('xen.xend.XendDomain')
     3.7 -    return xd.domain_lookup(name)
     3.8 +    return xd.domain_lookup_by_name(name)
     3.9  
    3.10  def shutdown_reason(code):
    3.11      """Get a shutdown reason from a code.
    3.12 @@ -248,7 +248,6 @@ class XendDomainInfo:
    3.13          
    3.14          self.config = None
    3.15          self.id = None
    3.16 -        self.dom = None
    3.17          self.cpu_weight = 1
    3.18          self.start_time = None
    3.19          self.name = None
    3.20 @@ -290,11 +289,10 @@ class XendDomainInfo:
    3.21  
    3.22          @param dom: domain id
    3.23          """
    3.24 -        self.dom = int(dom)
    3.25 -        self.id = str(dom)
    3.26 +        self.id = int(dom)
    3.27  
    3.28      def getDomain(self):
    3.29 -        return self.dom
    3.30 +        return self.id
    3.31  
    3.32      def getName(self):
    3.33          return self.name
    3.34 @@ -484,7 +482,7 @@ class XendDomainInfo:
    3.35              return
    3.36          if dominfo.is_terminated():
    3.37              return
    3.38 -        if not self.dom or (dominfo.dom != self.dom):
    3.39 +        if not self.id or (dominfo.id != self.id):
    3.40              raise VmError('vm name clash: ' + name)
    3.41          
    3.42      def construct(self, config):
    3.43 @@ -532,8 +530,8 @@ class XendDomainInfo:
    3.44          if self.memory is None:
    3.45              raise VmError('missing memory size')
    3.46          cpu = sxp.child_value(config, 'cpu')
    3.47 -        if self.recreate and self.dom and cpu is not None and int(cpu) >= 0:
    3.48 -            xc.domain_pincpu(self.dom, 0, 1<<int(cpu))
    3.49 +        if self.recreate and self.id and cpu is not None and int(cpu) >= 0:
    3.50 +            xc.domain_pincpu(self.id, 0, 1<<int(cpu))
    3.51          try:
    3.52              image = sxp.child_value(self.config, 'image')
    3.53              vcpus = sxp.child_value(image, 'vcpus')
    3.54 @@ -622,9 +620,9 @@ class XendDomainInfo:
    3.55          if self.channel:
    3.56              self.channel.close()
    3.57              self.channel = None
    3.58 -        if self.dom is None: return 0
    3.59 +        if self.id is None: return 0
    3.60          try:
    3.61 -            return xc.domain_destroy(dom=self.dom)
    3.62 +            return xc.domain_destroy(dom=self.id)
    3.63          except Exception, err:
    3.64              log.exception("Domain destroy failed: %s", self.name)
    3.65  
    3.66 @@ -652,7 +650,7 @@ class XendDomainInfo:
    3.67      def show(self):
    3.68          """Print virtual machine info.
    3.69          """
    3.70 -        print "[VM dom=%d name=%s memory=%d" % (self.dom, self.name, self.memory)
    3.71 +        print "[VM dom=%d name=%s memory=%d" % (self.id, self.name, self.memory)
    3.72          print "image:"
    3.73          sxp.show(self.image)
    3.74          print
    3.75 @@ -671,7 +669,7 @@ class XendDomainInfo:
    3.76              self.start_time = time.time()
    3.77          if self.restore:
    3.78              return
    3.79 -        dom = self.dom or 0
    3.80 +        dom = self.id or 0
    3.81          memory = self.memory
    3.82          try:
    3.83              cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
    3.84 @@ -707,8 +705,8 @@ class XendDomainInfo:
    3.85          if ramdisk and not os.path.isfile(ramdisk):
    3.86              raise VmError('Kernel ramdisk does not exist: %s' % ramdisk)
    3.87          if len(cmdline) >= 256:
    3.88 -            log.warning('kernel cmdline too long, domain %d', self.dom)
    3.89 -        dom = self.dom
    3.90 +            log.warning('kernel cmdline too long, domain %d', self.id)
    3.91 +        dom = self.id
    3.92          buildfn = getattr(xc, '%s_build' % ostype)
    3.93          flags = 0
    3.94          if self.netif_backend: flags |= SIF_NET_BE_DOMAIN
    3.95 @@ -763,7 +761,7 @@ class XendDomainInfo:
    3.96              if info:
    3.97                  local = int(sxp.child_value(info, "local_port", 0))
    3.98                  remote = int(sxp.child_value(info, "remote_port", 1))
    3.99 -        self.channel = channelFactory().openChannel(self.dom,
   3.100 +        self.channel = channelFactory().openChannel(str(self.id),
   3.101                                                      local_port=local,
   3.102                                                      remote_port=remote)
   3.103  
   3.104 @@ -810,7 +808,7 @@ class XendDomainInfo:
   3.105          #todo: self.memory?
   3.106          memory = sxp.child_value(self.config, "memory")
   3.107          # Create an event channel
   3.108 -        device_channel = channel.eventChannel(0, self.dom)
   3.109 +        device_channel = channel.eventChannel(0, self.id)
   3.110          # see if a vncviewer was specified
   3.111          # XXX RN: bit of a hack. should unify this, maybe stick in config space
   3.112          vncconnect=""
   3.113 @@ -830,7 +828,7 @@ class XendDomainInfo:
   3.114          os.system(device_model
   3.115                    + " -f %s" % device_config
   3.116                    + vncconnect
   3.117 -                  + " -d %d" % self.dom
   3.118 +                  + " -d %d" % self.id
   3.119                    + " -p %d" % device_channel['port1']
   3.120                    + " -m %s" % memory)
   3.121  
   3.122 @@ -1222,7 +1220,7 @@ def vm_field_maxmem(vm, config, val, ind
   3.123          maxmem = int(maxmem)
   3.124      except:
   3.125          raise VmError("invalid maxmem: " + str(maxmem))
   3.126 -    xc.domain_setmaxmem(vm.dom, maxmem_kb = maxmem * 1024)
   3.127 +    xc.domain_setmaxmem(vm.id, maxmem_kb = maxmem * 1024)
   3.128  
   3.129  #============================================================================
   3.130  # Register image handlers.
     4.1 --- a/tools/python/xen/xend/server/SrvConsole.py	Fri Jun 03 16:17:30 2005 +0000
     4.2 +++ b/tools/python/xen/xend/server/SrvConsole.py	Mon Jun 06 09:59:18 2005 +0000
     4.3 @@ -30,7 +30,7 @@ class SrvConsole(SrvDir):
     4.4              #self.ls()
     4.5              req.write('<p>%s</p>' % self.info)
     4.6              req.write('<p><a href="%s">Connect to domain %d</a></p>'
     4.7 -                      % (self.info.uri(), self.info.dom))
     4.8 +                      % (self.info.uri(), self.info.id))
     4.9              self.form(req)
    4.10              req.write('</body></html>')
    4.11  
     5.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Fri Jun 03 16:17:30 2005 +0000
     5.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Mon Jun 06 09:59:18 2005 +0000
     5.3 @@ -28,19 +28,19 @@ class SrvDomain(SrvDir):
     5.4          fn = FormFn(self.xd.domain_configure,
     5.5                      [['dom',    'int'],
     5.6                       ['config', 'sxpr']])
     5.7 -        return fn(req.args, {'dom': self.dom.dom})
     5.8 +        return fn(req.args, {'dom': self.dom.id})
     5.9  
    5.10      def op_unpause(self, op, req):
    5.11 -        val = self.xd.domain_unpause(self.dom.name)
    5.12 +        val = self.xd.domain_unpause(self.dom.id)
    5.13          return val
    5.14          
    5.15      def op_pause(self, op, req):
    5.16 -        val = self.xd.domain_pause(self.dom.name)
    5.17 +        val = self.xd.domain_pause(self.dom.id)
    5.18          return val
    5.19  
    5.20      def op_shutdown(self, op, req):
    5.21          fn = FormFn(self.xd.domain_shutdown,
    5.22 -                    [['dom',    'str'],
    5.23 +                    [['dom',    'int'],
    5.24                       ['reason', 'str'],
    5.25                       ['key',    'int']])
    5.26          val = fn(req.args, {'dom': self.dom.id})
    5.27 @@ -50,7 +50,7 @@ class SrvDomain(SrvDir):
    5.28  
    5.29      def op_destroy(self, op, req):
    5.30          fn = FormFn(self.xd.domain_destroy,
    5.31 -                    [['dom',    'str'],
    5.32 +                    [['dom',    'int'],
    5.33                       ['reason', 'str']])
    5.34          val = fn(req.args, {'dom': self.dom.id})
    5.35          req.setHeader("Location", "%s/.." % req.prePathURL())
    5.36 @@ -61,7 +61,7 @@ class SrvDomain(SrvDir):
    5.37  
    5.38      def do_save(self, op, req):
    5.39          fn = FormFn(self.xd.domain_save,
    5.40 -                    [['dom',  'str'],
    5.41 +                    [['dom',  'int'],
    5.42                       ['file', 'str']])
    5.43          val = fn(req.args, {'dom': self.dom.id})
    5.44          return 0
    5.45 @@ -71,7 +71,7 @@ class SrvDomain(SrvDir):
    5.46      
    5.47      def do_migrate(self, op, req):
    5.48          fn = FormFn(self.xd.domain_migrate,
    5.49 -                    [['dom',         'str'],
    5.50 +                    [['dom',         'int'],
    5.51                       ['destination', 'str'],
    5.52                       ['live',        'int'],
    5.53                       ['resource',    'int']])
    5.54 @@ -79,7 +79,7 @@ class SrvDomain(SrvDir):
    5.55  
    5.56      def op_pincpu(self, op, req):
    5.57          fn = FormFn(self.xd.domain_pincpu,
    5.58 -                    [['dom', 'str'],
    5.59 +                    [['dom', 'int'],
    5.60                       ['vcpu', 'int'],
    5.61                       ['cpumap', 'int']])
    5.62          val = fn(req.args, {'dom': self.dom.id})
    5.63 @@ -87,7 +87,7 @@ class SrvDomain(SrvDir):
    5.64  
    5.65      def op_cpu_bvt_set(self, op, req):
    5.66          fn = FormFn(self.xd.domain_cpu_bvt_set,
    5.67 -                    [['dom',       'str'],
    5.68 +                    [['dom',       'int'],
    5.69                       ['mcuadv',    'int'],
    5.70                       ['warpback',  'int'],
    5.71                       ['warpvalue', 'int'],
    5.72 @@ -99,7 +99,7 @@ class SrvDomain(SrvDir):
    5.73      
    5.74      def op_cpu_sedf_set(self, op, req):
    5.75          fn = FormFn(self.xd.domain_cpu_sedf_set,
    5.76 -                    [['dom', 'str'],
    5.77 +                    [['dom', 'int'],
    5.78                       ['period', 'int'],
    5.79                       ['slice', 'int'],
    5.80  		     ['latency', 'int'],
    5.81 @@ -110,28 +110,28 @@ class SrvDomain(SrvDir):
    5.82  
    5.83      def op_maxmem_set(self, op, req):
    5.84          fn = FormFn(self.xd.domain_maxmem_set,
    5.85 -                    [['dom',    'str'],
    5.86 +                    [['dom',    'int'],
    5.87                       ['memory', 'int']])
    5.88          val = fn(req.args, {'dom': self.dom.id})
    5.89          return val
    5.90      
    5.91      def op_mem_target_set(self, op, req):
    5.92          fn = FormFn(self.xd.domain_mem_target_set,
    5.93 -                    [['dom',    'str'],
    5.94 +                    [['dom',    'int'],
    5.95                       ['target', 'int']])
    5.96          val = fn(req.args, {'dom': self.dom.id})
    5.97          return val
    5.98  
    5.99      def op_devices(self, op, req):
   5.100          fn = FormFn(self.xd.domain_devtype_ls,
   5.101 -                    [['dom',    'str'],
   5.102 +                    [['dom',    'int'],
   5.103                       ['type',   'str']])
   5.104          val = fn(req.args, {'dom': self.dom.id})
   5.105          return val
   5.106  
   5.107      def op_device(self, op, req):
   5.108          fn = FormFn(self.xd.domain_devtype_get,
   5.109 -                    [['dom',    'str'],
   5.110 +                    [['dom',    'int'],
   5.111                       ['type',   'str'],
   5.112                       ['idx',    'int']])
   5.113          val = fn(req.args, {'dom': self.dom.id})
   5.114 @@ -142,14 +142,14 @@ class SrvDomain(SrvDir):
   5.115  
   5.116      def op_device_create(self, op, req):
   5.117          fn = FormFn(self.xd.domain_device_create,
   5.118 -                    [['dom',    'str'],
   5.119 +                    [['dom',    'int'],
   5.120                       ['config', 'sxpr']])
   5.121          val = fn(req.args, {'dom': self.dom.id})
   5.122          return val
   5.123  
   5.124      def op_device_refresh(self, op, req):
   5.125          fn = FormFn(self.xd.domain_device_refresh,
   5.126 -                    [['dom',  'str'],
   5.127 +                    [['dom',  'int'],
   5.128                       ['type', 'str'],
   5.129                       ['idx',  'str']])
   5.130          val = fn(req.args, {'dom': self.dom.id})
   5.131 @@ -157,7 +157,7 @@ class SrvDomain(SrvDir):
   5.132  
   5.133      def op_device_destroy(self, op, req):
   5.134          fn = FormFn(self.xd.domain_device_destroy,
   5.135 -                    [['dom',  'str'],
   5.136 +                    [['dom',  'int'],
   5.137                       ['type', 'str'],
   5.138                       ['idx',  'str']])
   5.139          val = fn(req.args, {'dom': self.dom.id})
   5.140 @@ -165,7 +165,7 @@ class SrvDomain(SrvDir):
   5.141                  
   5.142      def op_device_configure(self, op, req):
   5.143          fn = FormFn(self.xd.domain_device_configure,
   5.144 -                    [['dom',    'str'],
   5.145 +                    [['dom',    'int'],
   5.146                       ['config', 'sxpr'],
   5.147                       ['idx',    'str']])
   5.148          val = fn(req.args, {'dom': self.dom.id})
   5.149 @@ -173,7 +173,7 @@ class SrvDomain(SrvDir):
   5.150  
   5.151      def op_vif_limit_set(self, op, req):
   5.152          fn = FormFn(self.xd.domain_vif_limit_set,
   5.153 -                    [['dom',    'str'],
   5.154 +                    [['dom',    'int'],
   5.155                       ['vif',    'int'],
   5.156                       ['credit', 'int'],
   5.157                       ['period', 'int']])
     6.1 --- a/tools/python/xen/xend/server/SrvDomainDir.py	Fri Jun 03 16:17:30 2005 +0000
     6.2 +++ b/tools/python/xen/xend/server/SrvDomainDir.py	Mon Jun 06 09:59:18 2005 +0000
     6.3 @@ -24,7 +24,7 @@ class SrvDomainDir(SrvDir):
     6.4  
     6.5      def domain(self, x):
     6.6          val = None
     6.7 -        dom = self.xd.domain_lookup(x)
     6.8 +        dom = self.xd.domain_lookup_by_name(x)
     6.9          if not dom:
    6.10              raise XendError('No such domain ' + str(x))
    6.11          val = SrvDomain(dom)
     7.1 --- a/tools/python/xen/xend/server/blkif.py	Fri Jun 03 16:17:30 2005 +0000
     7.2 +++ b/tools/python/xen/xend/server/blkif.py	Mon Jun 06 09:59:18 2005 +0000
     7.3 @@ -3,12 +3,12 @@
     7.4  """
     7.5  import string
     7.6  
     7.7 -from xen.util import blkif
     7.8 -from xen.xend.XendError import XendError, VmError
     7.9 -from xen.xend import XendRoot
    7.10 -from xen.xend.XendLogging import log
    7.11  from xen.xend import sxp
    7.12  from xen.xend import Blkctl
    7.13 +from xen.xend.XendError import XendError, VmError
    7.14 +from xen.xend.XendLogging import log
    7.15 +from xen.util import blkif
    7.16 +from xen.xend.XendRoot import get_component
    7.17  
    7.18  import channel
    7.19  from controller import CtrlMsgRcvr, Dev, DevController
    7.20 @@ -206,7 +206,8 @@ class BlkDev(Dev):
    7.21              raise VmError('vbd: Device not found: %s' % self.dev)
    7.22          
    7.23          try:
    7.24 -            self.backendDomain = int(sxp.child_value(config, 'backend', '0'))
    7.25 +            xd = get_component('xen.xend.XendDomain')
    7.26 +            self.backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
    7.27          except:
    7.28              raise XendError('invalid backend domain')
    7.29  
    7.30 @@ -263,7 +264,7 @@ class BlkDev(Dev):
    7.31  
    7.32      def check_mounted(self, name):
    7.33          mode = blkif.mount_mode(name)
    7.34 -        xd = XendRoot.get_component('xen.xend.XendDomain')
    7.35 +        xd = get_component('xen.xend.XendDomain')
    7.36          for vm in xd.list():
    7.37              ctrl = vm.getDeviceController(self.getType(), error=False)
    7.38              if (not ctrl): continue
     8.1 --- a/tools/python/xen/xend/server/netif.py	Fri Jun 03 16:17:30 2005 +0000
     8.2 +++ b/tools/python/xen/xend/server/netif.py	Mon Jun 06 09:59:18 2005 +0000
     8.3 @@ -102,7 +102,7 @@ class NetDev(Dev):
     8.4              else:
     8.5                  #todo: Code below will fail on xend restart when backend is not domain 0.
     8.6                  xd = get_component('xen.xend.XendDomain')
     8.7 -                self.backendDomain = int(xd.domain_lookup(sxp.child_value(config, 'backend', '0')).id)
     8.8 +                self.backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
     8.9          except:
    8.10              raise XendError('invalid backend domain')
    8.11          return self.config
    8.12 @@ -127,13 +127,13 @@ class NetDev(Dev):
    8.13          ipaddr = self._get_config_ipaddr(config)
    8.14          
    8.15          xd = get_component('xen.xend.XendDomain')
    8.16 -        backendDomain = str(xd.domain_lookup(sxp.child_value(config, 'backend', '0')).id)
    8.17 +        backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
    8.18  
    8.19          if (mac is not None) and (mac != self.mac):
    8.20              raise XendError("cannot change mac")
    8.21          if (be_mac is not None) and (be_mac != self.be_mac):
    8.22              raise XendError("cannot change backend mac")
    8.23 -        if (backendDomain is not None) and (backendDomain != str(self.backendDomain)):
    8.24 +        if (backendDomain is not None) and (backendDomain != self.backendDomain):
    8.25              raise XendError("cannot change backend")
    8.26          if (bridge is not None) and (bridge != self.bridge):
    8.27              changes['bridge'] = bridge