qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] block/rbd: pull out qemu_rbd_convert_option


From: John Snow
Subject: Re: [Qemu-devel] [PATCH 1/2] block/rbd: pull out qemu_rbd_convert_options
Date: Tue, 11 Sep 2018 14:06:12 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1


On 09/11/2018 01:15 AM, Jeff Cody wrote:
> Code movement to pull the conversion from Qdict to BlockdevOptionsRbd
> into a helper function.
> 
> Signed-off-by: Jeff Cody <address@hidden>
> ---
>  block/rbd.c | 36 ++++++++++++++++++++++++------------
>  1 file changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index ca8e5bbace..a8e79d01d2 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -655,12 +655,34 @@ failed_opts:
>      return r;
>  }
>  
> +static int qemu_rbd_convert_options(BlockDriverState *bs, 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(bs, options, &opts, &local_err);
>      if (local_err) {
>          error_propagate(errp, local_err);
> -        r = -EINVAL;
>          goto out;
>      }
>  
> 

Reviewed-by: John Snow <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]