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-devel

[Xen-devel] [PATCH 4/6] tapdisk-ioemu: Write messages to a logfile

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 4/6] tapdisk-ioemu: Write messages to a logfile
From: Kevin Wolf <kwolf@xxxxxxx>
Date: Fri, 13 Mar 2009 10:16:41 +0100
Cc: Ian.Jackson@xxxxxxxxxxxxx, Kevin Wolf <kwolf@xxxxxxx>
Delivery-date: Fri, 13 Mar 2009 02:11:51 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1236935803-32548-1-git-send-email-kwolf@xxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1236935803-32548-1-git-send-email-kwolf@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Typically, tapdisk-ioemu runs as a daemon and messages to stderr are
simply lost. Write them to a logfile instead.

Signed-off-by: Kevin Wolf <kwolf@xxxxxxx>
---
 tapdisk-ioemu.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/tapdisk-ioemu.c b/tapdisk-ioemu.c
index 5e5ccc2..31f7f59 100644
--- a/tapdisk-ioemu.c
+++ b/tapdisk-ioemu.c
@@ -86,15 +86,22 @@ int main(void)
     struct timeval tv;
     void *old_fd_start = NULL;
 
-    logfile = stderr;
-    
+    /* Daemonize */
+    if (fork() != 0)
+        exit(0);
+
     bdrv_init();
     init_blktap();
 
-    /* Daemonize */
-    if (fork() != 0)
-       exit(0);
-   
+    logfile = fopen("/var/log/xen/tapdisk-ioemu.log", "a");
+    if (logfile) {
+        setbuf(logfile, NULL);
+        fclose(stderr);
+        stderr = logfile;
+    } else {
+        logfile = stderr;
+    }
+
     /* 
      * Main loop: Pass events to the corrsponding handlers and check for
      * completed aio operations.
-- 
1.6.0.2


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