From: "Daniel P. Berrange" <berrange@redhat.com>
To: Knut Omang <knut.omang@oracle.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v6 4/4] sockets: Handle race condition between binds to the same port
Date: Mon, 7 Aug 2017 09:40:08 +0100 [thread overview]
Message-ID: <20170807084008.GE18259@redhat.com> (raw)
In-Reply-To: <76cb37b3decd6d6c1c9bac72e21a06fabf7579be.1501362828.git-series.knut.omang@oracle.com>
On Sat, Jul 29, 2017 at 11:18:18PM +0200, Knut Omang wrote:
> If an offset of ports is specified to the inet_listen_saddr function(),
> and two or more processes tries to bind from these ports at the same time,
> occasionally more than one process may be able to bind to the same
> port. The condition is detected by listen() but too late to avoid a failure.
>
> This function is called by socket_listen() and used
> by all socket listening code in QEMU, so all cases where any form of dynamic
> port selection is used should be subject to this issue.
>
> Add code to close and re-establish the socket when this
> condition is observed, hiding the race condition from the user.
>
> Also clean up some issues with error handling to allow more
> accurate reporting of the cause of an error.
>
> This has been developed and tested by means of the
> test-listen unit test in the previous commit.
> Enable the test for make check now that it passes.
>
> Reviewed-by: Bhavesh Davda <bhavesh.davda@oracle.com>
> Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
> Reviewed-by: Girish Moodalbail <girish.moodalbail@oracle.com>
> Signed-off-by: Knut Omang <knut.omang@oracle.com>
> ---
> tests/Makefile.include | 2 +-
> util/qemu-sockets.c | 58 ++++++++++++++++++++++++++++++-------------
> 2 files changed, 42 insertions(+), 18 deletions(-)
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
prev parent reply other threads:[~2017-08-07 8:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-29 21:18 [Qemu-devel] [PATCH v6 0/4] Unit test+fix for problem with QEMU handling of multiple bind()s to the same port Knut Omang
2017-07-29 21:18 ` [Qemu-devel] [PATCH v6 1/4] tests: Add test-listen - a stress test for QEMU socket listen Knut Omang
2017-08-07 8:45 ` Daniel P. Berrange
2017-08-07 9:21 ` Knut Omang
2017-08-07 10:27 ` Daniel P. Berrange
2017-08-07 10:30 ` Knut Omang
2017-07-29 21:18 ` [Qemu-devel] [PATCH v6 2/4] sockets: factor out a new try_bind() function Knut Omang
2017-07-29 21:18 ` [Qemu-devel] [PATCH v6 3/4] sockets: factor out create_fast_reuse_socket Knut Omang
2017-08-07 8:38 ` Daniel P. Berrange
2017-07-29 21:18 ` [Qemu-devel] [PATCH v6 4/4] sockets: Handle race condition between binds to the same port Knut Omang
2017-08-07 8:40 ` Daniel P. Berrange [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=20170807084008.GE18259@redhat.com \
--to=berrange@redhat.com \
--cc=knut.omang@oracle.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).