From patchwork Thu Jul 31 05:41:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 375133 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 B9528140174 for ; Thu, 31 Jul 2014 15:41:47 +1000 (EST) Received: from localhost ([::1]:54382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCj7Z-0003DP-Ob for incoming@patchwork.ozlabs.org; Thu, 31 Jul 2014 01:41:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCj7F-0002w8-0P for qemu-devel@nongnu.org; Thu, 31 Jul 2014 01:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCj78-0000Ro-W1 for qemu-devel@nongnu.org; Thu, 31 Jul 2014 01:41:24 -0400 Received: from mail.ispras.ru ([83.149.199.45]:44770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCj78-0000Rh-OD for qemu-devel@nongnu.org; Thu, 31 Jul 2014 01:41:18 -0400 Received: from PASHAISP (unknown [80.250.189.177]) by mail.ispras.ru (Postfix) with ESMTPSA id 4E5A2540151; Thu, 31 Jul 2014 09:41:16 +0400 (MSK) From: "Pavel Dovgaluk" To: Date: Thu, 31 Jul 2014 09:41:17 +0400 Message-ID: <000601cfac82$0e135e30$2a3a1a90$@Dovgaluk@ispras.ru> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac+sggyIZe290wHbRN2ANd44MepIXw== Content-Language: ru X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Cc: 'Paolo Bonzini' Subject: [Qemu-devel] [PATCH] exec: save exception_index field 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 This patch adds subsection with exception_index field to the VMState for correct saving the CPU state. Without this patch simulator could miss the pending exception in the saved virtual machine state. Signed-off-by: Pavel Dovgalyuk Reviewed-by: Andreas Färber --- exec.c | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/exec.c b/exec.c index 765bd94..7581c06 100644 --- a/exec.c +++ b/exec.c @@ -430,15 +430,50 @@ static int cpu_common_post_load(void *opaque, int version_id) return 0; } +static int cpu_common_pre_load(void *opaque) +{ + CPUState *cpu = opaque; + + cpu->exception_index = 0; + + return 0; +} + +static bool cpu_common_exception_index_needed(void *opaque) +{ + CPUState *cpu = opaque; + + return cpu->exception_index != 0; +} + +static const VMStateDescription vmstate_cpu_common_exception_index = { + .name = "cpu_common/exception_index", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_INT32(exception_index, CPUState), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_cpu_common = { .name = "cpu_common", .version_id = 1, .minimum_version_id = 1, + .pre_load = cpu_common_pre_load, .post_load = cpu_common_post_load, .fields = (VMStateField[]) { VMSTATE_UINT32(halted, CPUState), VMSTATE_UINT32(interrupt_request, CPUState), VMSTATE_END_OF_LIST() + }, + .subsections = (VMStateSubsection[]) { + { + .vmsd = &vmstate_cpu_common_exception_index, + .needed = cpu_common_exception_index_needed, + } , { + /* empty */ + } } };