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] [XEN] Implement log levels. It adds the t

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEN] Implement log levels. It adds the thresholds and code to printk
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 27 Oct 2006 18:30:17 +0000
Delivery-date: Fri, 27 Oct 2006 11:30:35 -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 kaf24@xxxxxxxxxxxxxxxxxxxxx
# Node ID fd8036d06e10b0830305a43962087b7c50317723
# Parent  e834d5b965d025e110f84d29512eab4703b86278
[XEN] Implement log levels. It adds the thresholds and code to printk
to implement the thresholds.
Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>
---
 xen/drivers/char/console.c |   41 +++++++++++++++
 xen/include/xen/config.h   |  119 ++++++++++++++++++++++++++++++++++++++++-----
 xen/include/xen/lib.h      |    4 +
 3 files changed, 151 insertions(+), 13 deletions(-)

diff -r e834d5b965d0 -r fd8036d06e10 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Fri Oct 27 18:46:20 2006 +0100
+++ b/xen/drivers/char/console.c        Fri Oct 27 18:52:55 2006 +0100
@@ -57,6 +57,13 @@ static int sercon_handle = -1;
 static int sercon_handle = -1;
 
 static DEFINE_SPINLOCK(console_lock);
+
+int xenlog_upper_thresh = XENLOG_UPPER_THRESHOLD;
+int xenlog_lower_thresh = XENLOG_LOWER_THRESHOLD;
+int xenlog_guest_upper_thresh = XENLOG_GUEST_UPPER_THRESHOLD;
+int xenlog_guest_lower_thresh = XENLOG_GUEST_LOWER_THRESHOLD;
+
+static int xen_startup = 1;
 
 /*
  * ********************************************************
@@ -307,6 +314,10 @@ void printk(const char *fmt, ...)
     va_list       args;
     char         *p, *q;
     unsigned long flags;
+    int           level = XENLOG_DEFAULT;
+    int           upper_thresh = xenlog_upper_thresh;
+    int           lower_thresh = xenlog_lower_thresh;
+    int           print_regardless = xen_startup;
 
     spin_lock_irqsave(&console_lock, flags);
 
@@ -315,6 +326,32 @@ void printk(const char *fmt, ...)
     va_end(args);        
 
     p = buf;
+
+    /* Is this print caused by a guest? */
+    if ( strncmp("<G>", p, 3) == 0 )
+    {
+        upper_thresh = xenlog_guest_upper_thresh;
+        lower_thresh = xenlog_guest_lower_thresh;
+        level = XENLOG_GUEST_DEFAULT;
+        p += 3;
+    }
+
+    if ( (p[0] == '<') &&
+         (p[1] >= '0') && (p[1] <= ('0' + XENLOG_MAX)) &&
+         (p[2] == '>') )
+    {
+        level = p[1] - '0';
+        p += 3;
+    }
+
+    if ( !print_regardless )
+    {
+        if ( level > upper_thresh )
+            goto out;
+        if ( (level >= lower_thresh) && (!printk_ratelimit()) )
+            goto out;
+    }
+
     while ( (q = strchr(p, '\n')) != NULL )
     {
         *q = '\0';
@@ -334,6 +371,7 @@ void printk(const char *fmt, ...)
         start_of_line = 0;
     }
 
+ out:
     spin_unlock_irqrestore(&console_lock, flags);
 }
 
@@ -419,6 +457,9 @@ void console_endboot(void)
 
     /* Serial input is directed to DOM0 by default. */
     switch_serial_input();
+
+    /* Now we implement the logging thresholds. */
+    xen_startup = 0;
 }
 
 void console_force_unlock(void)
