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] Diagnose a failure to open the xend-debug

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Diagnose a failure to open the xend-debug.log, and make the /var/log/xen
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 29 Nov 2006 14:00:14 +0000
Delivery-date: Wed, 29 Nov 2006 05:59:45 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID ec2af46f9472f6e10796b28f8929b53a4b65e61e
# Parent  a98bec6aacac18c3d396c7e5d1481d3d84de3ffd
Diagnose a failure to open the xend-debug.log, and make the /var/log/xen
directory on startup, which was the most common reason to fail.
Closes bug #823.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/server/SrvDaemon.py |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff -r a98bec6aacac -r ec2af46f9472 tools/python/xen/xend/server/SrvDaemon.py
--- a/tools/python/xen/xend/server/SrvDaemon.py Wed Nov 29 10:48:06 2006 +0000
+++ b/tools/python/xen/xend/server/SrvDaemon.py Wed Nov 29 10:56:02 2006 +0000
@@ -6,7 +6,9 @@
 ###########################################################
 
 import os
+import os.path
 import signal
+import stat
 import sys
 import threading
 import time
@@ -102,17 +104,32 @@ class Daemon:
 
         # Detach from standard file descriptors, and redirect them to
         # /dev/null or the log as appropriate.
+        # We open the log file first, so that we can diagnose a failure to do
+        # so _before_ we close stderr.
+        try:
+            parent = os.path.dirname(XEND_DEBUG_LOG)
+            if not os.path.exists(parent):
+                os.makedirs(parent, stat.S_IRWXU)
+            fd = os.open(XEND_DEBUG_LOG, os.O_WRONLY|os.O_CREAT|os.O_APPEND)
+        except Exception, exn:
+            print >>sys.stderr, exn
+            print >>sys.stderr, ("Xend failed to open %s.  Exiting!" %
+                                 XEND_DEBUG_LOG)
+            sys.exit(1)
+
         os.close(0)
         os.close(1)
         os.close(2)
         if XEND_DEBUG:
             os.open('/dev/null', os.O_RDONLY)
-            os.open(XEND_DEBUG_LOG, os.O_WRONLY|os.O_CREAT|os.O_APPEND)
-            os.dup(1)
+            os.dup(fd)
+            os.dup(fd)
         else:
             os.open('/dev/null', os.O_RDWR)
             os.dup(0)
-            os.open(XEND_DEBUG_LOG, os.O_WRONLY|os.O_CREAT|os.O_APPEND)
+            os.dup(fd)
+        os.close(fd)
+
         print >>sys.stderr, ("Xend started at %s." %
                              time.asctime(time.localtime()))
 

_______________________________________________
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] Diagnose a failure to open the xend-debug.log, and make the /var/log/xen, Xen patchbot-unstable <=