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

[Xen-devel] [PATCH] generate notification of new console ring data



This patch provides notification of console updates via VIRQ.
The readconsolering capabilities provide the opportunity to
provide console output to other clients (remote systems,
logging systems, etc). This patchs adds the ability to generate
a notification of a change in the console buffer.

I have available both client and server programs that will take
either serial line (from qemu) or consolering data and remote
them to another system via UDP.  I can easily post these as
examples, if there's any interest.  We use these programs
fairly heavily to send serial line and/or dom 0 console output
to other systems for debugging and/or logging.

-b

--
------------------------------------------------------------------------
Ben Thomas                                         Virtual Iron Software
bthomas@xxxxxxxxxxxxxxx                            Tower 1, Floor 2
978-849-1214                                       900 Chelmsford Street
                                                   Lowell, MA 01851
Allow notification of console updates via VIRQ.

The readconsolering capabilities provide the opportunity to
provide console output to other clients (remote systems,
logging systems, etc). This patchs adds the ability to generate
a notification of a change in the console buffer.

Signed-off-by: Ben Thomas (ben@xxxxxxxxxxxxxxx)

diff -r 80ccadd3cd47 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Fri Mar 02 07:48:55 2007 -0500
+++ b/tools/libxc/xc_misc.c     Fri Mar 02 14:08:58 2007 -0500
@@ -31,6 +31,20 @@ int xc_readconsolering(int xc_handle,
     unlock_pages(buffer, nr_chars);
 
     return ret;
+}
+
+int xc_set_conring_notify(int xc_handle, int enable)
+{
+    int ret;
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_conring_notify;
+    sysctl.u.conring_notify.enable = enable;
+
+    if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 )
+        return ret;
+
+    return 0;
 }
 
 int xc_physinfo(int xc_handle,
diff -r 80ccadd3cd47 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Mar 02 07:48:55 2007 -0500
+++ b/tools/libxc/xenctrl.h     Fri Mar 02 07:58:38 2007 -0500
@@ -465,6 +465,7 @@ int xc_readconsolering(int xc_handle,
                        unsigned int *pnr_chars,
                        int clear);
 
+int xc_set_conring_notify(int xc_handle, int enable);
 typedef xen_sysctl_physinfo_t xc_physinfo_t;
 int xc_physinfo(int xc_handle,
                 xc_physinfo_t *info);
diff -r 80ccadd3cd47 xen/common/sysctl.c
--- a/xen/common/sysctl.c       Fri Mar 02 07:48:55 2007 -0500
+++ b/xen/common/sysctl.c       Fri Mar 02 14:16:15 2007 -0500
@@ -128,6 +128,13 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
     break;
 #endif
 
+    case XEN_SYSCTL_conring_notify:
+    {
+        ret = set_conring_notify(op->u.conring_notify.enable);
+    }
+
+    break;
+
     default:
         ret = arch_do_sysctl(op, u_sysctl);
         break;
diff -r 80ccadd3cd47 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Fri Mar 02 07:48:55 2007 -0500
+++ b/xen/drivers/char/console.c        Fri Mar 02 14:02:26 2007 -0500
@@ -52,6 +52,7 @@ boolean_param("sync_console", opt_sync_c
 #define CONRING_IDX_MASK(i) ((i)&(CONRING_SIZE-1))
 static char conring[CONRING_SIZE];
 static unsigned int conringc, conringp;
+static int conring_notify = 0;
 
 static char printk_prefix[16] = "";
 
@@ -173,6 +174,12 @@ static void putchar_console_ring(int c)
         conringc = conringp - CONRING_SIZE;
 }
 
+int set_conring_notify(int enable)
+{
+    conring_notify = enable;
+    return 0;
+}
+
 long read_console_ring(XEN_GUEST_HANDLE(char) str, u32 *pcount, int clear)
 {
     unsigned int idx, len, max, sofar, c;
@@ -328,8 +335,13 @@ static long guest_console_write(XEN_GUES
 
         sercon_puts(kbuf);
 
-        for ( kptr = kbuf; *kptr != '\0'; kptr++ )
+        for ( kptr = kbuf; *kptr != '\0'; kptr++ ) {
             vga_putchar(*kptr);
+            putchar_console_ring(*kptr);
+        }
+
+        if (conring_notify)
+            send_guest_global_virq(dom0, VIRQ_CON_RING);
 
         guest_handle_add_offset(buffer, kcount);
         count -= kcount;
@@ -399,6 +411,10 @@ static void __putstr(const char *str)
         vga_putchar(c);
         putchar_console_ring(c);
     }
+
+    if (conring_notify)
+        send_guest_global_virq(dom0, VIRQ_CON_RING);
+
 }
 
 static int printk_prefix_check(char *p, char **pp)
diff -r 80ccadd3cd47 xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h       Fri Mar 02 07:48:55 2007 -0500
+++ b/xen/include/public/sysctl.h       Fri Mar 02 09:17:37 2007 -0500
@@ -140,6 +140,14 @@ typedef struct xen_sysctl_getdomaininfol
 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
 
+#define XEN_SYSCTL_conring_notify 7
+struct xen_sysctl_conring_notify {
+    /* IN variables. */
+    uint32_t              enable;
+};
+typedef struct xen_sysctl_conring_notify xen_sysctl_conring_notify_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_conring_notify_t);
+
 struct xen_sysctl {
     uint32_t cmd;
     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
@@ -150,6 +158,7 @@ struct xen_sysctl {
         struct xen_sysctl_sched_id          sched_id;
         struct xen_sysctl_perfc_op          perfc_op;
         struct xen_sysctl_getdomaininfolist getdomaininfolist;
+        struct xen_sysctl_conring_notify    conring_notify;
         uint8_t                             pad[128];
     } u;
 };
diff -r 80ccadd3cd47 xen/include/public/xen.h
--- a/xen/include/public/xen.h  Fri Mar 02 07:48:55 2007 -0500
+++ b/xen/include/public/xen.h  Fri Mar 02 07:48:58 2007 -0500
@@ -131,6 +131,7 @@
 #define VIRQ_TBUF       4  /* G. (DOM0) Trace buffer has records available.  */
 #define VIRQ_DEBUGGER   6  /* G. (DOM0) A domain has paused for debugging.   */
 #define VIRQ_XENOPROF   7  /* V. XenOprofile interrupt: new sample available */
+#define VIRQ_CON_RING   8  /* G. (DOM0) Bytes received on console            */
 
 /* Architecture-specific VIRQ definitions. */
 #define VIRQ_ARCH_0    16
diff -r 80ccadd3cd47 xen/include/xen/console.h
--- a/xen/include/xen/console.h Fri Mar 02 07:48:55 2007 -0500
+++ b/xen/include/xen/console.h Fri Mar 02 07:48:58 2007 -0500
@@ -14,6 +14,7 @@ void set_printk_prefix(const char *prefi
 void set_printk_prefix(const char *prefix);
 
 long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int);
+int set_conring_notify(int enable);
 
 void init_console(void);
 void console_endboot(void);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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