All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] make a dump directory per DomU
@ 2009-07-28  8:20 Rikiya Ayukawa
  0 siblings, 0 replies; only message in thread
From: Rikiya Ayukawa @ 2009-07-28  8:20 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

Hi all,

I attached a patch to make a dump directory per DomU for crash dump.

Currently, xend dumps a core file of a DomU
in the directory "/var/xen/dump/", when the DomU has crashed.

The patch modifies this directory to "/var/xen/dump/<domain name>/".

It enables you to select HDD partition per DomU to dump core by using
mount command.


Diffstat:
 XendDomainInfo.py |   37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

Signed-off-by: Rikiya Ayukawa <ayukawa.rikiya@jp.fujitsu.com>

Best Regards,
--
Rikiya Ayukawa


[-- Attachment #2: make-a-dump-directory-per-domain.patch --]
[-- Type: text/plain, Size: 1863 bytes --]

diff -r 8af26fef898c tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jul 24 12:08:54 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Jul 28 16:49:34 2009 +0900
@@ -31,6 +31,7 @@
 import re
 import copy
 import os
+import stat
 import traceback
 from types import StringTypes
 
@@ -39,6 +40,7 @@
 from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
 import xen.util.xsm.xsm as security
 from xen.util import xsconstants
+from xen.util import mkdir
 from xen.util.pci import serialise_pci_opts, pci_opts_list_to_sxp, \
                          pci_dict_to_bdf_str, pci_dict_to_xc_str, \
                          pci_convert_sxp_to_dict, pci_convert_dict_to_sxp, \
@@ -2162,9 +2164,23 @@
         """
         
         if not corefile:
+            # To prohibit directory traversal
+            based_name = os.path.basename(self.info['name_label'])
+            
+            coredir = "/var/xen/dump/%s" % (based_name)
+            if not os.path.exists(coredir):
+                try:
+                    mkdir.parents(coredir, stat.S_IRWXU)
+                except Exception, ex:
+                    log.error("Cannot create directory: %s" % str(ex))
+
+            if not os.path.isdir(coredir):
+                # Use former directory to dump core
+                coredir = '/var/xen/dump'
+
             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)
+            corefile = "%s/%s-%s.%s.core" % (coredir, this_time,
+                                             self.info['name_label'], self.domid)
                 
         if os.path.isdir(corefile):
             raise XendError("Cannot dump core in a directory: %s" %

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-28  8:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28  8:20 [PATCH] make a dump directory per DomU Rikiya Ayukawa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.