Handle guest halting. Print nice message.
authorRonald G. Minnich <rminnich@gmail.com>
Fri, 21 Aug 2015 20:17:36 +0000 (13:17 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Nov 2015 23:24:25 +0000 (18:24 -0500)
I wanted to print a dead penguin but I'm not good enough.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tests/vmm/vmrunkernel.c

index efaa099..2bbd283 100644 (file)
@@ -115,7 +115,7 @@ void *consin(void *arg)
        
        if (debug) printf("Spin on console being read, print num queues, halt\n");
 
-       for(num = 0;;num++) {
+       for(num = 0;! quit;num++) {
                int debug = 1;
                /* host: use any buffers we should have been sent. */
                head = wait_for_vq_desc(v, iov, &outlen, &inlen);
@@ -133,6 +133,11 @@ void *consin(void *arg)
                                exit(0);
                        } 
                        if (debug) printf("GOT A LINE:%s:\n", consline);
+                       if (strlen(consline) < 3 && consline[0] == 'q' ) {
+                               quit = 1;
+                               break;
+                       }
+
                        memmove(iov[i].v, consline, strlen(consline)+ 1);
                        iov[i].length = strlen(consline) + 1;
                }
@@ -337,9 +342,13 @@ int main(int argc, char **argv)
                        case EXIT_REASON_EXTERNAL_INTERRUPT:
                                fprintf(stderr, "XINT\n");
                                // Just inject a GPF for now. See what shakes.
-                               vmctl.interrupt = 0;//x8000080d;
+                               vmctl.interrupt = 0;//x8000030e; // b0d;
                                vmctl.command = RESUME;
                                break;
+                       case EXIT_REASON_HLT:
+                               printf("\n================== Guest halted. RIP. =======================\n");
+                               quit = 1;
+                               break;
                        default:
                                fprintf(stderr, "Don't know how to handle exit %d\n", vmctl.ret_code);
                                quit = 1;