qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size.
@ 2009-06-27  2:11 Nolan
  2009-06-29 13:45 ` Anthony Liguori
  0 siblings, 1 reply; 5+ messages in thread
From: Nolan @ 2009-06-27  2:11 UTC (permalink / raw)
  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 <nolan <at> 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 <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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size.
  2009-06-27  2:11 [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size Nolan
@ 2009-06-29 13:45 ` Anthony Liguori
  2009-06-30 13:09   ` Alexander Graf
  0 siblings, 1 reply; 5+ messages in thread
From: Anthony Liguori @ 2009-06-29 13:45 UTC (permalink / raw)
  To: Nolan; +Cc: qemu-devel@nongnu.org

Nolan wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size.
  2009-06-29 13:45 ` Anthony Liguori
@ 2009-06-30 13:09   ` Alexander Graf
  2009-06-30 13:36     ` Anthony Liguori
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2009-06-30 13:09 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Nolan, qemu-devel@nongnu.org


On 29.06.2009, at 15:45, Anthony Liguori wrote:

> Nolan wrote:
>> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size.
  2009-06-30 13:09   ` Alexander Graf
@ 2009-06-30 13:36     ` Anthony Liguori
  2009-06-30 16:44       ` Jamie Lokier
  0 siblings, 1 reply; 5+ messages in thread
From: Anthony Liguori @ 2009-06-30 13:36 UTC (permalink / raw)
  To: Alexander Graf; +Cc: Nolan, qemu-devel@nongnu.org

Alexander Graf wrote:
>
> On 29.06.2009, at 15:45, Anthony Liguori wrote:
>
>> Nolan wrote:
>>> 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.

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

> Alex
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size.
  2009-06-30 13:36     ` Anthony Liguori
@ 2009-06-30 16:44       ` Jamie Lokier
  0 siblings, 0 replies; 5+ messages in thread
From: Jamie Lokier @ 2009-06-30 16:44 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Nolan, Alexander Graf, qemu-devel@nongnu.org

Anthony Liguori wrote:
> Alexander Graf wrote:
> >
> >On 29.06.2009, at 15:45, Anthony Liguori wrote:
> >
> >>Nolan wrote:
> >>>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.
> 
> 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.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-30 16:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-27  2:11 [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size Nolan
2009-06-29 13:45 ` Anthony Liguori
2009-06-30 13:09   ` Alexander Graf
2009-06-30 13:36     ` Anthony Liguori
2009-06-30 16:44       ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).