From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxDCJ-0002Mk-3f for qemu-devel@nongnu.org; Mon, 21 Jan 2013 03:57:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TxDCH-0007N9-CX for qemu-devel@nongnu.org; Mon, 21 Jan 2013 03:57:43 -0500 Received: from mail-ea0-f174.google.com ([209.85.215.174]:54622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxDCH-0007N3-2j for qemu-devel@nongnu.org; Mon, 21 Jan 2013 03:57:41 -0500 Received: by mail-ea0-f174.google.com with SMTP id 1so2306027eaa.5 for ; Mon, 21 Jan 2013 00:57:40 -0800 (PST) Sender: Paolo Bonzini Message-ID: <50FD0300.8030006@redhat.com> Date: Mon, 21 Jan 2013 09:57:36 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1358727810-24055-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <1358727810-24055-4-git-send-email-morita.kazutaka@lab.ntt.co.jp> In-Reply-To: <1358727810-24055-4-git-send-email-morita.kazutaka@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 3/3] sheepdog: add support for connecting to unix domain socket List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: MORITA Kazutaka Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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:: > > Note that 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 > --- > 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 : */ > + /* If it begins with 'unix:/', this is a UNIX domain socket. Otherwise, > + * it's a string of the form : > + */ > 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 > + * [::][:] > + * - using Unix Domain Socket > + * unix::[:] > * > * 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:'' > - > -``sheepdog::'' > - > -``sheepdog::'' > - > -``sheepdog:::'' > - > -``sheepdog::::'' > +using TCP: > +@example > +sheepdog:[::][:] > +@end example > > -``sheepdog::::'' > +using Unix Domain Socket: > +@example > +sheepdog:unix::[:] > +@end example > +Note that must be an absolute path. > @end table > > Example >