98 lines
2.4 KiB
Diff
98 lines
2.4 KiB
Diff
|
From 2f2068568e87fc1f20bc891cce18b4e65965b091 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
||
|
Date: Mon, 25 Feb 2013 23:31:11 +0100
|
||
|
Subject: [PATCH 217/241] util: move socket_init() to osdep.c
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
vscclient needs to call socket_init() for portability.
|
||
|
Moving to osdep.c since it has no internal dependency.
|
||
|
|
||
|
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||
|
Reviewed-by: Alon Levy <alevy@redhat.com>
|
||
|
(cherry picked from commit d3bf825e59125bc6a0accec0dca119ea0155cb82)
|
||
|
|
||
|
Conflicts:
|
||
|
util/qemu-sockets.c
|
||
|
---
|
||
|
util/osdep.c | 23 +++++++++++++++++++++++
|
||
|
util/qemu-sockets.c | 26 +-------------------------
|
||
|
2 files changed, 24 insertions(+), 25 deletions(-)
|
||
|
|
||
|
diff --git a/util/osdep.c b/util/osdep.c
|
||
|
index 5b51a03..3c1a0a3 100644
|
||
|
--- a/util/osdep.c
|
||
|
+++ b/util/osdep.c
|
||
|
@@ -400,3 +400,26 @@ bool fips_get_state(void)
|
||
|
return fips_enabled;
|
||
|
}
|
||
|
|
||
|
+#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/util/qemu-sockets.c b/util/qemu-sockets.c
|
||
|
index b32510a..7909381 100644
|
||
|
--- a/util/qemu-sockets.c
|
||
|
+++ b/util/qemu-sockets.c
|
||
|
@@ -618,7 +618,7 @@ int inet_connect(const char *str, Error **errp)
|
||
|
|
||
|
addr = inet_parse(str, errp);
|
||
|
if (addr != NULL) {
|
||
|
- opts = qemu_opts_create_nofail(&dummy_opts);
|
||
|
+ opts = qemu_opts_create_nofail(&socket_optslist);
|
||
|
inet_addr_to_opts(opts, addr);
|
||
|
qapi_free_InetSocketAddress(addr);
|
||
|
sock = inet_connect_opts(opts, errp, NULL, NULL);
|
||
|
@@ -945,27 +945,3 @@ int socket_listen(SocketAddress *addr, Error **errp)
|
||
|
qemu_opts_del(opts);
|
||
|
return fd;
|
||
|
}
|
||
|
-
|
||
|
-#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;
|
||
|
-}
|
||
|
--
|
||
|
1.8.3.1
|
||
|
|