From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoWKa-0000nU-Li for qemu-devel@nongnu.org; Wed, 12 Nov 2014 06:43:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoWKS-0002Yt-1D for qemu-devel@nongnu.org; Wed, 12 Nov 2014 06:43:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoWKR-0002Yp-N8 for qemu-devel@nongnu.org; Wed, 12 Nov 2014 06:43:15 -0500 From: Paolo Bonzini Date: Wed, 12 Nov 2014 12:43:07 +0100 Message-Id: <1415792587-8367-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] apic_common: migrate missing fields List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Pavel Dovgalyuk From: Pavel Dovgalyuk 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: Pavel Dovgalyuk Signed-off-by: Paolo Bonzini --- Found while cleaning up an old branch. hw/intc/apic_common.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index ce3d903..7cf795a 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -324,6 +324,18 @@ static void apic_common_realize(DeviceState *dev, Error **errp) } +static void 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; +} + static void apic_dispatch_pre_save(void *opaque) { APICCommonState *s = APIC_COMMON(opaque); @@ -345,12 +357,30 @@ static int apic_dispatch_post_load(void *opaque, int version_id) 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 = { .name = "apic", .version_id = 3, .minimum_version_id = 3, .minimum_version_id_old = 1, .load_state_old = apic_load_old, + .pre_load = apic_pre_load, .pre_save = apic_dispatch_pre_save, .post_load = apic_dispatch_post_load, .fields = (VMStateField[]) { @@ -375,6 +405,13 @@ static const VMStateDescription vmstate_apic_common = { VMSTATE_INT64(timer_expiry, APICCommonState), /* open-coded timer state */ VMSTATE_END_OF_LIST() + }, + .subsections = (VMStateSubsection[]) { + { + .vmsd = &vmstate_apic_common_sipi, + .needed = apic_common_sipi_needed, + }, + VMSTATE_END_OF_LIST() } }; -- 1.8.3.1