Skip to contentSkip to conversation

serial stdio char drop fix

PATCH New Magnus Damm 1 participant 1 message Dec 17, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial stdio char drop fix

Hello,

This little patch makes the serial port connected to stdio work correctly. Without the patch chars sent from the host to the guest are silently dropped if the uart is full. And that happens now and then. Now with the patch it is possible to correctly paste many lines of sh-scripts to the serial console on a Linux guest!

/ magnus

Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.110

vl.c +9 -6
diff -u -r1.110 vl.c
@@ -1173,18 +1173,21 @@
             chr = stdio_clients[client_index];
             s = chr->opaque;
             buf[0] = ch;
-            /* XXX: should queue the char if the device is not
-               ready */
-            if (s->fd_can_read(s->fd_opaque) > 0) 
-                s->fd_read(s->fd_opaque, buf, 1);
+
+            s->fd_read(s->fd_opaque, buf, 1);
         }
     }
 }
 
 static int stdio_can_read(void *opaque)
 {
-    /* XXX: not strictly correct */
-    return 1;
+    CharDriverState *chr;
+    FDCharDriver *s;
+
+    chr = stdio_clients[client_index];
+    s = chr->opaque;
+
+    return s->fd_can_read(s->fd_opaque) > 0;
 }
 
 static void stdio_read(void *opaque, const uint8_t *buf, int size)