* [Qemu-devel] [PATCH] cpu: init vmstate for ticks and clock offset
@ 2014-09-01 5:34 Pavel Dovgalyuk
2014-09-01 8:02 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Dovgalyuk @ 2014-09-01 5:34 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, zealot351, maria.klimushenkova, pavel.dovgaluk
Ticks and clock offset used by CPU timers have to be saved in vmstate.
But vmstate for these fields registered only in icount mode.
Missing registration leads to breaking the continuity when vmstate is loaded.
This patch introduces new initialization function which fixes this.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
cpus.c | 8 ++++++--
include/qemu-common.h | 2 ++
vl.c | 1 +
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/cpus.c b/cpus.c
index 2b5c0bd..c07826d 100644
--- a/cpus.c
+++ b/cpus.c
@@ -492,13 +492,17 @@ static const VMStateDescription vmstate_timers = {
}
};
+void cpu_ticks_init(void)
+{
+ seqlock_init(&timers_state.vm_clock_seqlock, NULL);
+ vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
+}
+
void configure_icount(QemuOpts *opts, Error **errp)
{
const char *option;
char *rem_str = NULL;
- seqlock_init(&timers_state.vm_clock_seqlock, NULL);
- vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
option = qemu_opt_get(opts, "shift");
if (!option) {
if (qemu_opt_get(opts, "align") != NULL) {
diff --git a/include/qemu-common.h b/include/qemu-common.h
index bcf7a6a..dcb57ab 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -105,6 +105,8 @@ static inline char *realpath(const char *path, char *resolved_path)
}
#endif
+void cpu_ticks_init(void);
+
/* icount */
void configure_icount(QemuOpts *opts, Error **errp);
extern int use_icount;
diff --git a/vl.c b/vl.c
index b796c67..9241e2d 100644
--- a/vl.c
+++ b/vl.c
@@ -4330,6 +4330,7 @@ int main(int argc, char **argv, char **envp)
qemu_spice_init();
#endif
+ cpu_ticks_init();
if (icount_opts) {
if (kvm_enabled() || xen_enabled()) {
fprintf(stderr, "-icount is not allowed with kvm or xen\n");
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] cpu: init vmstate for ticks and clock offset
2014-09-01 5:34 [Qemu-devel] [PATCH] cpu: init vmstate for ticks and clock offset Pavel Dovgalyuk
@ 2014-09-01 8:02 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-09-01 8:02 UTC (permalink / raw)
To: Pavel Dovgalyuk, qemu-devel; +Cc: zealot351, maria.klimushenkova
Il 01/09/2014 07:34, Pavel Dovgalyuk ha scritto:
> Ticks and clock offset used by CPU timers have to be saved in vmstate.
> But vmstate for these fields registered only in icount mode.
> Missing registration leads to breaking the continuity when vmstate is loaded.
> This patch introduces new initialization function which fixes this.
>
> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> ---
> cpus.c | 8 ++++++--
> include/qemu-common.h | 2 ++
> vl.c | 1 +
> 3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 2b5c0bd..c07826d 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -492,13 +492,17 @@ static const VMStateDescription vmstate_timers = {
> }
> };
>
> +void cpu_ticks_init(void)
> +{
> + seqlock_init(&timers_state.vm_clock_seqlock, NULL);
> + vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
> +}
> +
> void configure_icount(QemuOpts *opts, Error **errp)
> {
> const char *option;
> char *rem_str = NULL;
>
> - seqlock_init(&timers_state.vm_clock_seqlock, NULL);
> - vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
> option = qemu_opt_get(opts, "shift");
> if (!option) {
> if (qemu_opt_get(opts, "align") != NULL) {
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index bcf7a6a..dcb57ab 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -105,6 +105,8 @@ static inline char *realpath(const char *path, char *resolved_path)
> }
> #endif
>
> +void cpu_ticks_init(void);
> +
> /* icount */
> void configure_icount(QemuOpts *opts, Error **errp);
> extern int use_icount;
> diff --git a/vl.c b/vl.c
> index b796c67..9241e2d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4330,6 +4330,7 @@ int main(int argc, char **argv, char **envp)
> qemu_spice_init();
> #endif
>
> + cpu_ticks_init();
> if (icount_opts) {
> if (kvm_enabled() || xen_enabled()) {
> fprintf(stderr, "-icount is not allowed with kvm or xen\n");
>
>
>
Thanks, will send a pull request for this ASAP.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-01 8:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-01 5:34 [Qemu-devel] [PATCH] cpu: init vmstate for ticks and clock offset Pavel Dovgalyuk
2014-09-01 8:02 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).