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] Use name instead of pid in QEMU logs.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Use name instead of pid in QEMU logs.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 11 Jun 2007 02:22:09 -0700
Delivery-date: Mon, 11 Jun 2007 02:24:48 -0700
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 kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1180966669 -3600
# Node ID fc8e406926908909fe062a45357dcc48c7a365fe
# Parent  edf407a3dd70db0af60617b6c90aa3589d7c1c7d
Use name instead of pid in QEMU logs.

Change the logfile name generated by qemu-dm to use the pattern
qemu-dm-[NAME].log instead of qemu-dm-[PID].log. This makes it
easier for the adminsitrator to figure out which log corresponds to
which guest (particularly after a crash where you no long know what
PID the qemu-dm process for your guest had). It also prevents the
number of log files from growing unbounded.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tools/ioemu/target-i386-dm/exec-dm.c |   40 ++++++++++++++++-------------------
 tools/ioemu/vl.c                     |   10 +++++---
 2 files changed, 25 insertions(+), 25 deletions(-)

diff -r edf407a3dd70 -r fc8e40692690 tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c      Mon Jun 04 14:49:12 2007 +0100
+++ b/tools/ioemu/target-i386-dm/exec-dm.c      Mon Jun 04 15:17:49 2007 +0100
@@ -124,7 +124,6 @@ static int io_mem_nb = 1;
 static int io_mem_nb = 1;
 
 /* log support */
-char *logfilename = "/tmp/qemu.log";
 FILE *logfile;
 int loglevel;
 
@@ -166,29 +165,28 @@ void cpu_set_log(int log_flags)
 void cpu_set_log(int log_flags)
 {
     loglevel = log_flags;
+    if (!logfile)
+      logfile = stderr;
+}
+
+void cpu_set_log_filename(const char *filename)
+{
+    logfile = fopen(filename, "w");
     if (!logfile) {
-        logfile = fopen(logfilename, "w");
-        if (!logfile) {
-            perror(logfilename);
-            _exit(1);
-        }
+        perror(filename);
+       _exit(1);
+    }
 #if !defined(CONFIG_SOFTMMU)
-        /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
-        {
-            static uint8_t logfile_buf[4096];
-            setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
-        }
+    /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
+    {
+        static uint8_t logfile_buf[4096];
+       setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
+    }
 #else
-        setvbuf(logfile, NULL, _IOLBF, 0);
-#endif
-        stdout = logfile;
-        stderr = logfile;
-    }
-}
-
-void cpu_set_log_filename(const char *filename)
-{
-    logfilename = strdup(filename);
+    setvbuf(logfile, NULL, _IOLBF, 0);
+#endif
+    stdout = logfile;
+    stderr = logfile;
 }
 
 /* mask must never be zero, except for A20 change call */
diff -r edf407a3dd70 -r fc8e40692690 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Mon Jun 04 14:49:12 2007 +0100
+++ b/tools/ioemu/vl.c  Mon Jun 04 15:17:49 2007 +0100
@@ -7146,9 +7146,7 @@ int main(int argc, char **argv)
     nb_nics = 0;
     /* default mac address of the first network interface */
     
-    /* init debug */
-    sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm.%ld.log", 
(long)getpid());
-    cpu_set_log_filename(qemu_dm_logfilename);
+    /* Init logs to stderr to start with */
     cpu_set_log(0);
     
     optind = 1;
@@ -7527,7 +7525,7 @@ int main(int argc, char **argv)
                 semihosting_enabled = 1;
                 break;
             case QEMU_OPTION_domainname:
-                strncat(domain_name, optarg, sizeof(domain_name) - 20);
+                strncpy(domain_name, optarg, sizeof(domain_name) - 1);
                 break;
             case QEMU_OPTION_d:
                 domid = atoi(optarg);
@@ -7549,6 +7547,10 @@ int main(int argc, char **argv)
             }
         }
     }
+
+    /* Now send logs to our named config */
+    sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm-%s.log", domain_name);
+    cpu_set_log_filename(qemu_dm_logfilename);
 
 #ifndef _WIN32
     if (daemonize && !nographic && vnc_display == NULL && vncunused == 0) {

_______________________________________________
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] Use name instead of pid in QEMU logs., Xen patchbot-unstable <=