[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 08/14] create main-loop.h
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [RFC PATCH 08/14] create main-loop.h |
Date: |
Fri, 16 Sep 2011 17:09:04 +0200 |
Signed-off-by: Paolo Bonzini <address@hidden>
---
async.c | 1 +
cpus.c | 7 +----
cpus.h | 1 -
main-loop.h | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
qemu-char.h | 12 +--------
qemu-common.h | 11 --------
sysemu.h | 10 +------
vl.c | 1 +
8 files changed, 85 insertions(+), 38 deletions(-)
create mode 100644 main-loop.h
diff --git a/async.c b/async.c
index ca13962..332d511 100644
--- a/async.c
+++ b/async.c
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "qemu-aio.h"
+#include "main-loop.h"
/* Anchor of the list of Bottom Halves belonging to the context */
static struct QEMUBH *first_bh;
diff --git a/cpus.c b/cpus.c
index f8799f5..627a2b7 100644
--- a/cpus.c
+++ b/cpus.c
@@ -33,17 +33,12 @@
#include "qemu-thread.h"
#include "cpus.h"
+#include "main-loop.h"
#ifndef _WIN32
#include "compatfd.h"
#endif
-#ifdef SIGRTMIN
-#define SIG_IPI (SIGRTMIN+4)
-#else
-#define SIG_IPI SIGUSR1
-#endif
-
#ifdef CONFIG_LINUX
#include <sys/prctl.h>
diff --git a/cpus.h b/cpus.h
index f42b54e..f7b23ef 100644
--- a/cpus.h
+++ b/cpus.h
@@ -2,7 +2,6 @@
#define QEMU_CPUS_H
/* cpus.c */
-int qemu_init_main_loop(void);
void qemu_main_loop_start(void);
void resume_all_vcpus(void);
void pause_all_vcpus(void);
diff --git a/main-loop.h b/main-loop.h
new file mode 100644
index 0000000..d61dfdd
--- /dev/null
+++ b/main-loop.h
@@ -0,0 +1,80 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef QEMU_MAIN_LOOP_H
+#define QEMU_MAIN_LOOP_H 1
+
+#ifdef SIGRTMIN
+#define SIG_IPI (SIGRTMIN+4)
+#else
+#define SIG_IPI SIGUSR1
+#endif
+
+int qemu_init_main_loop(void);
+int main_loop_wait(int nonblocking);
+
+/* Force QEMU to process pending events */
+void qemu_notify_event(void);
+
+typedef struct vm_change_state_entry VMChangeStateEntry;
+typedef void VMChangeStateHandler(void *opaque, int running, int reason);
+
+VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
+ void *opaque);
+void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
+
+#ifdef _WIN32
+/* return TRUE if no sleep should be done afterwards */
+typedef int PollingFunc(void *opaque);
+
+int qemu_add_polling_cb(PollingFunc *func, void *opaque);
+void qemu_del_polling_cb(PollingFunc *func, void *opaque);
+
+/* Wait objects handling */
+typedef void WaitObjectFunc(void *opaque);
+
+int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
+void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
+#endif
+
+/* async I/O support */
+
+typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
+typedef int IOCanReadHandler(void *opaque);
+typedef void IOHandler(void *opaque);
+
+void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set
*xfds);
+void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int
rc);
+
+int qemu_set_fd_handler2(int fd,
+ IOCanReadHandler *fd_read_poll,
+ IOHandler *fd_read,
+ IOHandler *fd_write,
+ void *opaque);
+int qemu_set_fd_handler(int fd,
+ IOHandler *fd_read,
+ IOHandler *fd_write,
+ void *opaque);
+
+#endif
diff --git a/qemu-char.h b/qemu-char.h
index eebbdd8..7efcf99 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -7,6 +7,7 @@
#include "qemu-config.h"
#include "qobject.h"
#include "qstring.h"
+#include "main-loop.h"
/* character device */
@@ -237,15 +238,4 @@ void qemu_chr_close_mem(CharDriverState *chr);
QString *qemu_chr_mem_to_qs(CharDriverState *chr);
size_t qemu_chr_mem_osize(const CharDriverState *chr);
-/* async I/O support */
-
-int qemu_set_fd_handler2(int fd,
- IOCanReadHandler *fd_read_poll,
- IOHandler *fd_read,
- IOHandler *fd_write,
- void *opaque);
-int qemu_set_fd_handler(int fd,
- IOHandler *fd_read,
- IOHandler *fd_write,
- void *opaque);
#endif
diff --git a/qemu-common.h b/qemu-common.h
index 16cc5e9..e4fb661 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -211,14 +211,6 @@ int qemu_pipe(int pipefd[2]);
void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-/* IO callbacks. */
-typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
-typedef int IOCanReadHandler(void *opaque);
-typedef void IOHandler(void *opaque);
-
-void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set
*xfds);
-void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int
rc);
-
struct ParallelIOArg {
void *buffer;
int count;
@@ -283,9 +275,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id);
/* Force QEMU to stop what it's doing and service IO */
void qemu_service_io(void);
-/* Force QEMU to process pending events */
-void qemu_notify_event(void);
-
/* Unblock cpu */
void qemu_cpu_kick(void *env);
void qemu_cpu_kick_self(void);
diff --git a/sysemu.h b/sysemu.h
index 9090457..351f1bb 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -7,6 +7,7 @@
#include "qemu-queue.h"
#include "qemu-timer.h"
#include "notify.h"
+#include "main-loop.h"
/* vl.c */
extern const char *bios_name;
@@ -17,13 +18,6 @@ extern uint8_t qemu_uuid[];
int qemu_uuid_parse(const char *str, uint8_t *uuid);
#define UUID_FMT
"%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
-typedef struct vm_change_state_entry VMChangeStateEntry;
-typedef void VMChangeStateHandler(void *opaque, int running, int reason);
-
-VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
- void *opaque);
-void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
-
#define VMSTOP_USER 0
#define VMSTOP_DEBUG 1
#define VMSTOP_SHUTDOWN 2
@@ -67,8 +61,6 @@ void do_info_snapshots(Monitor *mon);
void qemu_announce_self(void);
-int main_loop_wait(int nonblocking);
-
bool qemu_savevm_state_blocked(Monitor *mon);
int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
int shared);
diff --git a/vl.c b/vl.c
index 56a3db2..f67baf7 100644
--- a/vl.c
+++ b/vl.c
@@ -147,6 +147,7 @@ int main(int argc, char **argv)
#include "qemu-config.h"
#include "qemu-objects.h"
#include "qemu-options.h"
+#include "main-loop.h"
#ifdef CONFIG_VIRTFS
#include "fsdev/qemu-fsdev.h"
#endif
--
1.7.6
- [Qemu-devel] [RFC PATCH 00/14] allow tools to use the QEMU main loop, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 01/14] remove unused function, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 02/14] qemu-timer: remove active_timers array, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 04/14] qemu-timer: more clock functions, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 05/14] qemu-timer: move icount to cpus.c, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 06/14] qemu-timer: do not refer to vm_running, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 08/14] create main-loop.h,
Paolo Bonzini <=
- [Qemu-devel] [RFC PATCH 10/14] Revert to a hand-made select loop, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 07/14] qemu-timer: move more stuff out of qemu-timer.c, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 12/14] makefile: extract tools-obj-y, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 11/14] simplify main loop functions, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 03/14] qemu-timer: move common code to qemu_rearm_alarm_timer, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 09/14] create main-loop.c, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 14/14] qemu-nbd: use common main loop, Paolo Bonzini, 2011/09/16
- [Qemu-devel] [RFC PATCH 13/14] link the main loop and its dependencies into the tools, Paolo Bonzini, 2011/09/16