From patchwork Thu Apr 3 16:52:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 27696 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 89E9B20490 for ; Thu, 3 Apr 2014 16:58:32 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf8022711iec.6 for ; Thu, 03 Apr 2014 09:58:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:message-id:references :mime-version:in-reply-to: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:content-type :content-disposition; bh=muNSWRd2SWL0q+3OmHSp+ZKCqsuwkMUx3UYAltwqT7A=; b=h8jsme0NYcPXmjzvp3TA8etUksOCqTJljO/uekAwEkySasLR0zeTPfRh2mX6GqleqH 5Xdpe24b1rGfmiEV+fHoc0GbHLAl1wwBA7guN2pgQE8bTwsCj/TAEvSEyyWM8J9MVkIz plrYZZIlHtKZz7lX6kDzBmgaaewhhENmob7bxOnwph4D5fzlP+SK+VqZ8CyqrLU6CfDl YYnMCQjEeHoN9AYRKVujkckrt2ytTod1z6SshLQ7kGUkZqlZnZHrUVeBYGeogVanASfm CI8tQUBw9+gjMjG6E/oeakWAX1i7wubcSC5Ie6nTGVT6X0eVAC9VGLbX0VIp8NNWzu/W P5PQ== X-Gm-Message-State: ALoCoQmjsvfrIAWV0ViGq3LW6+Q5z2aZn050MNNedMUmA5N/V1dQ7IcLGHVO5rBUZMMP3EskH+dn X-Received: by 10.42.235.206 with SMTP id kh14mr4019926icb.30.1396544311955; Thu, 03 Apr 2014 09:58:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.16 with SMTP id g16ls718873qgd.25.gmail; Thu, 03 Apr 2014 09:58:31 -0700 (PDT) X-Received: by 10.58.202.106 with SMTP id kh10mr468500vec.31.1396544311859; Thu, 03 Apr 2014 09:58:31 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id xo2si316705vec.170.2014.04.03.09.58.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Apr 2014 09:58:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id lc6so2133251vcb.7 for ; Thu, 03 Apr 2014 09:58:31 -0700 (PDT) X-Received: by 10.52.15.132 with SMTP id x4mr7062774vdc.31.1396544311763; Thu, 03 Apr 2014 09:58:31 -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 v8csp44517vcv; Thu, 3 Apr 2014 09:58:30 -0700 (PDT) X-Received: by 10.140.95.142 with SMTP id i14mr8339161qge.6.1396544309648; Thu, 03 Apr 2014 09:58:29 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 5si2388185qch.25.2014.04.03.09.58.29 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Apr 2014 09:58:29 -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]:45140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVkyD-0000lK-9B for patch@linaro.org; Thu, 03 Apr 2014 12:58:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVks1-00071x-Nx for qemu-devel@nongnu.org; Thu, 03 Apr 2014 12:52:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVkrw-0005u1-Kl for qemu-devel@nongnu.org; Thu, 03 Apr 2014 12:52:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVkrw-0005tb-DN; Thu, 03 Apr 2014 12:52:00 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s33Gptm5021501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Apr 2014 12:51:55 -0400 Received: from redhat.com (vpn1-4-68.ams2.redhat.com [10.36.4.68]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id s33GpmFh029891; Thu, 3 Apr 2014 12:51:49 -0400 Date: Thu, 3 Apr 2014 19:52:28 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1396543778-22307-25-git-send-email-mst@redhat.com> References: <1396543778-22307-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <1396543778-22307-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Lei Li , Juan Quintela , Alexey Kardashevskiy , Michael Tokarev , qemu-stable@nongnu.org, dgilbert@redhat.com, Amit Shah , mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v5 24/24] 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: mst@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.176 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 Content-Disposition: inline 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 Reviewed-by: Juan Quintela --- vmstate.c | 9 +++++---- docs/migration.txt | 12 +++++------- 2 files changed, 10 insertions(+), 11 deletions(-) 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); 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 ....