[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 03/29] io: fix qio_channel_socket_accept err handl
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [RFC 03/29] io: fix qio_channel_socket_accept err handling |
Date: |
Mon, 31 Jul 2017 17:53:39 +0100 |
User-agent: |
Mutt/1.8.3 (2017-05-23) |
* Peter Xu (address@hidden) 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.
>
> Signed-off-by: Peter Xu <address@hidden>
> ---
> io/channel-socket.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/io/channel-socket.c b/io/channel-socket.c
> index 53386b7..7bc308e 100644
> --- a/io/channel-socket.c
> +++ b/io/channel-socket.c
> @@ -344,6 +344,7 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
> if (errno == EINTR) {
> goto retry;
> }
> + error_setg_errno(errp, errno, "Unable to accept connection");
> goto error;
OK, but this code actually has a bigger problem as well:
the original is:
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;
}
goto error;
}
Stefan confirmed that trace_ doesn't preserve errno; so the if
following it is wrong. It needs to preserve errno.
(Again this patch can go on it's own)
Dave
> }
>
> --
> 2.7.4
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- [Qemu-devel] [RFC 00/29] Migration: postcopy failure recovery, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 02/29] migration: fix comment disorder in RAMState, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 03/29] io: fix qio_channel_socket_accept err handling, Peter Xu, 2017/07/28
- Re: [Qemu-devel] [RFC 03/29] io: fix qio_channel_socket_accept err handling,
Dr. David Alan Gilbert <=
- [Qemu-devel] [RFC 04/29] bitmap: introduce bitmap_invert(), Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 05/29] bitmap: introduce bitmap_count_one(), Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 06/29] migration: dump str in migrate_set_state trace, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 08/29] migration: reuse mis->userfault_quit_fd, Peter Xu, 2017/07/28