From fd7f8c65377ee918479e43b38d44f54f13aa6548 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 25 Apr 2012 16:51:00 +0100 Subject: block: use Error mechanism instead of -errno for block_job_create() The block job API uses -errno return values internally and we convert these to Error in the QMP functions. This is ugly because the Error should be created at the point where we still have all the relevant information. More importantly, it is hard to add new error cases to this case since we quickly run out of -errno values without losing information. Go ahead and use Error directly and don't convert later. Signed-off-by: Stefan Hajnoczi Acked-by: Kevin Wolf Signed-off-by: Luiz Capitulino --- block.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'block.c') diff --git a/block.c b/block.c index fe74dddb13..2b72a0f3b0 100644 --- a/block.c +++ b/block.c @@ -4083,11 +4083,13 @@ out: } void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, - BlockDriverCompletionFunc *cb, void *opaque) + BlockDriverCompletionFunc *cb, void *opaque, + Error **errp) { BlockJob *job; if (bs->job || bdrv_in_use(bs)) { + error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs)); return NULL; } bdrv_set_in_use(bs, 1); -- cgit v1.2.3