2014-03-03 18:30:05 +08:00
|
|
|
/*
|
|
|
|
* Event loop thread
|
|
|
|
*
|
|
|
|
* Copyright Red Hat Inc., 2013
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IOTHREAD_H
|
|
|
|
#define IOTHREAD_H
|
|
|
|
|
|
|
|
#include "block/aio.h"
|
2014-03-20 22:06:31 +08:00
|
|
|
#include "qemu/thread.h"
|
2014-03-03 18:30:05 +08:00
|
|
|
|
|
|
|
#define TYPE_IOTHREAD "iothread"
|
|
|
|
|
2014-03-20 22:06:31 +08:00
|
|
|
typedef struct {
|
|
|
|
Object parent_obj;
|
|
|
|
|
|
|
|
QemuThread thread;
|
|
|
|
AioContext *ctx;
|
2017-08-29 15:22:37 +08:00
|
|
|
GMainContext *worker_context;
|
|
|
|
GMainLoop *main_loop;
|
|
|
|
GOnce once;
|
2014-03-20 22:06:31 +08:00
|
|
|
QemuMutex init_done_lock;
|
|
|
|
QemuCond init_done_cond; /* is thread initialization done? */
|
|
|
|
bool stopping;
|
|
|
|
int thread_id;
|
2016-12-02 03:26:45 +08:00
|
|
|
|
|
|
|
/* AioContext poll parameters */
|
|
|
|
int64_t poll_max_ns;
|
2016-12-02 03:26:52 +08:00
|
|
|
int64_t poll_grow;
|
|
|
|
int64_t poll_shrink;
|
2014-03-20 22:06:31 +08:00
|
|
|
} IOThread;
|
2014-03-03 18:30:05 +08:00
|
|
|
|
|
|
|
#define IOTHREAD(obj) \
|
|
|
|
OBJECT_CHECK(IOThread, obj, TYPE_IOTHREAD)
|
|
|
|
|
|
|
|
char *iothread_get_id(IOThread *iothread);
|
2017-12-06 22:45:48 +08:00
|
|
|
IOThread *iothread_by_id(const char *id);
|
2014-03-03 18:30:05 +08:00
|
|
|
AioContext *iothread_get_aio_context(IOThread *iothread);
|
2016-09-08 17:28:51 +08:00
|
|
|
void iothread_stop_all(void);
|
2017-08-29 15:22:37 +08:00
|
|
|
GMainContext *iothread_get_g_main_context(IOThread *iothread);
|
2014-03-03 18:30:05 +08:00
|
|
|
|
2017-09-28 10:59:55 +08:00
|
|
|
/*
|
|
|
|
* Helpers used to allocate iothreads for internal use. These
|
|
|
|
* iothreads will not be seen by monitor clients when query using
|
|
|
|
* "query-iothreads".
|
|
|
|
*/
|
|
|
|
IOThread *iothread_create(const char *id, Error **errp);
|
2017-09-28 10:59:56 +08:00
|
|
|
void iothread_stop(IOThread *iothread);
|
2017-09-28 10:59:55 +08:00
|
|
|
void iothread_destroy(IOThread *iothread);
|
|
|
|
|
2014-03-03 18:30:05 +08:00
|
|
|
#endif /* IOTHREAD_H */
|