Allow adjustment of http block device's readahead size.
PATCH 1/1 Allow adjustment of http block device's readahead size.
Allow adjustment of http block device's readahead size, via the environment variable "HTTP_READAHEAD_SIZE".
block/curl.c +16 -1
@@ -24,6 +24,7 @@#include "qemu-common.h" #include "block_int.h" #include <curl/curl.h> +#include <stdlib.h> // #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;
Quoted 5 lines · Nolan
Allow adjustment of http block device's readahead size, via the environment variable "
HTTP_READAHEAD_SIZE".Signed-off-by Nolan Leake <nolan <at> sigbus.net>
I'd rather a command line option than an environmental variable.
Regards,
Anthony Liguori
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Nolan
Allow adjustment of http block device's readahead size, via the environment variable "
HTTP_READAHEAD_SIZE".Signed-off-by Nolan Leake <nolan <at> sigbus.net>I'd rather a command line option than an environmental variable.
Wouldn't it make sense to pass arbitrary options via -drive to backends?
That way we could have -drive file=http://sample.com/test.iso,http-readahead=1024.
Alex
Quoted 7 lines · Alexander Graf
Quoted 4 lines · Anthony Liguori
Quoted 3 lines · Nolan
Allow adjustment of http block device's readahead size, via the environment variable "
HTTP_READAHEAD_SIZE".
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Nolan Leake <nolan <at> sigbus.net>I'd rather a command line option than an environmental variable.
Wouldn't it make sense to pass arbitrary options via -drive to backends?
That way we could have -drive file=http://sample.com/test.iso,http-readahead=1024.
Where it gets complex is that you probably want those options to be included as qcow2 backing_file too. I've thought about this in the past and haven't been able to come to a great solution.
Regards,
Anthony Liguori
Quoted 2 lines
Alex
Quoted 13 lines · Anthony Liguori
Quoted 12 lines · Alexander Graf
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Nolan
Allow adjustment of http block device's readahead size, via the environment variable "
HTTP_READAHEAD_SIZE".Signed-off-by Nolan Leake <nolan <at> sigbus.net>I'd rather a command line option than an environmental variable.
Quoted 8 lines
Quoted 4 lines
Wouldn't it make sense to pass arbitrary options via -drive to backends?
That way we could have -drive file=http://sample.com/test.iso,http-readahead=1024.
Where it gets complex is that you probably want those options to be included as qcow2
backing_filetoo. I've thought about this in the past and haven't been able to come to a great solution.
And sometimes you want to change or override the qcow2 backing_file options...
It's already awkward when you want to rename a bunch of image files, that the backing relative file path is fixed in the qcow2 file and cannot be overridden by a management program (without rewriting the qcow2 file).
Options like http-readahead=1024 on the backing file are the sort of thing it's reasonable to want to change more often. Imho they are in the same category as the cache= option, which should be controllable for backing files when invoking QEMU independently from the main file.
-- Jamie