From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btyix-0001jv-EE for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:12:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btyis-0001EQ-Tp for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:12:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btyis-0001EG-Jz for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:12:06 -0400 Date: Tue, 11 Oct 2016 16:12:02 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20161011151201.GC16796@work-vm> References: <20161011102637.GA28347@zurbaran.home> <20161011131107.GF14917@redhat.com> <20161011140834.GA16796@work-vm> <20161011141704.GI14917@redhat.com> <20161011142654.GJ14917@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161011142654.GJ14917@redhat.com> Subject: Re: [Qemu-devel] Multiple QMP socket clients List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Samuel Ortiz , qemu-devel@nongnu.org * Daniel P. Berrange (berrange@redhat.com) wrote: > On Tue, Oct 11, 2016 at 03:17:04PM +0100, Daniel P. Berrange wrote: > > On Tue, Oct 11, 2016 at 03:08:34PM +0100, Dr. David Alan Gilbert wrote: > > > * Daniel P. Berrange (berrange@redhat.com) wrote: > > > > On Tue, Oct 11, 2016 at 12:26:37PM +0200, Samuel Ortiz wrote: > > > > > Hi, > > > > > > > > > > On a qemu instance started with a qmp unix socket: > > > > > > > > > > -qmp unix:/tmp/ctrl.sock,server,nowait > > > > > > > > > > I am trying to have multiple clients working on that socket but > > > > > although the qmp server seems to accept the connections, only the first > > > > > connected client gets his request processed. The next client requests > > > > > will just hang until the first one exits. > > > > > > > > > > Is that an intended behaviour ? > > > > > > > > Yes, the character device code is designed around the idea of a single > > > > endpoint. > > > > > > > > In the case of the monitor you could work around it by adding multiple > > > > -qmp arguemnts, each with different socket. Of course you have to make > > > > sure each client doesn't trample on the other client when doing this. > > > > > > But why does it accept the connection? > > > I thought you could say only accept a single connection on a socket. > > > (The backlog parameter to listen(2) but I can't find out listen.) > > > > QEMU won't accept the connection, as while it is still listen()ing on > > the socket, it is not poll()ing for incoming clients, so will never > > trigger accept(). The kernel will queue the incoming connection until > > QEMU starts polling for clients again. From the client POV this is > > indistinguishable from QEMU accepting the client, but not processing > > I/O on it. > > Oh, and the backlog parameter to listen() is fairly useless - it won't > stop new clients getting into an established socket state > > https://veithen.github.io/2014/01/01/how-tcp-backlog-works-in-linux.html Oh, that's annoying; ok, if that's all we can do that's fine; and I did check with an strace and we do have a : [pid 22661] listen(9, 1) = 0 and I do only see a single call to accept4() even though the 2nd telnet apparently shows it connected. > QEMU could just accept() all incoming connections and explicitly close > them if something is already connected, but this just burns CPU really. It might make failures more obvious than a non-responsive socket. Dave > > Regards, > Daniel > -- > |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| > |: http://libvirt.org -o- http://virt-manager.org :| > |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :| -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK