From nobody Sat Nov 15 11:14:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1752713076; cv=none; d=zohomail.com; s=zohoarc; b=lJu+l/83XOUAPrKXD4b/duIJcctUFkKrVPaaZkGtEvhQFL1yYaoMGLTkuOXHhDVxHziXCdcf4E29bzQfu+do8LZTiCGk08GBuzvpiuuQKHTqowWWIkwJts+ebn8/Zitck3uOJvubdIF8v6qO4aJnPO6UTD8F32quwlVNTVZvNEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752713076; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5r7DYLmp+E9ag1L7wKjeNhUnOiKaPcopIlcFiJkBtOc=; b=AJRjBNeCU6qA5lmHuuxlKAcu/vym28lHqJ7tRsS7hDz14puj6EtLf9uvZ2lw7POhMI2iaOeHZCtPx2+UznJ3ZjUAQ93tNSeCkzHSnPPqsnaLbp4KvEqzzHxxrxLkoBUv4d44HcrS/Iw6QygqeQzKQFtKu1SiZE3ONYO18pcNSPI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175271307659744.881378208285696; Wed, 16 Jul 2025 17:44:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ucCj5-0000iu-E1; Wed, 16 Jul 2025 20:43:55 -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 1ucChW-000626-9v for qemu-devel@nongnu.org; Wed, 16 Jul 2025 20:42:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ucChT-0005Li-4R for qemu-devel@nongnu.org; Wed, 16 Jul 2025 20:42:17 -0400 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-339-_ukr-oB9O-euigQW9xfG9Q-1; Wed, 16 Jul 2025 20:42:11 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-313c3915345so600746a91.3 for ; Wed, 16 Jul 2025 17:42:11 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.97.205]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31c9f287c19sm2214424a91.31.2025.07.16.17.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 17:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752712933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5r7DYLmp+E9ag1L7wKjeNhUnOiKaPcopIlcFiJkBtOc=; b=SEAmIles1H0lKUi6b9xTKIuVv0PJ8zRWejXBAKOtcTCovQYAwYH48fVwFjdB80F5O06x7S ty7goxTDVbS+M1aTIHDfCm5WSl7INbvwyrdcFavNo/u9Y/gz2yg3RIxI4eOWXpdaUCeiK4 11FaCRkkCDm0HIQcjsYj1OGQMD+tFs0= X-MC-Unique: _ukr-oB9O-euigQW9xfG9Q-1 X-Mimecast-MFC-AGG-ID: _ukr-oB9O-euigQW9xfG9Q_1752712931 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752712930; x=1753317730; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5r7DYLmp+E9ag1L7wKjeNhUnOiKaPcopIlcFiJkBtOc=; b=KT2uODa6qcxYClT/7WUcZs7FUWTa17GXXxl7So/d1GAKhHVUvUSFNLDNY2VhVnfeh4 0fszIASIUHSKtp1sRNeR0QlaAD79ZgJejylSKfW3/HhGSGVf7clEv0z2hzdMUMNy5KSA GnC9hFylRA4YmPEwGlkeX3ZOpYsb5i7r6X/qjpPe800iUdOuThKxS+GvAlKraJyFSIQY 7R6kH2TPYB09fYL4Sj9q7GPpIkDH75p2WCsOtRAJCiDxYV19OxHP6G38nGZl65s0167L g1KPBnL30eiq15HVuP3XAdGa79yiIA9xtc2KJnKu5/ByBCRj/I8WFyee96Nj3IEyOjrm Pyhg== X-Gm-Message-State: AOJu0YwXBpSRd9czszRTHx3CvwbV6gypzN2hmuMFlXeQ9ElFL0BI7jzt u/wmmlihQ8kBPpTrkZ2FRqy88UoKkB4MzCAZckRsUPzvfUe7fQz3QYZtsWJK6tRtPYne4siGd3a OigMPThbFssNChkIhq48WklQVOMDBrjxXu1UoQ5IlRqRUiXP3ekd/XV+4 X-Gm-Gg: ASbGnct40txhED0ps3U5074rTxsq36aOtF4qCfQtwZa27ARqhl64TyEvt1zr12g9tmb bMW6u29AW0lFTcmRntsxloxnGyA2LM1trwFHsVfWYpX9cFI72WgmZmyYvtW5tlB+iibzyi7+7PA agE7+i99Vzdq0YWittUZvjT0Ph58EWQcHWE0rXAOwRlTwidjDyYzJoZy6LaVzeYfb1vLg7Oe0DX aJ3tNE1OLzeNZBYUYqeSJ/969/juZG2TZHSBzXJ1uP48rvfNjjAfQbeijhQyC5iD4gsjuIHguiy C3z3DxwkDbjXtijhe5t4ya/ckowBtTl/ZavPUNxL9RFU0js69oeS X-Received: by 2002:a17:90b:37c7:b0:313:db0b:75db with SMTP id 98e67ed59e1d1-31caf921e68mr1520932a91.33.1752712930473; Wed, 16 Jul 2025 17:42:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcBcC4aFTv+LaK2xP+TQMkJEutHYmMtxsDA/0udJ+JEtHOpvNFxPDtefSpeVnicS7CXZS1NA== X-Received: by 2002:a17:90b:37c7:b0:313:db0b:75db with SMTP id 98e67ed59e1d1-31caf921e68mr1520894a91.33.1752712930075; Wed, 16 Jul 2025 17:42:10 -0700 (PDT) From: Arun Menon Date: Thu, 17 Jul 2025 06:07:45 +0530 Subject: [PATCH v5 22/23] migration: Add error-parameterized function variants in VMSD struct MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250717-propagate_tpm_error-v5-22-1f406f88ee65@redhat.com> References: <20250717-propagate_tpm_error-v5-0-1f406f88ee65@redhat.com> In-Reply-To: <20250717-propagate_tpm_error-v5-0-1f406f88ee65@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Christian Borntraeger , Paolo Bonzini , Fam Zheng , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Xu , Fabiano Rosas , Hailiang Zhang , Steve Sistare , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Stefan Berger , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Matthew Rosato , Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5680; i=armenon@redhat.com; h=from:subject:message-id; bh=3Jq36iXUSbHTQC9cQ7Zq45KdL78RMO+hdXGkLCz9CVo=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0aFm/JMpndrNoRZtShX/RI60hd4sdKXPXWD/w7RF8kRV q6toekdpSwMYlwMsmKKLA1fA2SbAgojIm1fXoeZw8oEMoSBi1MAJrKkm+GfaTyX+/+mbQF7FA6V CSh7atzZ4Mf85/bS9YodDd9Cq54dZmRYc+KaQZPx5LWm7rftDto/445dOOmw1MejUVxnQs7Eyyx iAAA= X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armenon@redhat.com; helo=us-smtp-delivery-124.mimecast.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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1752713078415116600 - We need to have good error reporting in the callbacks in VMStateDescription struct. Specifically pre_save, post_save, pre_load and post_load callbacks. - It is not possible to change these functions everywhere in one patch, therefore, we introduce a duplicate set of callbacks with Error object passed to them. - So, in this commit, we implement 'errp' variants of these callbacks, introducing an explicit Error object parameter. - This is a functional step towards transitioning the entire codebase to the new error-parameterized functions. - Deliberately called in mutual exclusion from their counterparts, to prevent conflicts during the transition. - New impls should preferentally use 'errp' variants of these methods, and existing impls incrementally converted. The variants without 'errp' are intended to be removed once all usage is converted. Signed-off-by: Arun Menon --- include/migration/vmstate.h | 11 +++++++++++ migration/vmstate.c | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 056781b1c21e737583f081594d9f88b32adfd674..53fa72c1bbde399be02c88fc874= 5fdbb79bfd7c8 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -200,15 +200,26 @@ struct VMStateDescription { * exclusive. For this reason, also early_setup VMSDs are migrated in a * QEMU_VM_SECTION_FULL section, while save_setup() data is migrated in * a QEMU_VM_SECTION_START section. + * + * There are duplicate impls of the post/pre save/load hooks. + * New impls should preferentally use 'errp' variants of these + * methods and existing impls incrementally converted. + * The variants without 'errp' are intended to be removed + * once all usage is converted. */ + bool early_setup; int version_id; int minimum_version_id; MigrationPriority priority; int (*pre_load)(void *opaque); + int (*pre_load_errp)(void *opaque, Error **errp); int (*post_load)(void *opaque, int version_id); + int (*post_load_errp)(void *opaque, int version_id, Error **errp); int (*pre_save)(void *opaque); + int (*pre_save_errp)(void *opaque, Error **errp); int (*post_save)(void *opaque); + int (*post_save_errp)(void *opaque, Error **errp); bool (*needed)(void *opaque); bool (*dev_unplug_pending)(void *opaque); =20 diff --git a/migration/vmstate.c b/migration/vmstate.c index 078a00003023cc248fb16f05017d4c4251fd86df..bff4539cbe526c5a0718678d4e1= f32ba9ac57889 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -152,7 +152,13 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *vmsd, trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL); return -EINVAL; } - if (vmsd->pre_load) { + if (vmsd->pre_load_errp) { + ret =3D vmsd->pre_load_errp(opaque, errp); + if (ret) { + error_prepend(errp, "VM pre load failed : %d ", ret); + return ret; + } + } else if (vmsd->pre_load) { ret =3D vmsd->pre_load(opaque); if (ret) { error_setg(errp, "VM pre load failed : %d", ret); @@ -238,7 +244,12 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *vmsd, qemu_file_set_error(f, ret); return ret; } - if (vmsd->post_load) { + if (vmsd->post_load_errp) { + ret =3D vmsd->post_load_errp(opaque, version_id, errp); + if (ret < 0) { + error_prepend(errp, "VM Post load failed : %d ", ret); + } + } else if (vmsd->post_load) { ret =3D vmsd->post_load(opaque, version_id); if (ret < 0) { error_setg(errp, "VM Post load failed : %d", ret); @@ -414,7 +425,14 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDes= cription *vmsd, =20 trace_vmstate_save_state_top(vmsd->name); =20 - if (vmsd->pre_save) { + if (vmsd->pre_save_errp) { + ret =3D vmsd->pre_save_errp(opaque, errp); + trace_vmstate_save_state_pre_save_res(vmsd->name, ret); + if (ret) { + error_prepend(errp, "pre-save failed: %s ", vmsd->name); + return ret; + } + } else if (vmsd->pre_save) { ret =3D vmsd->pre_save(opaque); trace_vmstate_save_state_pre_save_res(vmsd->name, ret); if (ret) { @@ -524,7 +542,9 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, if (ret) { error_setg(errp, "Save of field %s/%s failed", vmsd->name, field->name); - if (vmsd->post_save) { + if (vmsd->post_save_errp) { + vmsd->post_save_errp(opaque, errp); + } else if (vmsd->post_save) { vmsd->post_save(opaque); } return ret; @@ -552,7 +572,13 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDes= cription *vmsd, =20 ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); =20 - if (vmsd->post_save) { + if (vmsd->post_save_errp) { + int ps_ret =3D vmsd->post_save_errp(opaque, errp); + if (!ret && ps_ret) { + ret =3D ps_ret; + error_prepend(errp, "post-save failed: %s ", vmsd->name); + } + } else if (vmsd->post_save) { int ps_ret =3D vmsd->post_save(opaque); if (!ret && ps_ret) { ret =3D ps_ret; --=20 2.50.0