X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=iothread.c;h=f183d380e6a440e3c8846a1ac38fab5bc3c94866;hb=56f101ecce0eafd09e2daf1c4eeb1377d6959261;hp=0416fc4268c3db241bad9421724894a2e6069787;hpb=0403b0f539f40a21da60409b825b4653b273ab39;p=mirror_qemu.git diff --git a/iothread.c b/iothread.c index 0416fc4268..f183d380e6 100644 --- a/iothread.c +++ b/iothread.c @@ -11,6 +11,7 @@ * */ +#include "qemu/osdep.h" #include "qom/object.h" #include "qom/object_interfaces.h" #include "qemu/module.h" @@ -18,8 +19,7 @@ #include "sysemu/iothread.h" #include "qmp-commands.h" #include "qemu/error-report.h" - -#define IOTHREADS_PATH "/objects" +#include "qemu/rcu.h" typedef ObjectClass IOThreadClass; @@ -31,15 +31,26 @@ typedef ObjectClass IOThreadClass; static void *iothread_run(void *opaque) { IOThread *iothread = opaque; + bool blocking; + + rcu_register_thread(); qemu_mutex_lock(&iothread->init_done_lock); iothread->thread_id = qemu_get_thread_id(); qemu_cond_signal(&iothread->init_done_cond); qemu_mutex_unlock(&iothread->init_done_lock); - while (!atomic_read(&iothread->stopping)) { - aio_poll(iothread->ctx, true); + while (!iothread->stopping) { + aio_context_acquire(iothread->ctx); + blocking = true; + while (!iothread->stopping && aio_poll(iothread->ctx, blocking)) { + /* Progress was made, keep going */ + blocking = false; + } + aio_context_release(iothread->ctx); } + + rcu_unregister_thread(); return NULL; } @@ -62,6 +73,7 @@ static void iothread_complete(UserCreatable *obj, Error **errp) { Error *local_error = NULL; IOThread *iothread = IOTHREAD(obj); + char *name, *thread_name; iothread->stopping = false; iothread->thread_id = -1; @@ -77,8 +89,12 @@ static void iothread_complete(UserCreatable *obj, Error **errp) /* This assumes we are called from a thread with useful CPU affinity for us * to inherit. */ - qemu_thread_create(&iothread->thread, "iothread", iothread_run, + name = object_get_canonical_path_component(OBJECT(obj)); + thread_name = g_strdup_printf("IO %s", name); + qemu_thread_create(&iothread->thread, thread_name, iothread_run, iothread, QEMU_THREAD_JOINABLE); + g_free(thread_name); + g_free(name); /* Wait for initialization to complete */ qemu_mutex_lock(&iothread->init_done_lock); @@ -153,7 +169,7 @@ IOThreadInfoList *qmp_query_iothreads(Error **errp) { IOThreadInfoList *head = NULL; IOThreadInfoList **prev = &head; - Object *container = container_get(object_get_root(), IOTHREADS_PATH); + Object *container = object_get_objects_root(); object_child_foreach(container, query_one_iothread, &prev); return head;