From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agt82-0004K2-33 for qemu-devel@nongnu.org; Fri, 18 Mar 2016 08:03:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agt7w-0000Iq-7A for qemu-devel@nongnu.org; Fri, 18 Mar 2016 08:03:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agt7w-0000II-1h for qemu-devel@nongnu.org; Fri, 18 Mar 2016 08:03:36 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id AC4E7804FC for ; Fri, 18 Mar 2016 12:03:33 +0000 (UTC) Date: Fri, 18 Mar 2016 12:03:30 +0000 From: "Daniel P. Berrange" Message-ID: <20160318120321.GE17895@redhat.com> References: <1457718924-19338-1-git-send-email-marcandre.lureau@redhat.com> <56EBECB6.7020901@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56EBECB6.7020901@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] char: translate from QIOChannel error to errno Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org On Fri, Mar 18, 2016 at 12:55:34PM +0100, Paolo Bonzini wrote: >=20 >=20 > On 11/03/2016 18:55, marcandre.lureau@redhat.com wrote: > > From: Marc-Andr=C3=A9 Lureau > >=20 > > Caller of CharDriverState.chr* callback assume errno error convention= s. > > Translate QIOChannel error to errno (this fixes potential EAGAIN > > regression, for ex if a vhost-user backend block, qemu_chr_fe_read_al= l() > > could get error -2 and not wait) > >=20 > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > --- > > qemu-char.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > >=20 > > 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 *c= hr, char *buf, size_t len) > > NULL); > > } > > =20 > > + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { > > + errno =3D EAGAIN; > > + ret =3D -1; > > + } else if (ret =3D=3D -1) { > > + errno =3D EIO; > > + } > > + > > if (msgfds_num) { > > /* close and clean read_msgfds */ > > for (i =3D 0; i < s->read_msgfds_num; i++) { > >=20 >=20 > I can take this patch as it fixes a real regression, but could > QIOChannel just return negative errno? No, QIOChannel explicitly does not ever use errno's because that only works if all the functions QIOChannel uses internally set errnos. This is not the case for the TLS impl of QIOChannel. For this reason, the QIOChannel APIs all use 'Error **errp' for error reporting. Ultimately as callers of the QIOChannel code in QEMU are converted to propagate 'Error **errp' we'll be ok, but in the immediate some callers like chardev still have a built-in assumption that they'll have errno's available, so we have to do this compat hack. Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|