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-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?IrCCxtDi0JhLD6ruxRldVW27mArV?= =?utf-8?q?l52+Iz0BaDAmzkQOWQtPBdVGH1naj9SoWoEkh/oPXHJZwH/0USvC8nK4OzGCoycOy?= =?utf-8?q?qKCHTDOjQZrhH0WNIBb6pxvrxshn2EcRR4Twb4Fk3M5vD2FHUl54uht/GH1K9TVAb?= =?utf-8?q?ByMtHg+WmVACGn0fEB2lrN/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ufvjdT53f7DMxsSWgS3twvF4aY2Lq?= =?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); }