On 2018-02-23 20:25, Kevin Wolf wrote: > With the conversion to a QAPI options object, the function is now > prepared to be used in a .bdrv_co_create implementation. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > block/rbd.c | 109 > +++++++++++++++++++++++++++++------------------------------- > 1 file changed, 53 insertions(+), 56 deletions(-) > > diff --git a/block/rbd.c b/block/rbd.c > index 2e79c2d1fd..9b247f020d 100644 > --- a/block/rbd.c > +++ b/block/rbd.c
[...] > @@ -482,29 +484,27 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb) > qemu_aio_unref(acb); > } > > -static char *qemu_rbd_mon_host(QDict *options, Error **errp) > +static char *qemu_rbd_mon_host(BlockdevOptionsRbd *opts, Error **errp) > { > - const char **vals = g_new(const char *, qdict_size(options) + 1); > - char keybuf[32]; > + const char **vals; > const char *host, *port; > char *rados_str; > - int i; > - > - for (i = 0;; i++) { > - sprintf(keybuf, "server.%d.host", i); > - host = qdict_get_try_str(options, keybuf); > - qdict_del(options, keybuf); > - sprintf(keybuf, "server.%d.port", i); > - port = qdict_get_try_str(options, keybuf); > - qdict_del(options, keybuf); > - if (!host && !port) { > - break; > - } > - if (!host) { > - error_setg(errp, "Parameter server.%d.host is missing", i); > - rados_str = NULL; > - goto out; > - } > + InetSocketAddressBaseList *p; > + int i, cnt; > + > + if (!opts->has_server) { > + return NULL; > + } > + > + for (cnt = 0, p = opts->server; p; p = p->next) { > + cnt++; > + } > + > + vals = g_new(const char *, cnt + 1); > + > + for (i = 0, p = opts->server; p; p = p->next, i++) { > + host = p->value->host; > + port = p->value->port; > > if (strchr(host, ':')) { > vals[i] = port ? g_strdup_printf("[%s]:%s", host, port) host *and* port are mandatory, so this and the next ternary can be simplified, too. ;-) But not necessary, so: Reviewed-by: Max Reitz <mre...@redhat.com>
signature.asc
Description: OpenPGP digital signature