From patchwork Mon Sep 28 05:38:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 7275141 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 96152BEEA4 for ; Mon, 28 Sep 2015 05:38:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D891B206E7 for ; Mon, 28 Sep 2015 05:38:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECCE8206E6 for ; Mon, 28 Sep 2015 05:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756043AbbI1Fiv (ORCPT ); Mon, 28 Sep 2015 01:38:51 -0400 Received: from mga03.intel.com ([134.134.136.65]:26592 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751962AbbI1Fiu (ORCPT ); Mon, 28 Sep 2015 01:38:50 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 27 Sep 2015 22:38:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,601,1437462000"; d="scan'208";a="798596352" Received: from hzzhang-optiplex-9020.sh.intel.com (HELO localhost) ([10.239.12.62]) by fmsmga001.fm.intel.com with ESMTP; 27 Sep 2015 22:38:49 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Paolo Bonzini , Marcelo Tosatti , Richard Henderson , Eduardo Habkost , Haozhong Zhang Subject: [PATCH 1/3] target-i386: add a subsection of vcpu's TSC rate in vmstate_x86_cpu Date: Mon, 28 Sep 2015 13:38:29 +0800 Message-Id: <1443418711-24106-2-git-send-email-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.4.8 In-Reply-To: <1443418711-24106-1-git-send-email-haozhong.zhang@intel.com> References: <1443418711-24106-1-git-send-email-haozhong.zhang@intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The newly added subsection 'vmstate_tsc_khz' in this patch results in vcpu's TSC rate being saved on the source machine and loaded on the target machine during the migration. Signed-off-by: Haozhong Zhang --- target-i386/machine.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target-i386/machine.c b/target-i386/machine.c index 9fa0563..80108a3 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -752,6 +752,25 @@ static const VMStateDescription vmstate_xss = { } }; +static bool tsc_khz_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + + return env->tsc_khz != 0; +} + +static const VMStateDescription vmstate_tsc_khz = { + .name = "cpu/tsc_khz", + .version_id = 1, + .minimum_version_id = 1, + .needed = tsc_khz_needed, + .fields = (VMStateField[]) { + VMSTATE_INT64(env.tsc_khz, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + VMStateDescription vmstate_x86_cpu = { .name = "cpu", .version_id = 12, @@ -871,6 +890,7 @@ VMStateDescription vmstate_x86_cpu = { &vmstate_msr_hyperv_crash, &vmstate_avx512, &vmstate_xss, + &vmstate_tsc_khz, NULL } };