virtio: console: Return -EPIPE to hvc_console if we lost the connection
authorAmit Shah <amit.shah@redhat.com>
Thu, 20 May 2010 04:15:47 +0000 (22:15 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 19 May 2010 12:45:47 +0000 (22:15 +0930)
hvc_console handles -EPIPE properly when the connection to the host is
lost.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/char/virtio_console.c

index f63bf77a48252de15bcc57c05485559b54f71efb..11a9573f901e06b66a7214db2b9b2cce9f88ad04 100644 (file)
@@ -653,7 +653,7 @@ static int put_chars(u32 vtermno, const char *buf, int count)
 
        port = find_port_by_vtermno(vtermno);
        if (!port)
-               return 0;
+               return -EPIPE;
 
        return send_buf(port, (void *)buf, count);
 }
@@ -669,9 +669,13 @@ static int get_chars(u32 vtermno, char *buf, int count)
 {
        struct port *port;
 
+       /* If we've not set up the port yet, we have no input to give. */
+       if (unlikely(early_put_chars))
+               return 0;
+
        port = find_port_by_vtermno(vtermno);
        if (!port)
-               return 0;
+               return -EPIPE;
 
        /* If we don't have an input queue yet, we can't get input. */
        BUG_ON(!port->in_vq);