From patchwork Tue Jul 8 17:17:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 33257 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 019132070A for ; Wed, 9 Jul 2014 01:48:07 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id a41sf27175091yho.5 for ; Tue, 08 Jul 2014 18:48:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=aV0NVzXWFXiy/PZGAoi9nQBasX413nJpdXOxjNxcwHk=; b=hGFzV+brjiCWBT2t036dQdDZ4bIuS2LcR49G3e9LJfQW3QI09k+ua/5gfcGvmPKoFc dKAYv4S46lcZ9QmUrzrAwC1Af+5jACmlsElYXyr/yvkk7Tepb5F51XCsHGwDziJz6ZjH zajSa9MKdiE79V65xjLNjd/omziBgtkrPm0dejJvW84FZ6Z6IX6xDAGdih8XthgvTk9s 8HR7sZR5WsZyjIw5tUUnqjKQbsSG2ymc4E1HUtK6UZn3jooM1PSHaGIz4VRtrV7XnemW 8VqhLi6Jgx7wQ21NtdkHMtZN3UEZMVPD6G4X0bEHp9CDb2Cv0p3O3j70+ZJDiHOMshP1 70oA== X-Gm-Message-State: ALoCoQmZK0GW5S4og+GTHyVLNxyyYLjjORSLVqaf58pspYng+O8vv8+wEJz5fzqxZw7a7OxYIxbs X-Received: by 10.52.230.71 with SMTP id sw7mr9255740vdc.9.1404870487598; Tue, 08 Jul 2014 18:48:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.199 with SMTP id x65ls775899qgx.23.gmail; Tue, 08 Jul 2014 18:48:07 -0700 (PDT) X-Received: by 10.58.245.194 with SMTP id xq2mr37120874vec.26.1404870487489; Tue, 08 Jul 2014 18:48:07 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id wx3si20849067vdc.10.2014.07.08.18.48.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Jul 2014 18:48:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id id10so6207156vcb.24 for ; Tue, 08 Jul 2014 18:48:07 -0700 (PDT) X-Received: by 10.58.150.1 with SMTP id ue1mr36286481veb.11.1404870487408; Tue, 08 Jul 2014 18:48:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp273vcb; Tue, 8 Jul 2014 18:48:07 -0700 (PDT) X-Received: by 10.224.51.18 with SMTP id b18mr67452789qag.81.1404870486896; Tue, 08 Jul 2014 18:48:06 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n9si38011670qcc.26.2014.07.08.18.48.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Jul 2014 18:48:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:57101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4ZHk-0004hp-9U for patch@linaro.org; Tue, 08 Jul 2014 13:34:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z5L-000464-CU for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Z4s-0007xv-MS for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:21:43 -0400 Received: from e31.co.us.ibm.com ([32.97.110.149]:43974) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z4s-0007xh-En for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:21:14 -0400 Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Jul 2014 11:21:14 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 8 Jul 2014 11:21:11 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 570831FF001C; Tue, 8 Jul 2014 11:21:10 -0600 (MDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by b03cxnp08025.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s68HLAfa66257008; Tue, 8 Jul 2014 19:21:10 +0200 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id s68HPEtS006557; Tue, 8 Jul 2014 11:25:14 -0600 Received: from localhost ([9.41.105.211]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id s68HPEKK006544; Tue, 8 Jul 2014 11:25:14 -0600 From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 8 Jul 2014 12:17:27 -0500 Message-Id: <1404839947-1086-57-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14070817-8236-0000-0000-000003ACD172 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.149 Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 056/156] savevm: Ignore minimum_version_id_old if there is no load_state_old 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mdroth@linux.vnet.ibm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Peter Maydell At the moment we require vmstate definitions to set minimum_version_id_old to the same value as minimum_version_id if they do not provide a load_state_old handler. Since the load_state_old functionality is required only for a handful of devices that need to retain migration compatibility with a pre-vmstate implementation, this means the bulk of devices have pointless boilerplate. Relax the definition so that minimum_version_id_old is ignored if there is no load_state_old handler. Note that under the old scheme we would segfault if the vmstate specified a minimum_version_id_old that was less than minimum_version_id but did not provide a load_state_old function, and the incoming state specified a version number between minimum_version_id_old and minimum_version_id. Under the new scheme this will just result in our failing the migration. Signed-off-by: Peter Maydell Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Signed-off-by: Juan Quintela (cherry picked from commit 767adce2d9cd397de3418caa16be35ea18d56f22) Conflicts: vmstate.c *removed dependency on b6fcfa59 (Move VMState code to vmstate.c) Signed-off-by: Michael Roth --- docs/migration.txt | 12 +++++------- savevm.c | 9 +++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/migration.txt b/docs/migration.txt index 0e0a1d4..fe1f2bb 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -139,7 +139,6 @@ static const VMStateDescription vmstate_kbd = { .name = "pckbd", .version_id = 3, .minimum_version_id = 3, - .minimum_version_id_old = 3, .fields = (VMStateField []) { VMSTATE_UINT8(write_cmd, KBDState), VMSTATE_UINT8(status, KBDState), @@ -168,12 +167,13 @@ You can see that there are several version fields: - minimum_version_id: the minimum version_id that VMState is able to understand for that device. - minimum_version_id_old: For devices that were not able to port to vmstate, we can - assign a function that knows how to read this old state. + assign a function that knows how to read this old state. This field is + ignored if there is no load_state_old handler. So, VMState is able to read versions from minimum_version_id to -version_id. And the function load_state_old() is able to load state -from minimum_version_id_old to minimum_version_id. This function is -deprecated and will be removed when no more users are left. +version_id. And the function load_state_old() (if present) is able to +load state from minimum_version_id_old to minimum_version_id. This +function is deprecated and will be removed when no more users are left. === Massaging functions === @@ -255,7 +255,6 @@ const VMStateDescription vmstate_ide_drive_pio_state = { .name = "ide_drive/pio_state", .version_id = 1, .minimum_version_id = 1, - .minimum_version_id_old = 1, .pre_save = ide_drive_pio_pre_save, .post_load = ide_drive_pio_post_load, .fields = (VMStateField []) { @@ -275,7 +274,6 @@ const VMStateDescription vmstate_ide_drive = { .name = "ide_drive", .version_id = 3, .minimum_version_id = 0, - .minimum_version_id_old = 0, .post_load = ide_drive_post_load, .fields = (VMStateField []) { .... several fields .... diff --git a/savevm.c b/savevm.c index b436732..a271c2b 100644 --- a/savevm.c +++ b/savevm.c @@ -1729,11 +1729,12 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, if (version_id > vmsd->version_id) { return -EINVAL; } - if (version_id < vmsd->minimum_version_id_old) { - return -EINVAL; - } if (version_id < vmsd->minimum_version_id) { - return vmsd->load_state_old(f, opaque, version_id); + if (vmsd->load_state_old && + version_id >= vmsd->minimum_version_id_old) { + return vmsd->load_state_old(f, opaque, version_id); + } + return -EINVAL; } if (vmsd->pre_load) { int ret = vmsd->pre_load(opaque);