diff mbox series

[v2,23/36] rbd: Assing s->snap/image_name in qemu_rbd_open()

Message ID 20180221135404.27598-24-kwolf@redhat.com
State New
Headers show
Series x-blockdev-create for protocols and qcow2 | expand

Commit Message

Kevin Wolf Feb. 21, 2018, 1:53 p.m. UTC
Now that the options are already available in qemu_rbd_open() and not
only parsed in qemu_rbd_connect(), we can assign s->snap and
s->image_name there instead of passing the fields by reference to
qemu_rbd_connect().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/rbd.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Max Reitz Feb. 22, 2018, 11:34 p.m. UTC | #1
I suppose the first word after the colon in your subject is supposed to
be "assign" and not what it currently is (which is something I am not
going to repeat!). :-)

On 2018-02-21 14:53, Kevin Wolf wrote:
> Now that the options are already available in qemu_rbd_open() and not
> only parsed in qemu_rbd_connect(), we can assign s->snap and
> s->image_name there instead of passing the fields by reference to
> qemu_rbd_connect().
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/rbd.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 82f03505a9..a34bf0be46 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c

[...]

> @@ -716,13 +710,15 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
>          goto out;
>      }
>  
> -    r = qemu_rbd_connect(&s->cluster, &s->io_ctx, &s->snap, &s->image_name,
> -                         opts, !(flags & BDRV_O_NOCACHE), keypairs, secretid,
> -                         errp);
> +    r = qemu_rbd_connect(&s->cluster, &s->io_ctx, opts,
> +                         !(flags & BDRV_O_NOCACHE), keypairs, secretid, errp);
>      if (r < 0) {
>          goto out;
>      }
>  
> +    s->snap = g_strdup(opts->snapshot);
> +    s->image_name = g_strdup(opts->image);
> +

Same question as in patch 21: Should we guard these by checking
opts->has_* first?

Max

>      /* rbd_open is always r/w */
>      r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap);
>      if (r < 0) {
>
diff mbox series

Patch

diff --git a/block/rbd.c b/block/rbd.c
index 82f03505a9..a34bf0be46 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -577,7 +577,6 @@  out:
 }
 
 static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
-                            char **s_snap, char **s_image_name,
                             BlockdevOptionsRbd *opts, bool cache,
                             const char *keypairs, const char *secretid,
                             Error **errp)
@@ -599,9 +598,6 @@  static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
         goto failed_opts;
     }
 
-    *s_snap = g_strdup(opts->snapshot);
-    *s_image_name = g_strdup(opts->image);
-
     /* try default location when conf=NULL, but ignore failure */
     r = rados_conf_read_file(*cluster, opts->conf);
     if (opts->has_conf && r < 0) {
@@ -655,8 +651,6 @@  static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
 
 failed_shutdown:
     rados_shutdown(*cluster);
-    g_free(*s_snap);
-    g_free(*s_image_name);
 failed_opts:
     g_free(mon_host);
     return r;
@@ -716,13 +710,15 @@  static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         goto out;
     }
 
-    r = qemu_rbd_connect(&s->cluster, &s->io_ctx, &s->snap, &s->image_name,
-                         opts, !(flags & BDRV_O_NOCACHE), keypairs, secretid,
-                         errp);
+    r = qemu_rbd_connect(&s->cluster, &s->io_ctx, opts,
+                         !(flags & BDRV_O_NOCACHE), keypairs, secretid, errp);
     if (r < 0) {
         goto out;
     }
 
+    s->snap = g_strdup(opts->snapshot);
+    s->image_name = g_strdup(opts->image);
+
     /* rbd_open is always r/w */
     r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap);
     if (r < 0) {