From patchwork Wed Jul 20 16:24:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 105991 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 5A6F4B6F70 for ; Thu, 21 Jul 2011 16:56:45 +1000 (EST) Received: from localhost ([::1]:60255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjdoQ-0001o3-Ib for incoming@patchwork.ozlabs.org; Wed, 20 Jul 2011 16:56:10 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjZhG-0005zp-FA for qemu-devel@nongnu.org; Wed, 20 Jul 2011 12:32:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QjZhB-0001Km-0J for qemu-devel@nongnu.org; Wed, 20 Jul 2011 12:32:30 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:39186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjZhA-0001K0-AH for qemu-devel@nongnu.org; Wed, 20 Jul 2011 12:32:24 -0400 Received: from oxygen-old.pond.sub.org (unknown [IPv6:2a01:4f8:130:9021::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "oxygen.pond.sub.org", Issuer "CAcert Class 3 Root" (verified OK)) by oxygen.pond.sub.org (Postfix) with ESMTPS id CFAD6A246F; Wed, 20 Jul 2011 18:32:22 +0200 (CEST) Received: from blackfin.pond.sub.org (p5B32D5F4.dip.t-dialin.net [91.50.213.244]) by oxygen-old.pond.sub.org (Postfix) with ESMTPA id 8CE4B2771CC; Wed, 20 Jul 2011 18:32:22 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id B2551360; Wed, 20 Jul 2011 18:24:32 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 20 Jul 2011 18:24:11 +0200 Message-Id: <1311179069-27882-38-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1311179069-27882-1-git-send-email-armbru@redhat.com> References: <1311179069-27882-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, quintela@redhat.com, dbaryshkov@gmail.com, stefano.stabellini@eu.citrix.com, lcapitulino@redhat.com, amit.shah@redhat.com Subject: [Qemu-devel] [PATCH 37/55] 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 --- 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 709645e..90ad497 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2042,6 +2042,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; @@ -2069,6 +2085,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, @@ -2123,6 +2152,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, }, {