diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-02-16 18:54:52 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-03-09 15:17:47 +0100 |
commit | d41a55885de18f4fe8dddb8ae88be80497f8eb05 (patch) | |
tree | cb87f33599c3f1e63b8914e251fca5f0e7c19bc9 | |
parent | 1bebea37b43223a45c39dcbc158f3cec6164fdbf (diff) |
rbd: Assign s->snap/image_name in qemu_rbd_open()
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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
-rw-r--r-- | block/rbd.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/block/rbd.c b/block/rbd.c index 1cd526bcea..2ac7ffca42 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -571,7 +571,6 @@ static char *qemu_rbd_mon_host(BlockdevOptionsRbd *opts, Error **errp) } 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) @@ -593,9 +592,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) { @@ -649,8 +645,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; @@ -711,13 +705,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) { |