From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpZHL-0005L6-Ga for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:13:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpZHI-0000Py-5f for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:13:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpZHH-0000Pq-VX for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:13:24 -0400 Date: Thu, 29 Sep 2016 12:13:18 +0100 From: "Daniel P. Berrange" Message-ID: <20160929111318.GN5312@redhat.com> Reply-To: "Daniel P. Berrange" References: <1475146935-12118-1-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1475146935-12118-1-git-send-email-den@openvz.org> Subject: Re: [Qemu-devel] [PATCH 1/1] qemu-nbd: add the option to use pre-created server socket List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: qemu-devel@nongnu.org, Denis Plotnikov , Paolo Bonzini On Thu, Sep 29, 2016 at 02:02:15PM +0300, Denis V. Lunev wrote: > From: Denis Plotnikov > > Originally NBD server socket was created by qemu-nbd code. This leads to > the race when the management layer starts qemu-nbd server and allows a > client to connect to the server. In this case there is a possibility that > qemu-nbd does not open listening server socket yet. Creating listening > socket before starting of qemu-ndb and passing socket fd via command line > solves this issue completely. FWIW, this could be solved in qemu-nbd itself if we had a general ability to request "daemon" mode - currently it only daemonizes if attaching to a nbd block device. The key would be that qemu-nbd would open the listening socket before daemonizing. Thus when the mgmt application spawned qemu-nbd in daemon mode, it can be sure that the listener socket is present when waitpid() completes. 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/ :|