From patchwork Mon Nov 5 18:51:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 993344 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=os.amperecomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amperemail.onmicrosoft.com header.i=@amperemail.onmicrosoft.com header.b="mnlWAzo9"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42phdT0y30z9sDb for ; Tue, 6 Nov 2018 05:53:01 +1100 (AEDT) Received: from localhost ([::1]:37102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJjze-0004mx-Jq for incoming@patchwork.ozlabs.org; Mon, 05 Nov 2018 13:52:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJjyn-0004a0-6q for qemu-devel@nongnu.org; Mon, 05 Nov 2018 13:52:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJjyl-0000Wl-EC for qemu-devel@nongnu.org; Mon, 05 Nov 2018 13:52:05 -0500 Received: from mail-eopbgr810103.outbound.protection.outlook.com ([40.107.81.103]:6323 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gJjya-0000MQ-J8; Mon, 05 Nov 2018 13:51:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amperemail.onmicrosoft.com; s=selector1-os-amperecomputing-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=STKh8Eqo6HA18AmpdKl/7DJjvk/NyLNwlfv6QlRGaqc=; b=mnlWAzo9O50ailJpALVpeVHh+2E7eOVrilZMWd0A0/1Ds+RhoeusvsffpULmYpRuslYKYzz1WtSR9ZyD9fhsWFnEN2O+gay0TylIS7wzNqsSIejI/ZyUs+8b1qc0WMg+CH/eVyx25xWXgmBhbrjFSwunV+YZWYNwo9o3CEBhzAM= Received: from DM6PR01MB4825.prod.exchangelabs.com (20.177.218.222) by DM6PR01MB5034.prod.exchangelabs.com (20.176.120.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.25; Mon, 5 Nov 2018 18:51:50 +0000 Received: from DM6PR01MB4825.prod.exchangelabs.com ([fe80::4cf7:c8dc:b673:ec66]) by DM6PR01MB4825.prod.exchangelabs.com ([fe80::4cf7:c8dc:b673:ec66%3]) with mapi id 15.20.1294.028; Mon, 5 Nov 2018 18:51:50 +0000 From: Aaron Lindsay To: "qemu-arm@nongnu.org" , Peter Maydell , Alistair Francis , Wei Huang , Peter Crosthwaite , Richard Henderson Thread-Topic: [PATCH v7 01/12] migration: Add post_save function to VMStateDescription Thread-Index: AQHUdTic+xF/b3bKKEmBMC9gYr82JQ== Date: Mon, 5 Nov 2018 18:51:50 +0000 Message-ID: <20181105185046.2802-2-aaron@os.amperecomputing.com> References: <20181105185046.2802-1-aaron@os.amperecomputing.com> In-Reply-To: <20181105185046.2802-1-aaron@os.amperecomputing.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BN6PR20CA0070.namprd20.prod.outlook.com (2603:10b6:404:151::32) To DM6PR01MB4825.prod.exchangelabs.com (2603:10b6:5:6b::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aaron@os.amperecomputing.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [216.85.170.153] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM6PR01MB5034; 6:9wjBNs8m887zt7jowrYpNXlcmeEUX4ypMl/FAusFtuvjPj9Fw5KDkpg/ZiaDUdDfXjRYODCZJbRkx5KYwsbX50bKfBi4mgMeu1jrw9rGCKdyCrJwi+ruLB5j9n8vyN20wfSSEmEGDp/GhDfw+1JlqrR5UuhBe8wV3gf27RbMeHEshRlMtXV+3QH/r7GTp8mb1HWrVjukl8eGpZP64Gow0cai8QVvcFSu69FvPBXIRfu+TL0Rw0x0HH1S1UtokSDaNONBz/Ws0oJv8upaB4/egt5twU+AxRe72r8NJ82/jedWsAg73MoKq2iml3sVHUtcgDGC64abZ/IMx6YsxoOy/eFEnSIQH6vrmJP0bquRl4VCioVJqi/ULjyhvXzs4wLkmIxrH/FP+PT4f7qG/oNeiYpSn9XpU6SLg8dWEzS5NY4+HtJaOclMQihbpOlQAghYD8S5ojBUlqVZxmfPF1km3Q==; 5:2s+d/EbncJoSt4UWfSwn8GJb5J9UgKWK11OGbu3LwQVJXHzTrLmwGK4ncOjHMpMi5fTxB83Acc5OVxE+zHKWjU3JPPWqTJvNlFQ222Faglq5rrvhWKep8IMgX81Uji8j201cL0IKWnjCjiX3ecnxHISIdg2pBk7qyqlyIvNmYEU=; 7:hMh6JQXxUGQthcuzyqnwm7BhJNbrLS5VoY8AyghjieZ2L1SY/mugWEIpIfyxGV0PPNb62viLPYUJy33hUfDwYd0z/u15KKCQdXTQDZ+dDvX93GiMkQ/HR5HfTlB7nH1cA8ceJCRggrqN294hWUXazQ== x-ms-office365-filtering-correlation-id: 07e7dcb4-8f5f-4f07-0ac5-08d6434fbee6 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DM6PR01MB5034; x-ms-traffictypediagnostic: DM6PR01MB5034: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193)(85827821059158); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:DM6PR01MB5034; BCL:0; PCL:0; RULEID:; SRVR:DM6PR01MB5034; x-forefront-prvs: 08476BC6EF x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(366004)(39840400004)(396003)(376002)(346002)(189003)(199004)(81166006)(52116002)(110136005)(105586002)(76176011)(1076002)(86362001)(8936002)(54906003)(68736007)(8676002)(81156014)(66066001)(102836004)(6512007)(14454004)(2900100001)(2906002)(53936002)(3846002)(6116002)(6506007)(386003)(7416002)(71200400001)(478600001)(14444005)(71190400001)(26005)(5660300001)(316002)(446003)(11346002)(6486002)(256004)(25786009)(106356001)(305945005)(99286004)(7736002)(39060400002)(476003)(2616005)(486006)(6436002)(97736004)(4326008)(2501003)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:DM6PR01MB5034; H:DM6PR01MB4825.prod.exchangelabs.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: os.amperecomputing.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 8BNgOY5iQQpllBzgBViVXw9h3iwxQFd1XURENF8xir6plEMeXscdgP5lh+GKq4aMPyiE9rsF7rljYLoahqSEIAXAdovFnfSnWcjsHIt0GVIOJp62tRvBbLE2znKC5+nO+k39vXXlBVrWtMuR+fpTYUJjLhSduaa24gaCb0fgvJaeQiWzbOO8oP7IrzOUQMikju2TWecbwqh60V1+9w51+Mq/Wq0zKgwqCu2SBQXcCO4w2DOyJO2ouOur/9BYRnLFAoEGUBvbfsU+ZWDrympY6G4/WOMNa2dqbIu6XLXW+9i5bG5+EdS9Gj/g1fpIF+mGUqlkV90/EsZN7AgIrcgj+1OCHwG5CiA1OLSGA2Z8K04= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07e7dcb4-8f5f-4f07-0ac5-08d6434fbee6 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Nov 2018 18:51:50.5579 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB5034 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.81.103 Subject: [Qemu-devel] [PATCH v7 01/12] migration: Add post_save function to VMStateDescription X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Spradling , Digant Desai , "qemu-devel@nongnu.org" , "Dr . David Alan Gilbert" , Aaron Lindsay , Aaron Lindsay Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In some cases it may be helpful to modify state before saving it for migration, and then modify the state back after it has been saved. The existing pre_save function provides half of this functionality. This patch adds a post_save function to provide the second half. Signed-off-by: Aaron Lindsay Cc: Dr. David Alan Gilbert Reviewed-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert --- docs/devel/migration.rst | 9 +++++++-- include/migration/vmstate.h | 1 + migration/vmstate.c | 13 ++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index 687570754d..92fb521ad2 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -419,8 +419,13 @@ The functions to do that are inside a vmstate definition, and are called: This function is called before we save the state of one device. -Example: You can look at hpet.c, that uses the three function to -massage the state that is transferred. +- ``int (*post_save)(void *opaque);`` + + This function is called after we save the state of one device + (even upon failure, unless the call to pre_save returned an error). + +Example: You can look at hpet.c, that uses the first three functions +to massage the state that is transferred. The ``VMSTATE_WITH_TMP`` macro may be useful when the migration data doesn't match the stored device data well; it allows an diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 2b501d0466..9355d83056 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -185,6 +185,7 @@ struct VMStateDescription { int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); int (*pre_save)(void *opaque); + int (*post_save)(void *opaque); bool (*needed)(void *opaque); VMStateField *fields; const VMStateDescription **subsections; diff --git a/migration/vmstate.c b/migration/vmstate.c index 0bc240a317..c15d75260a 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -387,6 +387,9 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, if (ret) { error_report("Save of field %s/%s failed", vmsd->name, field->name); + if (vmsd->post_save) { + vmsd->post_save(opaque); + } return ret; } @@ -412,7 +415,15 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, json_end_array(vmdesc); } - return vmstate_subsection_save(f, vmsd, opaque, vmdesc); + ret = vmstate_subsection_save(f, vmsd, opaque, vmdesc); + + if (vmsd->post_save) { + int ps_ret = vmsd->post_save(opaque); + if (!ret) { + ret = ps_ret; + } + } + return ret; } static const VMStateDescription *