From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz5u7-0004qC-KP for qemu-devel@nongnu.org; Mon, 23 Jun 2014 11:11:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wz5u2-0002Dq-Kd for qemu-devel@nongnu.org; Mon, 23 Jun 2014 11:11:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz5u2-0002Cn-CB for qemu-devel@nongnu.org; Mon, 23 Jun 2014 11:11:26 -0400 Message-ID: <53A84391.7040904@redhat.com> Date: Mon, 23 Jun 2014 09:11:13 -0600 From: Eric Blake MIME-Version: 1.0 References: <1403533836-28589-1-git-send-email-pl@kamp.de> In-Reply-To: <1403533836-28589-1-git-send-email-pl@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="W5B4s7awp0Xfd9ohtgFSRaRecX7wT2BRS" Subject: Re: [Qemu-devel] [PATCH] block/nfs: add knob to set readahead List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, ronniesahlberg@gmail.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --W5B4s7awp0Xfd9ohtgFSRaRecX7wT2BRS Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/23/2014 08:30 AM, Peter Lieven wrote: > upcoming libnfs will feature internal readahead support. > Add a knob to pass the optional readahead value as a URL > parameter. >=20 > This patch fixes also the incorrect usage of strncmp. But not the incorrect usage of atoi() (hint - atoi cannot detect overflow; it should NEVER be used on user-provided input; instead strtol() should be preferred). >=20 > Signed-off-by: Peter Lieven > --- > block/nfs.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/block/nfs.c b/block/nfs.c > index ec43201..a5c0577 100644 > --- a/block/nfs.c > +++ b/block/nfs.c > @@ -309,12 +309,16 @@ static int64_t nfs_client_open(NFSClient *client,= const char *filename, > qp->p[i].name); > goto fail; > } > - if (!strncmp(qp->p[i].name, "uid", 3)) { > + if (!strcmp(qp->p[i].name, "uid")) { > nfs_set_uid(client->context, atoi(qp->p[i].value)); Of course, the use of atoi was pre-existing, so it doesn't necessarily need to be done in _this_ patch. > - } else if (!strncmp(qp->p[i].name, "gid", 3)) { > + } else if (!strcmp(qp->p[i].name, "gid")) { > nfs_set_gid(client->context, atoi(qp->p[i].value)); > - } else if (!strncmp(qp->p[i].name, "tcp-syncnt", 10)) { > + } else if (!strcmp(qp->p[i].name, "tcp-syncnt")) { > nfs_set_tcp_syncnt(client->context, atoi(qp->p[i].value));= > +#ifdef LIBNFS_FEATURE_READAHEAD > + } else if (!strcmp(qp->p[i].name, "readahead")) { > + nfs_set_readahead(client->context, atoi(qp->p[i].value)); > +#endif I'm not a fan of adding even more special-casing to the file-name URI without also adding it to the QAPI schema for use in the blockdev-add command. Of course, we don't have structured nfs options for blockdev-add yet, but maybe it's time to start thinking about that addition before we do this addition. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --W5B4s7awp0Xfd9ohtgFSRaRecX7wT2BRS 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/ iQEcBAEBCAAGBQJTqEORAAoJEKeha0olJ0Nq6REH/3iXeHExpTLmXBQWHwau+6CM alZjC+oTpmveGQdwhx8mMoxtuX2pmntuDlOzKYTYsU0Gaaf6wyARFNeK/P7Utkr0 LS7weVFC+6ON+4nG27PavUMU74MiApPAs4RpO5Ev1H0J3GAVF5bjzp3D4XgsucJP H2PvH+JIG7A+/sy9GD4OQ8fg9jsBrZ46jICKmPXWXIrLg9l0+UOu/uWjaz0pFQv7 OQSiA/KmZOXiwKoODEpcRaNqSaf4tbREtJQO+6N4pMco20PgjFaoUgjYMfLFhmXI xfXOUJS0PDXPDo075zv1+8VIqN05kWkYfJNonIssW18Lu9I3GqSBcQExGLR3bRg= =0Kre -----END PGP SIGNATURE----- --W5B4s7awp0Xfd9ohtgFSRaRecX7wT2BRS--