From: Peter Xu <peterx@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, Laurent Vivier <lvivier@redhat.com>,
Juan Quintela <quintela@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling
Date: Wed, 2 Aug 2017 17:37:27 +0800 [thread overview]
Message-ID: <20170802093727.GA5561@pxdev.xzpeter.org> (raw)
In-Reply-To: <20170802093020.GD4098@redhat.com>
On Wed, Aug 02, 2017 at 10:30:20AM +0100, Daniel P. Berrange wrote:
> On Wed, Aug 02, 2017 at 11:25:21AM +0800, Peter Xu wrote:
> > When accept failed, we should setup errp with the reason. More
> > importantly, the caller may assume errp be non-NULL when error happens,
> > and not setting the errp may crash QEMU.
> >
> > At the same time, move the trace_qio_channel_socket_accept_fail() after
> > the if check on EINTR. Two reasons:
> >
> > 1. when EINTR happened, it's not really a fault (we should just try
> > again), so we should not log with an "accept failure".
> >
> > 2. trace_*() functions may overwrite errno, then the old errno will be
> > missing. We need to either check errno before trace_*() calls, or
> > reserve the errno.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > io/channel-socket.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/io/channel-socket.c b/io/channel-socket.c
> > index 53386b7..442f230 100644
> > --- a/io/channel-socket.c
> > +++ b/io/channel-socket.c
> > @@ -340,10 +340,11 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
> > cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr,
> > &cioc->remoteAddrLen);
> > if (cioc->fd < 0) {
> > - trace_qio_channel_socket_accept_fail(ioc);
> > if (errno == EINTR) {
> > goto retry;
> > }
> > + trace_qio_channel_socket_accept_fail(ioc);
> > + error_setg_errno(errp, errno, "Unable to accept connection");
>
> Err, you're still clobbering errno in trace_qio_channel_socket_accept_fail
> before calling error_setg_errno
Oops! I'll do a quick respin. Thanks for pointing out.
--
Peter Xu
prev parent reply other threads:[~2017-08-02 9:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 3:25 [Qemu-devel] [PATCH 0/2] migration: fixes for 2.10 Peter Xu
2017-08-02 3:25 ` [Qemu-devel] [PATCH 1/2] migration: fix comment disorder in RAMState Peter Xu
2017-08-02 8:23 ` Juan Quintela
2017-08-02 3:25 ` [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling Peter Xu
2017-08-02 8:26 ` Juan Quintela
2017-08-02 9:30 ` Daniel P. Berrange
2017-08-02 9:37 ` Peter Xu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170802093727.GA5561@pxdev.xzpeter.org \
--to=peterx@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).