vhost-user: disconnect on HUP
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 26 Jul 2016 21:14:57 +0000 (01:14 +0400)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 28 Jul 2016 21:33:46 +0000 (00:33 +0300)
In some cases, qemu_chr_fe_read_all() on HUP event doesn't raise
CHR_EVENT_CLOSED because the read/recv function returns -1 on
disconnected peers (for example with tch_chr_recv, an ECONNRESET errno
overwritten as EIO).

It is simpler to explicitely disconnect on HUP, rising CHR_EVENT_CLOSED
if it wasn't disconnected already.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
net/vhost-user.c

index 2af212bddb6c4e662d6788500cff76066d222644..2cac32e3b74e8dd0948aad869e18a5bdaf25c1f7 100644 (file)
@@ -188,12 +188,8 @@ static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
                                            void *opaque)
 {
     VhostUserState *s = opaque;
-    uint8_t buf[1];
 
-    /* We don't actually want to read anything, but CHR_EVENT_CLOSED will be
-     * raised as a side-effect of the read.
-     */
-    qemu_chr_fe_read_all(s->chr, buf, sizeof(buf));
+    qemu_chr_disconnect(s->chr);
 
     return FALSE;
 }