From: Anthony Liguori Date: Wed, 5 Sep 2012 18:52:49 +0000 (-0500) Subject: socket: don't attempt to reconnect a TCP socket in server mode X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=455aa1e08;p=qemu.git socket: don't attempt to reconnect a TCP socket in server mode Commit c3767ed0eb5d0bb25fe409ae5dec06e3411ff1b6 introduced a possible SEGV when using a socket chardev with server=on because it assumes that all TCP sockets are in client mode. This patch adds a check to only reconnect when in client mode. Cc: Lei Li Reported-by: Michael Roth Signed-off-by: Anthony Liguori --- diff --git a/qemu-char.c b/qemu-char.c index 398baf1e04..767da93862 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2148,10 +2148,12 @@ static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len) TCPCharDriver *s = chr->opaque; if (s->connected) { return send_all(s->fd, buf, len); - } else { + } else if (s->listen_fd == -1) { /* (Re-)connect for unconnected writing */ tcp_chr_connect(chr); return 0; + } else { + return len; } }