block/rbd: pull out qemu_rbd_convert_options

Code movement to pull the conversion from Qdict to BlockdevOptionsRbd
into a helper function.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Message-id: 5b49a980f2cde6610ab1df41bb0277d00b5db893.1536704901.git.jcody@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
(cherry picked from commit f24b03b56c)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
stable-3.0
Jeff Cody 2018-09-11 18:32:30 -04:00 committed by Michael Roth
parent 481be11cba
commit 22e766bcf3
1 changed files with 24 additions and 12 deletions

View File

@ -655,12 +655,34 @@ failed_opts:
return r;
}
static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
Error **errp)
{
Visitor *v;
Error *local_err = NULL;
/* Convert the remaining options into a QAPI object */
v = qobject_input_visitor_new_flat_confused(options, errp);
if (!v) {
return -EINVAL;
}
visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
visit_free(v);
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
}
return 0;
}
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRBDState *s = bs->opaque;
BlockdevOptionsRbd *opts = NULL;
Visitor *v;
const QDictEntry *e;
Error *local_err = NULL;
char *keypairs, *secretid;
@ -676,19 +698,9 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
qdict_del(options, "password-secret");
}
/* Convert the remaining options into a QAPI object */
v = qobject_input_visitor_new_flat_confused(options, errp);
if (!v) {
r = -EINVAL;
goto out;
}
visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
visit_free(v);
r = qemu_rbd_convert_options(options, &opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
r = -EINVAL;
goto out;
}