ia64/xen-unstable

changeset 7208:84c585a99a7b

Removed unused xen_domain method, and unused imports. Comment those methods
expecting domains_lock protection. Remove notifications through eserver for
_add_domain and _delete_domain, and remove the notify parameters therein.

Tidy the exception handling in domain_restore_fd.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Tue Oct 04 16:38:04 2005 +0100 (2005-10-04)
parents 81246a2923d2
children bc325488f47f
files tools/python/xen/xend/XendDomain.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Oct 04 16:27:16 2005 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Oct 04 16:38:04 2005 +0100
     1.3 @@ -22,14 +22,12 @@
     1.4   Needs to be persistent for one uptime.
     1.5  """
     1.6  import os
     1.7 -import string
     1.8  import threading
     1.9  
    1.10  import xen.lowlevel.xc
    1.11  
    1.12  import XendDomainInfo
    1.13  
    1.14 -from xen.xend import sxp
    1.15  from xen.xend import XendRoot
    1.16  from xen.xend import XendCheckpoint
    1.17  from xen.xend import EventServer
    1.18 @@ -116,8 +114,10 @@ class XendDomain:
    1.19          from xen.xend.xenstore.xswatch import xswatch
    1.20          self.releaseDomain = xswatch("@releaseDomain", self.onReleaseDomain)
    1.21  
    1.22 +
    1.23      def xen_domains(self):
    1.24 -        """Get table of domains indexed by id from xc.
    1.25 +        """Get table of domains indexed by id from xc.  Expects to be
    1.26 +        protected by the domains_lock.
    1.27          """
    1.28          domlist = xc.domain_getinfo()
    1.29          doms = {}
    1.30 @@ -126,57 +126,34 @@ class XendDomain:
    1.31              doms[domid] = d
    1.32          return doms
    1.33  
    1.34 -    def xen_domain(self, dom):
    1.35 -        """Get info about a single domain from xc.
    1.36 -        Returns None if not found.
    1.37 -
    1.38 -        @param dom domain id (int)
    1.39 -        """
    1.40 -        dominfo = xc.domain_getinfo(dom, 1)
    1.41 -        if dominfo == [] or dominfo[0]['dom'] != dom:
    1.42 -            dominfo = None
    1.43 -        else:
    1.44 -            dominfo = dominfo[0]
    1.45 -        return dominfo
    1.46 -
    1.47  
    1.48      def dom0_setup(self):
    1.49 +        """Expects to be protected by the domains_lock."""
    1.50          dom0 = self.domains[PRIV_DOMAIN]
    1.51          dom0.dom0_enforce_vcpus()
    1.52  
    1.53  
    1.54 -    def _add_domain(self, info, notify=True):
    1.55 -        """Add a domain entry to the tables.
    1.56 -
    1.57 -        @param info:   domain info object
    1.58 -        @param notify: send a domain created event if true
    1.59 +    def _add_domain(self, info):
    1.60 +        """Add the given domain entry to this instance's internal cache.
    1.61 +        Expects to be protected by the domains_lock.
    1.62          """
    1.63 -        if info.getDomid() in self.domains:
    1.64 -            notify = False
    1.65          self.domains[info.getDomid()] = info
    1.66 -        #info.exportToDB()
    1.67 -        #if notify:
    1.68 -        #    eserver.inject('xend.domain.create', [info.getName(),
    1.69 -        #                                          info.getDomid()])
    1.70  
    1.71 -    def _delete_domain(self, domid, notify=True):
    1.72 -        """Remove a domain from the tables.
    1.73  
    1.74 -        @param id:     domain id
    1.75 -        @param notify: send a domain died event if true
    1.76 +    def _delete_domain(self, domid):
    1.77 +        """Remove the given domain from this instance's internal cache.
    1.78 +        Expects to be protected by the domains_lock.
    1.79          """
    1.80          info = self.domains.get(domid)
    1.81          if info:
    1.82              del self.domains[domid]
    1.83              info.cleanupDomain()
    1.84              info.cleanupVm()
    1.85 -            if notify:
    1.86 -                eserver.inject('xend.domain.died', [info.getName(),
    1.87 -                                                    info.getDomid()])
    1.88  
    1.89  
    1.90      def refresh(self):
    1.91 -        """Refresh domain list from Xen.
    1.92 +        """Refresh domain list from Xen.  Expects to be protected by the
    1.93 +        domains_lock.
    1.94          """
    1.95          doms = self.xen_domains()
    1.96          for d in self.domains.values():
    1.97 @@ -249,7 +226,10 @@ class XendDomain:
    1.98  
    1.99          try:
   1.100              return XendCheckpoint.restore(self, fd)
   1.101 -        except Exception, ex:
   1.102 +        except:
   1.103 +            # I don't really want to log this exception here, but the error
   1.104 +            # handling in the relocation-socket handling code (relocate.py) is
   1.105 +            # poor, so we need to log this for debugging.
   1.106              log.exception("Restore failed")
   1.107              raise
   1.108