mirror of https://github.com/xemu-project/xemu.git
block: Introduce .bdrv_co_ioctl() driver callback
This allows drivers to implement ioctls in a coroutine-based way. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
61b2450414
commit
16a389dc9e
16
block/io.c
16
block/io.c
|
@ -2502,17 +2502,21 @@ int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)
|
||||||
BlockAIOCB *acb;
|
BlockAIOCB *acb;
|
||||||
|
|
||||||
tracked_request_begin(&tracked_req, bs, 0, 0, BDRV_TRACKED_IOCTL);
|
tracked_request_begin(&tracked_req, bs, 0, 0, BDRV_TRACKED_IOCTL);
|
||||||
if (!drv || !drv->bdrv_aio_ioctl) {
|
if (!drv || (!drv->bdrv_aio_ioctl && !drv->bdrv_co_ioctl)) {
|
||||||
co.ret = -ENOTSUP;
|
co.ret = -ENOTSUP;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
|
if (drv->bdrv_co_ioctl) {
|
||||||
if (!acb) {
|
co.ret = drv->bdrv_co_ioctl(bs, req, buf);
|
||||||
co.ret = -ENOTSUP;
|
} else {
|
||||||
goto out;
|
acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
|
||||||
|
if (!acb) {
|
||||||
|
co.ret = -ENOTSUP;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
qemu_coroutine_yield();
|
||||||
}
|
}
|
||||||
qemu_coroutine_yield();
|
|
||||||
out:
|
out:
|
||||||
tracked_request_end(&tracked_req);
|
tracked_request_end(&tracked_req);
|
||||||
return co.ret;
|
return co.ret;
|
||||||
|
|
|
@ -244,6 +244,8 @@ struct BlockDriver {
|
||||||
BlockAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs,
|
BlockAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs,
|
||||||
unsigned long int req, void *buf,
|
unsigned long int req, void *buf,
|
||||||
BlockCompletionFunc *cb, void *opaque);
|
BlockCompletionFunc *cb, void *opaque);
|
||||||
|
int coroutine_fn (*bdrv_co_ioctl)(BlockDriverState *bs,
|
||||||
|
unsigned long int req, void *buf);
|
||||||
|
|
||||||
/* List of options for creating images, terminated by name == NULL */
|
/* List of options for creating images, terminated by name == NULL */
|
||||||
QemuOptsList *create_opts;
|
QemuOptsList *create_opts;
|
||||||
|
|
Loading…
Reference in New Issue