Patchwork [1/2] qemu-tool: Stub out qemu-timer functions

login
register
mail settings
Submitter Stefan Hajnoczi
Date Feb. 17, 2011, 2:59 p.m.
Message ID <1297954788-22670-2-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/83456/
State New
Headers show

Comments

Stefan Hajnoczi - Feb. 17, 2011, 2:59 p.m.
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 <stefanha@linux.vnet.ibm.com>
---
 qemu-tool.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
Michael Roth - Feb. 17, 2011, 4:27 p.m.
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<stefanha@linux.vnet.ibm.com>
> ---
>   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<sys/time.h>
>
>   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:

Patch

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 <sys/time.h>
 
 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;
+}