From patchwork Mon May 5 20:30: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: 29673 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 13B94202E6 for ; Mon, 5 May 2014 20:42:44 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf17289830oag.0 for ; Mon, 05 May 2014 13:42:44 -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=Dl3z+xFGYRhc/hdzfcUz2fJ9NIKmtm+iI/etDqtOz0g=; b=LcqyW0oQ2nImd6z315dw4eJjERdXEkPTgyRSwkZ+tuAvjL/NDEcnp3Y4PUfPELejOc aO07BOC4hiqI6/P87iAu287DW7jznHt4rD8CXvb+uMN8jEWVTPw2tVdf20riJBvCIEuv XkOycjrX5dOH0Ydh2as+nyimkk+Wimc/wei9qtNzZYeOpp3anFDz7UIBqnkplwnu2yz3 agTdL5C4n7mpM4fEyJaiYbh3r65FEB9yjR1UcSHBwhHM2/WjBqR0EsW4a8v7vAQCY23w 2h2Ju+jl5L/xug8p4M1wQOTJfECcNClGRAXKBoymBW5b0Y0Rz5TDaBcSAS+RMFj6XpXE oxCg== X-Gm-Message-State: ALoCoQl4j55YHGQ/CZcj17J5NM8VXmJxO4HV84O76Q71DaY9/aHi/Ze8de5+LVEyLMY9jOJmmaRd X-Received: by 10.182.128.166 with SMTP id np6mr18580940obb.16.1399322564359; Mon, 05 May 2014 13:42:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.72 with SMTP id s66ls2663876qgs.85.gmail; Mon, 05 May 2014 13:42:44 -0700 (PDT) X-Received: by 10.58.98.232 with SMTP id el8mr1519169veb.42.1399322564210; Mon, 05 May 2014 13:42:44 -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 a8si1848726vej.71.2014.05.05.13.42.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 May 2014 13:42:44 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id pa12so8565077veb.12 for ; Mon, 05 May 2014 13:42:44 -0700 (PDT) X-Received: by 10.52.252.43 with SMTP id zp11mr1436590vdc.44.1399322564129; Mon, 05 May 2014 13:42:44 -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 ib8csp170695vcb; Mon, 5 May 2014 13:42:43 -0700 (PDT) X-Received: by 10.224.169.6 with SMTP id w6mr8330700qay.102.1399322562981; Mon, 05 May 2014 13:42:42 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c4si4087374qad.164.2014.05.05.13.42.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 05 May 2014 13:42:42 -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]:59660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhPik-00053y-Di for patch@linaro.org; Mon, 05 May 2014 16:42:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhPXr-0007i9-LD for qemu-devel@nongnu.org; Mon, 05 May 2014 16:31:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhPXm-00011B-QQ for qemu-devel@nongnu.org; Mon, 05 May 2014 16:31:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhPXm-000113-Jj for qemu-devel@nongnu.org; Mon, 05 May 2014 16:31:22 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s45KVJN4012695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 May 2014 16:31:19 -0400 Received: from trasno.mitica (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s45KUYEr008860; Mon, 5 May 2014 16:31:17 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 5 May 2014 22:30:19 +0200 Message-Id: <1399321834-31310-22-git-send-email-quintela@redhat.com> In-Reply-To: <1399321834-31310-1-git-send-email-quintela@redhat.com> References: <1399321834-31310-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 21/36] 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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 dbb7666..b5882fa 100644 --- a/vmstate.c +++ b/vmstate.c @@ -63,11 +63,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);