From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpcuP-0004j6-Nr for qemu-devel@nongnu.org; Thu, 29 Sep 2016 11:06:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpcuL-0000jQ-Ea for qemu-devel@nongnu.org; Thu, 29 Sep 2016 11:06:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpcuL-0000jK-5p for qemu-devel@nongnu.org; Thu, 29 Sep 2016 11:05:57 -0400 References: <1475146935-12118-1-git-send-email-den@openvz.org> From: Eric Blake Message-ID: <672b32a4-1061-8e5f-1ab1-2968d942b30e@redhat.com> Date: Thu, 29 Sep 2016 10:05:55 -0500 MIME-Version: 1.0 In-Reply-To: <1475146935-12118-1-git-send-email-den@openvz.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GEFlfEoALtKQarCvMIOV1sIJB3Aw5DeS0" 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" , qemu-devel@nongnu.org Cc: Denis Plotnikov , Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GEFlfEoALtKQarCvMIOV1sIJB3Aw5DeS0 From: Eric Blake To: "Denis V. Lunev" , qemu-devel@nongnu.org Cc: Denis Plotnikov , Paolo Bonzini Message-ID: <672b32a4-1061-8e5f-1ab1-2968d942b30e@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/1] qemu-nbd: add the option to use pre-created server socket References: <1475146935-12118-1-git-send-email-den@openvz.org> In-Reply-To: <1475146935-12118-1-git-send-email-den@openvz.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/29/2016 06:02 AM, Denis V. Lunev wrote: > From: Denis Plotnikov >=20 > Originally NBD server socket was created by qemu-nbd code. This leads t= o > 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 th= at > qemu-nbd does not open listening server socket yet. Creating listening > socket before starting of qemu-ndb and passing socket fd via command li= ne > solves this issue completely. >=20 > 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=3DIFACE interface to bind to (default `0.0.0.0'= )\n" > " -k, --socket=3DPATH path to the unix socket\n" > " (default '"SOCKET_PATH"')\n" > +" --server-sock-fd=3DNUM pre-opened listening server socket file= descriptor\n" > " -e, --shared=3DNUM device can be shared by NUM clients (de= fault '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). > =20 > -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 =3D=3D NULL) { > + *address =3D "0.0.0.0"; > + } > + > + if (*port =3D=3D NULL) { > + *port =3D 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? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GEFlfEoALtKQarCvMIOV1sIJB3Aw5DeS0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX7S3TAAoJEKeha0olJ0NqQ0YH/jruB4KWPGI4cwrwultYhkKO 20YcjxxA0Ktv8rR4EawpzlF0LmdM5OQlEkJUqa0flh93PQq0FoKBuug24Pu17Yjd NnsB5wScHaDhxgF8RDII+PXC2/flVbx0s7pEkAd0nKgXkrdfV9CIwZ5deuoabdE3 yNqJtw3nR+pcmcbF5MOkpXhi3ukX4jya0Tw9ockEFWV5LDLYBWvwVrWejm5YjKkS TLwvKuKs8Agnod/pQqly3x5Zfg2SKBVT7JKa0zml+Sw3+Y7tERr09Y/kM/U25gW+ lnOsNS5PyDKq/bzbeuf+xMje7dlslVW6dqLtrlmQrahoHFQUcCr4Jsyl47FidhI= =hcbZ -----END PGP SIGNATURE----- --GEFlfEoALtKQarCvMIOV1sIJB3Aw5DeS0--