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); From patchwork Wed Jul 19 06:35:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejus GK X-Patchwork-Id: 13318349 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 2FBE7C001B0 for ; Wed, 19 Jul 2023 06:36:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qM0mM-00089K-9p; Wed, 19 Jul 2023 02:35:18 -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 1qM0mK-00088v-Fh for qemu-devel@nongnu.org; Wed, 19 Jul 2023 02:35:16 -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 1qM0mI-0008ET-8S for qemu-devel@nongnu.org; Wed, 19 Jul 2023 02:35:16 -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 36J5wtNT007757; Tue, 18 Jul 2023 23:35:13 -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=BJqct+rEp0y2UM+zT8R95oKcAqdzUmKvTihYe3ha0 Q4=; b=1p/gdoa+IbE0hk4CfjupL4XcCDsV9qBAV6lLIpZ5EXf6DmIrnx4I300kT RqRwm0tSWxwU1xSW2ss+OZ2USMXyDjungsN+fnJBLobCZ9tydkG7Vb/9M3YwM9WZ r46sgPpvNEG6cjqPmtgQXEGORtJOfoVMw25GcVwAf6miU8RPk9ZWhAhbjtvyivTa vIk0xdG0L5i43+KNuYSQa4hDSslvbHu3dfWj3z4qpqguxng2WVPNaLcmmDVC71Lh 51EnV8P5/yConJ2OxvukZIc7UMRLR3GkzByAmk5tcWe4HOkWbUnbh7MqQ621Xabf 6j5+DwORfXBuTMQN2DL0vdO7w03/A== 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 3rx2wn0u8k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jul 2023 23:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M3c2w9NsfujmrNCSXNu5qWFWC/QqMSREWVnFXvWIezkeJXYNtDYk2wH8bLo18kIZoLXeqZdIGVQIa1DbT6dj6FvgHIGmfybxzCx8UQg2woL0j1DRnWs7lXZl/pnznDLwh4pvoa2AduGyLaADmc39qcZav1mdbhQn0fOfg5OSLFArzwOWPrFCJo4zbIrgqnPPyfwV631R0LPxKhQe1DwiHj8vW0z5LnIk0gfbnRBe2yIehkxKdJ9Bi8LRwvYs6eu6P61UWr0T1VNFza5Pu8mq5bxVwyqWWUjUns+y8qeBIXoO6vlv9ptVxfOKgJbCtIVHE5nWv8nKRLflDzX3dj/Ztg== 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=BJqct+rEp0y2UM+zT8R95oKcAqdzUmKvTihYe3ha0Q4=; b=YlSuUZlMdDgmKSi1r/y/QXFMT4vlmtSnZpC5uvBouBAEOOvkkMhochkOnRKHpfA9omLeRiMhRGyFMquC1CQ6frG+dkeWMxuD0WILJmfkBGlMq7jGhth6ZGokB6wJR8MRRZIKhvL807KO+VZwLH1hDXzp+v40hkGRUqsmVQEzJPFYymoD/1mDG6DIVIOA9GSZtOOxcY2fpkwkPIgIGP7shD/cJpUCmHejFtmQ+kJgKiqGHIjmrBnZ4b8FRSnm/GwGOS6hcvbCVe61OKDjZ9fLi61i9IhBgnB5q+Db+7O+Sdh9iV1bT6tm17VKheGX2x4YfOjDqitCH2RL9TVjzIRsSw== 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=BJqct+rEp0y2UM+zT8R95oKcAqdzUmKvTihYe3ha0Q4=; b=H5x2RtjWvptzqR0fO+ujUqwkTFu8ce7FPEOm6f0j53bihFHiF29S/9Am9sdChMjCAM7jqzIKWz4H/spDGz5YJCm7EfTl8ix6FNPbdPocdqy60PbtK67osJrZNzWBzqYjCPI2p15gX/Dc3EpYtQ6Pq8+cFhM6OUy3uc75h4jg5iy7RMhlEN6AsaJv8deBD8GthXllNXvOvWt8Agx7LUIOefJ9tOE3rA12mCH/bNE86CPSpdZQmHjb223Hh6Q011BsM9C8msWBRYCV92mCgAhsdvRrn5HgBwKGn5CvlIQR6wjGWEmWh8pvAmIyGB5kZxezbS0Drfp3NhedhaPkAYWjMw== 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:08 +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:08 +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 2/2] migration: Update error description outside migration.c Thread-Topic: [PATCH v3 2/2] migration: Update error description outside migration.c Thread-Index: Adm6CylU5upkHJpCzkSEe+TkelQnLw== Date: Wed, 19 Jul 2023 06:35:08 +0000 Message-ID: <20230719063455.128000-3-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: f87b120a-bd1b-4167-1337-08db88224bd1 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: vM9OtfXZKJvAk121NcaG51j7xlLBG4kBdt7bcu0f/Bo95n594ZJWrKjPafCy/wzmUy/Qgisyrj6ca1WmD83S+rnOUeaoPvyOEq/YXUtlFsVC4fwkHSKcPBR59lQuwzuuGNr261Q9NGIggfGj5fAlFaqVfpKCW7vfa0H95WWlyC7cNq7hMS1aTPynasUXX4s7rGBWzZaNSs6vFnIyTI/VAAb315ejAe8kMr2Nbk1d9CXpCbJy+vl5f55ZBPH62PIBSCiEG3KTkrzbi6AP4q4X6MxinPW94r7VS5yrNWngNegyt8QfFQYSqakos85hTVOHOAerK6uduZI5DO+rM8eibBbtIlkJYXSK3DvCq64rLiBtzlS0w4NtdnAbJ8wrkHROVHABDMu07vBPTxIWBP49VlcYDm3W99P3WUYyekRGPTbio+mAwGPt7aehXk+cyvUsVqzl3sBQIBthbxBLF0SI8rjbKkqKA2XCNS1xiSGsSAbWKMsDuF1KK9NTMwCNZWvX4qZz1aeRnDboGHsO0SFkgNj81DQaNxiTNouECNlyBtiH9J1oWYviUvwjs2+B+yA7wiHxT3pdvsIEcpZfvyaGC/giK1TNzxk3az7LJxU4sVUUw4WxaIC2uWa4ilWeoQUM 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)(15650500001)(6916009)(66946007)(316002)(4326008)(5660300002)(36756003)(52116002)(2616005)(64756008)(122000001)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messag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z8XWvgYDqGGPCjptu10L8dQS20y2A40i62okVWOduuWgzkkYX7V4NiusGK+gNbr?= =?utf-8?q?XQncXikRTtm+hKt0747ASoJQqlyAqtNnZ1/NuNRR9uPX/5ZzEtXcsaOkEmtCYRz6v?= =?utf-8?q?W46U6qg+fK8hHL6EMrbMf4xufa/MZDYubcygiJJMz7TcodwRc0kSTZkULYBwXkpOA?= =?utf-8?q?YBt5KM2d7iG82llGLRZ/Y4GRbkgC1D1AnsJdufvjdT53f7DMxsSWgS3twvF4aY2Lq?= =?utf-8?q?q5MxdNvAJU7ouPwIJSZzz+cFqrCDGJXI+70HIz2J7VRSO3Ry0/5zUXmaUZn3OkvL4?= =?utf-8?q?QIx9quz0/0fbNYsYw+ml194Png2BYHeA34xG8jSXHTwQ/SCq7X6XdC3R4h3VZLIRz?= =?utf-8?q?03MGyoQN/ZVA2o7/zPHvYH2cZuqEHyD730Og73GoHtz//7N/fTBIKOQys3u115Cph?= =?utf-8?q?BPR35bqCzbAs8iUwIoiVrCj6Me3K84yNJ98Veugh7AlBKAopyUjO3xJlkj4yYGm/q?= =?utf-8?q?fScbD4Mgk7j3FamDqz8llzSQdNG0dh0GjyWeh8gZvALmwW/dw/hJblx5z2nfn88BU?= =?utf-8?q?wJZ46vww/XcMj16QysZbl4xNnfsX3qXWk9uMCLqLeuFvODZLHaz1VDdkeKktq6Sig?= =?utf-8?q?JR19874fkWoW2Q+eynlCesqnRzbCynUZ/grKUSVAp+kJaAHc714r0cMiBKykARyWi?= =?utf-8?q?r1HT0vV+bZMv?= 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: f87b120a-bd1b-4167-1337-08db88224bd1 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2023 06:35:08.5028 (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: zaPKo3+BsuBV1JDIfHnrFCqoo5AxSfpWVVOvWOmqeqJlpVGc62pmuNe57Z5frVo73M7etHTcHUciTHuLZpRIlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR02MB9572 X-Proofpoint-GUID: c2J-u9K3xqv5xOxzUDxopzekwc6NBMav X-Proofpoint-ORIG-GUID: c2J-u9K3xqv5xOxzUDxopzekwc6NBMav 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 A few code paths exist in the source code,where a migration is marked as failed via MIGRATION_STATUS_FAILED, but the failure happens outside of migration.c In such cases, an error_report() call is made, however the current MigrationState is never updated with the error description, and hence clients like libvirt never know the actual reason for the failure. This patch covers such cases outside of migration.c and updates the error description at the appropriate places. Acked-by: Peter Xu Signed-off-by: Tejus GK --- migration/savevm.c | 17 ++++++++++++++--- migration/vmstate.c | 7 ++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index ea1cc1a26b..67a7ea7ba1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -979,6 +979,8 @@ static void save_section_footer(QEMUFile *f, SaveStateEntry *se) static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) { int ret; + Error *local_err = NULL; + MigrationState *s = migrate_get_current(); if ((!se->ops || !se->ops->save_state) && !se->vmsd) { return 0; @@ -1002,6 +1004,8 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) } else { ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc, &local_err); if (ret) { + migrate_set_error(s, local_err); + error_report_err(local_err); return ret; } } @@ -1068,10 +1072,14 @@ void qemu_savevm_send_open_return_path(QEMUFile *f) int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len) { uint32_t tmp; + MigrationState *ms = migrate_get_current(); + Error *local_err = NULL; if (len > MAX_VM_CMD_PACKAGED_SIZE) { - error_report("%s: Unreasonably large packaged state: %zu", + error_setg(&local_err, "%s: Unreasonably large packaged state: %zu", __func__, len); + migrate_set_error(ms, local_err); + error_report_err(local_err); return -1; } @@ -1475,8 +1483,11 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, * bdrv_activate_all() on the other end won't fail. */ ret = bdrv_inactivate_all(); if (ret) { - error_report("%s: bdrv_inactivate_all() failed (%d)", - __func__, ret); + Error *local_err = NULL; + error_setg(&local_err, "%s: bdrv_inactivate_all() failed (%d)", + __func__, ret); + migrate_set_error(ms, local_err); + error_report_err(local_err); qemu_file_set_error(f, ret); return ret; } diff --git a/migration/vmstate.c b/migration/vmstate.c index 35a9b67afc..71dc21c273 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -14,6 +14,7 @@ #include "migration.h" #include "migration/vmstate.h" #include "savevm.h" +#include "qapi/error.h" #include "qapi/qmp/json-writer.h" #include "qemu-file.h" #include "qemu/bitops.h" @@ -336,7 +337,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, ret = vmsd->pre_save(opaque); trace_vmstate_save_state_pre_save_res(vmsd->name, ret); if (ret) { - error_report("pre-save failed: %s", vmsd->name); + error_setg(errp, "pre-save failed: %s", vmsd->name); return ret; } } @@ -389,8 +390,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, vmdesc_loop); } if (ret) { - error_report("Save of field %s/%s failed", - vmsd->name, field->name); + error_setg(errp, "Save of field %s/%s failed", + vmsd->name, field->name); if (vmsd->post_save) { vmsd->post_save(opaque); }