qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] rbd: allow client id to be specified in conf


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2] rbd: allow client id to be specified in config string
Date: Tue, 23 Aug 2011 08:58:29 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Aug 22, 2011 at 02:45:48PM -0700, Sage Weil wrote:
> diff --git a/block/rbd.c b/block/rbd.c
> index d5659cd..b0cd750 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -169,6 +169,34 @@ done:
>      return ret;
>  }
>  
> +static char *qemu_rbd_parse_clientname(const char *conf, char *clientname)
> +{
> +    const char *p = conf;
> +
> +    while (*p) {
> +     int len;
> +     const char *end = strchr(p, ':');
> +
> +     if (end) {
> +         len = end - p;
> +     } else {
> +         len = strlen(p);
> +     }
> +
> +     if (strncmp(p, "id=", 3) == 0) {
> +         len -= 3;
> +         strncpy(clientname, p + 3, len);
> +         clientname[len] = '\0';
> +         return clientname;
> +     }
> +     if (end == NULL) {
> +         break;
> +     }
> +     p = end + 1;
> +    }
> +    return NULL;
> +}

Please run scripts/checkpatch.pl to check coding style.  You are using
tab characters, QEMU uses 4 spaces for indentation instead of tabs.

> @@ -398,7 +433,8 @@ static int qemu_rbd_open(BlockDriverState *bs, const char 
> *filename, int flags)
>          s->snap = qemu_strdup(snap_buf);
>      }
>  
> -    r = rados_create(&s->cluster, NULL);
> +    clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
> +    r = rados_create(&s->cluster, clientname);
>      if (r < 0) {
>          error_report("error initializing");
>          return r;

s->snap may be leaked here.  If .bdrv_file_open() fails .bdrv_close()
will not be called to clean things up.

Stefan



reply via email to

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