From: Marc-André Lureau <marcandre.lur...@redhat.com> Allow to pass additional arguments, such as options and opaque
Signed-off-by: Marc-André Lureau <marcandre.lur...@gmail.com> --- blockdev.c | 24 +++++++++++++++++++----- include/sysemu/blockdev.h | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/blockdev.c b/blockdev.c index b8db544..f2c3c4e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1498,12 +1498,13 @@ void qmp_block_passwd(const char *device, const char *password, Error **errp) static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, int bdrv_flags, BlockDriver *drv, - const char *password, Error **errp) + const char *password, QDict *options, + Error **errp) { Error *local_err = NULL; int ret; - ret = bdrv_open(bs, filename, NULL, bdrv_flags, drv, &local_err); + ret = bdrv_open(bs, filename, options, bdrv_flags, drv, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; @@ -1523,8 +1524,9 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, } } -void qmp_change_blockdev(const char *device, const char *filename, - const char *format, Error **errp) +void qmp_change_blockdev_int(const char *device, const char *filename, + const char *format, QDict *options, void *opaque, + Error **errp) { BlockDriverState *bs; BlockDriver *drv = NULL; @@ -1554,7 +1556,19 @@ void qmp_change_blockdev(const char *device, const char *filename, bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; - qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, errp); + if (bs->opaque) { + error_set(errp, QERR_INVALID_PARAMETER, device); + return; + } + bs->opaque = opaque; + + qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, options, errp); +} + +void qmp_change_blockdev(const char *device, const char *filename, + const char *format, Error **errp) +{ + qmp_change_blockdev_int(device, filename, format, NULL, NULL, errp); } /* throttling disk I/O limits */ diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 134712b..5ce4997 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -65,6 +65,9 @@ DriveInfo *add_init_drive(const char *opts); void qmp_change_blockdev(const char *device, const char *filename, const char *format, Error **errp); +void qmp_change_blockdev_int(const char *device, const char *filename, + const char *format, QDict *options, void *opaque, + Error **errp); void do_commit(Monitor *mon, const QDict *qdict); int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif -- 1.8.3.1 _______________________________________________ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel