From patchwork Tue Sep 27 16:31:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 116640 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 E0CCB1007D1 for ; Wed, 28 Sep 2011 03:10:18 +1000 (EST) Received: from localhost ([::1]:37183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8aaY-0002VO-PI for incoming@patchwork.ozlabs.org; Tue, 27 Sep 2011 12:32:58 -0400 Received: from eggs.gnu.org ([140.186.70.92]:42439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8aZy-0001TK-SH for qemu-devel@nongnu.org; Tue, 27 Sep 2011 12:32:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8aZs-0002SU-Aa for qemu-devel@nongnu.org; Tue, 27 Sep 2011 12:32:22 -0400 Received: from mail-bw0-f45.google.com ([209.85.214.45]:60225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8aZs-0002Pr-2v for qemu-devel@nongnu.org; Tue, 27 Sep 2011 12:32:16 -0400 Received: by mail-bw0-f45.google.com with SMTP id zv15so7356448bkb.4 for ; Tue, 27 Sep 2011 09:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=P2GLPnAXSk/n5bnNaogeFXzFm7MKr+64YZXRK8hL7IQ=; b=uDx9Hfv9xowEbY5hGgzN5low0WDuquYWZ9fPGenf7+9Nrxtc55MsHVbs21yW/pKL58 TyYaZdO2YmT4iMdYJyk1+tUTAMVpzVI6IUJLo2GTptl+exFqmgSigp/5MvHLeBmN/MSK 6NzMLPkdfhJedRPKAOMkVyYBU0M8XEERxlIzc= Received: by 10.204.136.220 with SMTP id s28mr4899087bkt.152.1317141135499; Tue, 27 Sep 2011 09:32:15 -0700 (PDT) Received: from localhost.localdomain (93-34-218-143.ip51.fastwebnet.it. [93.34.218.143]) by mx.google.com with ESMTPS id d1sm25178167bku.1.2011.09.27.09.32.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Sep 2011 09:32:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 27 Sep 2011 18:31:48 +0200 Message-Id: <1317141111-27701-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1317141111-27701-1-git-send-email-pbonzini@redhat.com> References: <1317141111-27701-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.45 Subject: [Qemu-devel] [PATCH 09/12] 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 | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-char.h | 12 +-------- qemu-common.h | 11 -------- sysemu.h | 3 +- vl.c | 1 + 8 files changed, 78 insertions(+), 31 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 751833d..8684423 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 5885885..4ccf986 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..7b2e675 --- /dev/null +++ b/main-loop.h @@ -0,0 +1,73 @@ +/* + * 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); + +#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 b1d2f0f..23794a3 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -218,14 +218,6 @@ int qemu_sendv(int sockfd, struct iovec *iov, int len, int iov_offset); 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; @@ -287,9 +279,6 @@ void cpu_exec_init_all(void); void cpu_save(QEMUFile *f, void *opaque); int cpu_load(QEMUFile *f, void *opaque, int version_id); -/* 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 43ff546..592f165 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 */ @@ -81,8 +82,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 19e7169..8e8cbf2 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