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] [xen-unstable] Domain core-dumping fixes

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Domain core-dumping fixes
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Mar 2009 04:30:31 -0700
Delivery-date: Thu, 12 Mar 2009 04:32:04 -0700
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1236856197 0
# Node ID 1e9342bc6d6e9f7f8f6ce903a52dd6b307f2b734
# Parent  b3b6aee082d604a980e50ee10d638b712028bf55
Domain core-dumping fixes

The code was attempting to use the domain's current number of pages
(info.nr_pages) as a maximum index.  We then walk the memory map and
can easily over-write past the end of the nr_pages-sized array, if the
domain has more pages mapped in than earlier (live dump).  Restrict
ourselves to the current number of pages.

Also fix the dump core method in xend to actually implement the crash
and live options.  In particular this means that xend clients other
than xm now get non-live dumps by default.

Signed-off-by: John Levon <john.levon@xxxxxxx>
---
 tools/libxc/xc_core.c                   |   10 +++++++
 tools/libxc/xenctrl.h                   |    2 -
 tools/python/xen/xend/XendDomain.py     |   24 +++++++++++++-----
 tools/python/xen/xend/XendDomainInfo.py |   41 +++++++++++++++++---------------
 tools/python/xen/xm/main.py             |   20 +++------------
 5 files changed, 55 insertions(+), 42 deletions(-)

