All of lore.kernel.org
 help / color / mirror / Atom feed
From: MINAI Katsuhito <minai@jp.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] [1/5] put xen console message into syslog
Date: Fri, 20 Oct 2006 21:47:42 +0900	[thread overview]
Message-ID: <20061020212121.C2E2.MINAI@jp.fujitsu.com> (raw)

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

Hi,

[1/5] add consumer index to the xen console ring

Signed-off-by: Katsuhito Minai <minai@jp.fujitsu.com>

Best Regards,
Katsuhito Minai

[-- Attachment #2: 1.consdev.patch --]
[-- Type: application/octet-stream, Size: 3504 bytes --]

diff -r 6ed4368b4a9e xen/common/sysctl.c
--- a/xen/common/sysctl.c	Sun Oct 15 09:53:20 2006 +0100
+++ b/xen/common/sysctl.c	Wed Oct 11 11:37:27 2006 +0900
@@ -50,7 +50,8 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
         ret = read_console_ring(
             guest_handle_cast(op->u.readconsole.buffer, char),
             &op->u.readconsole.count,
-            op->u.readconsole.clear);
+            op->u.readconsole.clear,
+            &op->u.readconsole.cindex);
         if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
     }
diff -r 6ed4368b4a9e xen/drivers/char/console.c
--- a/xen/drivers/char/console.c	Sun Oct 15 09:53:20 2006 +0100
+++ b/xen/drivers/char/console.c	Wed Oct 11 11:37:27 2006 +0900
@@ -66,13 +66,16 @@ static void putchar_console_ring(int c)
         conringc = conringp - CONRING_SIZE;
 }
 
-long read_console_ring(XEN_GUEST_HANDLE(char) str, u32 *pcount, int clear)
+long read_console_ring(XEN_GUEST_HANDLE(char) str, u32 *pcount, int clear, u32 *pcindex)
 {
     unsigned int idx, len, max, sofar, c;
     unsigned long flags;
 
     max   = *pcount;
     sofar = 0;
+
+    if ( clear < 0 )
+        goto readbyindex;
 
     c = conringc;
     while ( (c != conringp) && (sofar < max) )
@@ -100,6 +103,36 @@ long read_console_ring(XEN_GUEST_HANDLE(
     }
 
     *pcount = sofar;
+    return 0;
+
+readbyindex:
+    c = *pcindex;
+    if ( conringp < c )
+    {
+        *pcindex = conringp - CONRING_SIZE;
+        *pcount = sofar;
+        return 0;
+    }
+
+    if (((conringp - c) > CONRING_SIZE) || (conringp < c))
+        c = conringp - CONRING_SIZE;
+
+    while ( (c != conringp) && (sofar < max) )
+    {
+        idx = CONRING_IDX_MASK(c);
+        len = conringp - c;
+        if ( (idx + len) > CONRING_SIZE )
+            len = CONRING_SIZE - idx;
+        if ( (sofar + len) > max )
+            len = max - sofar;
+        if ( copy_to_guest_offset(str, sofar, &conring[idx], len) )
+            return -EFAULT;
+        sofar += len;
+        c += len;
+    }
+
+    *pcindex = c;
+    *pcount  = sofar;
     return 0;
 }
 
diff -r 6ed4368b4a9e xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h	Sun Oct 15 09:53:20 2006 +0100
+++ b/xen/include/public/sysctl.h	Fri Oct 20 21:35:15 2006 +0900
@@ -24,10 +24,12 @@
 #define XEN_SYSCTL_readconsole       1
 struct xen_sysctl_readconsole {
     /* IN variables. */
-    uint32_t clear;                /* Non-zero -> clear after reading. */
+    int32_t clear;                /* Greater-than-zero -> clear after reading. */
+                                  /* Less-than-zero -> use caller index. */
     XEN_GUEST_HANDLE(char) buffer; /* Buffer start */
     /* IN/OUT variables. */
     uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
+    uint32_t cindex;           /* In: Consumer index; Out: Next index */
 };
 typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
diff -r 6ed4368b4a9e xen/include/xen/console.h
--- a/xen/include/xen/console.h	Sun Oct 15 09:53:20 2006 +0100
+++ b/xen/include/xen/console.h	Wed Oct 11 11:37:27 2006 +0900
@@ -13,7 +13,7 @@
 
 void set_printk_prefix(const char *prefix);
 
-long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int);
+long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int, u32 *);
 
 void init_console(void);
 void console_endboot(void);

[-- 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:[~2006-10-20 12:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20061020212121.C2E2.MINAI@jp.fujitsu.com \
    --to=minai@jp.fujitsu.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.