WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] xend cleanups from Mike Wray.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] xend cleanups from Mike Wray.
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Fri, 03 Jun 2005 15:03:33 +0000
Delivery-date: Thu, 09 Jun 2005 17:02:13 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1662.1.1, 2005/06/03 16:03:33+01:00, cl349@xxxxxxxxxxxxxxxxxxxx

        xend cleanups from Mike Wray.
        XendDomain.py:
          Add comment for domain_mem_target_set.
        SrvDaemon.py:
          Use XEND_DAEMONIZE, XEND_DEBUG and XEND_DEBUGLOG.
        XendRoot.py:
          Use XEND_DEBUG.
        netif.py:
          Unknown domains are called "Domain-%d" % dom.
        params.py:
          Add additional parameters and set some parameters from
          environment variables.
        blkif.py, XendDomain.py:
          Cleanup whitespace.
        XendRoot.py:
          enable_dump default is 'no'.
          enable_dump is a bool.
          Add 'true' and 'false' to get_config_bool.
        XendDomainInfo.py:
          Add DOMAIN_CRASH shutdown code.
        XendDomain.py:
          Simplify.
          Add domain_dumpcore.
          Move class XendDomainDict outside of class XendDomain.
          Import shutdown_reason from XendDomainInfo.
          Update comment for xen_domain.
        PrettyPrint.py:
          Cleanup prettyprintstring.
        SrvDir.py:
          Cleanup render_GET.
        xc.c:
          Various cleanups.
        Signed-off-by: Mike Wray <mike.wray@xxxxxx>
        Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>



 lowlevel/xc/xc.c         |    5 +--
 web/SrvDir.py            |   23 ++++++-------
 xend/PrettyPrint.py      |   21 +++++++-----
 xend/XendDomain.py       |   78 ++++++++++++++++++++++++++++-------------------
 xend/XendDomainInfo.py   |    7 +++-
 xend/XendRoot.py         |   11 ++++--
 xend/server/SrvDaemon.py |   10 +++---
 xend/server/blkif.py     |    2 -
 xend/server/netif.py     |    2 -
 xend/server/params.py    |   31 ++++++++++++++++--
 10 files changed, 120 insertions(+), 70 deletions(-)


diff -Nru a/tools/python/xen/lowlevel/xc/xc.c 
b/tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c 2005-06-09 13:03:11 -04:00
+++ b/tools/python/xen/lowlevel/xc/xc.c 2005-06-09 13:03:11 -04:00
@@ -14,6 +14,7 @@
 #include <sys/socket.h>
 #include <netdb.h>
 #include <arpa/inet.h>
+
 #include "xc_private.h"
 #include "linux_boot_params.h"
 
