From patchwork Fri Oct 16 19:27:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 54406 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9GJRmpY014324 for ; Fri, 16 Oct 2009 19:27:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751864AbZJPT1l (ORCPT ); Fri, 16 Oct 2009 15:27:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751439AbZJPT1k (ORCPT ); Fri, 16 Oct 2009 15:27:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34523 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbZJPT1i (ORCPT ); Fri, 16 Oct 2009 15:27:38 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9GJRhK1016856 for ; Fri, 16 Oct 2009 15:27:43 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9GJRd8T023120; Fri, 16 Oct 2009 15:27:42 -0400 From: Glauber Costa 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 Message-Id: <1255721259-11740-4-git-send-email-glommer@redhat.com> In-Reply-To: <1255721259-11740-3-git-send-email-glommer@redhat.com> References: <1255721259-11740-1-git-send-email-glommer@redhat.com> <1255721259-11740-2-git-send-email-glommer@redhat.com> <1255721259-11740-3-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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; }