All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: xen-devel@lists.xensource.com
Subject: PATCH: Use name instead of pid in QEMU logs
Date: Fri, 1 Jun 2007 01:55:30 +0100	[thread overview]
Message-ID: <20070601005530.GH15661@redhat.com> (raw)

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

The attached patch changes 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@redhat.com>

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-qemu-logs.patch --]
[-- Type: text/plain, Size: 2933 bytes --]

diff -r 089696e0c603 tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c	Thu May 17 11:42:46 2007 +0100
+++ b/tools/ioemu/target-i386-dm/exec-dm.c	Thu May 31 20:50:51 2007 -0400
@@ -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 089696e0c603 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c	Thu May 17 11:42:46 2007 +0100
+++ b/tools/ioemu/vl.c	Thu May 31 20:51:20 2007 -0400
@@ -7144,9 +7144,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;
@@ -7525,7 +7523,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);
@@ -7547,6 +7545,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) {

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

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

             reply	other threads:[~2007-06-01  0:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-01  0:55 Daniel P. Berrange [this message]
2007-06-01  1:00 ` PATCH: Use name instead of pid in QEMU logs Mark Williamson
2007-06-01  8:39 ` Petersson, Mats
2007-06-12 14:59 ` Daniel P. Berrange
2007-06-12 15:44   ` Mark Williamson
2007-06-12 16:04   ` Keir Fraser
2007-06-12 16:36     ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070601005530.GH15661@redhat.com \
    --to=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.