direct-io.hg

changeset 12218:dd62270df2ad

[XEN] Add 'loglvl' and 'guest_loglvl' boot parameters.

<lvl> := none|error|warning|info|debug|all

loglvl=<lvl_print_always>[/<lvl_print_ratelimit>]
<lvl_print_always>: log level which is always printed
<lvl_print_rlimit>: log level which is rate-limit printed

'loglvl' applies to non-guest-related messages.
'guest_loglvl' applies to guest-related messages.

Defaults: loglvl=warning ; guest_loglvl=none/warning

Also clean up hvm_print_line().

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Thu Nov 02 22:24:20 2006 +0000 (2006-11-02)
parents 20204db0891b
children 7818629c336c
files docs/src/user.tex xen/arch/x86/domain.c xen/arch/x86/hvm/hvm.c xen/drivers/char/console.c xen/include/asm-x86/hvm/domain.h xen/include/xen/lib.h
line diff
     1.1 --- a/docs/src/user.tex	Thu Nov 02 18:52:04 2006 +0000
     1.2 +++ b/docs/src/user.tex	Thu Nov 02 22:24:20 2006 +0000
     1.3 @@ -3192,6 +3192,15 @@ editing \path{grub.conf}.
     1.4    input to DOM0 when it boots --- if it is `x' then auto-switching is
     1.5    disabled.  Any other value, or omitting the character, enables
     1.6    auto-switching.  [NB. Default switch-char is `a'.]
     1.7 +\item [ loglvl=$<$level$>/<$level$>$ ]
     1.8 +  Specify logging level. Messages of the specified severity level (and
     1.9 +  higher) will be printed to the Xen console. Valid levels are `none',
    1.10 +  `error', `warning', `info', `debug', and `all'. The second level
    1.11 +  specifier is optional: it is used to specify message severities
    1.12 +  which are to be rate limited. Default is `loglvl=warning'.
    1.13 +\item [ guest\_loglvl=$<$level$>/<$level$>$ ] As for loglvl, but
    1.14 +  applies to messages relating to guests. Default is
    1.15 +  `guest\_loglvl=none/warning'. 
    1.16  \item [ nmi=xxx ]
    1.17    Specify what to do with an NMI parity or I/O error. \\
    1.18    `nmi=fatal':  Xen prints a diagnostic and then hangs. \\
     2.1 --- a/xen/arch/x86/domain.c	Thu Nov 02 18:52:04 2006 +0000
     2.2 +++ b/xen/arch/x86/domain.c	Thu Nov 02 22:24:20 2006 +0000
     2.3 @@ -243,6 +243,8 @@ int arch_domain_create(struct domain *d)
     2.4              goto fail;
     2.5          }
     2.6  
     2.7 +        spin_lock_init(&d->arch.hvm_domain.pbuf_lock);
     2.8 +
     2.9          rc = shadow_enable(d, SHM2_refcounts|SHM2_translate|SHM2_external);
    2.10          if ( rc != 0 )
    2.11              goto fail;
     3.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Nov 02 18:52:04 2006 +0000
     3.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Nov 02 22:24:20 2006 +0000
     3.3 @@ -325,22 +325,22 @@ int hvm_copy_from_guest_virt(void *buf, 
     3.4      return __hvm_copy(buf, shadow_gva_to_gpa(current, vaddr), size, 0);
     3.5  }
     3.6  
     3.7 -/*
     3.8 - * HVM specific printbuf. Mostly used for hvmloader chit-chat.
     3.9 - */
    3.10 +/* HVM specific printbuf. Mostly used for hvmloader chit-chat. */
    3.11  void hvm_print_line(struct vcpu *v, const char c)
    3.12  {
    3.13 -    int *index = &v->domain->arch.hvm_domain.pbuf_index;
    3.14 -    char *pbuf = v->domain->arch.hvm_domain.pbuf;
    3.15 +    struct hvm_domain *hd = &v->domain->arch.hvm_domain;
    3.16  
    3.17 -    if (*index == HVM_PBUF_SIZE-2 || c == '\n') {
    3.18 -        if (*index == HVM_PBUF_SIZE-2)
    3.19 -            pbuf[(*index)++] = c;
    3.20 -        pbuf[*index] = '\0';
    3.21 -        printk("(GUEST: %u) %s\n", v->domain->domain_id, pbuf);
    3.22 -        *index = 0;
    3.23 -    } else
    3.24 -        pbuf[(*index)++] = c;
    3.25 +    spin_lock(&hd->pbuf_lock);
    3.26 +    hd->pbuf[hd->pbuf_idx++] = c;
    3.27 +    if ( (hd->pbuf_idx == (sizeof(hd->pbuf) - 2)) || (c == '\n') )
    3.28 +    {
    3.29 +        if ( c != '\n' )
    3.30 +            hd->pbuf[hd->pbuf_idx++] = '\n';
    3.31 +        hd->pbuf[hd->pbuf_idx] = '\0';
    3.32 +        printk(XENLOG_G_DEBUG "HVM%u: %s\n", v->domain->domain_id, hd->pbuf);
    3.33 +        hd->pbuf_idx = 0;
    3.34 +    }
    3.35 +    spin_unlock(&hd->pbuf_lock);
    3.36  }
    3.37  
    3.38  typedef unsigned long hvm_hypercall_t(
     4.1 --- a/xen/drivers/char/console.c	Thu Nov 02 18:52:04 2006 +0000
     4.2 +++ b/xen/drivers/char/console.c	Thu Nov 02 22:24:20 2006 +0000
     4.3 @@ -82,13 +82,76 @@ static DEFINE_SPINLOCK(console_lock);
     4.4  #define XENLOG_DEFAULT       1 /* XENLOG_WARNING */
     4.5  #define XENLOG_GUEST_DEFAULT 1 /* XENLOG_WARNING */
     4.6  
     4.7 -int xenlog_upper_thresh = XENLOG_UPPER_THRESHOLD;
     4.8 -int xenlog_lower_thresh = XENLOG_LOWER_THRESHOLD;
     4.9 -int xenlog_guest_upper_thresh = XENLOG_GUEST_UPPER_THRESHOLD;
    4.10 -int xenlog_guest_lower_thresh = XENLOG_GUEST_LOWER_THRESHOLD;
    4.11 +static int xenlog_upper_thresh = XENLOG_UPPER_THRESHOLD;
    4.12 +static int xenlog_lower_thresh = XENLOG_LOWER_THRESHOLD;
    4.13 +static int xenlog_guest_upper_thresh = XENLOG_GUEST_UPPER_THRESHOLD;
    4.14 +static int xenlog_guest_lower_thresh = XENLOG_GUEST_LOWER_THRESHOLD;
    4.15 +
    4.16 +static void parse_loglvl(char *s);
    4.17 +static void parse_guest_loglvl(char *s);
    4.18 +
    4.19 +/*
    4.20 + * <lvl> := none|error|warning|info|debug|all
    4.21 + * loglvl=<lvl_print_always>[/<lvl_print_ratelimit>]
    4.22 + *  <lvl_print_always>: log level which is always printed
    4.23 + *  <lvl_print_rlimit>: log level which is rate-limit printed
    4.24 + * Similar definitions for guest_loglvl, but applies to guest tracing.
    4.25 + * Defaults: loglvl=warning ; guest_loglvl=none/warning
    4.26 + */
    4.27 +custom_param("loglvl", parse_loglvl);
    4.28 +custom_param("guest_loglvl", parse_guest_loglvl);
    4.29  
    4.30  static int xen_startup = 1;
    4.31  
    4.32 +#define ___parse_loglvl(s, ps, lvlstr, lvlnum)          \
    4.33 +    if ( !strncmp((s), (lvlstr), strlen(lvlstr)) ) {    \
    4.34 +        *(ps) = (s) + strlen(lvlstr);                   \
    4.35 +        return (lvlnum);                                \
    4.36 +    }
    4.37 +
    4.38 +static int __parse_loglvl(char *s, char **ps)
    4.39 +{
    4.40 +    ___parse_loglvl(s, ps, "none",    0);
    4.41 +    ___parse_loglvl(s, ps, "error",   1);
    4.42 +    ___parse_loglvl(s, ps, "warning", 2);
    4.43 +    ___parse_loglvl(s, ps, "info",    3);
    4.44 +    ___parse_loglvl(s, ps, "debug",   4);
    4.45 +    ___parse_loglvl(s, ps, "all",     4);
    4.46 +    return 2; /* sane fallback */
    4.47 +}
    4.48 +
    4.49 +static void _parse_loglvl(char *s, int *lower, int *upper)
    4.50 +{
    4.51 +    *lower = *upper = __parse_loglvl(s, &s);
    4.52 +    if ( *s == '/' )
    4.53 +        *upper = __parse_loglvl(s+1, &s);
    4.54 +    if ( *upper < *lower )
    4.55 +        *upper = *lower;
    4.56 +}
    4.57 +
    4.58 +static void parse_loglvl(char *s)
    4.59 +{
    4.60 +    _parse_loglvl(s, &xenlog_lower_thresh, &xenlog_upper_thresh);
    4.61 +}
    4.62 +
    4.63 +static void parse_guest_loglvl(char *s)
    4.64 +{
    4.65 +    _parse_loglvl(s, &xenlog_guest_lower_thresh, &xenlog_guest_upper_thresh);
    4.66 +}
    4.67 +
    4.68 +static char *loglvl_str(int lvl)
    4.69 +{
    4.70 +    switch ( lvl )
    4.71 +    {
    4.72 +    case 0: return "Nothing";
    4.73 +    case 1: return "Errors";
    4.74 +    case 2: return "Errors and warnings";
    4.75 +    case 3: return "Errors, warnings and info";
    4.76 +    case 4: return "All";
    4.77 +    }
    4.78 +    return "???";
    4.79 +}
    4.80 +
    4.81  /*
    4.82   * ********************************************************
    4.83   * *************** ACCESS TO CONSOLE RING *****************
    4.84 @@ -450,6 +513,14 @@ void console_endboot(void)
    4.85  {
    4.86      int i, j;
    4.87  
    4.88 +    printk("Std. Loglevel: %s", loglvl_str(xenlog_lower_thresh));
    4.89 +    if ( xenlog_upper_thresh != xenlog_lower_thresh )
    4.90 +        printk(" (Rate-limited: %s)", loglvl_str(xenlog_upper_thresh));
    4.91 +    printk("\nGuest Loglevel: %s", loglvl_str(xenlog_guest_lower_thresh));
    4.92 +    if ( xenlog_guest_upper_thresh != xenlog_guest_lower_thresh )
    4.93 +        printk(" (Rate-limited: %s)", loglvl_str(xenlog_guest_upper_thresh));
    4.94 +    printk("\n");
    4.95 +
    4.96      if ( opt_sync_console )
    4.97      {
    4.98          printk("**********************************************\n");
     5.1 --- a/xen/include/asm-x86/hvm/domain.h	Thu Nov 02 18:52:04 2006 +0000
     5.2 +++ b/xen/include/asm-x86/hvm/domain.h	Thu Nov 02 22:24:20 2006 +0000
     5.3 @@ -28,8 +28,6 @@
     5.4  #include <asm/hvm/vioapic.h>
     5.5  #include <public/hvm/params.h>
     5.6  
     5.7 -#define HVM_PBUF_SIZE   80
     5.8 -
     5.9  struct hvm_domain {
    5.10      unsigned long          shared_page_va;
    5.11      unsigned long          buffered_io_va;
    5.12 @@ -45,8 +43,10 @@ struct hvm_domain {
    5.13      spinlock_t             round_robin_lock;
    5.14      int                    interrupt_request;
    5.15  
    5.16 -    int                    pbuf_index;
    5.17 -    char                   pbuf[HVM_PBUF_SIZE];
    5.18 +    /* hvm_print_line() logging. */
    5.19 +    char                   pbuf[80];
    5.20 +    int                    pbuf_idx;
    5.21 +    spinlock_t             pbuf_lock;
    5.22  
    5.23      uint64_t               params[HVM_NR_PARAMS];
    5.24  };
     6.1 --- a/xen/include/xen/lib.h	Thu Nov 02 18:52:04 2006 +0000
     6.2 +++ b/xen/include/xen/lib.h	Thu Nov 02 22:24:20 2006 +0000
     6.3 @@ -58,10 +58,6 @@ extern void panic(const char *format, ..
     6.4  extern long vm_assist(struct domain *, unsigned int, unsigned int);
     6.5  extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
     6.6  extern int printk_ratelimit(void);
     6.7 -extern int xenlog_upper_thresh;
     6.8 -extern int xenlog_lower_thresh;
     6.9 -extern int xenlog_guest_upper_thresh;
    6.10 -extern int xenlog_guest_lower_thresh;
    6.11  
    6.12  /* vsprintf.c */
    6.13  extern int sprintf(char * buf, const char * fmt, ...)