From patchwork Mon Dec 6 14:03:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 378392 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB6E7wtK007822 for ; Mon, 6 Dec 2010 14:07:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591Ab0LFOH4 (ORCPT ); Mon, 6 Dec 2010 09:07:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56542 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751476Ab0LFOHz (ORCPT ); Mon, 6 Dec 2010 09:07:55 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB6E7rYJ001630 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Dec 2010 09:07:54 -0500 Received: from virtlab1.virt.bos.redhat.com (virtlab1.virt.bos.redhat.com [10.16.72.21]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB6E7pj0006031; Mon, 6 Dec 2010 09:07:53 -0500 From: Glauber Costa To: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org, avi@redhat.com, mtosatti@redhat.com, Paolo Bonzini Subject: [PATCH v2 2/2] make kvmclock value idempotent for stopped machine Date: Mon, 6 Dec 2010 09:03:47 -0500 Message-Id: <1291644227-22923-3-git-send-email-glommer@redhat.com> In-Reply-To: <1291644227-22923-1-git-send-email-glommer@redhat.com> References: <1291644227-22923-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 06 Dec 2010 14:07:59 +0000 (UTC) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 14a52ce..0e357ac 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -500,11 +500,11 @@ 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) +static void kvmclock_update_clock(void *opaque, int running, int reason) { struct kvm_clock_data *cl = opaque; - if (!kvmclock_enabled) + if ((!kvmclock_enabled) || running) return; kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, cl); @@ -522,7 +522,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), @@ -537,6 +536,7 @@ void kvmclock_register_savevm(void) #ifdef KVM_CAP_ADJUST_CLOCK if (kvmclock_enabled && kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK)) { vmstate_register(NULL, 0, &vmstate_kvmclock, &kvmclock_data); + qemu_add_vm_change_state_handler(kvmclock_update_clock, &kvmclock_data); } #endif }