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

[Xen-changelog] [xen-unstable] xen: Changes to printk handling:



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1191517096 -3600
# Node ID 2d761ca771fb2c19d06a4835bfaca33d76a742f4
# Parent  65c4977850d71c759062019bee3e62c3d335e439
xen: Changes to printk handling:
 1. Command-line option 'console_timestamps' adds a timestamp prefix
 to each line of Xen console output (x86 only, after CMOS has been
 interrogated).
 2. Clean up prefix handling and vanity banner info.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/ia64/xen/xensetup.c   |    1 
 xen/arch/x86/time.c            |   12 ++++++++++
 xen/drivers/char/console.c     |   46 ++++++++++++++++++++++++++---------------
 xen/include/asm-ia64/time.h    |    7 ++++++
 xen/include/asm-powerpc/time.h |    3 ++
 xen/include/asm-x86/time.h     |    3 ++
 xen/include/xen/console.h      |    2 -
 7 files changed, 55 insertions(+), 19 deletions(-)

diff -r 65c4977850d7 -r 2d761ca771fb xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Thu Oct 04 14:21:11 2007 +0100
+++ b/xen/arch/ia64/xen/xensetup.c      Thu Oct 04 17:58:16 2007 +0100
@@ -315,7 +315,6 @@ void __init start_kernel(void)
 #endif
 
     init_console();
-    set_printk_prefix("(XEN) ");
 
     if (running_on_sim || ia64_boot_param->domain_start == 0 ||
                           ia64_boot_param->domain_size == 0) {
diff -r 65c4977850d7 -r 2d761ca771fb xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Thu Oct 04 14:21:11 2007 +0100
+++ b/xen/arch/x86/time.c       Thu Oct 04 17:58:16 2007 +0100
@@ -1038,6 +1038,18 @@ int dom0_pit_access(struct ioreq *ioreq)
     return 0;
 }
 
+struct tm wallclock_time(void)
+{
+    uint64_t seconds;
+
+    if ( !wc_sec )
+        return (struct tm) { 0 };
+
+    seconds = NOW() + (wc_sec * 1000000000ull) + wc_nsec;
+    do_div(seconds, 1000000000);
+    return gmtime(seconds);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 65c4977850d7 -r 2d761ca771fb xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Thu Oct 04 14:21:11 2007 +0100
+++ b/xen/drivers/char/console.c        Thu Oct 04 17:58:16 2007 +0100
@@ -53,12 +53,14 @@ static int opt_console_to_ring;
 static int opt_console_to_ring;
 boolean_param("console_to_ring", opt_console_to_ring);
 
+/* console_timestamps: include a timestamp prefix on every Xen console line. */
+static int opt_console_timestamps;
+boolean_param("console_timestamps", opt_console_timestamps);
+
 #define CONRING_SIZE 16384
 #define CONRING_IDX_MASK(i) ((i)&(CONRING_SIZE-1))
 static char conring[CONRING_SIZE];
 static unsigned int conringc, conringp;
-
-static char printk_prefix[16] = "";
 
 static int sercon_handle = -1;
 
@@ -448,6 +450,26 @@ static int printk_prefix_check(char *p, 
             ((loglvl < upper_thresh) && printk_ratelimit()));
 } 
 
+static void printk_start_of_line(void)
+{
+    struct tm tm;
+    char tstr[32];
+
+    __putstr("(XEN) ");
+
+    if ( !opt_console_timestamps )
+        return;
+
+    tm = wallclock_time();
+    if ( tm.tm_mday == 0 )
+        return;
+
+    snprintf(tstr, sizeof(tstr), "[%04u-%02u-%02u %02u:%02u:%02u] ",
+             1900 + tm.tm_year, tm.tm_mon, tm.tm_mday,
+             tm.tm_hour, tm.tm_min, tm.tm_sec);
+    __putstr(tstr);
+}
+
 void printk(const char *fmt, ...)
 {
     static char   buf[1024];
@@ -475,7 +497,7 @@ void printk(const char *fmt, ...)
         if ( do_print )
         {
             if ( start_of_line )
-                __putstr(printk_prefix);
+                printk_start_of_line();
             __putstr(p);
             __putstr("\n");
         }
@@ -490,7 +512,7 @@ void printk(const char *fmt, ...)
         if ( do_print )
         {
             if ( start_of_line )
-                __putstr(printk_prefix);
+                printk_start_of_line();
             __putstr(p);
         }
         start_of_line = 0;
@@ -498,11 +520,6 @@ void printk(const char *fmt, ...)
 
     spin_unlock_recursive(&console_lock);
     local_irq_restore(flags);
-}
-
-void set_printk_prefix(const char *prefix)
-{
-    safe_strcpy(printk_prefix, prefix);
 }
 
 void __init init_console(void)
