summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/bitmap.c8
-rw-r--r--util/event_notifier-posix.c9
-rw-r--r--util/event_notifier-win32.c12
-rw-r--r--util/qemu-sockets.c11
-rw-r--r--util/qemu-thread-posix.c12
-rw-r--r--util/qemu-thread-win32.c4
6 files changed, 25 insertions, 31 deletions
diff --git a/util/bitmap.c b/util/bitmap.c
index 43ed011720..c1a84ca5e3 100644
--- a/util/bitmap.c
+++ b/util/bitmap.c
@@ -164,6 +164,8 @@ void bitmap_set(unsigned long *map, long start, long nr)
int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
+ assert(start >= 0 && nr >= 0);
+
while (nr - bits_to_set >= 0) {
*p |= mask_to_set;
nr -= bits_to_set;
@@ -184,6 +186,8 @@ void bitmap_set_atomic(unsigned long *map, long start, long nr)
int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
+ assert(start >= 0 && nr >= 0);
+
/* First word */
if (nr - bits_to_set > 0) {
atomic_or(p, mask_to_set);
@@ -221,6 +225,8 @@ void bitmap_clear(unsigned long *map, long start, long nr)
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
+ assert(start >= 0 && nr >= 0);
+
while (nr - bits_to_clear >= 0) {
*p &= ~mask_to_clear;
nr -= bits_to_clear;
@@ -243,6 +249,8 @@ bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr)
unsigned long dirty = 0;
unsigned long old_bits;
+ assert(start >= 0 && nr >= 0);
+
/* First word */
if (nr - bits_to_clear > 0) {
old_bits = atomic_fetch_and(p, ~mask_to_clear);
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index f2aacfc8b3..7e40252ade 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -90,15 +90,6 @@ int event_notifier_get_fd(const EventNotifier *e)
return e->rfd;
}
-int event_notifier_set_handler(EventNotifier *e,
- bool is_external,
- EventNotifierHandler *handler)
-{
- aio_set_fd_handler(iohandler_get_aio_context(), e->rfd, is_external,
- (IOHandler *)handler, NULL, NULL, e);
- return 0;
-}
-
int event_notifier_set(EventNotifier *e)
{
static const uint64_t value = 1;
diff --git a/util/event_notifier-win32.c b/util/event_notifier-win32.c
index de87df02d6..519fb59123 100644
--- a/util/event_notifier-win32.c
+++ b/util/event_notifier-win32.c
@@ -32,18 +32,6 @@ HANDLE event_notifier_get_handle(EventNotifier *e)
return e->event;
}
-int event_notifier_set_handler(EventNotifier *e,
- bool is_external,
- EventNotifierHandler *handler)
-{
- if (handler) {
- return qemu_add_wait_object(e->event, (IOHandler *)handler, e);
- } else {
- qemu_del_wait_object(e->event, (IOHandler *)handler, e);
- return 0;
- }
-}
-
int event_notifier_set(EventNotifier *e)
{
SetEvent(e->event);
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index fe1d07aaef..7c120c45ce 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -38,6 +38,10 @@
# define AI_V4MAPPED 0
#endif
+#ifndef AI_NUMERICSERV
+# define AI_NUMERICSERV 0
+#endif
+
static int inet_getport(struct addrinfo *e)
{
@@ -110,8 +114,8 @@ NetworkAddressFamily inet_netfamily(int family)
* outside scope of this method and not currently handled by
* callers at all.
*/
-static int inet_ai_family_from_address(InetSocketAddress *addr,
- Error **errp)
+int inet_ai_family_from_address(InetSocketAddress *addr,
+ Error **errp)
{
if (addr->has_ipv6 && addr->has_ipv4 &&
!addr->ipv6 && !addr->ipv4) {
@@ -141,6 +145,9 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_PASSIVE;
+ if (saddr->has_numeric && saddr->numeric) {
+ ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
+ }
ai.ai_family = inet_ai_family_from_address(saddr, &err);
ai.ai_socktype = SOCK_STREAM;
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 37cd8ba3fe..73e3a0edf5 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -458,12 +458,6 @@ void qemu_thread_create(QemuThread *thread, const char *name,
if (err) {
error_exit(err, __func__);
}
- if (mode == QEMU_THREAD_DETACHED) {
- err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (err) {
- error_exit(err, __func__);
- }
- }
/* Leave signal handling to the iothread. */
sigfillset(&set);
@@ -476,6 +470,12 @@ void qemu_thread_create(QemuThread *thread, const char *name,
qemu_thread_set_name(thread, name);
}
+ if (mode == QEMU_THREAD_DETACHED) {
+ err = pthread_detach(thread->thread);
+ if (err) {
+ error_exit(err, __func__);
+ }
+ }
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
pthread_attr_destroy(&attr);
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index 178e0168a1..29c3e4dd85 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -497,8 +497,8 @@ HANDLE qemu_thread_get_handle(QemuThread *thread)
EnterCriticalSection(&data->cs);
if (!data->exited) {
- handle = OpenThread(SYNCHRONIZE | THREAD_SUSPEND_RESUME, FALSE,
- thread->tid);
+ handle = OpenThread(SYNCHRONIZE | THREAD_SUSPEND_RESUME |
+ THREAD_SET_CONTEXT, FALSE, thread->tid);
} else {
handle = NULL;
}