mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 14:23:53 -06:00
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 <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:
parent
be5ea8ed44
commit
fd7f8c6537
4 changed files with 20 additions and 22 deletions
16
blockdev.c
16
blockdev.c
|
@ -1095,7 +1095,7 @@ void qmp_block_stream(const char *device, bool has_base,
|
|||
{
|
||||
BlockDriverState *bs;
|
||||
BlockDriverState *base_bs = NULL;
|
||||
int ret;
|
||||
Error *local_err = NULL;
|
||||
|
||||
bs = bdrv_find(device);
|
||||
if (!bs) {
|
||||
|
@ -1111,16 +1111,10 @@ void qmp_block_stream(const char *device, bool has_base,
|
|||
}
|
||||
}
|
||||
|
||||
ret = stream_start(bs, base_bs, base, block_stream_cb, bs);
|
||||
if (ret < 0) {
|
||||
switch (ret) {
|
||||
case -EBUSY:
|
||||
error_set(errp, QERR_DEVICE_IN_USE, device);
|
||||
return;
|
||||
default:
|
||||
error_set(errp, QERR_NOT_SUPPORTED);
|
||||
return;
|
||||
}
|
||||
stream_start(bs, base_bs, base, block_stream_cb, bs, &local_err);
|
||||
if (error_is_set(&local_err)) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Grab a reference so hotplug does not delete the BlockDriverState from
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue