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

[Xen-changelog] Many files:



ChangeSet 1.1662.1.3, 2005/06/06 10:59:18+01:00, cl349@xxxxxxxxxxxxxxxxxxxx

        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@xxxxxx>
        Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>



 XendCheckpoint.py      |    4 -
 XendDomain.py          |  129 +++++++++++++++++++++++--------------------------
 XendDomainInfo.py      |   34 ++++++------
 server/SrvConsole.py   |    2 
 server/SrvDomain.py    |   38 +++++++-------
 server/SrvDomainDir.py |    2 
 server/blkif.py        |   13 ++--
 server/netif.py        |    6 +-
 8 files changed, 110 insertions(+), 118 deletions(-)


diff -Nru a/tools/python/xen/xend/XendCheckpoint.py 
b/tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py   2005-06-09 13:04:12 -04:00
+++ b/tools/python/xen/xend/XendCheckpoint.py   2005-06-09 13:04:12 -04:00
@@ -43,7 +43,7 @@
     write_exact(fd, config, "could not write guest state file: config")
 
     cmd = [PATH_XC_SAVE, str(xc.handle()), str(fd),
-           dominfo.id]
+           str(dominfo.id)]
     log.info("[xc_save] " + join(cmd))
     child = xPopen3(cmd, True, -1, [fd, xc.handle()])
     
@@ -109,7 +109,7 @@
             "not a valid guest state file: pfn count out of range")
 
     cmd = [PATH_XC_RESTORE, str(xc.handle()), str(fd),
-           dominfo.id, str(nr_pfns)]
+           str(dominfo.id), str(nr_pfns)]
     log.info("[xc_restore] " + join(cmd))
     child = xPopen3(cmd, True, -1, [fd, xc.handle()])
     child.tochild.close()
diff -Nru a/tools/python/xen/xend/XendDomain.py 
b/tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       2005-06-09 13:04:12 -04:00
+++ b/tools/python/xen/xend/XendDomain.py       2005-06-09 13:04:12 -04:00
@@ -78,7 +78,7 @@
         domlist = xc.domain_getinfo()
         doms = {}
         for d in domlist:
-            domid = str(d['dom'])
+            domid = d['dom']
             doms[domid] = d
         return doms
 
@@ -86,12 +86,8 @@
         """Get info about a single domain from xc.
         Returns None if not found.
 
-        @param dom domain id
+        @param dom domain id (int)
         """
-        try:
-            dom = int(dom)
-        except ValueError:
-            return None
         dominfo = xc.domain_getinfo(dom, 1)
         if dominfo == [] or dominfo[0]['dom'] != dom:
             dominfo = None
@@ -104,13 +100,12 @@
         """
         doms = self.xen_domains()
         for config in self.db.fetchall("").values():
-            domid = str(sxp.child_value(config, 'id'))
+            domid = int(sxp.child_value(config, 'id'))
             if domid in doms:
                 try:
                     self._new_domain(config, doms[domid])
-                    self.update_domain(domid)
                 except Exception, ex:
-                    log.exception("Error recreating domain info: id=%s", domid)
+                    log.exception("Error recreating domain info: id=%d", domid)
                     self._delete_domain(domid)
             else:
                 self._delete_domain(domid)
@@ -121,7 +116,7 @@
 
         info   domain info
         """
-        self.db.save(info.id, info.sxpr())
+        self.db.save(str(info.id), info.sxpr())
 
     def close(self):
         pass
@@ -135,6 +130,7 @@
         """
         dominfo = XendDomainInfo.recreate(savedinfo, info)
         self.domains[dominfo.id] = dominfo
+        self.sync_domain(dominfo)
         return dominfo
 
     def _add_domain(self, info, notify=True):
@@ -147,7 +143,7 @@
         for i, d in self.domains.items():
             if i != d.id:
                 del self.domains[i]
-                self.db.delete(i)
+                self.db.delete(str(i))
         if info.id in self.domains:
             notify = False
         self.domains[info.id] = info
@@ -166,7 +162,7 @@
             del self.domains[id]
             if notify:
                 eserver.inject('xend.domain.died', [info.name, info.id])
-            self.db.delete(id)
+            self.db.delete(str(id))
 
     def reap(self):
         """Look for domains that have crashed or stopped.
@@ -181,22 +177,21 @@
                             not(d['running'] or d['paused'] or d['blocked']))
             if dead:
                 casualties.append(d)
-        destroyed = 0
         for d in casualties:
-            id = str(d['dom'])
+            id = d['dom']
             #print 'reap>', id
             dominfo = self.domains.get(id)
             name = (dominfo and dominfo.name) or '??'
             if dominfo and dominfo.is_terminated():
                 #print 'reap> already terminated:', id
                 continue
