From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, avi@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] make kvmclock value idempotent for stopped machine
Date: Fri, 3 Dec 2010 05:49:33 -0500 [thread overview]
Message-ID: <1291373374-10296-2-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1291373374-10296-1-git-send-email-glommer@redhat.com>
Although we never made such commitment clear (well, to the best
of my knowledge), some people expect that two savevm issued in sequence
in a stopped machine will yield the same results. This is not a crazy
requirement, since we don't expect a stopped machine to be updating its state,
for any device.
With kvmclock, this is not the case, since the .pre_save hook will issue an
ioctl to the host to acquire a timestamp, which is always changing.
This patch moves the value acquisition to vm_stop. This should mean our
get clock ioctl is issued more times, but this should be fine since vm_stop
is not a hot path.
When we do migrate, we'll transfer that value along.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
cpus.c | 4 ++++
qemu-kvm-x86.c | 7 ++-----
qemu-kvm.h | 2 ++
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/cpus.c b/cpus.c
index a55c330..879a03a 100644
--- a/cpus.c
+++ b/cpus.c
@@ -112,6 +112,10 @@ static void do_vm_stop(int reason)
pause_all_vcpus();
vm_state_notify(0, reason);
monitor_protocol_event(QEVENT_STOP, NULL);
+ if (kvm_enabled()) {
+ kvmclock_update_clock();
+ }
+
}
}
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 20b7d6d..d099d3d 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -500,11 +500,9 @@ static int kvm_enable_tpr_access_reporting(CPUState *env)
#ifdef KVM_CAP_ADJUST_CLOCK
static struct kvm_clock_data kvmclock_data;
-static void kvmclock_pre_save(void *opaque)
+void kvmclock_update_clock(void)
{
- struct kvm_clock_data *cl = opaque;
-
- kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, cl);
+ kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &kvmclock_data);
}
static int kvmclock_post_load(void *opaque, int version_id)
@@ -519,7 +517,6 @@ static const VMStateDescription vmstate_kvmclock= {
.version_id = 1,
.minimum_version_id = 1,
.minimum_version_id_old = 1,
- .pre_save = kvmclock_pre_save,
.post_load = kvmclock_post_load,
.fields = (VMStateField []) {
VMSTATE_U64(clock, struct kvm_clock_data),
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 0f3fb50..b0b7ab3 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -752,6 +752,8 @@ int handle_tpr_access(void *opaque, CPUState *env, uint64_t rip,
#define qemu_kvm_cpu_stop(env) do {} while(0)
#endif
+void kvmclock_update_clock(void);
+
#ifdef CONFIG_KVM
typedef struct KVMSlot {
--
1.7.2.3
next prev parent reply other threads:[~2010-12-03 10:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-03 10:49 [Qemu-devel] [PATCH 0/2] Fix savevm odness related to kvmclock Glauber Costa
2010-12-03 10:49 ` Glauber Costa [this message]
2010-12-03 10:49 ` [Qemu-devel] [PATCH 2/2] Do not register kvmclock savevm section if kvmclock is disabled Glauber Costa
2010-12-04 13:39 ` [Qemu-devel] " Paolo Bonzini
2010-12-04 13:41 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291373374-10296-2-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).