From patchwork Thu Sep 10 08:58:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id A3D01B707B for ; Thu, 10 Sep 2009 19:04:45 +1000 (EST) Received: from localhost ([127.0.0.1]:34139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mlfa3-0000uD-QN for incoming@patchwork.ozlabs.org; Thu, 10 Sep 2009 05:04:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlfUk-0005QE-K4 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlfUf-0005Ns-5L for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:09 -0400 Received: from [199.232.76.173] (port=49313 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlfUe-0005NY-P9 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41175) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlfUd-0007Up-QQ for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:04 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8A8x0X5012246 for ; Thu, 10 Sep 2009 04:59:00 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-74.ams2.redhat.com [10.36.9.74]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n8A8ww1E020705; Thu, 10 Sep 2009 04:58:58 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 54377700D7; Thu, 10 Sep 2009 10:58:56 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 10:58:37 +0200 Message-Id: <1252573135-27688-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1252573135-27688-1-git-send-email-kraxel@redhat.com> References: <1252573135-27688-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2 05/23] sockets: add unix_connect_opts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add unix_connect_opts(). Does the same as unix_connect(), but uses QemuOpts. unix_connect() is a compatibility wrapper for unix_connect_opts() now and should go away some day. Signed-off-by: Gerd Hoffmann --- qemu-sockets.c | 34 +++++++++++++++++++++++++++++++++- qemu_socket.h | 3 +++ 2 files changed, 36 insertions(+), 1 deletions(-) diff --git a/qemu-sockets.c b/qemu-sockets.c index bd49d29..732d3e0 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -29,6 +29,19 @@ static int sockets_debug = 0; static const int on=1, off=0; +/* used temporarely until all users are converted to QemuOpts */ +QemuOptsList dummy_opts = { + .name = "dummy", + .head = TAILQ_HEAD_INITIALIZER(dummy_opts.head), + .desc = { + { + .name = "path", + .type = QEMU_OPT_STRING, + }, + { /* end if list */ } + }, +}; + static int inet_getport(struct addrinfo *e) { struct sockaddr_in *i4; @@ -376,11 +389,17 @@ err: return -1; } -int unix_connect(const char *path) +int unix_connect_opts(QemuOpts *opts) { struct sockaddr_un un; + const char *path = qemu_opt_get(opts, "path"); int sock; + if (NULL == path) { + fprintf(stderr, "unix connect: no path specified\n"); + return -1; + } + sock = socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { perror("socket(unix)"); @@ -400,6 +419,19 @@ int unix_connect(const char *path) return sock; } +/* compatibility wrapper */ +int unix_connect(const char *path) +{ + QemuOpts *opts; + int sock; + + opts = qemu_opts_create(&dummy_opts, NULL, 0); + qemu_opt_set(opts, "path", path); + sock = unix_connect_opts(opts); + qemu_opts_del(opts); + return sock; +} + #else int unix_listen(const char *path, char *ostr, int olen) diff --git a/qemu_socket.h b/qemu_socket.h index fc5b588..7ca4af7 100644 --- a/qemu_socket.h +++ b/qemu_socket.h @@ -29,6 +29,8 @@ int inet_aton(const char *cp, struct in_addr *ia); #endif /* !_WIN32 */ +#include "qemu-option.h" + /* misc helpers */ void socket_set_nonblock(int fd); int send_all(int fd, const void *buf, int len1); @@ -39,6 +41,7 @@ int inet_listen(const char *str, char *ostr, int olen, int inet_connect(const char *str, int socktype); int unix_listen(const char *path, char *ostr, int olen); +int unix_connect_opts(QemuOpts *opts); int unix_connect(const char *path); /* Old, ipv4 only bits. Don't use for new code. */