diff options
author | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2012-04-25 16:51:03 +0100 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-04-27 11:44:50 -0300 |
commit | c83c66c3b58893a4dc056e272822beb88fe9ec7f (patch) | |
tree | 890e9af2cbfef523b48c365df64820e96445185a /block.c | |
parent | 882ec7ce531091bc0f3ffc6ac71943cf383f86a6 (diff) | |
download | qemu-c83c66c3b58893a4dc056e272822beb88fe9ec7f.zip qemu-c83c66c3b58893a4dc056e272822beb88fe9ec7f.tar.gz qemu-c83c66c3b58893a4dc056e272822beb88fe9ec7f.tar.bz2 |
block: add 'speed' optional parameter to block-stream
Allow streaming operations to be started with an initial speed limit.
This eliminates the window of time between starting streaming and
issuing block-job-set-speed. Users should use the new optional 'speed'
parameter instead so that speed limits are in effect immediately when
the job starts.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -4083,8 +4083,8 @@ out: } void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, - BlockDriverCompletionFunc *cb, void *opaque, - Error **errp) + int64_t speed, BlockDriverCompletionFunc *cb, + void *opaque, Error **errp) { BlockJob *job; @@ -4100,6 +4100,20 @@ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, job->cb = cb; job->opaque = opaque; bs->job = job; + + /* Only set speed when necessary to avoid NotSupported error */ + if (speed != 0) { + Error *local_err = NULL; + + block_job_set_speed(job, speed, &local_err); + if (error_is_set(&local_err)) { + bs->job = NULL; + g_free(job); + bdrv_set_in_use(bs, 0); + error_propagate(errp, local_err); + return NULL; + } + } return job; } |