Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xing Lin
qemu
Commits
2ff68d07
Commit
2ff68d07
authored
Sep 12, 2011
by
Paolo Bonzini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qemu-timer: move more stuff out of qemu-timer.c
Signed-off-by:
Paolo Bonzini
<
pbonzini@redhat.com
>
parent
4260a739
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
31 deletions
+32
-31
qemu-timer.c
qemu-timer.c
+4
-31
qemu-timer.h
qemu-timer.h
+2
-0
savevm.c
savevm.c
+25
-0
vl.c
vl.c
+1
-0
No files found.
qemu-timer.c
View file @
2ff68d07
...
...
@@ -266,11 +266,8 @@ static QEMUClock *qemu_new_clock(int type)
clock
=
g_malloc0
(
sizeof
(
QEMUClock
));
clock
->
type
=
type
;
clock
->
enabled
=
1
;
clock
->
last
=
INT64_MIN
;
notifier_list_init
(
&
clock
->
reset_notifiers
);
/* required to detect & report backward jumps */
if
(
type
==
QEMU_CLOCK_HOST
)
{
clock
->
last
=
get_clock_realtime
();
}
return
clock
;
}
...
...
@@ -344,7 +341,7 @@ void qemu_del_timer(QEMUTimer *ts)
/* modify the current timer so that it will be fired when current_time
>= expire_time. The corresponding callback will be called. */
static
void
qemu_mod_timer_ns
(
QEMUTimer
*
ts
,
int64_t
expire_time
)
void
qemu_mod_timer_ns
(
QEMUTimer
*
ts
,
int64_t
expire_time
)
{
QEMUTimer
**
pt
,
*
t
;
...
...
@@ -378,8 +375,6 @@ static void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time)
}
}
/* modify the current timer so that it will be fired when current_time
>= expire_time. The corresponding callback will be called. */
void
qemu_mod_timer
(
QEMUTimer
*
ts
,
int64_t
expire_time
)
{
qemu_mod_timer_ns
(
ts
,
expire_time
*
ts
->
scale
);
...
...
@@ -464,33 +459,11 @@ void init_clocks(void)
rt_clock
=
qemu_new_clock
(
QEMU_CLOCK_REALTIME
);
vm_clock
=
qemu_new_clock
(
QEMU_CLOCK_VIRTUAL
);
host_clock
=
qemu_new_clock
(
QEMU_CLOCK_HOST
);
rtc_clock
=
host_clock
;
}
/* save a timer */
void
qemu_put_timer
(
QEMUFile
*
f
,
QEMUTimer
*
ts
)
uint64_t
qemu_timer_expire_time_ns
(
QEMUTimer
*
ts
)
{
uint64_t
expire_time
;
if
(
qemu_timer_pending
(
ts
))
{
expire_time
=
ts
->
expire_time
;
}
else
{
expire_time
=
-
1
;
}
qemu_put_be64
(
f
,
expire_time
);
}
void
qemu_get_timer
(
QEMUFile
*
f
,
QEMUTimer
*
ts
)
{
uint64_t
expire_time
;
expire_time
=
qemu_get_be64
(
f
);
if
(
expire_time
!=
-
1
)
{
qemu_mod_timer_ns
(
ts
,
expire_time
);
}
else
{
qemu_del_timer
(
ts
);
}
return
qemu_timer_pending
(
ts
)
?
ts
->
expire_time
:
-
1
;
}
void
qemu_run_all_timers
(
void
)
...
...
qemu-timer.h
View file @
2ff68d07
...
...
@@ -52,9 +52,11 @@ QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale,
QEMUTimerCB
*
cb
,
void
*
opaque
);
void
qemu_free_timer
(
QEMUTimer
*
ts
);
void
qemu_del_timer
(
QEMUTimer
*
ts
);
void
qemu_mod_timer_ns
(
QEMUTimer
*
ts
,
int64_t
expire_time
);
void
qemu_mod_timer
(
QEMUTimer
*
ts
,
int64_t
expire_time
);
int
qemu_timer_pending
(
QEMUTimer
*
ts
);
int
qemu_timer_expired
(
QEMUTimer
*
timer_head
,
int64_t
current_time
);
uint64_t
qemu_timer_expire_time_ns
(
QEMUTimer
*
ts
);
void
qemu_run_all_timers
(
void
);
int
qemu_alarm_pending
(
void
);
...
...
savevm.c
View file @
2ff68d07
...
...
@@ -81,6 +81,7 @@
#include "migration.h"
#include "qemu_socket.h"
#include "qemu-queue.h"
#include "qemu-timer.h"
#include "cpus.h"
#define SELF_ANNOUNCE_ROUNDS 5
...
...
@@ -712,6 +713,30 @@ uint64_t qemu_get_be64(QEMUFile *f)
return
v
;
}
/* timer */
void
qemu_put_timer
(
QEMUFile
*
f
,
QEMUTimer
*
ts
)
{
uint64_t
expire_time
;
expire_time
=
qemu_timer_expire_time_ns
(
ts
);
qemu_put_be64
(
f
,
expire_time
);
}
void
qemu_get_timer
(
QEMUFile
*
f
,
QEMUTimer
*
ts
)
{
uint64_t
expire_time
;
expire_time
=
qemu_get_be64
(
f
);
if
(
expire_time
!=
-
1
)
{
qemu_mod_timer_ns
(
ts
,
expire_time
);
}
else
{
qemu_del_timer
(
ts
);
}
}
/* bool */
static
int
get_bool
(
QEMUFile
*
f
,
void
*
pv
,
size_t
size
)
...
...
vl.c
View file @
2ff68d07
...
...
@@ -2311,6 +2311,7 @@ int main(int argc, char **argv, char **envp)
runstate_init
();
init_clocks
();
rtc_clock
=
host_clock
;
qemu_cache_utils_init
(
envp
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment