[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 06/10] qom/cpu: move apic vmstate register into x
From: |
Zhu Guihua |
Subject: |
[Qemu-devel] [PATCH v4 06/10] qom/cpu: move apic vmstate register into x86_cpu_apic_realize |
Date: |
Fri, 13 Feb 2015 18:25:29 +0800 |
From: Gu Zheng <address@hidden>
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 <address@hidden>
Signed-off-by: Zhu Guihua <address@hidden>
---
hw/intc/apic_common.c | 3 +--
include/hw/i386/apic_internal.h | 3 +++
target-i386/cpu.c | 10 +++++++++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index bfaebe2..3b420a6 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -387,7 +387,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,
@@ -440,7 +440,6 @@ static void apic_common_class_init(ObjectClass *klass, void
*data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- dc->vmsd = &vmstate_apic_common;
dc->reset = apic_reset_common;
dc->props = apic_properties_common;
dc->realize = apic_common_realize;
diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h
index 0421c20..578a616 100644
--- a/include/hw/i386/apic_internal.h
+++ b/include/hw/i386/apic_internal.h
@@ -22,6 +22,7 @@
#include "exec/memory.h"
#include "qemu/timer.h"
+#include "migration/vmstate.h"
/* APIC Local Vector Table */
#define APIC_LVT_TIMER 0
@@ -136,6 +137,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 25f4f54..028063c 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2737,10 +2737,18 @@ 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));
+ int cpu_index = cc->get_arch_id(CPU(cpu)) + max_cpus;
+ int compat_index = cc->get_compat_arch_id(CPU(cpu));
+
+ if (apic_state == NULL) {
return;
}
+ vmstate_register_with_alias_id(NULL, cpu_index, &vmstate_apic_common,
+ apic_state, compat_index, 3);
+
if (qdev_init(cpu->apic_state)) {
error_setg(errp, "APIC device '%s' could not be initialized",
object_get_typename(OBJECT(cpu->apic_state)));
--
1.9.3
- [Qemu-devel] [PATCH v4 00/10] cpu: add device_add foo-x86_64-cpu support, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 01/10] cpu/apic: drop icc bus/bridge/, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 03/10] cpu: introduce CpuTopoInfo structure for argument simplification, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 02/10] icc_bus: remove icc related files, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 06/10] qom/cpu: move apic vmstate register into x86_cpu_apic_realize,
Zhu Guihua <=
- [Qemu-devel] [PATCH v4 04/10] cpu: introduce get_compat_arch_id() method and override it for X86CPU, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 05/10] qom/cpu: move register_vmstate to common CPUClass.realizefn, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 07/10] monitor: use cc->get_arch_id as the cpu index, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 08/10] acpi: introduce acpi_send_gpe_event(), Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 09/10] cpu: add device_add foo-x86_64-cpu support, Zhu Guihua, 2015/02/13
- [Qemu-devel] [PATCH v4 10/10] i386/cpu: add instance finalize callback, Zhu Guihua, 2015/02/13
- Re: [Qemu-devel] [PATCH v4 00/10] cpu: add device_add foo-x86_64-cpu support, Gu Zheng, 2015/02/23