提交 c2c00148 编写于 作者: P Pavel Dovgalyuk 提交者: Paolo Bonzini

apic_common: migrate missing fields

This patch adds missed sipi_vector and wait_for_sipi fields to a new
subsection of the vmstate of the apic_common module. Saving and loading
of these fields makes migration of the apic state deterministic.
Signed-off-by: NPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
[Initialize the field in pre_load and kvm_apic_realize. - Paolo]
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 ae67dc72
...@@ -175,6 +175,9 @@ static void kvm_apic_realize(DeviceState *dev, Error **errp) ...@@ -175,6 +175,9 @@ static void kvm_apic_realize(DeviceState *dev, Error **errp)
{ {
APICCommonState *s = APIC_COMMON(dev); APICCommonState *s = APIC_COMMON(dev);
/* Not used by KVM, which uses the CPU mp_state instead. */
s->wait_for_sipi = 0;
memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, "kvm-apic-msi", memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, "kvm-apic-msi",
APIC_SPACE_SIZE); APIC_SPACE_SIZE);
......
...@@ -324,6 +324,19 @@ static void apic_common_realize(DeviceState *dev, Error **errp) ...@@ -324,6 +324,19 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
} }
static int apic_pre_load(void *opaque)
{
APICCommonState *s = APIC_COMMON(opaque);
/* The default is !cpu_is_bsp(s->cpu), but the common value is 0
* so that's what apic_common_sipi_needed checks for. Reset to
* the value that is assumed when the apic_sipi subsection is
* absent.
*/
s->wait_for_sipi = 0;
return 0;
}
static void apic_dispatch_pre_save(void *opaque) static void apic_dispatch_pre_save(void *opaque)
{ {
APICCommonState *s = APIC_COMMON(opaque); APICCommonState *s = APIC_COMMON(opaque);
...@@ -345,12 +358,30 @@ static int apic_dispatch_post_load(void *opaque, int version_id) ...@@ -345,12 +358,30 @@ static int apic_dispatch_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static bool apic_common_sipi_needed(void *opaque)
{
APICCommonState *s = APIC_COMMON(opaque);
return s->wait_for_sipi != 0;
}
static const VMStateDescription vmstate_apic_common_sipi = {
.name = "apic_sipi",
.version_id = 1,
.minimum_version_id = 1,
.fields = (VMStateField[]) {
VMSTATE_INT32(sipi_vector, APICCommonState),
VMSTATE_INT32(wait_for_sipi, APICCommonState),
VMSTATE_END_OF_LIST()
}
};
static const VMStateDescription vmstate_apic_common = { static const VMStateDescription vmstate_apic_common = {
.name = "apic", .name = "apic",
.version_id = 3, .version_id = 3,
.minimum_version_id = 3, .minimum_version_id = 3,
.minimum_version_id_old = 1, .minimum_version_id_old = 1,
.load_state_old = apic_load_old, .load_state_old = apic_load_old,
.pre_load = apic_pre_load,
.pre_save = apic_dispatch_pre_save, .pre_save = apic_dispatch_pre_save,
.post_load = apic_dispatch_post_load, .post_load = apic_dispatch_post_load,
.fields = (VMStateField[]) { .fields = (VMStateField[]) {
...@@ -375,6 +406,13 @@ static const VMStateDescription vmstate_apic_common = { ...@@ -375,6 +406,13 @@ static const VMStateDescription vmstate_apic_common = {
VMSTATE_INT64(timer_expiry, VMSTATE_INT64(timer_expiry,
APICCommonState), /* open-coded timer state */ APICCommonState), /* open-coded timer state */
VMSTATE_END_OF_LIST() VMSTATE_END_OF_LIST()
},
.subsections = (VMStateSubsection[]) {
{
.vmsd = &vmstate_apic_common_sipi,
.needed = apic_common_sipi_needed,
},
VMSTATE_END_OF_LIST()
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册