From patchwork Fri Sep 16 15:09:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 114996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 93DB2B6F81 for ; Sat, 17 Sep 2011 02:51:00 +1000 (EST) Received: from localhost ([::1]:50388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4a3w-0007Zd-4I for incoming@patchwork.ozlabs.org; Fri, 16 Sep 2011 11:10:44 -0400 Received: from eggs.gnu.org ([140.186.70.92]:41192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4a2j-0004c8-Jt for qemu-devel@nongnu.org; Fri, 16 Sep 2011 11:09:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4a2h-00081q-GY for qemu-devel@nongnu.org; Fri, 16 Sep 2011 11:09:29 -0400 Received: from mail-ww0-f53.google.com ([74.125.82.53]:51127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4a2g-000805-DY for qemu-devel@nongnu.org; Fri, 16 Sep 2011 11:09:26 -0400 Received: by mail-ww0-f53.google.com with SMTP id 14so4687113wwg.10 for ; Fri, 16 Sep 2011 08:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=3kkgwOr/+vKgQ4JCIU0DwYnL+xcej/ErOGJSo8nnSZI=; b=Gzul5d/E22IV/TyGnr5spUyVdOXVG2cRJ73wdzi6BEnr5jnyGjO59+QDPz8Ad9buMs 4kCiyjV6qmIYmc6/U+lBbKoNRAwZ+vGway7X0QacLEL0+OzRSsY0nZQw1tjBBGx9f7ty hVMZ+wuREWkh6wNIIfHJ6sqMYDJalG9Cya5kI= Received: by 10.216.133.8 with SMTP id p8mr853180wei.75.1316185766036; Fri, 16 Sep 2011 08:09:26 -0700 (PDT) Received: from localhost.localdomain (93-34-199-31.ip51.fastwebnet.it. [93.34.199.31]) by mx.google.com with ESMTPS id fd4sm12872738wbb.21.2011.09.16.08.09.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Sep 2011 08:09:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 16 Sep 2011 17:09:04 +0200 Message-Id: <1316185750-9187-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1316185750-9187-1-git-send-email-pbonzini@redhat.com> References: <1316185750-9187-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.53 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [RFC PATCH 08/14] create main-loop.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- 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 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