Modified vmrunkernel consin to use read instead of fgets.
authorGanShun <ganshun@gmail.com>
Tue, 29 Sep 2015 22:20:20 +0000 (15:20 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 3 Nov 2015 15:53:13 +0000 (10:53 -0500)
Fixed a bug where only one character would be sent into the guest at a time by swapping fgets for read

Signed-off-by: GanShun <ganshun@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tests/vmm/vmrunkernel.c

index 2412f1f..102cf77 100644 (file)
@@ -242,6 +242,7 @@ void *consin(void *arg)
        uint32_t vv;
        int i;
        int num;
+       //char c[1];
 
        int fd = open("#cons/vmctl", O_RDWR), ret;
        
@@ -261,7 +262,7 @@ void *consin(void *arg)
                for (i = outlen; i < outlen + inlen; i++) {
                        /* host: read a line. */
                        memset(consline, 0, 128);
-                       if (fgets(consline, 4096-256, stdin) == NULL) {
+                       if (read(0, consline, 1) < 0) {
                                exit(0);
                        } 
                        if (debug) fprintf(stderr, "CONSIN: GOT A LINE:%s:\n", consline);