From patchwork Tue Sep 6 16:58:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 113648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A62EEB6F77 for ; Wed, 7 Sep 2011 03:47:14 +1000 (EST) Received: from localhost ([::1]:36622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0yzy-0007HV-7f for incoming@patchwork.ozlabs.org; Tue, 06 Sep 2011 12:59:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]:38162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0yzR-0005hB-Hw for qemu-devel@nongnu.org; Tue, 06 Sep 2011 12:59:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0yzK-0004Yo-Gz for qemu-devel@nongnu.org; Tue, 06 Sep 2011 12:59:13 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:55979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0yzK-0004YQ-4t for qemu-devel@nongnu.org; Tue, 06 Sep 2011 12:59:06 -0400 Received: from blackfin.pond.sub.org (p5B32C9A8.dip.t-dialin.net [91.50.201.168]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 5E11CA2C88; Tue, 6 Sep 2011 18:59:04 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 9EEF26007A; Tue, 6 Sep 2011 18:59:01 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 6 Sep 2011 18:58:50 +0200 Message-Id: <1315328340-6192-18-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1315328340-6192-1-git-send-email-armbru@redhat.com> References: <1315328340-6192-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.46.104.156 Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com, lcapitulino@redhat.com, hare@suse.de, amit.shah@redhat.com, pbonzini@redhat.com, hch@lst.de Subject: [Qemu-devel] [PATCH v3 17/27] ide/atapi: Preserve tray state on migration 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 Use a subsection, so that migration to older version still works, provided the tray is closed and unlocked. Signed-off-by: Markus Armbruster Reviewed-by: Paolo Bonzini --- hw/ide/core.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index b1a73ee..30cb7de 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2058,6 +2058,22 @@ static bool ide_drive_pio_state_needed(void *opaque) || (s->bus->error_status & BM_STATUS_PIO_RETRY); } +static int ide_tray_state_post_load(void *opaque, int version_id) +{ + IDEState *s = opaque; + + bdrv_eject(s->bs, s->tray_open); + bdrv_lock_medium(s->bs, s->tray_locked); + return 0; +} + +static bool ide_tray_state_needed(void *opaque) +{ + IDEState *s = opaque; + + return s->tray_open || s->tray_locked; +} + static bool ide_atapi_gesn_needed(void *opaque) { IDEState *s = opaque; @@ -2085,6 +2101,19 @@ static const VMStateDescription vmstate_ide_atapi_gesn_state = { } }; +static const VMStateDescription vmstate_ide_tray_state = { + .name = "ide_drive/tray_state", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .post_load = ide_tray_state_post_load, + .fields = (VMStateField[]) { + VMSTATE_BOOL(tray_open, IDEState), + VMSTATE_BOOL(tray_locked, IDEState), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_ide_drive_pio_state = { .name = "ide_drive/pio_state", .version_id = 1, @@ -2139,6 +2168,9 @@ const VMStateDescription vmstate_ide_drive = { .vmsd = &vmstate_ide_drive_pio_state, .needed = ide_drive_pio_state_needed, }, { + .vmsd = &vmstate_ide_tray_state, + .needed = ide_tray_state_needed, + }, { .vmsd = &vmstate_ide_atapi_gesn_state, .needed = ide_atapi_gesn_needed, }, {