@@ -842,8 +843,8 @@
     { "domain_dumpcore", 
       (PyCFunction)pyxc_domain_dumpcore, 
       METH_VARARGS | METH_KEYWORDS, "\n"
-      "dump core of a domain.\n"
-      " dom [int]: Identifier of domain to be paused.\n\n"
+      "Dump core of a domain.\n"
+      " dom [int]: Identifier of domain to dump core of.\n\n"
       " corefile [string]: Name of corefile to be created.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
diff -Nru a/tools/python/xen/web/SrvDir.py b/tools/python/xen/web/SrvDir.py
--- a/tools/python/xen/web/SrvDir.py    2005-06-09 13:03:11 -04:00
+++ b/tools/python/xen/web/SrvDir.py    2005-06-09 13:03:11 -04:00
@@ -77,19 +77,16 @@
         return v
 
     def render_GET(self, req):
-        try:
-            if self.use_sxp(req):
-                req.setHeader("Content-type", sxp.mime_type)
-                self.ls(req, 1)
-            else:
-                req.write('<html><head></head><body>')
-                self.print_path(req)
-                self.ls(req)
-                self.form(req)
-                req.write('</body></html>')
-            return ''
-        except Exception, ex:
-            self._perform_err(ex, "GET", req)
+        if self.use_sxp(req):
+            req.setHeader("Content-type", sxp.mime_type)
+            self.ls(req, 1)
+        else:
+            req.write('<html><head></head><body>')
+            self.print_path(req)
+            self.ls(req)
+            self.form(req)
+            req.write('</body></html>')
+        return ''
             
     def ls(self, req, use_sxp=0):
         url = req.prePathURL()
diff -Nru a/tools/python/xen/xend/PrettyPrint.py 
b/tools/python/xen/xend/PrettyPrint.py
--- a/tools/python/xen/xend/PrettyPrint.py      2005-06-09 13:03:11 -04:00
+++ b/tools/python/xen/xend/PrettyPrint.py      2005-06-09 13:03:11 -04:00
@@ -285,15 +285,18 @@
         sxp.show(sxpr, out=out)
     print >> out
 
-def prettyprintstring(sxp):
-    class tmpstr:
-        def __init__(self):
-            self.str = ""
-        def write(self, str):
-            self.str = self.str + str
-    tmp = tmpstr()
-    prettyprint(sxp, out=tmp)
-    return tmp.str
+def prettyprintstring(sxp, width=80):
+    """Prettyprint an SXP form to a string.
+
+    sxpr       s-expression
+    width      maximum output width
+    """
+    io = StringIO.StringIO()
+    prettyprint(sxpr, out=io, width=width)
+    io.seek(0)
+    val = io.getvalue()
+    io.close()
+    return val
 
 def main():
     pin = sxp.Parser()
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:03:11 -04:00
+++ b/tools/python/xen/xend/XendDomain.py       2005-06-09 13:03:11 -04:00
@@ -20,7 +20,7 @@
 import XendRoot; xroot = XendRoot.instance()
 import XendCheckpoint
 import XendDB
-import XendDomainInfo
+from xen.xend.XendDomainInfo import XendDomainInfo, shutdown_reason
 import EventServer; eserver = EventServer.instance()
 from XendError import XendError
 from XendLogging import log
@@ -31,6 +31,13 @@
 
 SHUTDOWN_TIMEOUT = 30
 
+class XendDomainDict(dict):
+    def get_by_name(self, name):
+        try:
+            return filter(lambda d: d.name == name, self.values())[0]
+        except IndexError, err:
+            return None
+
 class XendDomain:
     """Index of all domains. Singleton.
     """
@@ -38,15 +45,8 @@
     """Path to domain database."""
     dbpath = "domain"
 
-    class XendDomainDict(dict):
-        def get_by_name(self, name):
-            try:
-                return filter(lambda d: d.name == name, self.values())[0]
-            except IndexError, err:
-                return None
-
     """Dict of domain info indexed by domain id."""
-    domains = XendDomainDict()
+    domains = None
     
     def __init__(self):
         # Hack alert. Python does not support mutual imports, but 
XendDomainInfo
@@ -54,6 +54,7 @@
         # to import XendDomain from XendDomainInfo causes unbounded recursion.
         # So we stuff the XendDomain instance (self) into xroot's components.
         xroot.add_component("xen.xend.XendDomain", self)
+        self.domains = XendDomainDict()
         # Table of domain info indexed by domain id.
         self.db = XendDB.XendDB(self.dbpath)
         eserver.subscribe('xend.virq', self.onVirq)
@@ -84,6 +85,8 @@
     def xen_domain(self, dom):
         """Get info about a single domain from xc.
         Returns None if not found.
+
+        @param dom domain id
         """
         try:
             dom = int(dom)
@@ -189,7 +192,7 @@
                 continue
             log.debug('XendDomain>reap> domain died name=%s id=%s', name, id)
             if d['shutdown']:
-                reason = XendDomainInfo.shutdown_reason(d['shutdown_reason'])
+                reason = shutdown_reason(d['shutdown_reason'])
                 log.debug('XendDomain>reap> shutdown name=%s id=%s reason=%s', 
name, id, reason)
                 if reason in ['suspend']:
                     if dominfo and dominfo.is_terminated():
@@ -203,8 +206,8 @@
                     eserver.inject('xend.domain.exit', [name, id, reason])
                     self.domain_restart_schedule(id, reason)
             else:
-               if xroot.get_enable_dump() == 'true':
-                   xc.domain_dumpcore(dom = int(id), corefile = 
"/var/xen/dump/%s.%s.core"%(name,id))
+               if xroot.get_enable_dump():
+                   self.domain_dumpcore(int(id))
                eserver.inject('xend.domain.exit', [name, id, 'crash']) 
             destroyed += 1
             self.final_domain_destroy(id)
@@ -216,7 +219,7 @@
             self.reap()
         doms = self.xen_domains()
         # Add entries for any domains we don't know about.
-        for (id, d) in doms.items():
+        for id in doms.keys():
             if id not in self.domains:
                 self.domain_lookup(id)
         # Remove entries for domains that no longer exist.
@@ -326,9 +329,7 @@
 
         try:
             fd = os.open(src, os.O_RDONLY)
-
             return XendCheckpoint.restore(self, fd)
-
         except OSError, ex:
             raise XendError("can't read guest state file %s: %s" %
                             (src, ex[1]))
@@ -343,20 +344,19 @@
         self.refresh_domain(id)
         return self.domains.get(id)
 
-    def domain_lookup(self, name):
-        name = str(name)
-        dominfo = self.domains.get_by_name(name) or self.domains.get(name)
-        if dominfo:
-            return dominfo
-        try:
-            d = self.xen_domain(name)
-            if d:
-                log.info("Creating entry for unknown domain: id=%s", name)
-                dominfo = XendDomainInfo.vm_recreate(None, d)
-                self._add_domain(dominfo)
-                return dominfo
-        except Exception, ex:
-            log.exception("Error creating domain info: id=%s", name)
+    def domain_lookup(self, id):
+        name = str(id)
+        dominfo = self.domains.get_by_name(name) or 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)
+                    dominfo = XendDomainInfo.vm_recreate(None, info)
+                    self._add_domain(dominfo)
+            except Exception, ex:
+                log.exception("Error creating domain info: id=%s", name)
+        return dominfo
 
     def domain_unpause(self, id):
         """Unpause domain execution.
@@ -595,6 +595,7 @@
             return xc.sedf_domain_get(dominfo.dom)
         except Exception, ex:
             raise XendError(str(ex))
+
     def domain_device_create(self, id, devconfig):
         """Create a new device for a domain.
 
@@ -700,11 +701,28 @@
             raise XendError(str(ex))
 
     def domain_mem_target_set(self, id, target):
+        """Set the memory target for a domain.
+
+        @param id: domain
+        @param target: memory target (in MB)
+        @return: 0 on success, -1 on error
+        """
         dominfo = self.domain_lookup(id)
         return dominfo.mem_target_set(target)
-        
 
+    def domain_dumpcore(self, id):
+        """Save a core dump for a crashed domain.
 
+        @param id: domain
+        """
+        dominfo = self.domain_lookup(id)
+        corefile = "/var/xen/dump/%s.%s.core"% (dominfo.name, dominfo.id)
+        try:
+            xc.domain_dumpcore(dom=dominfo.id, corefile=corefile)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] xend cleanups from Mike Wray., BitKeeper Bot <=