From patchwork Mon Apr 21 14:39:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 28707 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BE67B20341 for ; Mon, 21 Apr 2014 14:43:09 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id pa12sf21594750veb.0 for ; Mon, 21 Apr 2014 07:43:09 -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=XUzIbq8hUB8boltodTfEJy3ApPd/S7ZJI0MYrkCFHdIX3vH7DCLiBjRzklW3qjhH7v ytSfP5YL1TVYDpTCG29bx/QzpuMHjXSvkN8ZdpHw44okRPrITL7fMiY6NmcEZR1xIt9t JJUi1TNdG6UIUAeeHxlHNog9E7aZkFLFx2xCHNeWZxH69TT30fH0lVQ7/lTs5t+8UISf 7K1Zc0IG3qK6uEDje8kwA0sYP339lG58hAxwELFyzyHWSnLuPC10C0BI4Q7gqjr0NCuL 3ulFgvnvv+w+sFaoav8hPbNQqYqWuXsIFm2w2My5jaA3O6S2mPnTBCVc3Ldq287ImTsS 3DXA== X-Gm-Message-State: ALoCoQnNfX2pTKnfCmFYFyW53m2k6lh6olnyigwqbv79xekdpwzRbmC2miottTxE7/lu/oFFuFPA X-Received: by 10.236.92.15 with SMTP id i15mr16799948yhf.8.1398091389486; Mon, 21 Apr 2014 07:43:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.201 with SMTP id f67ls2446383qgd.91.gmail; Mon, 21 Apr 2014 07:43:09 -0700 (PDT) X-Received: by 10.52.164.237 with SMTP id yt13mr26260690vdb.18.1398091389020; Mon, 21 Apr 2014 07:43:09 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id ud8si5750319vdc.15.2014.04.21.07.43.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 07:43:09 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 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.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so7822058veb.26 for ; Mon, 21 Apr 2014 07:43:08 -0700 (PDT) X-Received: by 10.58.161.101 with SMTP id xr5mr367055veb.36.1398091388934; Mon, 21 Apr 2014 07:43:08 -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.221.72 with SMTP id ib8csp295929vcb; Mon, 21 Apr 2014 07:43:08 -0700 (PDT) X-Received: by 10.229.176.72 with SMTP id bd8mr39654714qcb.12.1398091388025; Mon, 21 Apr 2014 07:43:08 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a7si8444445qcf.63.2014.04.21.07.43.07 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 21 Apr 2014 07:43:08 -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]:49197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFR5-00047g-Lk for patch@linaro.org; Mon, 21 Apr 2014 10:43:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFPz-0002u3-9R for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:42:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcFPq-0003qq-VZ for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:41:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFPq-0003qc-NU for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:41:50 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3LEfmih004865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Apr 2014 10:41:48 -0400 Received: from trasno.mitica (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3LEfi67019220; Mon, 21 Apr 2014 10:41:47 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 21 Apr 2014 16:39:41 +0200 Message-Id: <1398091304-10677-2-git-send-email-quintela@redhat.com> In-Reply-To: <1398091304-10677-1-git-send-email-quintela@redhat.com> References: <1398091304-10677-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 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 001/124] 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.181 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);