On 09/29/2016 06:02 AM, 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. > > Signed-off-by: Denis Plotnikov > Reviewed-by: Roman Kagan > Signed-off-by: Denis V. Lunev > CC: Paolo Bonzini > --- > @@ -78,6 +79,7 @@ static void usage(const char *name) > " -b, --bind=IFACE interface to bind to (default `0.0.0.0')\n" > " -k, --socket=PATH path to the unix socket\n" > " (default '"SOCKET_PATH"')\n" > +" --server-sock-fd=NUM pre-opened listening server socket file descriptor\n" > " -e, --shared=NUM device can be shared by NUM clients (default '1')\n" Looking at 'qemu-nbd --help', all other long-option-only options are indented so that the -- line up to the same column (see for example --cache and --aio). > > -static SocketAddress *nbd_build_socket_address(const char *sockpath, > +static SocketAddress *nbd_build_sock_fd(const char *sockpath, > const char *bindto, > const char *port) Indentation now looks off. > +static void setup_address_and_port(const char **address, const char **port) > +{ > + if (*address == NULL) { > + *address = "0.0.0.0"; > + } > + > + if (*port == NULL) { > + *port = g_strdup_printf("%d", NBD_DEFAULT_PORT);; s/;;/;/ Why is one of these parameters malloc'd, but the other pointing to const storage? Do you have a memory leak, or else a risk of corrupting read-only memory? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org