[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.