From patchwork Mon Aug 21 03:32:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejus GK X-Patchwork-Id: 13359010 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 EA861EE4996 for ; Mon, 21 Aug 2023 03:33:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXvez-0004L7-Ra; Sun, 20 Aug 2023 23:32:57 -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 1qXvey-0004Kn-5p for qemu-devel@nongnu.org; Sun, 20 Aug 2023 23:32:56 -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 1qXvev-0007ET-EB for qemu-devel@nongnu.org; Sun, 20 Aug 2023 23:32:55 -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 37L0eAoL032093; Sun, 20 Aug 2023 20:32:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= proofpoint20171006; bh=FxmeBqXXQDYJurqHbQXewSXVv0MMatw8ulB+h2pVK Uo=; b=EdMcb549ujUQdbrQRkvMlJBXa/uC1T5WZvjktPzhr6PZIz1DgSoyBTj3k u4VBBUwdetmiEtZpkJoSL6wkE9vhlE8sGGlJ0NGsMizw8PuraoO5TD+kt+4EC38H MIFu5AbeOqmrvxKco9CMErIkcO7vcfehAh3c/rlTSQxQwu6V4w4/YIWrlmzY/UCo 3nX0pJWIMVzkC5DCQoVZPKEKzUM9WY94f5uq1uKIIwR+RLUOqav8FycH3XMk6s6q /PLaU2euumhnGRTi+rJR552QCBcWfPkJjubKHH7vmL0gCtBdvbeuvVnbOeFEubG+ pBue+8f2Z5QlMmMGredSqwcSnOZJA== Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3sktp1gak9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 20 Aug 2023 20:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3cvT2raY43hKLLHTSMR3cgSZiqj1W9kHeqtw2J/jQjajhwXjYLVyrzVzi9rwX07TYV15nfHkxiyKBstffGL6KArzgWR4jKKMlh+oqrRf325h2XFOGRUEQC0Zw76RV8dnFqIveFHco2QBbn8QSuyQY/O7qDmM884OhzXH7vuT27MKSHALaEEnCSitofu/dSeONZD3ne8g6IMmt+c8RSZSED4XEZ/GsEsNS4K/DS9ttTg88yw9cj+l41JMg8AZcIZ/BwwG06wzsvnHTlZBcKEhxiT5kDV9NjhzPAOD7th/45wCqH5GbYB9k+8EegTjsXV7dC6YxCTYHZP9+YbUq9jWA== 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=FxmeBqXXQDYJurqHbQXewSXVv0MMatw8ulB+h2pVKUo=; b=IaEW/N8fx6Pp42SNSequz6MXtDiLkv8iTJCrb4cjb62+ooPo4t7VrlpwFphttw8TDL5MgonmdFiF7vLsIxbT2DKqZLcXlh3Vch6tTIOWGQfxEHYtSwBIWNa0wSPKts0cxxW1KS0m+LhL3E+eFuifWuctrb4C1IzVLFAv/yz/9BR0cEhX1FrkYar7solwkmKsCdW8iKRM+L6c+ijg2jBX1T/dYObU0DRuD/zghCYClpnYwJZKNPe+3bEuEaLbZ9NUxy9bS7cUFLFz2nYmfUgfdqnRh+k8sRzbh8kJR8p0HUS31Y7fWGb+bZQvjTRF3nxqPJ8YAMT+J+ofnq3uWkrTZw== 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=FxmeBqXXQDYJurqHbQXewSXVv0MMatw8ulB+h2pVKUo=; b=c7NPP+ORnbYXOK2BIFUTO90Ez2qc2UuMMXjG+FZ61mOwW+cF5W+tGzUMKtrQJQyFxe8bodmekIQePyreSx5F1b31RxfNnxpMopf5ArWPhuwlQ0m4gADAgfgsmV7G/xRO6FZZNdCBoUOCW/bmt9oyTiz954glniykhwIj5bbmvEsfUn9Y299l/0TB8xVrhN7p3wLD0aNtw855qowohoMpFvnDt+ULxeOdtlRnyDb1eaGTFp3jGiYFzQHgsCTNMRt80iP/ckBmI/lzQ77wNxmiX3mExoIsovwIvu8u+OBqkV3PMHsCjJupGn7DlGodcahRiRBI27TaSev0MvCbojihCA== Received: from BYAPR02MB4806.namprd02.prod.outlook.com (2603:10b6:a03:42::30) by CYXPR02MB10228.namprd02.prod.outlook.com (2603:10b6:930:dd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Mon, 21 Aug 2023 03:32:49 +0000 Received: from BYAPR02MB4806.namprd02.prod.outlook.com ([fe80::6c22:957:5d20:651b]) by BYAPR02MB4806.namprd02.prod.outlook.com ([fe80::6c22:957:5d20:651b%6]) with mapi id 15.20.6699.022; Mon, 21 Aug 2023 03:32:49 +0000 From: Tejus GK To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, berrange@redhat.com, aravind.retnakaran@nutanix.com, shivam.kumar1@nutanix.com, Tejus GK Subject: [PATCH v4 2/2] migration: Update error description outside migration.c Date: Mon, 21 Aug 2023 03:32:16 +0000 Message-Id: <20230821033215.6112-3-tejus.gk@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230821033215.6112-1-tejus.gk@nutanix.com> References: <20230821033215.6112-1-tejus.gk@nutanix.com> X-ClientProxiedBy: BY5PR20CA0027.namprd20.prod.outlook.com (2603:10b6:a03:1f4::40) To BYAPR02MB4806.namprd02.prod.outlook.com (2603:10b6:a03:42::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4806:EE_|CYXPR02MB10228:EE_ X-MS-Office365-Filtering-Correlation-Id: 62169fbd-3608-4dee-6be7-08dba1f74ac6 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: FpRg4o/Hta5xCWPKu6l9DIudBjcutclzT9OrcME3NHT6B8U8WXZAcx7hXCFUDpsBev+h+Bve7mduh+//M3+EtjIjiJx0pYRfAbp96mVCo4xtIBWBpn2cuMkyhTbqkbuPtFYfp8a0BpMohs8syl+XxA8/MvKhZtFxoblX2sEtFYZYCZvIz7qzSyuTUQli5jbVJqLt7hyaa7jpdJkEfHetnP0IS6cCX0POpcK6Q7dnsrbvh6klKvGZ+0lStj8yEMMgZJbqC0KmNNoLVgzBKQ5C5admPCY0xl0sXgUbrGoduRePEfmXWfJj+KmhO2CK2+zc4qiNJUAn+4rUTwmR+6TA7ITtixY7Ub/Cpim7zRSFkkXbo5yKaL27HhlxEpsLEKlg6+ZIFA1k00NOpR3+NIS9G5pltISpnYmM39cTHowf+1QTGmk7OY4WxBTkZ+hvGU6uiG1KWf0wSRQuBKgq+Cu60aClVVgr96spbuPr1OGo5ZNYeHZpvzP2MYOjceMzpvrOCjr4IE23h0VzpPDT7VPkftzfIokY+kErjfnBqm0R5buZyhwjR553AHg8/C4dYnaafOfiOXaZ1zuNPVqSmH87n9YorxccEBbQKo582FxTGuEpWp4KCpKTBpntNelHDLUO 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:(13230031)(376002)(366004)(396003)(39860400002)(136003)(346002)(186009)(1800799009)(451199024)(6666004)(6512007)(52116002)(6486002)(478600001)(83380400001)(15650500001)(41300700001)(5660300002)(86362001)(8936002)(8676002)(38350700002)(38100700002)(107886003)(6916009)(4326008)(66946007)(66476007)(66556008)(2616005)(316002)(26005)(1076003)(6506007)(36756003)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pozwdNDBN1TC8X66cRzIPfPkyWnomlKA/1O/wqj4i5KuFjkb5qWaanTIgTemBsxdzs6oKLN7k1EysespdohRaYOEd6MILEKgWjISQBo58IULa82t7PbMHczNibZ3G0o4VYSHpXuyyPC7Yr2cNrrrq5N5oMPkHo3z2/bs7rSldFb2sAJYiIjEA/fAWJh03nHjNgsoWAmhzhrZHXneJIQ/hh/5Y6998zC2NVbz26JtiLWOP4Ffox84ne9rc8K8+mvKgn08KsQas/4EaI32p5YERoBDR28hp2RTFu959G9Bnaejw6886vTrluuCok+Xjvep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lmmZNn0feY0RM3uZHMI9gneevsX5dkgJ3FXYeG4I7pyyn/zuimpYMsufQCFB3Q3d9Jy6MEbTq0moaHINBWW/NxvreAp6JUnEvWWPMPHwsBtDhlkhBsL/qFPLRU8bKsT1zYgs6iQvBv/9nzt2OGhqtw79kNciwHBRN7wtcmUxc2PxUrCgAwzgg4iFH79MlAvjqD7Yr6i X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62169fbd-3608-4dee-6be7-08dba1f74ac6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4806.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 03:32:48.8301 (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: mQv9xe/1W0b9MN5A38eVvNRcN0By4lPpFJiDoDxPwqfPqEm4bE9oq580M1VYFEG1sF+8q+YxvVVWaEMWcEQQYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR02MB10228 X-Proofpoint-ORIG-GUID: 9Kmaaitpsi_6wC-j1xogGh62KtGEuPV_ X-Proofpoint-GUID: 9Kmaaitpsi_6wC-j1xogGh62KtGEuPV_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-20_15,2023-08-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 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 6c404ead1e..540bce3213 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 417a83215d..7618822e61 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); }