aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/aio-win32.c2
-rw-r--r--util/error.c5
-rw-r--r--util/log.c2
-rw-r--r--util/oslib-posix.c9
-rw-r--r--util/oslib-win32.c29
5 files changed, 36 insertions, 11 deletions
diff --git a/util/aio-win32.c b/util/aio-win32.c
index 6583d5c..c6fbce6 100644
--- a/util/aio-win32.c
+++ b/util/aio-win32.c
@@ -121,7 +121,7 @@ void aio_set_fd_handler(AioContext *ctx,
QLIST_INSERT_HEAD_RCU(&ctx->aio_handlers, node, node);
event = event_notifier_get_handle(&ctx->notifier);
- qemu_socket_select(fd, event, bitmask, NULL);
+ qemu_socket_select_nofail(fd, event, bitmask);
}
if (old_node) {
aio_remove_fd_handler(ctx, old_node);
diff --git a/util/error.c b/util/error.c
index daea214..0ae0822 100644
--- a/util/error.c
+++ b/util/error.c
@@ -19,7 +19,6 @@
Error *error_abort;
Error *error_fatal;
-Error *error_warn;
static void error_handle(Error **errp, Error *err)
{
@@ -41,9 +40,7 @@ static void error_handle(Error **errp, Error *err)
error_report_err(err);
exit(1);
}
- if (errp == &error_warn) {
- warn_report_err(err);
- } else if (errp && !*errp) {
+ if (errp && !*errp) {
*errp = err;
} else {
error_free(err);
diff --git a/util/log.c b/util/log.c
index abdcb6b..41f78ce 100644
--- a/util/log.c
+++ b/util/log.c
@@ -44,7 +44,7 @@ static FILE *global_file;
static __thread FILE *thread_file;
static __thread Notifier qemu_log_thread_cleanup_notifier;
-int qemu_loglevel;
+unsigned qemu_loglevel;
static bool log_per_thread;
static GArray *debug_regions;
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 14cf94a..3c14b72 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -305,6 +305,15 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2])
return ret;
}
+void qemu_clear_cloexec(int fd)
+{
+ int f;
+ f = fcntl(fd, F_GETFD);
+ assert(f != -1);
+ f = fcntl(fd, F_SETFD, f & ~FD_CLOEXEC);
+ assert(f != -1);
+}
+
char *
qemu_get_local_state_dir(void)
{
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index b9ce2f9..839b8a4 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -182,7 +182,7 @@ bool qemu_set_blocking(int fd, bool block, Error **errp)
unsigned long opt = block ? 0 : 1;
if (block) {
- qemu_socket_unselect(fd, NULL);
+ qemu_socket_unselect_nofail(fd);
}
if (ioctlsocket(fd, FIONBIO, &opt) != NO_ERROR) {
@@ -219,6 +219,10 @@ void qemu_set_cloexec(int fd)
{
}
+void qemu_clear_cloexec(int fd)
+{
+}
+
int qemu_get_thread_id(void)
{
return GetCurrentThreadId();
@@ -293,10 +297,6 @@ bool qemu_socket_select(int sockfd, WSAEVENT hEventObject,
{
SOCKET s = _get_osfhandle(sockfd);
- if (errp == NULL) {
- errp = &error_warn;
- }
-
if (s == INVALID_SOCKET) {
error_setg(errp, "invalid socket fd=%d", sockfd);
return false;
@@ -315,6 +315,25 @@ bool qemu_socket_unselect(int sockfd, Error **errp)
return qemu_socket_select(sockfd, NULL, 0, errp);
}
+void qemu_socket_select_nofail(int sockfd, WSAEVENT hEventObject,
+ long lNetworkEvents)
+{
+ Error *err = NULL;
+
+ if (!qemu_socket_select(sockfd, hEventObject, lNetworkEvents, &err)) {
+ warn_report_err(err);
+ }
+}
+
+void qemu_socket_unselect_nofail(int sockfd)
+{
+ Error *err = NULL;
+
+ if (!qemu_socket_unselect(sockfd, &err)) {
+ warn_report_err(err);
+ }
+}
+
int qemu_socketpair(int domain, int type, int protocol, int sv[2])
{
struct sockaddr_un addr = {