block: use Error mechanism instead of -errno for block_job_set_speed()

There are at least two different errors that can occur in
block_job_set_speed(): the job might not support setting speeds or the
value might be invalid.

Use the Error mechanism to report the error where it occurs.

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>
This commit is contained in:
Stefan Hajnoczi 2012-04-25 16:51:01 +01:00 committed by Luiz Capitulino
parent fd7f8c6537
commit 9e6636c72d
5 changed files with 18 additions and 15 deletions

17
block.c
View file

@ -4114,18 +4114,21 @@ void block_job_complete(BlockJob *job, int ret)
bdrv_set_in_use(bs, 0);
}
int block_job_set_speed(BlockJob *job, int64_t value)
void block_job_set_speed(BlockJob *job, int64_t value, Error **errp)
{
int rc;
Error *local_err = NULL;
if (!job->job_type->set_speed) {
return -ENOTSUP;
error_set(errp, QERR_NOT_SUPPORTED);
return;
}
rc = job->job_type->set_speed(job, value);
if (rc == 0) {
job->speed = value;
job->job_type->set_speed(job, value, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
return rc;
job->speed = value;
}
void block_job_cancel(BlockJob *job)