From patchwork Wed Jul 19 06:35:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejus GK X-Patchwork-Id: 13318350 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78EDAEB64DA for ; Wed, 19 Jul 2023 06:36:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qM0mK-00088s-GP; Wed, 19 Jul 2023 02:35:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qM0mH-00088F-LP for qemu-devel@nongnu.org; Wed, 19 Jul 2023 02:35:14 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qM0mE-0008Dg-4x for qemu-devel@nongnu.org; Wed, 19 Jul 2023 02:35:13 -0400 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36J5wtwU007760; Tue, 18 Jul 2023 23:35:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= from:to:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s= proofpoint20171006; bh=ydC4RSAHJvUhilam0Gaq9vCtLh3B3Rk4Mcc0Yb2Kn nI=; b=askYpGNqB3C/Zc9DyX64B/wR29tVkPQQ9BzmlmzxLcD5barTwK4arfIs3 9IH/9NEOGu7dP7UpU0wANeyVbideLMYShvpO556rRzB7yiJ7gmBiER8n1uknmVWe tK6Y4/rhDNz1Jn+S+FhR0n02ok7obz/m9Z7ZhMPdMK179iNJmThLXcAdYzyemdf4 h0uWO6AHMKg0qN3LYIJxOrYTxbCSawuPpp9l6y7OQVUckXC/FrbAaUXn+Opj+LGf P7wa4UbQJ+ljzJMfXS5VCYB9HK0Hc4OKe3oXKtUhBrZ7h2h6fraQG9uqzFKtf7FT FxRDcp0CwFbgKdDIjLFD7TDA28wvg== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3rx2wn0u8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jul 2023 23:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cd3gj9kCrKrgvx3dWxbQoKQesWJ3yNH+MLh/Tn/pNiT669KXN+sylcBBRVKzxChu1zyBFAdXyTr53Eb+xqKWZ7bJZcXpfdR4bXSnCesCW7app43Htvert4Tc0U7GAK8XYQ2vlQaEvgdqmBhPpo3PPPZr0WgOm3oT4poJBhYFY/UcYUESpgnECqZVoQIoJnNTbnUw+Tye2gKQJR8coI+g3mGKGUY/TDakrYDSxA4l44laWgv9voAJ1TDgAxxuUckJqLU8QkP+L0eXx5prJiMjGAdYC5h4/hnVXbKv5kd+rwUpN3RRBTW869/ZmjcbNKSmHqBf4BsIwNyPVCg4HW5Drg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ydC4RSAHJvUhilam0Gaq9vCtLh3B3Rk4Mcc0Yb2KnnI=; b=VgML+rwMvJ97sHZ78qoRK8uTDmTGgKm7K8qRAbcAJvi+mryZz3Hmod8WMYpqCJThtDJl40v7qYHgfSLeRWJSe6TyedeElX1zXnVJCC6ERQnQ/tbX6H2OsjVHTaSnhnfepV6tqWZE+lhwOtBSlYxdILnF1IEKWBlgmjppc1EujFm971VJQ/1dL9pNr/fkja4xQ7eBnp/QtlX6VyUSB7i1IQKi1u8UFeRiVdUPo0LOdQmk5qf8pLGkjVpMQddb3/WACoy7JFLZnrHkHrM0ncMR1pQIS3LkHG9ZPm6YLoyzL6OvK00gljyTYfwSS/02QS6wpibBsXXW+5IfpIHzysd21g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ydC4RSAHJvUhilam0Gaq9vCtLh3B3Rk4Mcc0Yb2KnnI=; b=XYQrBwBmnDbDpQxdhJ6V/lJiTX7co1YJX1Zezum3pBF9GkNV4p1swQj6FPf5G9wwSqVtlrM7YUqHcNCWp+r6Pm3wdSB/bMZzqchRYQkXj/dM+ozBQPJYKnNLF4yFktJ2DS1V3wPKRWI6IfV68oofDlf76BX/xbcwc09Cl0ODJEQI3AvBgYdTrlKUDmq/EXhIPY9tHG+fDIgMc02ru36+C3Ym3H7+GnU9LYfo/V6F0hNkzDRuIT9CdX7uxBy9aDab8okuEzh2TiKBLWX9fjOjGYVZE2qqKHqZ4Xqy8iKJ0pA9xw5CX0w15FRu50v2ZBJMNlp4PlvfvT8d1eauTXAe2A== Received: from BYAPR02MB4806.namprd02.prod.outlook.com (2603:10b6:a03:42::30) by DS0PR02MB9572.namprd02.prod.outlook.com (2603:10b6:8:f5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.22; Wed, 19 Jul 2023 06:35:07 +0000 Received: from BYAPR02MB4806.namprd02.prod.outlook.com ([fe80::82a3:a948:abf6:8676]) by BYAPR02MB4806.namprd02.prod.outlook.com ([fe80::82a3:a948:abf6:8676%2]) with mapi id 15.20.6609.022; Wed, 19 Jul 2023 06:35:07 +0000 From: Tejus GK To: "qemu-devel@nongnu.org" CC: "quintela@redhat.com" , "peterx@redhat.com" , "leobras@redhat.com" , "berrange@redhat.com" , Aravind Retnakaran , Shivam Kumar , Tejus GK Subject: [PATCH v3 1/2] migration/vmstate: Introduce vmstate_save_state_with_err Thread-Topic: [PATCH v3 1/2] migration/vmstate: Introduce vmstate_save_state_with_err Thread-Index: Adm6CyhxxGDZjD6U80yBMbvyqb8drw== Date: Wed, 19 Jul 2023 06:35:07 +0000 Message-ID: <20230719063455.128000-2-tejus.gk@nutanix.com> References: <20230719063455.128000-1-tejus.gk@nutanix.com> In-Reply-To: <20230719063455.128000-1-tejus.gk@nutanix.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0060.namprd07.prod.outlook.com (2603:10b6:a03:60::37) To BYAPR02MB4806.namprd02.prod.outlook.com (2603:10b6:a03:42::30) x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BYAPR02MB4806:EE_|DS0PR02MB9572:EE_ x-ms-office365-filtering-correlation-id: 4fdf94aa-4d0f-4ca0-97c0-08db88224aee x-proofpoint-crosstenant: true x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mXGCp+zMjKCOy2sULL7KaDbH3z0acERB1eAKIj37yhz9LF7JyEFDEobtCER8OQ464uX80KGdOuKzW4Z0zWmq7aYvk0yLYUR8P0qE0fNfZjWdUJpMTt8ORsLzKLwOQboplCTb6EFJuhIYNEfarlOr9rs1atHtgXHH0y5tQUxjrzK5fCJ6t/FsOso3fQyySA94vCz+HK5Af2QHblmeNbifXPkPz/PC923eIKh9JJQObsx5FiViqYsm2EvbdmJ/u26ZNiecAaIQ+/55+4Wu0SKlvu5ZLrZiLWKotq1Bu6Zaes81VxPC/G2t2U3LXgLfQf7WE8zYjMeCyFVXDfxIRHoeTBHtch4z7J0Ub1glzL1XesbCuCTloqgK+GaF8uP0xkMBxp8iGEBBEQGmkOMsjNeTQ/4btQR4wO6/clHjU2ywXTD2TFk5W3f0XiuybUrXD/MGgLP4z9L0GWW9w0kxQQrloBRxfAduFMT2eQlSSsACGzPOi26R++PnFFPwU/Rp82RvTh73geX0F/9Gt7NC2I8aw71Rgqnnap9azZpZc3yPbOuOtLUvrVrJcQuRGXSc9zGZOMyPHfz4+OynVtTJ8rbyE8RI6lGMoQjrkVGdVWb36zs12p9dPtWrX/0LxYvj2ZM1 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4806.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(346002)(396003)(39860400002)(366004)(136003)(376002)(451199021)(107886003)(6506007)(71200400001)(83380400001)(1076003)(38100700002)(186003)(26005)(38350700002)(478600001)(6486002)(54906003)(66476007)(6512007)(41300700001)(8676002)(66446008)(2906002)(8936002)(66556008)(6916009)(66946007)(316002)(4326008)(5660300002)(36756003)(52116002)(2616005)(64756008)(122000001)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?rSSznYiP+hH85xEUxKhn9kDZBZ00?= =?utf-8?q?kNRNAz8Q/Wm8rAPAki7qx43Jl+7cmjuFQ2b3dgkrXtpYDifH129LgpPFBQUyQOrQ+?= =?utf-8?q?iT3ATvZDzMY1QtPycvVRERUIsCLxwVm67AJiNNvY4L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76NGED7TzRdTYyo5OdNs5?= =?utf-8?q?zpudLZXMO1GV/0a3YtmTHDJeD8wrpzwwcSlf9zRB4vOPU2+yPuQaBkyo4HItcTC8q?= =?utf-8?q?mNHvuGacWb5ubko3KsvwqmPDspbI1qFDAwUt9rH6TaZtoMODnjO7Xzf7DrnhANZSw?= =?utf-8?q?CLHoAdDHT2t+8ms2WfjqEweq1Z2x38AqhviAkKI1Wik6CcsoC89MEN+EFpr3PT1Wj?= =?utf-8?q?nbzc5LeR/4lfvzj9rTtMSGo5qhTg4zuuy5nA7kB06zBN0Y/mc2TJGwjBm09iQnWmV?= =?utf-8?q?Lpx0ZxoZQWMY1VSGZfykDeaf+a/UzDDetaqtmji4o5CKXYGXgMsDC2vXmVRehMHsa?= =?utf-8?q?yWfQaK2d0aM5vZWxfXUT2/vd51WEgA4zIMBu2iDjzs9XhcnTtijLmi1TCwG9ZhUno?= =?utf-8?q?ys+SyO9+FaiVb1AvOvRwiCvGbMaGC0sPtd9gIbn2BrdOcy6tBPQcH0caqQo2T8uBV?= =?utf-8?q?UsLway+z6WiHONDEMlXpszJpSr+UpaEKCLXLVuXaeplxRWbuBJvtBiv+wp/Oqq2+X?= =?utf-8?q?Vo6IjTN2zv8U?= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4806.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4fdf94aa-4d0f-4ca0-97c0-08db88224aee X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2023 06:35:07.0211 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7EWiFWO105hhfYTE9YHU3AhmrIzpPAOdVvFw+SPZDxD+xe6oT4xu2s7D1uYJ4Qk6PDbDZZ3pMox3zs9fdsAJ4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR02MB9572 X-Proofpoint-GUID: LqqbnCR3rf1QBZvpFnM89d6OtHlczYzJ X-Proofpoint-ORIG-GUID: LqqbnCR3rf1QBZvpFnM89d6OtHlczYzJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-19_03,2023-07-18_01,2023-05-22_02 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=tejus.gk@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Currently, a few code paths exist in the function vmstate_save_state_v, which ultimately leads to a migration failure. However, an update in the current MigrationState for the error description is never done. vmstate.c somehow doesn't seem to allow the use of migrate_set_error due to some dependencies for unit tests. Hence, this patch introduces a new function vmstate_save_state_with_err, which will eventually propagate the error message to savevm.c where a migrate_set_error call can be eventually done. Acked-by: Peter Xu Signed-off-by: Tejus GK --- include/migration/vmstate.h | 4 +++- migration/savevm.c | 2 +- migration/vmstate.c | 12 +++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index d1b8abe08d..2eb6002b3c 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1194,9 +1194,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id); int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc); +int vmstate_save_state_with_err(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, JSONWriter *vmdesc, Error **errp); int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc, - int version_id); + int version_id, Error **errp); bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque); diff --git a/migration/savevm.c b/migration/savevm.c index 95c2abf47c..ea1cc1a26b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1000,7 +1000,7 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) if (!se->vmsd) { vmstate_save_old_style(f, se, vmdesc); } else { - ret = vmstate_save_state(f, se->vmsd, se->opaque, vmdesc); + ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc, &local_err); if (ret) { return ret; } diff --git a/migration/vmstate.c b/migration/vmstate.c index af01d54b6f..35a9b67afc 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -315,11 +315,17 @@ bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque) int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc_id) { - return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_id); + return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_id, NULL); +} + +int vmstate_save_state_with_err(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, JSONWriter *vmdesc_id, Error **errp) +{ + return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_id, errp); } int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc, int version_id) + void *opaque, JSONWriter *vmdesc, int version_id, Error **errp) { int ret = 0; const VMStateField *field = vmsd->fields; @@ -377,7 +383,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, } else if (field->flags & VMS_VSTRUCT) { ret = vmstate_save_state_v(f, field->vmsd, curr_elem, vmdesc_loop, - field->struct_version_id); + field->struct_version_id, errp); } else { ret = field->info->put(f, curr_elem, size, field, vmdesc_loop);