From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QobHk-0005O7-6F for qemu-devel@nongnu.org; Wed, 03 Aug 2011 09:14:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QobHg-0002Xb-DK for qemu-devel@nongnu.org; Wed, 03 Aug 2011 09:14:56 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:36904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QobHf-0002Vx-TC for qemu-devel@nongnu.org; Wed, 03 Aug 2011 09:14:52 -0400 From: Markus Armbruster Date: Wed, 3 Aug 2011 15:08:05 +0200 Message-Id: <1312376904-16115-27-git-send-email-armbru@redhat.com> In-Reply-To: <1312376904-16115-1-git-send-email-armbru@redhat.com> References: <1312376904-16115-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 26/45] ide/atapi: Preserve tray state on migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, quintela@redhat.com, stefano.stabellini@eu.citrix.com, lcapitulino@redhat.com, hare@suse.de, amit.shah@redhat.com, hch@lst.de 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 cbda0c2..22a2dc7 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2036,6 +2036,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; @@ -2063,6 +2079,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, @@ -2117,6 +2146,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, }, { -- 1.7.6