qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 3/3] sheepdog: add support for connecting to


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 3/3] sheepdog: add support for connecting to unix domain socket
Date: Mon, 21 Jan 2013 09:57:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

Il 21/01/2013 01:23, MORITA Kazutaka ha scritto:
> This patch adds support for a unix domain socket for a connection
> between qemu and local sheepdog server.  You can use the unix domain
> socket with the following syntax like NBD driver:
> 
>  $ qemu sheepdog:unix:<socket path>:<image name>
> 
> Note that <socket path> must be an absolute path.

Please look at how NBD supports URIs.  Something like

  sheepdog[+tcp|+unix]://[host:port]/vdiname[/snapid|/tag][?socket=path]

or

  sheepdog[+tcp|+unix]://[host:port]/vdiname[?socket=path][#snapid|#tag]

would be similar to what we use for NBD and Gluster.

Paolo

> 
> Signed-off-by: MORITA Kazutaka <address@hidden>
> ---
>  block/sheepdog.c |   37 +++++++++++++++++++++----------------
>  qemu-options.hx  |   19 +++++++++----------
>  2 files changed, 30 insertions(+), 26 deletions(-)
> 
> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index c287827..34685fd 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -296,7 +296,9 @@ typedef struct BDRVSheepdogState {
>      bool is_snapshot;
>      uint32_t cache_flags;
>  
> -    /* It's a string of the form <hostname>:<port> */
> +    /* If it begins with  'unix:/', this is a UNIX domain socket. Otherwise,
> +     * it's a string of the form <hostname>:<port>
> +     */
>      char *host_spec;
>  
>      int fd;
> @@ -449,13 +451,25 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState 
> *bs, QEMUIOVector *qiov,
>  static int connect_to_sdog(const char *host_spec)
>  {
>      int fd;
> +    const char *path;
>      Error *err = NULL;
>  
>      if (host_spec == NULL) {
>          host_spec = SD_DEFAULT_ADDR_AND_PORT;
>      }
>  
> -    fd = inet_connect(host_spec, &err);
> +    if (strstart(host_spec, "unix:", &path) && path[0] == '/') {
> +        fd = unix_connect(path, &err);
> +    } else {
> +        fd = inet_connect(host_spec, &err);
> +
> +        if (err == NULL) {
> +            int ret = socket_set_nodelay(fd);
> +            if (ret < 0) {
> +                error_report("%s", strerror(errno));
> +            }
> +        }
> +    }
>  
>      if (err != NULL) {
>          qerror_report_err(err);
> @@ -761,7 +775,7 @@ static int aio_flush_request(void *opaque)
>   */
>  static int get_sheep_fd(BDRVSheepdogState *s)
>  {
> -    int ret, fd;
> +    int fd;
>  
>      fd = connect_to_sdog(s->host_spec);
>      if (fd < 0) {
> @@ -770,13 +784,6 @@ static int get_sheep_fd(BDRVSheepdogState *s)
>  
>      socket_set_nonblock(fd);
>  
> -    ret = socket_set_nodelay(fd);
> -    if (ret) {
> -        error_report("%s", strerror(errno));
> -        closesocket(fd);
> -        return -errno;
> -    }
> -
>      qemu_aio_set_fd_handler(fd, co_read_response, NULL, aio_flush_request, 
> s);
>      return fd;
>  }
> @@ -785,12 +792,10 @@ static int get_sheep_fd(BDRVSheepdogState *s)
>   * Parse a filename
>   *
>   * filename must be one of the following formats:
> - *   1. [vdiname]
> - *   2. [vdiname]:[snapid]
> - *   3. [vdiname]:[tag]
> - *   4. [hostname]:[port]:[vdiname]
> - *   5. [hostname]:[port]:[vdiname]:[snapid]
> - *   6. [hostname]:[port]:[vdiname]:[tag]
> + *   - using TCP
> + *     [<hostname>:<port>:]<vdiname>[:<snapid or tag>]
> + *   - using Unix Domain Socket
> + *     unix:<domain-socket>:<vdiname>[:<snapid or tag>]
>   *
>   * You can boot from the snapshot images by specifying `snapid` or
>   * `tag'.
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 40cd683..0583b4a 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2061,17 +2061,16 @@ devices.
>  
>  Syntax for specifying a sheepdog device
>  @table @list
> -``sheepdog:<vdiname>''
> -
> -``sheepdog:<vdiname>:<snapid>''
> -
> -``sheepdog:<vdiname>:<tag>''
> -
> -``sheepdog:<host>:<port>:<vdiname>''
> -
> -``sheepdog:<host>:<port>:<vdiname>:<snapid>''
> +using TCP:
> address@hidden
> +sheepdog:[<hostname>:<port>:]<vdiname>[:<snapid or tag>]
> address@hidden example
>  
> -``sheepdog:<host>:<port>:<vdiname>:<tag>''
> +using Unix Domain Socket:
> address@hidden
> +sheepdog:unix:<domain-socket>:<vdiname>[:<snapid or tag>]
> address@hidden example
> +Note that <domain-socket> must be an absolute path.
>  @end table
>  
>  Example
> 




reply via email to

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