Received: from eggs.gnu.org ([2001:4830:134:3::10]:52210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzB88-0006iT-V6 for qemu-devel@nongnu.org; Mon, 23 Jun 2014 16:46:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzB82-0006kl-VJ for qemu-devel@nongnu.org; Mon, 23 Jun 2014 16:46:20 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:32777 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzB82-0006kT-It for qemu-devel@nongnu.org; Mon, 23 Jun 2014 16:46:14 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) From: Peter Lieven In-Reply-To: <53A84391.7040904@redhat.com> Date: Mon, 23 Jun 2014 22:47:22 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <439D6F63-2D86-4ABC-9796-4298179201AB@kamp.de> References: <1403533836-28589-1-git-send-email-pl@kamp.de> <53A84391.7040904@redhat.com> 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: Eric Blake Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, ronniesahlberg@gmail.com Am 23.06.2014 um 17:11 schrieb Eric Blake : > 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. >=20 > 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). Thanks for that hint I was not aware and somehow everybody mist it when it first went in. I will respin for that. >=20 >>=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)); >=20 > Of course, the use of atoi was pre-existing, so it doesn't necessarily > need to be done in _this_ patch. >=20 >> - } 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 >=20 > 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. I would like to leave this for a follow-up and I promise to take care of = this. If you could give me a pointer of an existing driver that does this as a = reference I would be grateful. For the read ahead parameter its likely not needed as (at least in my = use case) the read ahead makes only sense when converting a compressed QCOW2 = Template File which lives on an NFS Share to a RAW Device. So I use it with qemu-img. For a Container File that is used as a VM hard drive I would likely not = use read ahead as the operating system itself will implement some sort of read ahead = already. Peter >=20 > --=20 > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org >=20