From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9ZzO-0007zv-TY for qemu-devel@nongnu.org; Wed, 05 May 2010 04:29:55 -0400 Received: from [140.186.70.92] (port=39696 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9ZzL-0007uL-6I for qemu-devel@nongnu.org; Wed, 05 May 2010 04:29:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9ZzJ-0003Tx-47 for qemu-devel@nongnu.org; Wed, 05 May 2010 04:29:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25107) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9ZzI-0003Tq-T4 for qemu-devel@nongnu.org; Wed, 05 May 2010 04:29:49 -0400 Date: Wed, 5 May 2010 09:29:45 +0100 From: "Daniel P. Berrange" Subject: Re: [Qemu-devel] Patch to improve handling of server sockets Message-ID: <20100505082945.GB8862@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Reply-To: "Daniel P. Berrange" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Reinhard Max Cc: qemu-devel@nongnu.org On Tue, May 04, 2010 at 03:49:50PM +0200, Reinhard Max wrote: > Hi, > > I am maintaining the tightvnc package for openSUSE and was recently > confronted with an alleged vnc problem with QWMU that turned out to be > a shortcoming in QEMU's code for handling TCP server sockets, which is > used by the vnc and char modules. > > The problem occurs when the address to listen on is given as a name > which resolves to multiple IP addresses the most prominent example > being "localhost" resolving to 127.0.0.1 and ::1 . > > The existing code stopped walking the list of addresses returned by > getaddrinfo() as soon as one socket was successfully opened and bound. > The result was that a qemu instance started with "-vnc localhost:42" > only listened on ::1, wasn't reachable through 127.0.0.1. The fact > that the code set the IPV6_V6ONLY socket option didn't help, because > that option only works when the socket gets bound to the IPv6 wildcard > address (::), but is useless for explicit address bindings. This seems to be something we overlooked in the initial impl. I don't see any alternative but to make QEMU listen on multiple sockets in the scenario you describe. An even clear example is to consider binding QEMU to a machine with multiple non-localhost addresses, eg myserver.com resolving to 192.168.122.41 + 2a00:123:456::1 because there's no way that the kernel can know/decide to automatically listen on 192.168.122.41, when given the address 2a00:123:456::1 and if the machine has many NICs, you can't assume the wildcard address is suitable either. > The attached patch against QEMU 0.11.0 extends inet_listen() to create > sockets for as many addresses from the address list as possible and > adapts its callers and their data structures to deal with a linked > list of socket FDs rather than a single file descriptor. The approach looks reasonable, though the patch is somewhat mangled by the mix of tabs + spaces Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|