From patchwork Fri Dec 12 07:43:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gu Zheng X-Patchwork-Id: 420378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 385341400A0 for ; Fri, 12 Dec 2014 19:01:18 +1100 (AEDT) Received: from localhost ([::1]:55892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzLA4-0005Yr-9H for incoming@patchwork.ozlabs.org; Fri, 12 Dec 2014 03:01:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzL9A-00049u-18 for qemu-devel@nongnu.org; Fri, 12 Dec 2014 03:00:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzL95-0002lq-8T for qemu-devel@nongnu.org; Fri, 12 Dec 2014 03:00:19 -0500 Received: from [59.151.112.132] (port=36915 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzL94-0002lB-PG for qemu-devel@nongnu.org; Fri, 12 Dec 2014 03:00:15 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="44939410" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 12 Dec 2014 15:56:53 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id sBC7xnCZ031831; Fri, 12 Dec 2014 15:59:49 +0800 Received: from localhost.localdomain (10.167.226.100) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 12 Dec 2014 16:00:13 +0800 From: Gu Zheng To: Date: Fri, 12 Dec 2014 15:43:55 +0800 Message-ID: <1418370238-24386-4-git-send-email-guz.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1418370238-24386-1-git-send-email-guz.fnst@cn.fujitsu.com> References: <1418370238-24386-1-git-send-email-guz.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.100] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: zhugh.fnst@cn.fujitsu.com, qemu-devel@nongnu.org, tangchen@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, chen.fan.fnst@cn.fujitsu.com, anshul.makkar@profitbricks.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH V2 3/6] qom/cpu: move apic vmstate register into x86_cpu_apic_realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org move apic vmstate register into x86_cpu_apic_realize, and use cc->get_arch_id as the instance id to avoid using the auto-id which will break the migration if we add device not in order. Signed-off-by: Gu Zheng Signed-off-by: Zhu Guihua --- hw/intc/apic_common.c | 3 +-- include/hw/i386/apic_internal.h | 3 +++ target-i386/cpu.c | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 4e62f25..62843dc 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -375,7 +375,7 @@ static const VMStateDescription vmstate_apic_common_sipi = { } }; -static const VMStateDescription vmstate_apic_common = { +const VMStateDescription vmstate_apic_common = { .name = "apic", .version_id = 3, .minimum_version_id = 3, @@ -429,7 +429,6 @@ static void apic_common_class_init(ObjectClass *klass, void *data) ICCDeviceClass *idc = ICC_DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); - dc->vmsd = &vmstate_apic_common; dc->reset = apic_reset_common; dc->props = apic_properties_common; idc->realize = apic_common_realize; diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index 83e2a42..61fddf6 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -23,6 +23,7 @@ #include "exec/memory.h" #include "hw/cpu/icc_bus.h" #include "qemu/timer.h" +#include "migration/vmstate.h" /* APIC Local Vector Table */ #define APIC_LVT_TIMER 0 @@ -137,6 +138,8 @@ typedef struct VAPICState { extern bool apic_report_tpr_access; +extern const VMStateDescription vmstate_apic_common; + void apic_report_irq_delivered(int delivered); bool apic_next_timer(APICCommonState *s, int64_t current_time); void apic_enable_tpr_access_reporting(DeviceState *d, bool enable); diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e9df33e..4b4a595 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2692,10 +2692,16 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) { - if (cpu->apic_state == NULL) { + DeviceState *apic_state = cpu->apic_state; + CPUClass *cc = CPU_GET_CLASS(CPU(cpu)); + + if (apic_state == NULL) { return; } + vmstate_register(0, cc->get_arch_id(CPU(cpu)), + &vmstate_apic_common, apic_state); + if (qdev_init(cpu->apic_state)) { error_setg(errp, "APIC device '%s' could not be initialized", object_get_typename(OBJECT(cpu->apic_state)));