@@ -523,15 +540,12 @@ void __init init_console(void)
     serial_set_rx_handler(sercon_handle, serial_rx);
 
     /* HELLO WORLD --- start-of-day banner text. */
-    printk(xen_banner());
-    printk(" http://www.cl.cam.ac.uk/netos/xen\n";);
-    printk(" University of Cambridge Computer Laboratory\n\n");
-    printk(" Xen version %d.%d%s (%s@%s) (%s) %s\n",
+    __putstr(xen_banner());
+    printk("Xen version %d.%d%s (%s@%s) (%s) %s\n",
            xen_major_version(), xen_minor_version(), xen_extra_version(),
            xen_compile_by(), xen_compile_domain(),
            xen_compiler(), xen_compile_date());
-    printk(" Latest ChangeSet: %s\n\n", xen_changeset());
-    set_printk_prefix("(XEN) ");
+    printk("Latest ChangeSet: %s\n", xen_changeset());
 
     if ( opt_sync_console )
     {
@@ -687,7 +701,7 @@ int __printk_ratelimit(int ratelimit_ms,
             snprintf(lost_str, sizeof(lost_str), "%d", lost);
             /* console_lock may already be acquired by printk(). */
             spin_lock_recursive(&console_lock);
-            __putstr(printk_prefix);
+            printk_start_of_line();
             __putstr("printk: ");
             __putstr(lost_str);
             __putstr(" messages suppressed.\n");
diff -r 65c4977850d7 -r 2d761ca771fb xen/include/asm-ia64/time.h
--- a/xen/include/asm-ia64/time.h       Thu Oct 04 14:21:11 2007 +0100
+++ b/xen/include/asm-ia64/time.h       Thu Oct 04 17:58:16 2007 +0100
@@ -1,2 +1,9 @@
+#ifndef _ASM_TIME_H_
+#define _ASM_TIME_H_
+
 #include <asm/linux/time.h>
 #include <asm/timex.h>
+
+#define wallclock_time() ((struct tm) { 0 })
+
+#endif /* _ASM_TIME_H_ */
diff -r 65c4977850d7 -r 2d761ca771fb xen/include/asm-powerpc/time.h
--- a/xen/include/asm-powerpc/time.h    Thu Oct 04 14:21:11 2007 +0100
+++ b/xen/include/asm-powerpc/time.h    Thu Oct 04 17:58:16 2007 +0100
@@ -80,4 +80,7 @@ static inline u64 tb_to_ns(u64 tb)
 {
     return tb * (__nano(1) / timebase_freq);
 }
+
+#define wallclock_time() ((struct tm) { 0 })
+
 #endif
diff -r 65c4977850d7 -r 2d761ca771fb xen/include/asm-x86/time.h
--- a/xen/include/asm-x86/time.h        Thu Oct 04 14:21:11 2007 +0100
+++ b/xen/include/asm-x86/time.h        Thu Oct 04 17:58:16 2007 +0100
@@ -31,4 +31,7 @@ int dom0_pit_access(struct ioreq *ioreq)
 
 int cpu_frequency_change(u64 freq);
 
+struct tm;
+struct tm wallclock_time(void);
+
 #endif /* __X86_TIME_H__ */
diff -r 65c4977850d7 -r 2d761ca771fb xen/include/xen/console.h
--- a/xen/include/xen/console.h Thu Oct 04 14:21:11 2007 +0100
+++ b/xen/include/xen/console.h Thu Oct 04 17:58:16 2007 +0100
@@ -10,8 +10,6 @@
 #include <xen/spinlock.h>
 #include <xen/guest_access.h>
 #include <public/xen.h>
-
-void set_printk_prefix(const char *prefix);
 
 long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int);
 

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


 


Rackspace

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