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] Fix xenconsoled when sending lots of console data to a d

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix xenconsoled when sending lots of console data to a domU.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 30 Mar 2006 11:42:08 +0000
Delivery-date: Thu, 30 Mar 2006 11:43:59 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxx
# Node ID 7c994d80049c1a3003623b56c9667ca37fdd8b04
# Parent  9239f190736d85933bbe64eca0613c24c07617df
Fix xenconsoled when sending lots of console data to a domU.
Fixes bug #477.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 9239f190736d -r 7c994d80049c tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Wed Mar 29 23:11:53 2006
+++ b/tools/console/daemon/io.c Thu Mar 30 10:38:56 2006
@@ -434,25 +434,36 @@
        }
 }
 
+static int ring_free_bytes(struct domain *dom)
+{
+       struct xencons_interface *intf = dom->interface;
+       XENCONS_RING_IDX cons, prod, space;
+
+       cons = intf->in_cons;
+       prod = intf->in_prod;
+       mb();
+
+       space = prod - cons;
+       if (space > sizeof(intf->in))
+               return 0; /* ring is screwed: ignore it */
+
+       return (sizeof(intf->in) - space);
+}
+
 static void handle_tty_read(struct domain *dom)
 {
        ssize_t len = 0;
        char msg[80];
        int i;
        struct xencons_interface *intf = dom->interface;
-       XENCONS_RING_IDX cons, prod;
-
-       cons = intf->in_cons;
-       prod = intf->in_prod;
-       mb();
-
-       if (sizeof(intf->in) > (prod - cons))
-               len = sizeof(intf->in) - (prod - cons);
+       XENCONS_RING_IDX prod;
+
+       len = ring_free_bytes(dom);
+       if (len == 0)
+               return;
+
        if (len > sizeof(msg))
                len = sizeof(msg);
-
-       if (len == 0)
-               return;
 
        len = read(dom->tty_fd, msg, len);
        if (len < 1) {
@@ -465,6 +476,7 @@
                        shutdown_domain(dom);
                }
        } else if (domain_is_valid(dom->domid)) {
+               prod = intf->in_prod;
                for (i = 0; i < len; i++) {
                        intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
                                msg[i];
@@ -514,7 +526,7 @@
        (void)write_sync(dom->evtchn_fd, &v, sizeof(v));
 }
 
-static void handle_xs(int fd)
+static void handle_xs(void)
 {
        char **vec;
        int domid;
@@ -560,7 +572,7 @@
                        }
 
                        if (d->tty_fd != -1) {
-                               if (!d->is_dead)
+                               if (!d->is_dead && ring_free_bytes(d))
                                        FD_SET(d->tty_fd, &readfds);
 
                                if (!buffer_empty(&d->buffer))
@@ -572,7 +584,7 @@
                ret = select(max_fd + 1, &readfds, &writefds, 0, NULL);
 
                if (FD_ISSET(xs_fileno(xs), &readfds))
-                       handle_xs(xs_fileno(xs));
+                       handle_xs();
 
                for (d = dom_head; d; d = n) {
                        n = d->next;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Fix xenconsoled when sending lots of console data to a domU., Xen patchbot -unstable <=