All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] unnecessary removal of guest console characters
Date: Fri, 11 Apr 2008 14:46:58 +0100	[thread overview]
Message-ID: <47FF6BD2.2040207@eu.citrix.com> (raw)

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

Hi all,
currently when max_capacity is set in xenconsoled and the buffer if 
completely filled then some characters in the buffer are discarded (even 
though the rate limitation makes this unlikely to happen).
A better way to handle this scenario would be to stop reading from the 
ring until the buffer has some free space.
I am attaching a simple patch that does exactly this.
Best Regards,

Stefano Stabellini

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

[-- Attachment #2: xenconsoled.patch --]
[-- Type: text/x-diff, Size: 1776 bytes --]

diff -r 082d3886fded tools/console/daemon/io.c
--- a/tools/console/daemon/io.c	Fri Apr 11 09:14:03 2008 +0100
+++ b/tools/console/daemon/io.c	Fri Apr 11 14:12:51 2008 +0100
@@ -200,21 +200,6 @@ static void buffer_append(struct domain 
 			      "on domain %d: %d (%s)\n",
 			      dom->domid, errno, strerror(errno));
 	}
-
-	if (buffer->max_capacity &&
-	    buffer->size > buffer->max_capacity) {
-		/* Discard the middle of the data. */
-
-		size_t over = buffer->size - buffer->max_capacity;
-		char *maxpos = buffer->data + buffer->max_capacity;
-
-		memmove(maxpos - over, maxpos, over);
-		buffer->data = realloc(buffer->data, buffer->max_capacity);
-		buffer->size = buffer->capacity = buffer->max_capacity;
-
-		if (buffer->consumed > buffer->max_capacity - over)
-			buffer->consumed = buffer->max_capacity - over;
-	}
 }
 
 static bool buffer_empty(struct buffer *buffer)
@@ -228,6 +213,11 @@ static void buffer_advance(struct buffer
 	if (buffer->consumed == buffer->size) {
 		buffer->consumed = 0;
 		buffer->size = 0;
+		if (buffer->max_capacity &&
+		    buffer->capacity > buffer->max_capacity) {
+			buffer->data = realloc(buffer->data, buffer->max_capacity);
+			buffer->capacity = buffer->max_capacity;
+		}
 	}
 }
 
@@ -1005,9 +995,12 @@ void handle_io(void)
 				    d->next_period < next_timeout)
 					next_timeout = d->next_period;
 			} else if (d->xce_handle != -1) {
-				int evtchn_fd = xc_evtchn_fd(d->xce_handle);
-				FD_SET(evtchn_fd, &readfds);
-				max_fd = MAX(evtchn_fd, max_fd);
+				if (!d->buffer.max_capacity ||
+				    d->buffer.size < d->buffer.max_capacity) {
+					int evtchn_fd = xc_evtchn_fd(d->xce_handle);
+					FD_SET(evtchn_fd, &readfds);
+					max_fd = MAX(evtchn_fd, max_fd);
+				}
 			}
 
 			if (d->master_fd != -1) {

[-- 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:[~2008-04-11 13:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-11 13:46 Stefano Stabellini [this message]
2008-04-11 15:03 ` [PATCH] unnecessary removal of guest console characters Keir Fraser
2008-04-11 15:11   ` Samuel Thibault
2008-04-11 15:46     ` Keir Fraser
     [not found] <C429295A.1F98C%keir.fraser@eu.citrix.com>
2008-04-21 16:28 ` Stefano Stabellini

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=47FF6BD2.2040207@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.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.