* [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing
@ 2011-10-10 14:04 Roger Pau Monne
2011-10-10 14:06 ` Roger Pau Monne
2011-10-10 14:11 ` Andrew Cooper
0 siblings, 2 replies; 4+ messages in thread
From: Roger Pau Monne @ 2011-10-10 14:04 UTC (permalink / raw)
To: xen-devel; +Cc: Ian.Jackson, Ian.Campbell
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# 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@entel.upc.edu>
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)) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing
2011-10-10 14:04 [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing Roger Pau Monne
@ 2011-10-10 14:06 ` Roger Pau Monne
2011-10-10 14:11 ` Andrew Cooper
1 sibling, 0 replies; 4+ messages in thread
From: Roger Pau Monne @ 2011-10-10 14:06 UTC (permalink / raw)
To: xen-devel; +Cc: Ian.Jackson, Ian.Campbell
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1318255572 -7200
# Node ID 0012a80df7a0fe07497d58423ba651b302d84745
# 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@entel.upc.edu>
diff -r a5b8d5c8c98e -r 0012a80df7a0 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:06: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,6 +178,10 @@ 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;
@@ -208,9 +213,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)) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing
2011-10-10 14:04 [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing Roger Pau Monne
2011-10-10 14:06 ` Roger Pau Monne
@ 2011-10-10 14:11 ` Andrew Cooper
2011-10-10 14:17 ` Roger Pau Monné
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2011-10-10 14:11 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: Ian, xen-devel@lists.xensource.com, Jackson, Ian Campbell
On 10/10/11 15:04, Roger Pau Monne wrote:
> # HG changeset patch
> # User Roger Pau Monne <roger.pau@entel.upc.edu>
> # 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@entel.upc.edu>
>
> 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;
You appear to introduce an unreferenced variable here.
>
> 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@lists.xensource.com
> http://lists.xensource.com/xen-devel
--
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing
2011-10-10 14:11 ` Andrew Cooper
@ 2011-10-10 14:17 ` Roger Pau Monné
0 siblings, 0 replies; 4+ messages in thread
From: Roger Pau Monné @ 2011-10-10 14:17 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Ian, xen-devel@lists.xensource.com, Jackson, Ian Campbell
2011/10/10 Andrew Cooper <andrew.cooper3@citrix.com>:
>
>
> On 10/10/11 15:04, Roger Pau Monne wrote:
>> # HG changeset patch
>> # User Roger Pau Monne <roger.pau@entel.upc.edu>
>> # 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@entel.upc.edu>
>>
>> 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;
>
> You appear to introduce an unreferenced variable here.
Yes I've missed that one, sorry, second patch is ok.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-10 14:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-10 14:04 [PATCH] libxl: drop bootloader output if xenconsole file descriptor is not available for writing Roger Pau Monne
2011-10-10 14:06 ` Roger Pau Monne
2011-10-10 14:11 ` Andrew Cooper
2011-10-10 14:17 ` Roger Pau Monné
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.