qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 21/36] rbd: Pass BlockdevOptionsRbd to qemu_r


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v3 21/36] rbd: Pass BlockdevOptionsRbd to qemu_rbd_connect()
Date: Mon, 26 Feb 2018 13:23:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

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 <address@hidden>
> ---
>  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 <address@hidden>

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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