From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhFBV-0005X3-FD for qemu-devel@nongnu.org; Mon, 05 May 2014 05:27:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhFBP-0000pU-8V for qemu-devel@nongnu.org; Mon, 05 May 2014 05:27:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhFBP-0000pQ-17 for qemu-devel@nongnu.org; Mon, 05 May 2014 05:27:35 -0400 Date: Mon, 5 May 2014 11:27:30 +0200 From: Kevin Wolf Message-ID: <20140505092730.GC3317@noname.str.redhat.com> References: <1398867658-2069-1-git-send-email-mbooth@redhat.com> <1398867658-2069-2-git-send-email-mbooth@redhat.com> <20140430151638.GE4380@noname.redhat.com> <53620C41.3040506@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53620C41.3040506@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/3] curl: Fix parsing of readahead option from filename List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Matthew Booth Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Am 01.05.2014 um 10:56 hat Matthew Booth geschrieben: > On 30/04/14 16:16, Kevin Wolf wrote: > > Am 30.04.2014 um 16:20 hat Matthew Booth geschrieben: > >> curl_parse_filename wasn't removing the option string from the url, > >> resulting in a 404. > >> > >> This change is a essentially a rewrite of that function as I also need > >> to extend it to handle more options. The rewrite is also much easier > >> to read. > >> > >> Signed-off-by: Matthew Booth > >> --- > >> block/curl.c | 81 ++++++++++++++++++++++++++++++++++++++---------------------- > >> 1 file changed, 52 insertions(+), 29 deletions(-) > >> > >> diff --git a/block/curl.c b/block/curl.c > >> index d2f1084..4de6856 100644 > >> --- a/block/curl.c > >> +++ b/block/curl.c > >> @@ -46,12 +46,15 @@ > >> #define CURL_NUM_STATES 8 > >> #define CURL_NUM_ACB 8 > >> #define SECTOR_SIZE 512 > >> -#define READ_AHEAD_SIZE (256 * 1024) > >> +#define READ_AHEAD_DEFAULT (256 * 1024) > >> > >> #define FIND_RET_NONE 0 > >> #define FIND_RET_OK 1 > >> #define FIND_RET_WAIT 2 > >> > >> +#define CURL_BLOCK_OPT_URL "url" > >> +#define CURL_BLOCK_OPT_READAHEAD "readahead" > >> + > >> struct BDRVCURLState; > >> > >> typedef struct CURLAIOCB { > >> @@ -396,41 +399,60 @@ static void curl_clean_state(CURLState *s) > >> static void curl_parse_filename(const char *filename, QDict *options, > >> Error **errp) > >> { > >> - > >> - #define RA_OPTSTR ":readahead=" > >> char *file; > >> - char *ra; > >> - const char *ra_val; > >> - int parse_state = 0; > >> + char *end; > >> > >> file = g_strdup(filename); > >> + end = file + strlen(file) - 1; > >> + > >> + /* Don't fail if we've been passed an empty string. > >> + * Only examine strings with a trailing ':' > >> + */ > >> + if (end >= file && *end == ':') { > >> + /* We exit this loop when we don't find a recognised option immediately > >> + * preceding the trailing ':' of the form ':