diff -r b3b6aee082d6 -r 1e9342bc6d6e tools/libxc/xc_core.c
--- a/tools/libxc/xc_core.c     Thu Mar 12 11:08:45 2009 +0000
+++ b/tools/libxc/xc_core.c     Thu Mar 12 11:09:57 2009 +0000
@@ -518,7 +518,17 @@ xc_domain_dumpcore_via_callback(int xc_h
     if ( sts != 0 )
         goto out;
 
+    /*
+     * Note: this is the *current* number of pages and may change under
+     * a live dump-core.  We'll just take this value, and if more pages
+     * exist, we'll skip them.  If there's less, then we'll just not use
+     * all the array...
+     *
+     * We don't want to use the total potential size of the memory map
+     * since that is usually much higher than info.nr_pages.
+     */
     nr_pages = info.nr_pages;
+
     if ( !auto_translated_physmap )
     {
         /* obtain p2m table */
diff -r b3b6aee082d6 -r 1e9342bc6d6e tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Thu Mar 12 11:08:45 2009 +0000
+++ b/tools/libxc/xenctrl.h     Thu Mar 12 11:09:57 2009 +0000
@@ -158,7 +158,7 @@ typedef struct xc_dominfo {
                   paused:1, blocked:1, running:1,
                   hvm:1, debugged:1;
     unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
-    unsigned long nr_pages;
+    unsigned long nr_pages; /* current number, not maximum */
     unsigned long shared_info_frame;
     uint64_t      cpu_time;
     unsigned long max_memkb;
diff -r b3b6aee082d6 -r 1e9342bc6d6e tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Thu Mar 12 11:08:45 2009 +0000
+++ b/tools/python/xen/xend/XendDomain.py       Thu Mar 12 11:09:57 2009 +0000
@@ -1237,13 +1237,23 @@ class XendDomain:
                              POWER_STATE_NAMES[DOM_STATE_PAUSED],
                              POWER_STATE_NAMES[dominfo._stateGet()])
 
-        try:
-            log.info("Domain core dump requested for domain %s (%d) "
-                     "live=%d crash=%d.",
-                     dominfo.getName(), dominfo.getDomid(), live, crash)
-            return dominfo.dumpCore(filename)
-        except Exception, ex:
-            raise XendError(str(ex))
+        dopause = (not live and dominfo._stateGet() == DOM_STATE_RUNNING)
+        if dopause:
+            dominfo.pause()
+
+        try:
+            try:
+                log.info("Domain core dump requested for domain %s (%d) "
+                         "live=%d crash=%d.",
+                         dominfo.getName(), dominfo.getDomid(), live, crash)
+                dominfo.dumpCore(filename)
+                if crash:
+                    self.domain_destroy(domid)
+            except Exception, ex:
+                raise XendError(str(ex))
+        finally:
+            if dopause and not crash:
+                dominfo.unpause()
 
     def domain_destroy(self, domid):
         """Terminate domain immediately.
diff -r b3b6aee082d6 -r 1e9342bc6d6e tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Mar 12 11:08:45 2009 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Mar 12 11:09:57 2009 +0000
@@ -2027,26 +2027,31 @@ class XendDomainInfo:
         @raise: XendError if core dumping failed.
         """
         
+        if not corefile:
+            this_time = time.strftime("%Y-%m%d-%H%M.%S", time.localtime())
+            corefile = "/var/xen/dump/%s-%s.%s.core" % (this_time,
+                              self.info['name_label'], self.domid)
+                
+        if os.path.isdir(corefile):
+            raise XendError("Cannot dump core in a directory: %s" %
+                            corefile)
+
         try:
-            if not corefile:
-                this_time = time.strftime("%Y-%m%d-%H%M.%S", time.localtime())
-                corefile = "/var/xen/dump/%s-%s.%s.core" % (this_time,
-                                  self.info['name_label'], self.domid)
-                
-            if os.path.isdir(corefile):
-                raise XendError("Cannot dump core in a directory: %s" %
-                                corefile)
-            
-            self._writeVm(DUMPCORE_IN_PROGRESS, 'True')
-            xc.domain_dumpcore(self.domid, corefile)
+            try:
+                self._writeVm(DUMPCORE_IN_PROGRESS, 'True')
+                xc.domain_dumpcore(self.domid, corefile)
+            except RuntimeError, ex:
+                corefile_incomp = corefile+'-incomplete'
+                try:
+                    os.rename(corefile, corefile_incomp)
+                except:
+                    pass
+
+                log.error("core dump failed: id = %s name = %s: %s",
+                          self.domid, self.info['name_label'], str(ex))
+                raise XendError("Failed to dump core: %s" %  str(ex))
+        finally:
             self._removeVm(DUMPCORE_IN_PROGRESS)
-        except RuntimeError, ex:
-            corefile_incomp = corefile+'-incomplete'
-            os.rename(corefile, corefile_incomp)
-            self._removeVm(DUMPCORE_IN_PROGRESS)
-            log.exception("XendDomainInfo.dumpCore failed: id = %s name = %s",
-                          self.domid, self.info['name_label'])
-            raise XendError("Failed to dump core: %s" %  str(ex))
 
     #
     # Device creation/deletion functions
diff -r b3b6aee082d6 -r 1e9342bc6d6e tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Mar 12 11:08:45 2009 +0000
+++ b/tools/python/xen/xm/main.py       Thu Mar 12 11:09:57 2009 +0000
@@ -1351,22 +1351,10 @@ def xm_dump_core(args):
     else:
         filename = None
 
-    if not live:
-        ds = server.xend.domain.pause(dom, True)
-
-    try:
-        print "Dumping core of domain: %s ..." % str(dom)
-        server.xend.domain.dump(dom, filename, live, crash)
-
-        if crash:
-            print "Destroying domain: %s ..." % str(dom)
-            server.xend.domain.destroy(dom)
-        elif reset:
-            print "Resetting domain: %s ..." % str(dom)
-            server.xend.domain.reset(dom)
-    finally:
-        if not live and not crash and not reset and ds == DOM_STATE_RUNNING:
-            server.xend.domain.unpause(dom)
+    print "Dumping core of domain: %s ..." % str(dom)
+    server.xend.domain.dump(dom, filename, live, crash)
+    if reset:
+        server.xend.domain.reset(dom)
 
 def xm_rename(args):
     arg_check(args, "rename", 2)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Domain core-dumping fixes, Xen patchbot-unstable <=