From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55464 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pq6ha-0001bU-LL for qemu-devel@nongnu.org; Thu, 17 Feb 2011 11:27:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pq6hY-0000OP-BU for qemu-devel@nongnu.org; Thu, 17 Feb 2011 11:27:34 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:57545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pq6hY-0000O1-1X for qemu-devel@nongnu.org; Thu, 17 Feb 2011 11:27:32 -0500 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e35.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p1HGD6jL019065 for ; Thu, 17 Feb 2011 09:13:06 -0700 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p1HGRUOf098912 for ; Thu, 17 Feb 2011 09:27:30 -0700 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p1HGW6XA027152 for ; Thu, 17 Feb 2011 09:32:06 -0700 Message-ID: <4D5D4C70.7050701@linux.vnet.ibm.com> Date: Thu, 17 Feb 2011 10:27:28 -0600 From: Michael Roth MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-tool: Stub out qemu-timer functions References: <1297954788-22670-1-git-send-email-stefanha@linux.vnet.ibm.com> <1297954788-22670-2-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1297954788-22670-2-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , qemu-devel@nongnu.org On 02/17/2011 08:59 AM, Stefan Hajnoczi wrote: > Block drivers may need timers for flushing data to disk or reconnecting > to a network drive. Stub out the following functions in qemu-tool.c: > > QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque) > void qemu_free_timer(QEMUTimer *ts) > void qemu_del_timer(QEMUTimer *ts) > void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time) > int64_t qemu_get_clock(QEMUClock *clock) > > They will result in timers never firing when linked against qemu-tool.o. > > Signed-off-by: Stefan Hajnoczi > --- > qemu-tool.c | 24 ++++++++++++++++++++++++ > 1 files changed, 24 insertions(+), 0 deletions(-) > > diff --git a/qemu-tool.c b/qemu-tool.c > index 392e1c9..2e2f2a8 100644 > --- a/qemu-tool.c > +++ b/qemu-tool.c > @@ -20,6 +20,7 @@ > #include > > QEMUClock *rt_clock; > +QEMUClock *vm_clock; > > FILE *logfile; > > @@ -111,3 +112,26 @@ int qemu_set_fd_handler2(int fd, > { > return 0; > } > + > +QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque) > +{ > + return qemu_malloc(1); > +} > + > +void qemu_free_timer(QEMUTimer *ts) > +{ > + qemu_free(ts); > +} > + > +void qemu_del_timer(QEMUTimer *ts) > +{ > +} > + > +void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time) > +{ > +} > + > +int64_t qemu_get_clock(QEMUClock *clock) > +{ > + return 0; > +} As an alternative to stubbing, can we consider the following patches which make timers functional for qemu-tools (if you add code to actually drive the timers...otherwise they'll just never fire as is the case with your patches)? These also make qemu_set_fd_handler() available for qemu-tools (again, if you actually drive the select() loop), but you could pull the timer-specific stuff out if that's a bit too out-of-scope for your changes. I could also post these as a separate patchset... I think these may be useful for driving some of the block testing utilities: ___ Move code related to fd handlers into utility functions This allows us to implement an i/o loop outside of vl.c that can interact with objects that use qemu_set_fd_handler() http://repo.or.cz/w/qemu/mdroth.git/commitdiff/2becd511df5f064e32f84e93dc5018933dcb5351 ___ Add qemu_set_fd_handler() wrappers to qemu-tools.c This adds state information for managing fd handlers to qemu-tools.c so that tools that build against it can implement an I/O loop for interacting with objects that use qemu_set_fd_handler() http://repo.or.cz/w/qemu/mdroth.git/commitdiff/fd1e5887e4aaa9dc8b6a25950a3f31b20e4b6390 ___ Make qemu timers available for tools To be able to use qemu_mod_timer() and friends to register timeout events for virtagent's qemu-va tool, we need to do the following: Move several blocks of code out of cpus.c that handle initialization of qemu's io_thread_fd and working with it via qemu_notify_event()/qemu_event_read()/etc, and make them accessible as backend functions to both the emulator code and qemu-tool.c via wrapper functions within cpus.c and qemu-tool.c, respectively. These have been added to qemu-ioh.c, where similar treatment was given to qemu_set_fd_handler() and friends. Some of these wrapper functions lack declarations when being built into tools, so we add those via qemu-tool.h, which can be included by a tool to access them. With these changes we can drive timers in a tool linking it against qemu-timer.o and then implementing something similar to the main i/o loop in vl.c: init_clocks(); configure_alarms("dynticks"); if (init_timer_alarm() < 0) { errx(EXIT_FAILURE, "could not initialize alarm timer"); } while (running) { //do work qemu_run_all_timers(); } http://repo.or.cz/w/qemu/mdroth.git/commitdiff/65dd692242334806f26e38d6f5cf9bc20c22ec2e