From patchwork Thu Apr 1 17:57:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 49228 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 ozlabs.org (Postfix) with ESMTPS id 57185B7D12 for ; Fri, 2 Apr 2010 04:59:54 +1100 (EST) Received: from localhost ([127.0.0.1]:54693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxOgJ-0004Dr-NY for incoming@patchwork.ozlabs.org; Thu, 01 Apr 2010 13:59:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NxOe5-0003q1-6b for qemu-devel@nongnu.org; Thu, 01 Apr 2010 13:57:33 -0400 Received: from [140.186.70.92] (port=59619 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxOe2-0003pK-00 for qemu-devel@nongnu.org; Thu, 01 Apr 2010 13:57:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NxOe0-0004ym-J9 for qemu-devel@nongnu.org; Thu, 01 Apr 2010 13:57:29 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:44407) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NxOe0-0004yh-Ce for qemu-devel@nongnu.org; Thu, 01 Apr 2010 13:57:28 -0400 Received: by pwi6 with SMTP id 6so1218687pwi.4 for ; Thu, 01 Apr 2010 10:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=niVYczibq0vfbg812uYljfK6pcb1uQPgDTQPSjVVtpU=; b=s906dFdie+kLqBbA8n8xbKG4jKVGTscETLr1X1i+VWzVI2swfUI/9ewp8JRn7zN5HQ JypFjq4KB1XkWzd9FnjymwWy5fLfhM6VwHYx9cUxJBgcUz2LDPnlQDMZu8cLkiTdySaI VmLInkmIhohevhH9G2evvdboIiscnEPQEG5KY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; b=brH9VsYnhPxnhh7RHoITUKUp9nlGWaQTjjXiEoDahoFdkuW6s3UfqhnhExRComLcKn Becs3E7SXQS+NB3qSpzaroEmGzb49GuRWUJe76GwueMCD//d5RXe5eyGZiXEwX8GcvkD TWwOmiJAweb4vRxN8Ugg/2sOB/wvLUQ/aGVj0= Received: by 10.142.119.3 with SMTP id r3mr437156wfc.145.1270144647303; Thu, 01 Apr 2010 10:57:27 -0700 (PDT) Received: from localhost.localdomain (93-34-197-68.ip51.fastwebnet.it [93.34.197.68]) by mx.google.com with ESMTPS id c21sm8510833ibr.22.2010.04.01.10.57.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 01 Apr 2010 10:57:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 1 Apr 2010 19:57:08 +0200 Message-Id: <1270144632-25063-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1270144632-25063-1-git-send-email-pbonzini@redhat.com> References: <1270144632-25063-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 1/5] move socket_init to qemu-sockets.c 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 Signed-off-by: Paolo Bonzini --- qemu-sockets.c | 24 ++++++++++++++++++++++++ qemu_socket.h | 1 + vl.c | 24 ------------------------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/qemu-sockets.c b/qemu-sockets.c index 23c3def..a7399aa 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -648,3 +648,27 @@ int unix_connect(const char *path) } #endif + +#ifdef _WIN32 +static void socket_cleanup(void) +{ + WSACleanup(); +} +#endif + +int socket_init(void) +{ +#ifdef _WIN32 + WSADATA Data; + int ret, err; + + ret = WSAStartup(MAKEWORD(2,2), &Data); + if (ret != 0) { + err = WSAGetLastError(); + fprintf(stderr, "WSAStartup: %d\n", err); + return -1; + } + atexit(socket_cleanup); +#endif + return 0; +} diff --git a/qemu_socket.h b/qemu_socket.h index 7ee46ac..164ae3e 100644 --- a/qemu_socket.h +++ b/qemu_socket.h @@ -56,5 +56,6 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str); int parse_host_src_port(struct sockaddr_in *haddr, struct sockaddr_in *saddr, const char *str); +int socket_init(void); #endif /* QEMU_SOCKET_H */ diff --git a/vl.c b/vl.c index 6768cf1..9ce6e4c 100644 --- a/vl.c +++ b/vl.c @@ -494,28 +494,6 @@ static void configure_rtc(QemuOpts *opts) } } -#ifdef _WIN32 -static void socket_cleanup(void) -{ - WSACleanup(); -} - -static int socket_init(void) -{ - WSADATA Data; - int ret, err; - - ret = WSAStartup(MAKEWORD(2,2), &Data); - if (ret != 0) { - err = WSAGetLastError(); - fprintf(stderr, "WSAStartup: %d\n", err); - return -1; - } - atexit(socket_cleanup); - return 0; -} -#endif - /***********************************************************/ /* Bluetooth support */ static int nb_hcis; @@ -3622,9 +3600,7 @@ int main(int argc, char **argv, char **envp) } configure_icount(icount_option); -#ifdef _WIN32 socket_init(); -#endif if (net_init_clients() < 0) { exit(1);