From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkwNm-0005Nk-1q for qemu-devel@nongnu.org; Thu, 15 May 2014 10:11:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkwNg-0008Uc-RN for qemu-devel@nongnu.org; Thu, 15 May 2014 10:11:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkwNg-0008UU-Jy for qemu-devel@nongnu.org; Thu, 15 May 2014 10:11:32 -0400 Message-ID: <5374CB10.70809@redhat.com> Date: Thu, 15 May 2014 08:11:28 -0600 From: Eric Blake MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="W7xXlQ7cu2QxgLGlBHvwtcNo9vGP9VrTj" Subject: Re: [Qemu-devel] [PATCH 1/5] block: Auto-generate node_names for each BDS entry List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , qemu-devel@nongnu.org Cc: kwolf@redhat.com, benoit.canet@irqsave.net, pkrempa@redhat.com, famz@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --W7xXlQ7cu2QxgLGlBHvwtcNo9vGP9VrTj Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/14/2014 09:20 PM, Jeff Cody wrote: > Currently, node_name is only filled in when done so explicitly by the > user. If no node_name is specified, then the node name field is not > populated. >=20 > If node_names are automatically generated when not specified, that mean= s > that all block job operations can be done by reference to the unique > node_name field. This eliminates ambiguity in filename pathing "pathing" sounds weird; a non-native speaker may get confused since it is not a real word. Maybe: This eliminates ambiguity in resolving filenames > (relative filenames, or file descriptors, symlinks, mounts, etc..) that= > qemu currently needs to deal with. >=20 > If a node name is specified, then it will not be automatically > generated for that BDS entry. >=20 > If it is automatically generated, it will be prefaced with "__qemu##", > followed by 8 characters of a unique number, followed by 8 random > ASCII characters in the range of 'A-Z'. Some sample generated node-nam= e > strings: > __qemu##00000000IAIYNXXR > __qemu##00000002METXTRBQ > __qemu##00000001FMBORDWG >=20 > The prefix is to aid in identifying it as a qemu-generated name, the > numeric portion is to guarantee uniqueness in a given qemu session, and= > the random characters are to further avoid any accidental collisions > with user-specified node-names. >=20 > Signed-off-by: Jeff Cody > --- > block.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) >=20 > { > + char gen_node_name[GEN_NODE_NAME_MAX_LEN]; > + static uint32_t counter; /* simple counter to guarantee uniqueness= */ > + > + /* if node_name is NULL, auto-generate a node name */ > if (!node_name) { > - return; > + int len; > + snprintf(gen_node_name, GEN_NODE_NAME_MAX_LEN, > + "%s%08x", GEN_NODE_NAME_PREFIX, counter++); > + len =3D strlen(gen_node_name); Why not just len =3D snprintf(), and avoid the strlen()? But that micro-optimization is not on the hot path, so: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --W7xXlQ7cu2QxgLGlBHvwtcNo9vGP9VrTj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTdMsQAAoJEKeha0olJ0Nq0ZwH/iEn+hPakFf5t0pDL/OhQqgB wyNYZ7FCbugZUfPRZ7o/4mf6mn8NKcP/vKTEHIEXsU3tAOJEJTN/NsvzVs/t/xUO MlBsKtQK1/pD6stk7N4QkQhvPu/V6SG65j0kV/yBBvTY1Vhloy7o2W+P/VyiufTL JdVUTivnNOAMGIW2QxRp63zy1eUwdsXPTPOk04YKPgpGz7Zt3T4sxPrRTqsrraiw ovB3w0SvmhbK5cxc3NoyeaBdtrKVIelbefpgYOhVbzKAK6YUsOF4OR9J0uNU6itU p8Ny+kGBus9m9L/k2ZVIpOe6Y30+F9e0jZ7cqtxJGgR4zWWK/P4iUFIVR24p9kM= =RVSg -----END PGP SIGNATURE----- --W7xXlQ7cu2QxgLGlBHvwtcNo9vGP9VrTj--