From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDT2-0001Gt-7Q for qemu-devel@nongnu.org; Wed, 16 Sep 2015 10:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDT1-0006Fn-7k for qemu-devel@nongnu.org; Wed, 16 Sep 2015 10:13:48 -0400 Date: Wed, 16 Sep 2015 15:13:35 +0100 From: "Daniel P. Berrange" Message-ID: <20150916141335.GF21184@redhat.com> References: <1442411543-28513-1-git-send-email-berrange@redhat.com> <1442411543-28513-3-git-send-email-berrange@redhat.com> <55F977E3.2060807@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <55F977E3.2060807@redhat.com> Subject: Re: [Qemu-devel] [PATCH v1 2/2] qemu-nbd: convert to use the QAPI SocketAddress object Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, qemu-block@nongnu.org On Wed, Sep 16, 2015 at 08:08:35AM -0600, Eric Blake wrote: > On 09/16/2015 07:52 AM, Daniel P. Berrange wrote: > > The qemu-nbd program currently uses a QemuOpts objects > > when setting up sockets. Switch it over to use the > > QAPI SocketAddress objects instead. > > > > Signed-off-by: Daniel P. Berrange > > --- > > qemu-nbd.c | 102 +++++++++++++++++++++++-------------------------------------- > > 1 file changed, 38 insertions(+), 64 deletions(-) > > > > > +static SocketAddress *nbd_build_socket_address(const char *sockpath, > > + const char *bindto, > > + const char *port) > > +{ > > + SocketAddress *saddr; > > + > > + saddr = g_new0(SocketAddress, 1); > > + if (sockpath) { > > + saddr->kind = SOCKET_ADDRESS_KIND_UNIX; > > More minor conflicts with my qapi cleanups. Not a show-stopper. > > > + saddr->q_unix = g_new0(UnixSocketAddress, 1); > > + saddr->q_unix->path = g_strdup(sockpath); > > + } else { > > + saddr->kind = SOCKET_ADDRESS_KIND_INET; > > + saddr->inet = g_new0(InetSocketAddress, 1); > > + saddr->inet->host = g_strdup(bindto); > > + if (port) { > > + saddr->inet->port = g_strdup(port); > > + } else { > > + saddr->inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT); > > The qapi type is gross for requiring port as a string. But we have plans > to clean that up, not a showstopper for this patch. On the contrary - QAPI is correct in requiring this, as it lets you provide a service name (as defined in /etc/services) instead of a numeric port, and getaddrinfo() will look that up and convert to numeric format. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|