From: Ian Jackson Subject: Re: [PATCH v2 qemu-traditional] qemu: Fix race condition when opening ports Date: Tue, 10 Dec 2013 15:28:55 +0000 Message-ID: <21159.13111.497836.79784@mariner.uk.xensource.com> References: <52A5C2E6.3080005@eu.citrix.com> <1386595643-8639-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1386595643-8639-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Stefano Stabellini , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org Andrew Cooper writes ("[PATCH v2 qemu-traditional] qemu: Fix race condition when opening ports"): > Two Qemus can race to bind the same VNC port. It is valid for multiple > bind()s on the same socket to succeed, but only the first listen() will > succeed. I don't think this is correct. The SuS page for listen(2) http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html doesn't list EADDRINUSE as a possible error condition. Although wheezy's listen(2) manpage does. > In the case that two Qemus are starting at the same time, and both trying to > grab the next free VNC port, the second one will fail with an EADDRINUSE, and > bail with a fatal error which renders the domain functionally useless. > > In the case that listen() fails with EADDRINUSE, rebind the socket again and > try for the next port. My preliminary view is that this is a kernel bug. Ian.