diff mbox

[1/3] move socket_init to qemu-sockets.c

Message ID 1270047363-12627-2-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini March 31, 2010, 2:56 p.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-sockets.c |   24 ++++++++++++++++++++++++
 qemu_socket.h  |    1 +
 vl.c           |   24 ------------------------
 3 files changed, 25 insertions(+), 24 deletions(-)
diff mbox

Patch

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);