-            log.debug('XendDomain>reap> domain died name=%s id=%s', name, id)
+            log.debug('XendDomain>reap> domain died name=%s id=%d', name, id)
             if d['shutdown']:
                 reason = shutdown_reason(d['shutdown_reason'])
-                log.debug('XendDomain>reap> shutdown name=%s id=%s reason=%s', 
name, id, reason)
+                log.debug('XendDomain>reap> shutdown name=%s id=%d reason=%s', 
name, id, reason)
                 if reason in ['suspend']:
                     if dominfo and dominfo.is_terminated():
-                        log.debug('XendDomain>reap> Suspended domain died 
id=%s', id)
+                        log.debug('XendDomain>reap> Suspended domain died 
id=%d', id)
                     else:
                         eserver.inject('xend.domain.suspended', [name, id])
                         if dominfo:
@@ -207,9 +202,8 @@
                     self.domain_restart_schedule(id, reason)
             else:
                if xroot.get_enable_dump():
-                   self.domain_dumpcore(int(id))
+                   self.domain_dumpcore(id)
                eserver.inject('xend.domain.exit', [name, id, 'crash']) 
-            destroyed += 1
             self.final_domain_destroy(id)
 
     def refresh(self, cleanup=False):
@@ -237,16 +231,7 @@
             scheduler.now(self.domain_restarts)
 
     def update_domain(self, id):
-        """Update the saved info for a domain.
-
-        @param id: domain id
-        """
-        dominfo = self.domains.get(id)
-        if dominfo:
-            self.sync_domain(dominfo)
-
-    def refresh_domain(self, id):
-        """Refresh information for a single domain.
+        """Update information for a single domain.
 
         @param id: domain id
         """
@@ -339,22 +324,30 @@
         @param id: domain id
         @return: domain object (or None)
         """
-        id = str(id)
-        self.refresh_domain(id)
+        self.update_domain(id)
         return self.domains.get(id)
 
     def domain_lookup(self, id):
-        name = str(id)
-        dominfo = self.domains.get_by_name(name) or self.domains.get(id)
+        dominfo = self.domains.get(id)
         if not dominfo:
             try:
                 info = self.xen_domain(id)
                 if info:
-                    log.info("Creating entry for unknown domain: id=%s", name)
+                    log.info("Creating entry for unknown domain: id=%d", id)
                     dominfo = XendDomainInfo.recreate(None, info, unknown=True)
                     self._add_domain(dominfo)
             except Exception, ex:
-                log.exception("Error creating domain info: id=%s", name)
+                log.exception("Error creating domain info: id=%d", id)
+        return dominfo
+
+    def domain_lookup_by_name(self, name):
+        dominfo = self.domains.get_by_name(name)
+        if not dominfo:
+            try:
+                id = int(name)
+                dominfo = self.domain_lookup(id)
+            except ValueError:
+                pass
         return dominfo
 
     def domain_unpause(self, id):
@@ -365,7 +358,7 @@
         dominfo = self.domain_lookup(id)
         eserver.inject('xend.domain.unpause', [dominfo.name, dominfo.id])
         try:
-            return xc.domain_unpause(dom=dominfo.dom)
+            return xc.domain_unpause(dom=dominfo.id)
         except Exception, ex:
             raise XendError(str(ex))
     
@@ -377,7 +370,7 @@
         dominfo = self.domain_lookup(id)
         eserver.inject('xend.domain.pause', [dominfo.name, dominfo.id])
         try:
-            return xc.domain_pause(dom=dominfo.dom)
+            return xc.domain_pause(dom=dominfo.id)
         except Exception, ex:
             raise XendError(str(ex))
     
@@ -435,7 +428,7 @@
         @param id:     domain id
         @param reason: shutdown reason
         """
-        log.debug('domain_restart_schedule> %s %s %d', id, reason, force)
+        log.debug('domain_restart_schedule> %d %s %d', id, reason, force)
         dominfo = self.domain_lookup(id)
         if not dominfo:
             return
@@ -483,7 +476,7 @@
         except:
             #todo
             try:
-                val = xc.domain_destroy(dom=int(id))
+                val = xc.domain_destroy(dom=id)
             except Exception, ex:
                 raise XendError(str(ex))
         return val       
@@ -552,7 +545,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.domain_pincpu(int(dominfo.id), vcpu, cpumap)
+            return xc.domain_pincpu(dominfo.id, vcpu, cpumap)
         except Exception, ex:
             raise XendError(str(ex))
 
@@ -561,7 +554,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.bvtsched_domain_set(dom=dominfo.dom, mcuadv=mcuadv,
+            return xc.bvtsched_domain_set(dom=dominfo.id, mcuadv=mcuadv,
                                           warpback=warpback, 
warpvalue=warpvalue, 
                                           warpl=warpl, warpu=warpu)
         except Exception, ex:
@@ -572,7 +565,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.bvtsched_domain_get(dominfo.dom)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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