Received: from eggs.gnu.org ([2001:4830:134:3::10]:45675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeRHn-0000oC-99 for qemu-devel@nongnu.org; Fri, 11 Mar 2016 12:55:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aeRHj-0003OM-0Q for qemu-devel@nongnu.org; Fri, 11 Mar 2016 12:55:39 -0500 Received: from mail-qk0-x234.google.com ([2607:f8b0:400d:c09::234]:33762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeRHi-0003Nz-OD for qemu-devel@nongnu.org; Fri, 11 Mar 2016 12:55:34 -0500 Received: by mail-qk0-x234.google.com with SMTP id s5so50808091qkd.0 for ; Fri, 11 Mar 2016 09:55:34 -0800 (PST) Sender: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= From: marcandre.lureau@redhat.com Date: Fri, 11 Mar 2016 18:55:24 +0100 Message-Id: <1457718924-19338-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH] char: translate from QIOChannel error to errno List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , danpb@redhat.com From: Marc-André Lureau Caller of CharDriverState.chr* callback assume errno error conventions. Translate QIOChannel error to errno (this fixes potential EAGAIN regression, for ex if a vhost-user backend block, qemu_chr_fe_read_all() could get error -2 and not wait) Signed-off-by: Marc-André Lureau --- qemu-char.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu-char.c b/qemu-char.c index ad11b75..4317388 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2727,6 +2727,13 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) NULL); } + if (ret == QIO_CHANNEL_ERR_BLOCK) { + errno = EAGAIN; + ret = -1; + } else if (ret == -1) { + errno = EIO; + } + if (msgfds_num) { /* close and clean read_msgfds */ for (i = 0; i < s->read_msgfds_num; i++) { -- 2.5.0