From patchwork Mon Apr 7 03:20:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 27887 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D94F220490 for ; Mon, 7 Apr 2014 03:23:34 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id if11sf18962480vcb.4 for ; Sun, 06 Apr 2014 20:23:34 -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=fA9nHvNjmRiDSZXWl0B5IBm8/qcJI1G4qSh04DPNggk=; b=l6yWcRDeXJAONhW0fTuLiN9PrQlPzYq1+XxYw+uJKYCW11NIqsgt0KsrjIX0eEE4C5 hMhTqat9kPp1jyXKVAvVcN7VAuGZsqm1cbJdRPVMQuFJRrAyyf2ALjKVyAfc0pYege0z cVJB3e5u5+di688Sff9Xtuj9KfNwD+zVeevZqfz3HLfyPEXh3yxL1BdxOTBlHIGLGok8 b4iSpZexM4s7SD36PAfQXCVeo9B/Y0482nGBQMuNeCz9sp7IlD3Cu3A4tZmXpwUSCX1l f/FpSbYlgEF9uUyWS3SicDvUjzwe0hYM1y9ovGDkHlUSRAFkS+KvBca/JOYIvaJjYwQF 7ooQ== X-Gm-Message-State: ALoCoQmn6xm/eabSyJ2CBpwIfJkfrDOybqjdquTgLF6/zExDg/TPzRnhbVnsrh05K1dBn8XP6aRl X-Received: by 10.224.113.202 with SMTP id b10mr14982945qaq.3.1396841014467; Sun, 06 Apr 2014 20:23:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.8 with SMTP id l8ls1636882qge.27.gmail; Sun, 06 Apr 2014 20:23:34 -0700 (PDT) X-Received: by 10.58.96.36 with SMTP id dp4mr704632veb.21.1396841014357; Sun, 06 Apr 2014 20:23:34 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id bw7si2905461vcb.51.2014.04.06.20.23.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 06 Apr 2014 20:23:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id oz11so3067299veb.19 for ; Sun, 06 Apr 2014 20:23:34 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr22035122vcx.7.1396841014272; Sun, 06 Apr 2014 20:23:34 -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.220.12.8 with SMTP id v8csp128163vcv; Sun, 6 Apr 2014 20:23:34 -0700 (PDT) X-Received: by 10.140.51.14 with SMTP id t14mr9918585qga.50.1396841013500; Sun, 06 Apr 2014 20:23:33 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k67si6171658qge.64.2014.04.06.20.23.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 06 Apr 2014 20:23:33 -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]:60060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX09l-0006hv-2e for patch@linaro.org; Sun, 06 Apr 2014 23:23:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX08Q-000560-5c for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WX08I-0007oX-Jc for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:22:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX08I-0007oO-Bh for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:22:02 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s373M0RG031130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 6 Apr 2014 23:22:00 -0400 Received: from trasno.mitica (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s373LuWT020053; Sun, 6 Apr 2014 23:21:58 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 7 Apr 2014 05:20:19 +0200 Message-Id: <1396840915-10384-2-git-send-email-quintela@redhat.com> In-Reply-To: <1396840915-10384-1-git-send-email-quintela@redhat.com> References: <1396840915-10384-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 01/97] 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: quintela@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 --- docs/migration.txt | 12 +++++------- vmstate.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/vmstate.c b/vmstate.c index b689f2f..bfa34cc 100644 --- a/vmstate.c +++ b/vmstate.c @@ -19,11 +19,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);