Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com
Subject: [PATCH 3/3] get and set clock upon migration
Date: Fri, 16 Oct 2009 15:27:39 -0400	[thread overview]
Message-ID: <1255721259-11740-4-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1255721259-11740-3-git-send-email-glommer@redhat.com>

Register a vmstate handler for kvmclock. The goal here is to pass
information about current time to migration, so we avoid going backwards
or jumping too much. We use our plain new ioctls for that.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 qemu-kvm-x86.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 693f5b2..909c147 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -767,6 +767,37 @@ int kvm_qemu_destroy_memory_alias(uint64_t phys_start)
 	return kvm_destroy_memory_alias(kvm_context, phys_start);
 }
 
+#ifdef KVM_CAP_ADJUST_CLOCK
+static struct kvm_clock_data kvmclock_data;
+
+static void kvmclock_pre_save(void *opaque)
+{
+    struct kvm_clock_data *cl = opaque;
+
+    kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, cl);
+}
+
+static int kvmclock_post_load(void *opaque, int version_id)
+{
+    struct kvm_clock_data *cl = opaque;
+
+    return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, cl);
+}
+
+static const VMStateDescription vmstate_kvmclock= {
+    .name = "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),
+        VMSTATE_END_OF_LIST()
+    }
+};
+#endif
+
 int kvm_arch_qemu_create_context(void)
 {
     int i;
@@ -788,6 +819,10 @@ int kvm_arch_qemu_create_context(void)
             kvm_has_vm_hsave_pa = 1;
     }
 
+#ifdef KVM_CAP_ADJUST_CLOCK
+    if (kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK))
+        vmstate_register(0, &vmstate_kvmclock, &kvmclock_data);
+#endif
     return 0;
 }
 
-- 
1.6.2.2


  reply	other threads:[~2009-10-16 19:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-16 19:27 [PATCH 0/3] Fix migration of linux guests using kvmclock Glauber Costa
2009-10-16 19:27 ` [PATCH 1/3] introduce VMSTATE_U64 Glauber Costa
2009-10-16 19:27   ` [PATCH 2/3] properly save kvm system time msr registers Glauber Costa
2009-10-16 19:27     ` Glauber Costa [this message]
2009-10-19 23:40   ` [PATCH 1/3] introduce VMSTATE_U64 Avi Kivity
2009-10-20  0:38     ` Glauber Costa
2009-10-19 19:51 ` [PATCH 0/3] Fix migration of linux guests using kvmclock Marcelo Tosatti

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=1255721259-11740-4-git-send-email-glommer@redhat.com \
    --to=glommer@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.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