From patchwork Tue Aug 26 07:14:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 382987 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 E550514010B for ; Tue, 26 Aug 2014 17:17:50 +1000 (EST) Received: from localhost ([::1]:52199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMB0m-0006qo-T0 for incoming@patchwork.ozlabs.org; Tue, 26 Aug 2014 03:17:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMAxy-0002Ax-1I for qemu-devel@nongnu.org; Tue, 26 Aug 2014 03:15:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMAxs-0004rL-03 for qemu-devel@nongnu.org; Tue, 26 Aug 2014 03:14:53 -0400 Received: from mail.ispras.ru ([83.149.199.45]:33236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMAxr-0004rD-J2 for qemu-devel@nongnu.org; Tue, 26 Aug 2014 03:14:47 -0400 Received: from [10.10.150.50] (unknown [80.250.189.177]) by mail.ispras.ru (Postfix) with ESMTPSA id E6525540151; Tue, 26 Aug 2014 11:14:46 +0400 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Tue, 26 Aug 2014 11:14:46 +0400 Message-ID: <20140826071446.1672.50267.stgit@PASHA-ISP> In-Reply-To: <20140826071427.1672.48119.stgit@PASHA-ISP> References: <20140826071427.1672.48119.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Cc: pbonzini@redhat.com, zealot351@gmail.com, maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru Subject: [Qemu-devel] [PATCH 03/12] fdc: adding vmstate for save/restore 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 VMState added by this patch preserves correct loading of the FDC device state. Signed-off-by: Pavel Dovgalyuk --- hw/block/fdc.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 81 insertions(+), 0 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 490d127..a10c458 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -695,10 +695,34 @@ static const VMStateDescription vmstate_fdrive_media_rate = { } }; +static bool fdrive_perpendicular_needed(void *opaque) +{ + FDrive *drive = opaque; + + return drive->perpendicular != 0; +} + +static const VMStateDescription vmstate_fdrive_perpendicular = { + .name = "fdrive/perpendicular", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT8(perpendicular, FDrive), + VMSTATE_END_OF_LIST() + } +}; + +static int fdrive_post_load(void *opaque, int version_id) +{ + fd_revalidate(opaque); + return 0; +} + static const VMStateDescription vmstate_fdrive = { .name = "fdrive", .version_id = 1, .minimum_version_id = 1, + .post_load = fdrive_post_load, .fields = (VMStateField[]) { VMSTATE_UINT8(head, FDrive), VMSTATE_UINT8(track, FDrive), @@ -713,6 +737,9 @@ static const VMStateDescription vmstate_fdrive = { .vmsd = &vmstate_fdrive_media_rate, .needed = &fdrive_media_rate_needed, } , { + .vmsd = &vmstate_fdrive_perpendicular, + .needed = &fdrive_perpendicular_needed, + } , { /* empty */ } } @@ -725,6 +752,14 @@ static void fdc_pre_save(void *opaque) s->dor_vmstate = s->dor | GET_CUR_DRV(s); } +static int fdc_pre_load(void *opaque) +{ + FDCtrl *s = opaque; + s->reset_sensei = 0; + timer_del(s->result_timer); + return 0; +} + static int fdc_post_load(void *opaque, int version_id) { FDCtrl *s = opaque; @@ -734,11 +769,46 @@ static int fdc_post_load(void *opaque, int version_id) return 0; } +static bool fdc_reset_sensei_needed(void *opaque) +{ + FDCtrl *s = opaque; + + return s->reset_sensei != 0; +} + +static const VMStateDescription vmstate_fdc_reset_sensei = { + .name = "fdc/reset_sensei", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_INT32(reset_sensei, FDCtrl), + VMSTATE_END_OF_LIST() + } +}; + +static bool fdc_result_timer_needed(void *opaque) +{ + FDCtrl *s = opaque; + + return timer_pending(s->result_timer); +} + +static const VMStateDescription vmstate_fdc_result_timer = { + .name = "fdc/result_timer", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_TIMER(result_timer, FDCtrl), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_fdc = { .name = "fdc", .version_id = 2, .minimum_version_id = 2, .pre_save = fdc_pre_save, + .pre_load = fdc_pre_load, .post_load = fdc_post_load, .fields = (VMStateField[]) { /* Controller State */ @@ -770,6 +840,17 @@ static const VMStateDescription vmstate_fdc = { VMSTATE_STRUCT_ARRAY(drives, FDCtrl, MAX_FD, 1, vmstate_fdrive, FDrive), VMSTATE_END_OF_LIST() + }, + .subsections = (VMStateSubsection[]) { + { + .vmsd = &vmstate_fdc_reset_sensei, + .needed = fdc_reset_sensei_needed, + } , { + .vmsd = &vmstate_fdc_result_timer, + .needed = fdc_result_timer_needed, + } , { + /* empty */ + } } };