diff -r e834d5b965d0 -r fd8036d06e10 xen/include/xen/config.h
--- a/xen/include/xen/config.h  Fri Oct 27 18:46:20 2006 +0100
+++ b/xen/include/xen/config.h  Fri Oct 27 18:52:55 2006 +0100
@@ -12,26 +12,119 @@
 #define EXPORT_SYMBOL(var)
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
-/* Linux syslog levels. */
-#define KERN_NOTICE  ""
-#define KERN_WARNING ""
-#define KERN_DEBUG   ""
-#define KERN_INFO    ""
-#define KERN_ERR     ""
-#define KERN_CRIT    ""
-#define KERN_EMERG   ""
-#define KERN_ALERT   ""
+/*
+ * The following log levels are as follows:
+ *
+ *   XENLOG_ERR: Fatal errors, either Xen, Guest or Dom0
+ *               is about to crash.
+ *
+ *   XENLOG_WARNING: Something bad happened, but we can recover.
+ *
+ *   XENLOG_INFO: Interesting stuff, but not too noisy.
+ *
+ *   XENLOG_DEBUG: Use where ever you like. Lots of noise.
+ *
+ *
+ * Since we don't trust the guest operating system, we don't want
+ * it to allow for DoS by causing the HV to print out a lot of
+ * info, so where ever the guest has control of what is printed
+ * we use the XENLOG_GUEST to distinguish that the output is
+ * controled by the Guest.
+ *
+ * To make it easier on the typing, the above log levels all
+ * have a corresponding _G_ equivalent that appends the
+ * XENLOG_GUEST. (see the defines below).
+ *
+ */
+#define XENLOG_ERR     "<0>"
+#define XENLOG_WARNING "<1>"
+#define XENLOG_INFO    "<2>"
+#define XENLOG_DEBUG   "<3>"
+
+#define XENLOG_GUEST   "<G>"
+
+#define XENLOG_G_ERR     XENLOG_GUEST XENLOG_ERR
+#define XENLOG_G_WARNING XENLOG_GUEST XENLOG_WARNING
+#define XENLOG_G_INFO    XENLOG_GUEST XENLOG_INFO
+#define XENLOG_G_DEBUG   XENLOG_GUEST XENLOG_DEBUG
+
+#define XENLOG_MAX 3
+
+/*
+ * To control the amount of printing, thresholds are added.
+ * These thresholds correspond to the above log levels.
+ * There's an upper and lower threshold for non-guests
+ * and Guest.  This works as follows:
+ *
+ * If printk log level > upper threshold
+ *   don't print anything
+ *
+ * If printk log level >= lower threshold
+ *   rate limit the print (keep the amount down)
+ *
+ * Otherwise, just print.
+ *
+ * Note, in the above algorithm, to never rate limit
+ * simply make the lower threshold greater than the upper.
+ * This way the output will never be rate limited.
+ *
+ * For example:
+ *   lower = 2; upper = 1;
+ *  This will always print ERR and WARNING messages
+ *  but will not print anything else.  Nothing is
+ *  rate limited.
+ */
+/*
+ * Defaults:
+ *   For the HV, always print ERR and WARNING
+ *   but nothing for INFO and DEBUG.
+ *
+ *   For Guests, always rate limit ERR and WARNING
+ *   but never print for INFO and DEBUG.
+ */
+#ifndef XENLOG_UPPER_THRESHOLD
+#define XENLOG_UPPER_THRESHOLD 1
+#endif
+#ifndef XENLOG_LOWER_THRESHOLD
+#define XENLOG_LOWER_THRESHOLD 2
+#endif
+#ifndef XENLOG_GUEST_UPPER_THRESHOLD
+#define XENLOG_GUEST_UPPER_THRESHOLD 1
+#endif
+#ifndef XENLOG_GUEST_LOWER_THRESHOLD
+#define XENLOG_GUEST_LOWER_THRESHOLD 0
+#endif
+
+/*
+ * The XENLOG_DEFAULT is the default given to printks that
+ * do not have any print level associated to it.
+ */
+#ifndef XENLOG_DEFAULT
+#define XENLOG_DEFAULT 1 /* Warning */
+#endif
+#ifndef XENLOG_GUEST_DEFAULT
+#define XENLOG_GUEST_DEFAULT 1 /* Warning */
+#endif
+
+/*
+ * Some code is copied directly from Linux.
+ * Match some of the Linux log levels to Xen.
+ *  (Should these be Guest logs?? - SDR)
+ */
+#define KERN_ERR       XENLOG_ERR
+#define KERN_CRIT      XENLOG_ERR
+#define KERN_EMERG     XENLOG_ERR
+#define KERN_WARNING   XENLOG_WARNING
+#define KERN_NOTICE    XENLOG_INFO
+#define KERN_INFO      XENLOG_INFO
+#define KERN_DEBUG     XENLOG_DEBUG
 
 /* Linux 'checker' project. */
 #define __iomem
 #define __user
 
-#ifdef VERBOSE
 #define DPRINTK(_f, _a...) printk("(file=%s, line=%d) " _f, \
                            __FILE__ , __LINE__ , ## _a )
-#else
-#define DPRINTK(_f, _a...) ((void)0)
-#endif
 
 #ifndef __ASSEMBLY__
 #include <xen/compiler.h>
diff -r e834d5b965d0 -r fd8036d06e10 xen/include/xen/lib.h
--- a/xen/include/xen/lib.h     Fri Oct 27 18:46:20 2006 +0100
+++ b/xen/include/xen/lib.h     Fri Oct 27 18:52:55 2006 +0100
@@ -58,6 +58,10 @@ extern long vm_assist(struct domain *, u
 extern long vm_assist(struct domain *, unsigned int, unsigned int);
 extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
 extern int printk_ratelimit(void);
+extern int xenlog_upper_thresh;
+extern int xenlog_lower_thresh;
+extern int xenlog_guest_upper_thresh;
+extern int xenlog_guest_lower_thresh;
 
 /* vsprintf.c */
 extern int sprintf(char * buf, const char * fmt, ...)

_______________________________________________
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] [XEN] Implement log levels. It adds the thresholds and code to printk, Xen patchbot-unstable <=