Received: from eggs.gnu.org ([208.118.235.92]:56230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7kU-0008TU-Ma for qemu-devel@nongnu.org; Fri, 19 Oct 2012 04:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TP7kQ-0004xx-40 for qemu-devel@nongnu.org; Fri, 19 Oct 2012 04:16:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7kP-0004xq-Qt for qemu-devel@nongnu.org; Fri, 19 Oct 2012 04:16:02 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9J8G0DX003802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Oct 2012 04:16:00 -0400 From: Markus Armbruster References: <1349877786-23514-1-git-send-email-pbonzini@redhat.com> <1349877786-23514-23-git-send-email-pbonzini@redhat.com> Date: Fri, 19 Oct 2012 10:15:55 +0200 In-Reply-To: <1349877786-23514-23-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Wed, 10 Oct 2012 16:03:03 +0200") Message-ID: <87391alvwk.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 22/25] qemu-sockets: add socket_listen, socket_connect, socket_parse List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com Paolo Bonzini writes: > These are QAPI-friendly versions of the qemu-sockets functions. They > support IP sockets, Unix sockets, and named file descriptors, using a > QAPI union to dispatch to the correct function. > > Reviewed-by: Luiz Capitulino > Signed-off-by: Paolo Bonzini > --- > Makefile | 2 +- > qemu-sockets.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > qemu-tool.c | 6 ++++ > qemu_socket.h | 5 +++ > 4 file modificati, 111 inserzioni(+). 1 rimozione(-) > > diff --git a/Makefile b/Makefile > index a9c22bf..b8b1f3c 100644 > --- a/Makefile > +++ b/Makefile > @@ -159,7 +159,7 @@ qemu-img.o: qemu-img-cmds.h > > tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ > qemu-timer-common.o main-loop.o notify.o \ > - iohandler.o cutils.o iov.o async.o > + iohandler.o cutils.o iov.o async.o error.o > tools-obj-$(CONFIG_POSIX) += compatfd.o > > qemu-img$(EXESUF): qemu-img.o $(tools-obj-y) $(block-obj-y) $(qapi-obj-y) \ > diff --git a/qemu-sockets.c b/qemu-sockets.c > index 5946962..e8d0a3c 100644 > --- a/qemu-sockets.c > +++ b/qemu-sockets.c > @@ -22,6 +22,7 @@ > #include > #include > > +#include "monitor.h" > #include "qemu_socket.h" > #include "qemu-common.h" /* for qemu_isdigit */ > #include "main-loop.h" > @@ -845,6 +846,104 @@ int unix_nonblocking_connect(const char *path, > return sock; > } > > +SocketAddress *socket_parse(const char *str, Error **errp) > +{ > + SocketAddress *addr = NULL; > + > + addr = g_new(SocketAddress, 1); > + if (strstart(str, "unix:", NULL)) { > + if (str[5] == '\0') { > + error_setg(errp, "invalid Unix socket address\n"); > + goto fail; > + } else { > + addr->kind = SOCKET_ADDRESS_KIND_UNIX; > + addr->q_unix = g_new(UnixSocketAddress, 1); > + addr->q_unix->path = g_strdup(str + 5); > + } > + } else if (strstart(str, "fd:", NULL)) { > + if (str[3] == '\0') { > + error_setg(errp, "invalid file descriptor address\n"); > + goto fail; > + } else { > + addr->kind = SOCKET_ADDRESS_KIND_FD; > + addr->fd = g_new(String, 1); > + addr->fd->str = g_strdup(str + 3); > + } > + } else { > + addr->kind = SOCKET_ADDRESS_KIND_INET; > + addr->inet = g_new(IPSocketAddress, 1); > + addr->inet = inet_parse(str, errp); > + if (addr->inet == NULL) { > + goto fail; > + } > + } > + return addr; > + > +fail: > + qapi_free_SocketAddress(addr); > + return NULL; > +} Yet another ad hoc parser. Have you considered sticking to QemuOpts syntax? Hmm, I guess it's for use with the existing ad hoc parser inet_parse(). Correct? [...]