From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MKNO9-0001tK-La for qemu-devel@nongnu.org; Fri, 26 Jun 2009 22:11:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MKNO4-0001sn-28 for qemu-devel@nongnu.org; Fri, 26 Jun 2009 22:11:32 -0400 Received: from [199.232.76.173] (port=42372 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKNO3-0001sk-VX for qemu-devel@nongnu.org; Fri, 26 Jun 2009 22:11:27 -0400 Received: from phong.sigbus.net ([65.49.35.42]:42250) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MKNO3-0000Fs-LT for qemu-devel@nongnu.org; Fri, 26 Jun 2009 22:11:27 -0400 Received: from localhost (unknown [71.198.47.97]) by phong.sigbus.net (Postfix) with ESMTPSA id 17A4995C06E for ; Fri, 26 Jun 2009 19:11:25 -0700 (PDT) From: Nolan Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Fri, 26 Jun 2009 19:11:24 -0700 Message-Id: <1246068684.4465.76.camel@voxel> Mime-Version: 1.0 Subject: [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" Allow adjustment of http block device's readahead size, via the environment variable "HTTP_READAHEAD_SIZE". Signed-off-by: Nolan Leake sigbus.net> diff --git a/block/curl.c b/block/curl.c index e1a553f..32530eb 100644 --- a/block/curl.c +++ b/block/curl.c @@ -24,6 +24,7 @@ #include "qemu-common.h" #include "block_int.h" #include +#include // #define DEBUG // #define DEBUG_VERBOSE @@ -71,6 +72,7 @@ typedef struct BDRVCURLState { size_t len; CURLState states[CURL_NUM_STATES]; char *url; + size_t readahead_size; } BDRVCURLState; static void curl_clean_state(CURLState *s); @@ -298,9 +300,21 @@ static int curl_open(BlockDriverState *bs, const char *filename, int flags) { BDRVCURLState *s = bs->opaque; CURLState *state = NULL; + char *readahead; double d; static int inited = 0; + s->readahead_size = READ_AHEAD_SIZE; + readahead = getenv("HTTP_READAHEAD_SIZE"); + if (readahead) { + s->readahead_size = atoi(readahead); + } + if ((s->readahead_size & 0x1ff) != 0) { + fprintf(stderr, "HTTP_READAHEAD_SIZE %Zd not a multiple of 512\n", + s->readahead_size); + goto out_noclean; + } + if (!inited) { curl_global_init(CURL_GLOBAL_ALL); inited = 1; @@ -346,6 +360,7 @@ out: curl_easy_cleanup(state->curl); state->curl = NULL; out_noclean: + qemu_free(s->url); return -EINVAL; } @@ -401,7 +416,7 @@ static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs, if (state->orig_buf) qemu_free(state->orig_buf); state->buf_start = start; - state->buf_len = acb->end + READ_AHEAD_SIZE; + state->buf_len = acb->end + s->readahead_size; end = MIN(start + state->buf_len, s->len) - 1; state->orig_buf = qemu_malloc(state->buf_len); state->acb[0] = acb;