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-devel

[Xen-devel] [PATCH] libxl: drop bootloader output if xenconsole file des

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing
From: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
Date: Mon, 10 Oct 2011 16:04:17 +0200
Cc: Ian.Jackson@xxxxxxxxxxxxx, Ian.Campbell@xxxxxxxxxx
Delivery-date: Mon, 10 Oct 2011 07:06:48 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:content-type:mime-version:content-transfer-encoding:subject :x-mercurial-node:message-id:user-agent:date:from:to:cc; bh=n8rWac6cx1IYcRCtXVMQOUqp9mfmdOLD5L85PvHdEnY=; b=gkcsLk7qmjvaLZ6ndV6LjWjwr8J4BTFHByLdDBY0FpqylNeKAG7cPPtJMO70HAhXN6 M1SRJlbcWdRngfOYznSPIErYqRMXrhn/s4Lj6oEFZi7dfz7ZC3RduVHR+Ojb2K/izLPU 47UnyFJP7+hgoJGwVO5rp6PAlvNzIX2yDiwV8=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.9.2
# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1318255452 -7200
# Node ID 1ebcb5d27ead38d6713d865704394ca99444f93c
# Parent  a5b8d5c8c98e0dd17368eea1801a8edaf1e79e69
libxl: drop bootloader output if xenconsole file descriptor is not available 
for writing.

Drop output from bootloader if the pty buffer is full and we cannot write more 
data. Prevents the bootloader from getting stuck when using ptys with small 
buffers.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>

diff -r a5b8d5c8c98e -r 1ebcb5d27ead tools/libxl/libxl_bootloader.c
--- a/tools/libxl/libxl_bootloader.c    Mon Oct 10 11:26:22 2011 +0200
+++ b/tools/libxl/libxl_bootloader.c    Mon Oct 10 16:04:12 2011 +0200
@@ -169,6 +169,7 @@ static char * bootloader_interact(libxl_
 
     size_t nr_out = 0, size_out = 0;
     char *output = NULL;
+    struct timeval timeout;
 
     /* input from xenconsole. read on xenconsoled_fd write to bootloader_fd */
     int xenconsoled_prod = 0, xenconsoled_cons = 0;
@@ -177,9 +178,14 @@ static char * bootloader_interact(libxl_
     int bootloader_prod = 0, bootloader_cons = 0;
     char bootloader_buf[BOOTLOADER_BUF_SIZE];
 
+    /* Set timeout to 1s before starting to discard data */
+    timeout.tv_sec = 1;
+    timeout.tv_usec = 0;
+
     while(1) {
         fd_set wsel, rsel;
         int nfds;
+        int space;
 
         if (xenconsoled_prod == xenconsoled_cons)
             xenconsoled_prod = xenconsoled_cons = 0;
@@ -208,9 +214,14 @@ static char * bootloader_interact(libxl_
             nfds = bootloader_fd + 1 > nfds ? bootloader_fd + 1 : nfds;
         }
 
-        ret = select(nfds, &rsel, &wsel, NULL, NULL);
+        ret = select(nfds, &rsel, &wsel, NULL, &timeout);
         if (ret < 0)
             goto out_err;
+        if (ret == 0) {
+            /* Timeout reached, force clear buffers */
+            xenconsoled_prod = xenconsoled_cons;
+            bootloader_prod = bootloader_cons;
+        }
 
         /* Input from xenconsole, read xenconsoled_fd, write bootloader_fd */
         if (FD_ISSET(xenconsoled_fd, &rsel)) {

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