From nobody Sat Nov 15 07:40:52 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=1753971557; cv=none; d=zohomail.com; s=zohoarc; b=jX48ei7HyWUWznLlGWj7EWz5yW645nhPUfGLlEMpxljnv9LhdLWYFJ3W4WstO3bKZAcC1LQ5Vx/QVz1e+qv61U8ZiptEEsRjUOPI7JRFs8PVQ1WmgKqSBxcJJxIxTmORiCQaj0KGQuLdr5GcsRzrhTeEx9v1J7+8xcB7U6IoGcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971557; 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=ei7O22C21LACZHTLer3cjrixsRRCYdJO9Tz9R6v8x3w=; b=GCjScpQiC1TYxhfzQKSlEZm4XRINqLTqFLnA5CibDweWFAbkRjHxokwP/BM1Tk7Vu9lhcncIxRkaeS3bl5sBLoh9KIVR6MJ2aofdsTMFohS9z3AYkEHf0OKYIkY0vXi9rAVGVTokjhWQ3xvn9wWFirFds2yUvYKOWswiP/WtUNI= 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 1753971556205448.2479899082887; Thu, 31 Jul 2025 07:19:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU7J-0001gB-Uf; Thu, 31 Jul 2025 10:18:46 -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 1uhTEb-0003lm-94 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:14 -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 1uhTEX-00080b-Qa for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:12 -0400 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-57-7nwNz21NP-CRW-GrhVRQBg-1; Thu, 31 Jul 2025 09:22:05 -0400 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-31f729bf733so1426744a91.1 for ; Thu, 31 Jul 2025 06:22:05 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968127; 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=ei7O22C21LACZHTLer3cjrixsRRCYdJO9Tz9R6v8x3w=; b=bBmfkaS6ma/9uz7v8XFoup+BbJgnu+u6cTmviWQOHmmETRNl1KLAg1Sh7ZDky2pXApPBWN 5bVPJCetnKWN8qiHc0baeEwky8cal9fEYnpji+XR1y/3xiAg3M/yWIn+WXAmjMYORB29Ww VUb6R48U/2IDPpr/hSkGCDDf1xeKO8Y= X-MC-Unique: 7nwNz21NP-CRW-GrhVRQBg-1 X-Mimecast-MFC-AGG-ID: 7nwNz21NP-CRW-GrhVRQBg_1753968124 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968124; x=1754572924; 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=ei7O22C21LACZHTLer3cjrixsRRCYdJO9Tz9R6v8x3w=; b=BJtnB+ENnkmkQsfwQNyJ0COh91BcWfZzzzBpcpL7SIyyXXtySxDt304N2OXGH9ez5Q OdPyZZDaLnMT7kww4Gd4Fxe5CAcdaY7ZYWuep/9x7e7tIUxXyfsIZz8gBu+s09Uf2F12 jAQEMMsMEIDTyXANGy+65tyDRBKLjH9uGHORXzks5HzaHJWh1J5zo/msgVKUZHg0ajyD xQfwJ77xlUeRcLWqhASQ8DXMa3B8zbROyZZNMJeTX+fnknVFD2PyXSKHKu6j5F/j8f0w wsFBP4cUMkMoOymoce8+TNCFHS0wPRkF5rRlrO/2vyPgnzvQD+qTjYLdpwt2LyawO+h5 Uzfg== X-Gm-Message-State: AOJu0YzS5AxuUDf4QpOp7ASUJEzG1QMZKhn/HvrxD9BPRZ1g4iZ7amLi AdX6D9TelKxDz6jHRhhGJGnovQjxbWU17zUJR/Ue9DGHjAK75F0I04+VtJYjS77hMgoGKig0ymV zAGosrLot1ICGL0/8OyBO64AiMLXd3WlSYDBmOdWN2J2IKlyKdejsD6IKe/AWDkGSM0nnMxFzPn WF1NY/YPKpy0IlB2d1j4X1LeeJqKt1s6xvMVA8YXxAqw== X-Gm-Gg: ASbGncv4VPsTUrTuLr8rN03lmMkDVndlsEfAp8w1AAxxFeyqmcxpeawUmudWVLXcdVY 59erJECStsA7la+xgqHnNrCtgmjMEQlKORLYLblRN0yblPqbr5rPrDHqBUBCDGRSYYIlRXbkeSt Wme5CbZ10QzJtjtLQs1k0C7sjiL31NMTwK8S6WVbrwBPeGunPnrFhXR5OZFoEWOMrhQTS0j/wpy 3OKpZFnCOs261bMxw2cL6QHywlbxzxWHBVG0+1pX1T3YzSaF7EJSK4aCrSShcIJzTOuj64xKZsY /XrvbHaMIZU3sVnQipc4YKR0U8Veh8hGCfRROgnnfjy99l1nwT1p X-Received: by 2002:a17:90b:1e0c:b0:311:abba:53d2 with SMTP id 98e67ed59e1d1-31f5de42527mr10512066a91.17.1753968123979; Thu, 31 Jul 2025 06:22:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdnpvsG5sciOioCa3Zl7Yf9PEr1vJZXa4pY4At0Fb/GSRRkpeTsE9rTC+SgmbMpWMpzKx7Mg== X-Received: by 2002:a17:90b:1e0c:b0:311:abba:53d2 with SMTP id 98e67ed59e1d1-31f5de42527mr10511969a91.17.1753968123048; Thu, 31 Jul 2025 06:22:03 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:41 +0530 Subject: [PATCH v8 01/27] migration: push Error **errp into vmstate_subsection_load() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-1-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=2856; i=armenon@redhat.com; h=from:subject:message-id; bh=kid0bXOsRop3xBGRskDAknpISUXylOTFB1pNzk2GZhw=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37pM72qH9b58o1OepOho12Z3OmPh+ga11+o7Hpdzay 6bseLawo5SFQYyLQVZMkaXha4BsU0BhRKTty+swc1iZQIYwcHEKwEQuRzP8lXipN/Fpn3yRwQsh 5r3GHc3Pd0tmrS+Q2aa1h7X0iVbHOUaGi57HWAMc8608ig40nF7NNPnOrIuPfMs3uGa737z0vqq DHQA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971560175116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that vmstate_subsection_load() must report an error in errp, in case of failure. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/vmstate.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 5feaa3244d259874f03048326b2497e7db32e47c..24451b054c11dfca2d76e24b053= d604bb7184e1c 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -25,7 +25,7 @@ static int vmstate_subsection_save(QEMUFile *f, const VMS= tateDescription *vmsd, void *opaque, JSONWriter *vmdesc, Error **errp); static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque); + void *opaque, Error **errp); =20 /* Whether this field should exist for either save or load the VM? */ static bool @@ -225,7 +225,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, field++; } assert(field->flags =3D=3D VMS_END); - ret =3D vmstate_subsection_load(f, vmsd, opaque); + ret =3D vmstate_subsection_load(f, vmsd, opaque, NULL); if (ret !=3D 0) { qemu_file_set_error(f, ret); return ret; @@ -566,7 +566,7 @@ vmstate_get_subsection(const VMStateDescription * const= *sub, } =20 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque) + void *opaque, Error **errp) { trace_vmstate_subsection_load(vmsd->name); =20 @@ -598,6 +598,8 @@ static int vmstate_subsection_load(QEMUFile *f, const V= MStateDescription *vmsd, sub_vmsd =3D vmstate_get_subsection(vmsd->subsections, idstr); if (sub_vmsd =3D=3D NULL) { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(lookup)= "); + error_setg(errp, "VM subsection '%s' in '%s' does not exist", + idstr, vmsd->name); return -ENOENT; } qemu_file_skip(f, 1); /* subsection */ @@ -608,6 +610,9 @@ static int vmstate_subsection_load(QEMUFile *f, const V= MStateDescription *vmsd, ret =3D vmstate_load_state(f, sub_vmsd, opaque, version_id); if (ret) { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(child)"= ); + error_setg(errp, + "Loading VM subsection '%s' in '%s' failed: %d", + idstr, vmsd->name, ret); return ret; } } --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971466; cv=none; d=zohomail.com; s=zohoarc; b=hJuQMnacclPWiIobqlb2lqyRTiyq1WqnIKG2iB1Umo5FYmlv+QQW8NCVAFlyiEyL77PolLv7JQ466NW12Ja+f3z/7cpVDsCBlqkFH8kbktd2wYGmBEwugbB5POIpf8CZ8G6a2an3mlo5vHj4AgXKzktPztuMUR2YKAABUrsCxNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971466; 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=e5ljIwIw1fmeA41qXl/XCB326DiBGUA/9yr5Gvb3waI=; b=mEBkwExzYLYGztnUSKYYIwxTKMtNy1r5uim+ef6A/t0TV7dOvLs8nDuiwceAI+AG0MAURt8sYdRy6Gj8gtnFsOY/4pd+MxVHYnmxv7WkNtNZ+vvx7k3KvCQvaX4jmMkXCm+qFtMjsn91Qt/sQMx8/R/+6idXRkQO8aVZz3kW8AM= 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 1753971466317633.4272093039632; Thu, 31 Jul 2025 07:17:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU1v-0005Lb-Tn; Thu, 31 Jul 2025 10:13:11 -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 1uhTEk-0004Ev-HZ for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTEg-000835-T0 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:22 -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-446-c15gaGZaMDGjGHshcNxbHw-1; Thu, 31 Jul 2025 09:22:16 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3132e7266d3so1316416a91.2 for ; Thu, 31 Jul 2025 06:22:15 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968138; 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=e5ljIwIw1fmeA41qXl/XCB326DiBGUA/9yr5Gvb3waI=; b=bLx/9GWJwd7vCt37xoPNNj3sO9KAqHFxsWXYIEjV1T4NMZaarIqueQdB38LEGeEAe6FFqC vjXJuUwVJjrdEkZ5OFDfjiyHrpH4eX7y7Z20i52qCMRb2HVHe0eU5gXBdYHJNpPHEU6P0c W5awRtzMMjQAnvbyql+RwL1EZplC8aA= X-MC-Unique: c15gaGZaMDGjGHshcNxbHw-1 X-Mimecast-MFC-AGG-ID: c15gaGZaMDGjGHshcNxbHw_1753968134 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968134; x=1754572934; 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=e5ljIwIw1fmeA41qXl/XCB326DiBGUA/9yr5Gvb3waI=; b=nWuDn+igclkmqAg4g3NDU89Pu+pmNXmDuRkQ3gUtaVCz5OZRzrOCWOTQTjPUZ7TceH qHE/MA6phiJvc+59U9EZuio221DLhW24Zbmd5bliBhnNLKiuoSd7KGVtDK0Sd/5xSRbL Nkabjpt24EK0xQE+V02O/OL2JZUQ/wIAg++jnZmWwzqouNsSaNCULSuJUUR4VGRRJGZN Ho3NuEX+Qehhc5682Dxd5VT6z2mtD7Y39gnZMM6RQEeaDg71Ld0nt1a6D27e8ZBbgW2g V+Wq4hOqnUrdacxtKQoFFqTORkh5SPa22GGBT1Yx24+l6jmo+14kbuSEGfVXHBE6fqrj DP0Q== X-Gm-Message-State: AOJu0YxFVwIuiWHNzJB7CA7aemcfqxUL/X6NEAv6WURhsLGjuR5mUyLr 4LbnMb+J5RJ2yOL3bGeAJba2KYIXHZ2xujoqo+CnwuXXSEeJYIxeC/SCjs+Q66/mSfF2a9d843a 1y9GIvd1OXUbH5NTFf5wwRBIF9lb7jMdeT5a2BTrQrFsi0BFvytScrIqkby7rCqvy9tpBBxsUy8 yXFph8CtAIHeh+bgrRenA+0Hb1wJnWA0oXA/8keXR1yw== X-Gm-Gg: ASbGncsWRGmVrj0fSmxR7cvgWIlfy4IIFp/LLpevBtL5L0EnFUd0TwSQj0j3lHNe/YC Y8C0qG4XilHU2s6lRNnYc/LIUT/u8O7zQC+1HMyzXErlAWTSm9oblXY8ePw6QFoNFzQ2yvgIgYq j6EAioP8jR1xS/3X1aubAHuPYCzzHeqdAqtwH9m1rmfHaSAD4KOlLrSX527xXYL51RzyGZU3LSb lJ0Qs0g3Rq1DzA0Qmu5KSCfBhbZT+NHkolKdTGnxUCnRXYeE7snll5xUKytE59TvLQmQZJr2HzD V3LCy0jj3qOiggHiiOEukCmBKSd+cduMTdQ0F3PMBwTJi+6jdIZy X-Received: by 2002:a17:90b:1e11:b0:312:e731:5a6b with SMTP id 98e67ed59e1d1-31f5de59ce3mr7959154a91.32.1753968133863; Thu, 31 Jul 2025 06:22:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2IiQAfZFBhGk+gbefUAy6AdWG5JkRuPkZydGhAv0R7pnDasIIvgGqCTn+8owDf7qAds+sHQ== X-Received: by 2002:a17:90b:1e11:b0:312:e731:5a6b with SMTP id 98e67ed59e1d1-31f5de59ce3mr7959068a91.32.1753968132990; Thu, 31 Jul 2025 06:22:12 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:42 +0530 Subject: [PATCH v8 02/27] migration: push Error **errp into vmstate_load_state() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-2-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=22258; i=armenon@redhat.com; h=from:subject:message-id; bh=WAjhSQSNuKAtWWv7VLLKD5YfRWH6XL8cThcuNt8ekCM=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37tMLW2MnJqjbPJV6Ob/UYnVo8XXBbVPLt+zueaWtf urWNabYjlIWBjEuBlkxRZaGrwGyTQGFEZG2L6/DzGFlAhnCwMUpABM5tIfhn9Xzw571XQa/IuOm fDH1S1ijZTd7bbVBU979CR7fiw3Swxj+F6RLlURtyZzFEcjz6MmFvzN3/lThkXKzs+cVYxB419b NBAA= 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971468965116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that vmstate_load_state() must report an error in errp, in case of failure. In cases where we do not want to essentially set the error in errp object and also not abort/exit, the caller only passes &error_warn, to warn on error. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- hw/display/virtio-gpu.c | 2 +- hw/pci/pci.c | 3 ++- hw/s390x/virtio-ccw.c | 2 +- hw/scsi/spapr_vscsi.c | 2 +- hw/vfio/pci.c | 2 +- hw/virtio/virtio-mmio.c | 3 ++- hw/virtio/virtio-pci.c | 2 +- hw/virtio/virtio.c | 4 ++-- include/migration/vmstate.h | 2 +- migration/cpr.c | 5 ++-- migration/savevm.c | 6 +++-- migration/vmstate-types.c | 11 +++++---- migration/vmstate.c | 56 ++++++++++++++++++++++++++++++-----------= ---- tests/unit/test-vmstate.c | 20 ++++++++-------- ui/vdagent.c | 2 +- 15 files changed, 75 insertions(+), 47 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 0a1a625b0ea6cf26cb0d799171a57ed3d3ab2442..5ff9f5e6dc0b6b112e36170318c= 900f893a73c5e 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1343,7 +1343,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, } =20 /* load & apply scanout state */ - vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1); + vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1, &error_warn); =20 return 0; } diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c70b5ceebaf1f2b10768bd030526cbb518da2b8d..80545189980f176ca6a3dc9abce= 7043c8bc2708c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -934,7 +934,8 @@ void pci_device_save(PCIDevice *s, QEMUFile *f) int pci_device_load(PCIDevice *s, QEMUFile *f) { int ret; - ret =3D vmstate_load_state(f, &vmstate_pci_device, s, s->version_id); + ret =3D vmstate_load_state(f, &vmstate_pci_device, s, s->version_id, + &error_warn); /* Restore the interrupt status bit. */ pci_update_irq_status(s); return ret; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index d2f85b39f30f7fc82e0c600144c0a958e1269b2c..bafcb9b76d81749925e31b5a0a1= 320b3332ad2cf 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1136,7 +1136,7 @@ static void virtio_ccw_save_config(DeviceState *d, QE= MUFile *f) static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev =3D VIRTIO_CCW_DEVICE(d); - return vmstate_load_state(f, &vmstate_virtio_ccw_dev, dev, 1); + return vmstate_load_state(f, &vmstate_virtio_ccw_dev, dev, 1, &error_w= arn); } =20 static void virtio_ccw_pre_plugged(DeviceState *d, Error **errp) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 20f70fb2729de78b9636a6b8c869695dab4f8902..a4812afd0cc7c495080ef03a531= c7d279af29b33 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -648,7 +648,7 @@ static void *vscsi_load_request(QEMUFile *f, SCSIReques= t *sreq) assert(!req->active); =20 memset(req, 0, sizeof(*req)); - rc =3D vmstate_load_state(f, &vmstate_spapr_vscsi_req, req, 1); + rc =3D vmstate_load_state(f, &vmstate_spapr_vscsi_req, req, 1, &error_= warn); if (rc) { fprintf(stderr, "VSCSI: failed loading request tag#%u\n", sreq->ta= g); return NULL; diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 4fa692c1a32bcfa4e4939e5fcb64f2bf19905b3b..04d385d7674f444844beeee7364= ee0424f762758 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2795,7 +2795,7 @@ static int vfio_pci_load_config(VFIODevice *vbasedev,= QEMUFile *f) old_addr[bar] =3D pdev->io_regions[bar].addr; } =20 - ret =3D vmstate_load_state(f, &vmstate_vfio_pci_config, vdev, 1); + ret =3D vmstate_load_state(f, &vmstate_vfio_pci_config, vdev, 1, &erro= r_warn); if (ret) { return ret; } diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 532c67107ba1d2978a76cf49f9cdc1de1dea3e11..f14f0487fec3ed30d2cc3aec969= 50c2121265716 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -34,6 +34,7 @@ #include "qemu/error-report.h" #include "qemu/log.h" #include "trace.h" +#include "qapi/error.h" =20 static bool virtio_mmio_ioeventfd_enabled(DeviceState *d) { @@ -619,7 +620,7 @@ static int virtio_mmio_load_extra_state(DeviceState *op= aque, QEMUFile *f) { VirtIOMMIOProxy *proxy =3D VIRTIO_MMIO(opaque); =20 - return vmstate_load_state(f, &vmstate_virtio_mmio, proxy, 1); + return vmstate_load_state(f, &vmstate_virtio_mmio, proxy, 1, &error_wa= rn); } =20 static bool virtio_mmio_has_extra_state(DeviceState *opaque) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 767216d795998708f5716a23ae16c79cd90ff489..07f144d6d1bfbb561b28015de71= 762601080dc23 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -161,7 +161,7 @@ static int virtio_pci_load_extra_state(DeviceState *d, = QEMUFile *f) { VirtIOPCIProxy *proxy =3D to_virtio_pci_proxy(d); =20 - return vmstate_load_state(f, &vmstate_virtio_pci, proxy, 1); + return vmstate_load_state(f, &vmstate_virtio_pci, proxy, 1, &error_war= n); } =20 static void virtio_pci_save_queue(DeviceState *d, int n, QEMUFile *f) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 2ab1d20769495ea39445b87e3673b076ad172510..aac317a93c3cd55ece9b0fd858c= 7b2459f8242f9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3317,14 +3317,14 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id) } =20 if (vdc->vmsd) { - ret =3D vmstate_load_state(f, vdc->vmsd, vdev, version_id); + ret =3D vmstate_load_state(f, vdc->vmsd, vdev, version_id, &error_= warn); if (ret) { return ret; } } =20 /* Subsections */ - ret =3D vmstate_load_state(f, &vmstate_virtio, vdev, 1); + ret =3D vmstate_load_state(f, &vmstate_virtio, vdev, 1, &error_warn); if (ret) { return ret; } diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 1ff7bd9ac425ba67cd5ca7ad97bcf570f9e19abe..056781b1c21e737583f081594d9= f88b32adfd674 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1196,7 +1196,7 @@ extern const VMStateInfo vmstate_info_qlist; } =20 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, int version_id); + void *opaque, int version_id, Error **errp); int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc); int vmstate_save_state_with_err(QEMUFile *f, const VMStateDescription *vms= d, diff --git a/migration/cpr.c b/migration/cpr.c index 42ad0b0d500e5de57faf0c6517e216b2d1c0cacf..bdb24736f44e91ba59b6e622a31= 5597c97e7f64d 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -202,6 +202,7 @@ int cpr_state_save(MigrationChannel *channel, Error **e= rrp) =20 int cpr_state_load(MigrationChannel *channel, Error **errp) { + ERRP_GUARD(); int ret; uint32_t v; QEMUFile *f; @@ -233,9 +234,9 @@ int cpr_state_load(MigrationChannel *channel, Error **e= rrp) return -ENOTSUP; } =20 - ret =3D vmstate_load_state(f, &vmstate_cpr_state, &cpr_state, 1); + ret =3D vmstate_load_state(f, &vmstate_cpr_state, &cpr_state, 1, errp); if (ret) { - error_setg(errp, "vmstate_load_state error %d", ret); + error_prepend(errp, "vmstate_load_state error %d: ", ret); qemu_fclose(f); return ret; } diff --git a/migration/savevm.c b/migration/savevm.c index fabbeb296ae987d0c06ba6dafda63720205fecfd..ab947620f724874f325fb9fb59b= ef50b7c16fb51 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -969,7 +969,8 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *se) if (!se->vmsd) { /* Old style */ return se->ops->load_state(f, se->opaque, se->load_version_id); } - return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id= ); + return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id, + NULL); } =20 static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, @@ -2839,7 +2840,8 @@ static int qemu_loadvm_state_header(QEMUFile *f) error_report("Configuration section missing"); return -EINVAL; } - ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0); + ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0, + NULL); =20 if (ret) { return ret; diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 741a588b7e18c6d37724b08a0101edc8bc74a0a5..e2020a733d0921d748b6f832a19= 3e5de8d302d5f 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -19,6 +19,7 @@ #include "qemu/error-report.h" #include "qemu/queue.h" #include "trace.h" +#include "qapi/error.h" =20 /* bool */ =20 @@ -549,7 +550,7 @@ static int get_tmp(QEMUFile *f, void *pv, size_t size, =20 /* Writes the parent field which is at the start of the tmp */ *(void **)tmp =3D pv; - ret =3D vmstate_load_state(f, vmsd, tmp, version_id); + ret =3D vmstate_load_state(f, vmsd, tmp, version_id, &error_warn); g_free(tmp); return ret; } @@ -649,7 +650,7 @@ static int get_qtailq(QEMUFile *f, void *pv, size_t unu= sed_size, =20 while (qemu_get_byte(f)) { elm =3D g_malloc(size); - ret =3D vmstate_load_state(f, vmsd, elm, version_id); + ret =3D vmstate_load_state(f, vmsd, elm, version_id, &error_warn); if (ret) { return ret; } @@ -803,7 +804,7 @@ static int get_gtree(QEMUFile *f, void *pv, size_t unus= ed_size, key =3D (void *)(uintptr_t)qemu_get_be64(f); } else { key =3D g_malloc0(key_size); - ret =3D vmstate_load_state(f, key_vmsd, key, version_id); + ret =3D vmstate_load_state(f, key_vmsd, key, version_id, &erro= r_warn); if (ret) { error_report("%s : failed to load %s (%d)", field->name, key_vmsd->name, ret); @@ -811,7 +812,7 @@ static int get_gtree(QEMUFile *f, void *pv, size_t unus= ed_size, } } val =3D g_malloc0(val_size); - ret =3D vmstate_load_state(f, val_vmsd, val, version_id); + ret =3D vmstate_load_state(f, val_vmsd, val, version_id, &error_wa= rn); if (ret) { error_report("%s : failed to load %s (%d)", field->name, val_vmsd->name, ret); @@ -892,7 +893,7 @@ static int get_qlist(QEMUFile *f, void *pv, size_t unus= ed_size, =20 while (qemu_get_byte(f)) { elm =3D g_malloc(size); - ret =3D vmstate_load_state(f, vmsd, elm, version_id); + ret =3D vmstate_load_state(f, vmsd, elm, version_id, &error_warn); if (ret) { error_report("%s: failed to load %s (%d)", field->name, vmsd->name, ret); diff --git a/migration/vmstate.c b/migration/vmstate.c index 24451b054c11dfca2d76e24b053d604bb7184e1c..b725202bfcf69c3c81338f1f547= 9aa2ddc5db86f 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -132,29 +132,33 @@ static void vmstate_handle_alloc(void *ptr, const VMS= tateField *field, } =20 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, int version_id) + void *opaque, int version_id, Error **errp) { const VMStateField *field =3D vmsd->fields; int ret =3D 0; =20 trace_vmstate_load_state(vmsd->name, version_id); if (version_id > vmsd->version_id) { - error_report("%s: incoming version_id %d is too new " - "for local version_id %d", - vmsd->name, version_id, vmsd->version_id); + error_setg(errp, "%s: incoming version_id %d is too new " + "for local version_id %d", + vmsd->name, version_id, vmsd->version_id); trace_vmstate_load_state_end(vmsd->name, "too new", -EINVAL); return -EINVAL; } if (version_id < vmsd->minimum_version_id) { - error_report("%s: incoming version_id %d is too old " - "for local minimum version_id %d", - vmsd->name, version_id, vmsd->minimum_version_id); + error_setg(errp, "%s: incoming version_id %d is too old " + "for local minimum version_id %d", + vmsd->name, version_id, vmsd->minimum_version_id); trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL); return -EINVAL; } if (vmsd->pre_load) { ret =3D vmsd->pre_load(opaque); if (ret) { + error_setg(errp, "VM pre load failed for: '%s', " + "version_id: '%d', minimum version_id: '%d', ret: %= d", + vmsd->name, vmsd->version_id, vmsd->minimum_version= _id, + ret); return ret; } } @@ -192,10 +196,12 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, =20 if (inner_field->flags & VMS_STRUCT) { ret =3D vmstate_load_state(f, inner_field->vmsd, curr_= elem, - inner_field->vmsd->version_id= ); + inner_field->vmsd->version_id, + errp); } else if (inner_field->flags & VMS_VSTRUCT) { ret =3D vmstate_load_state(f, inner_field->vmsd, curr_= elem, - inner_field->struct_version_i= d); + inner_field->struct_version_i= d, + errp); } else { ret =3D inner_field->info->get(f, curr_elem, size, inner_field); @@ -208,30 +214,43 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, =20 if (ret >=3D 0) { ret =3D qemu_file_get_error(f); + if (ret < 0) { + error_setg(errp, "Failed to load %s state: %d", + vmsd->name, ret); + return ret; + } } if (ret < 0) { qemu_file_set_error(f, ret); - error_report("Failed to load %s:%s", vmsd->name, - field->name); + error_setg(errp, + "Failed to load %s:%s version_id: %d: ", + vmsd->name, field->name, vmsd->version_id); trace_vmstate_load_field_error(field->name, ret); return ret; } } } else if (field->flags & VMS_MUST_EXIST) { - error_report("Input validation failed: %s/%s", - vmsd->name, field->name); + error_setg(errp, "Input validation failed: %s/%s version_id: %= d", + vmsd->name, field->name, vmsd->version_id); return -1; } field++; } assert(field->flags =3D=3D VMS_END); - ret =3D vmstate_subsection_load(f, vmsd, opaque, NULL); + ret =3D vmstate_subsection_load(f, vmsd, opaque, errp); if (ret !=3D 0) { qemu_file_set_error(f, ret); return ret; } if (vmsd->post_load) { ret =3D vmsd->post_load(opaque, version_id); + if (ret < 0) { + error_setg(errp, + "VM Post load failed for: %s, version_id: %d, " + "minimum_version: %d, ret: %d", + vmsd->name, vmsd->version_id, vmsd->minimum_version= _id, + ret); + } } trace_vmstate_load_state_end(vmsd->name, "end", ret); return ret; @@ -568,6 +587,7 @@ vmstate_get_subsection(const VMStateDescription * const= *sub, static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, void *opaque, Error **errp) { + ERRP_GUARD(); trace_vmstate_subsection_load(vmsd->name); =20 while (qemu_peek_byte(f, 0) =3D=3D QEMU_VM_SUBSECTION) { @@ -607,12 +627,12 @@ static int vmstate_subsection_load(QEMUFile *f, const= VMStateDescription *vmsd, qemu_file_skip(f, len); /* idstr */ version_id =3D qemu_get_be32(f); =20 - ret =3D vmstate_load_state(f, sub_vmsd, opaque, version_id); + ret =3D vmstate_load_state(f, sub_vmsd, opaque, version_id, errp); if (ret) { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(child)"= ); - error_setg(errp, - "Loading VM subsection '%s' in '%s' failed: %d", - idstr, vmsd->name, ret); + error_prepend(errp, + "Loading VM subsection '%s' in '%s' failed: '%d'= : ", + idstr, vmsd->name, ret); return ret; } } diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 63f28f26f45691a70936d33e7341d16477a3471f..807deb3531f3079864ac99567d4= dece7122571dd 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -30,6 +30,7 @@ #include "../migration/savevm.h" #include "qemu/module.h" #include "io/channel-file.h" +#include "qapi/error.h" =20 static int temp_fd; =20 @@ -114,7 +115,7 @@ static int load_vmstate_one(const VMStateDescription *d= esc, void *obj, qemu_fclose(f); =20 f =3D open_test_file(false); - ret =3D vmstate_load_state(f, desc, obj, version); + ret =3D vmstate_load_state(f, desc, obj, version, &error_warn); if (ret) { g_assert(qemu_file_get_error(f)); } else{ @@ -365,7 +366,7 @@ static void test_load_v1(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj =3D { .b =3D 200, .e =3D 500, .f =3D 600 }; - vmstate_load_state(loading, &vmstate_versioned, &obj, 1); + vmstate_load_state(loading, &vmstate_versioned, &obj, 1, &error_warn); g_assert(!qemu_file_get_error(loading)); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 200); @@ -391,7 +392,7 @@ static void test_load_v2(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj; - vmstate_load_state(loading, &vmstate_versioned, &obj, 2); + vmstate_load_state(loading, &vmstate_versioned, &obj, 2, &error_warn); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 20); g_assert_cmpint(obj.c, =3D=3D, 30); @@ -480,7 +481,7 @@ static void test_load_noskip(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj =3D { .skip_c_e =3D false }; - vmstate_load_state(loading, &vmstate_skipping, &obj, 2); + vmstate_load_state(loading, &vmstate_skipping, &obj, 2, &error_warn); g_assert(!qemu_file_get_error(loading)); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 20); @@ -504,7 +505,7 @@ static void test_load_skip(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj =3D { .skip_c_e =3D true, .c =3D 300, .e =3D 500 }; - vmstate_load_state(loading, &vmstate_skipping, &obj, 2); + vmstate_load_state(loading, &vmstate_skipping, &obj, 2, &error_warn); g_assert(!qemu_file_get_error(loading)); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 20); @@ -773,7 +774,7 @@ static void test_load_q(void) TestQtailq tgt; =20 QTAILQ_INIT(&tgt.q); - vmstate_load_state(fload, &vmstate_q, &tgt, 1); + vmstate_load_state(fload, &vmstate_q, &tgt, 1, &error_warn); char eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(tgt.i16, =3D=3D, obj_q.i16); @@ -1127,7 +1128,7 @@ static void test_gtree_load_domain(void) =20 fload =3D open_test_file(false); =20 - vmstate_load_state(fload, &vmstate_domain, dest_domain, 1); + vmstate_load_state(fload, &vmstate_domain, dest_domain, 1, &error_warn= ); eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(orig_domain->id, =3D=3D, dest_domain->id); @@ -1241,7 +1242,7 @@ static void test_gtree_load_iommu(void) qemu_fclose(fsave); =20 fload =3D open_test_file(false); - vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1); + vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1, &error_warn); eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(orig_iommu->id, =3D=3D, dest_iommu->id); @@ -1376,7 +1377,8 @@ static void test_load_qlist(void) qemu_fclose(fsave); =20 fload =3D open_test_file(false); - vmstate_load_state(fload, &vmstate_container, dest_container, 1); + vmstate_load_state(fload, &vmstate_container, dest_container, 1, + &error_warn); eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(eof, =3D=3D, QEMU_VM_EOF); diff --git a/ui/vdagent.c b/ui/vdagent.c index c0746fe5b168fdc7aeb4866de2ba0c3387566649..b9a22a689d9acfeafb862ae7330= 8db6fbd52331e 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -1008,7 +1008,7 @@ static int get_cbinfo(QEMUFile *f, void *pv, size_t s= ize, =20 vdagent_clipboard_peer_register(vd); =20 - ret =3D vmstate_load_state(f, &vmstate_cbinfo_array, &cbinfo, 0); + ret =3D vmstate_load_state(f, &vmstate_cbinfo_array, &cbinfo, 0, &erro= r_warn); if (ret) { return ret; } --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971797; cv=none; d=zohomail.com; s=zohoarc; b=lVsXSSN9yLAgsYov2sEJzE4OltywguYzyeQJ2mv2eebVH4+WEgzMloAQVZBi/iNVeZAQWiqnaMVHveHbw3GNprQ+x1UNgXYSEpRKxQoX7TMLWNIkCFXC1qDM+6mcdtmICwTDLLP/SDsnfwdUwijwaZ7io0lVddWax+xEcvVRwrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971797; 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=uikZn/s4wv+Bosyi+eWzU0VyruMTZ2EvxVsjZCQjpVw=; b=ImHrAVQzohyqAggrLwkmbAkihirIGY2t6OIZds32UV/igiikAlHMaUw6Xit5z6g7imh7KEwpjN2lhZaF/l8IQ92DBnvzpVF/UeLecSeVcAQK8qJU8q/kGneBamwwJtDVFXoI/Wgc28GSR84YkTzstjpZUsaQKR6CT2wWiOsgUiU= 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 1753971797896797.2861740180628; Thu, 31 Jul 2025 07:23:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU7T-0002PS-O5; Thu, 31 Jul 2025 10:18:56 -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 1uhTEq-0004Ii-J5 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTEo-00084Q-Dg for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:28 -0400 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-mp_BCUVpPGKWqPigP7Hc9A-1; Thu, 31 Jul 2025 09:22:24 -0400 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-23fe98c50daso9089185ad.3 for ; Thu, 31 Jul 2025 06:22:23 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968145; 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=uikZn/s4wv+Bosyi+eWzU0VyruMTZ2EvxVsjZCQjpVw=; b=Q/0MoHItaIjuvF3HJKmJ701JZJuMSK8B4kYqBmPobtdTEosXsuU7Q4SwtxLJXj/LKHijl4 vZB0Sw/x73iEEFEZVBEpnn8Zah67RRqHGw+IfgYNT/4eNpnhybf41Um+HpcwsfHz7Cqd1F NmCw8OLJXyHugMVlmGj4RvXs9VeH1F8= X-MC-Unique: mp_BCUVpPGKWqPigP7Hc9A-1 X-Mimecast-MFC-AGG-ID: mp_BCUVpPGKWqPigP7Hc9A_1753968143 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968143; x=1754572943; 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=uikZn/s4wv+Bosyi+eWzU0VyruMTZ2EvxVsjZCQjpVw=; b=w3Qhua3+7DxRU247lW2kGk9t1U78+PRFcNeToe/iLUJnGO/kYdvlGNGFPOwI0Lalqt 6hQKzvL2Wh17lppRd7zGiJ6+PCXyWxRGJEtj1EqK7pT48JksU20AsTQg7qXDfXHffA6z AvUVy86zgCN9mjHD1vFhwt7eqNKWW/VZLytbuQxbEqFQT0rbRRSMlF+SQAmZwp0ahTwp ZytsYSCx5NRupOSIvsevVpaDzik5/QCU3nhlzyeAXPJMHAc5cJHkd1xAYY1Cx/AkxfhG ujnEOeXcjFhG660DSjw9ADstQhrUtVLfqddfVAiezJ7cbKrtzUGIS7JwK41BnRM9IjOM 4upw== X-Gm-Message-State: AOJu0Yy9XJwD3Zvz56hsz+sQHeZrOscMLHKw2zpnRgSJzySZTOJPU8UE 5sHzNor5hQtow8/zVcBsm1+ZIEZ5KYH2op9b/BJAhliLdeG4bfnhXQaDF9gDT8SdrE68dIl5Ka8 vG29r8FEJHMJG+srMMEik1jbiHrDmY146gN4RlP/x2CI6R7CxFjXnaUCeeW3G+PRBLOTi2KfnhG 6E5GopJHA8cVbyrYG+1HZRGfIFFEv2PdPe7QnvbD5Prg== X-Gm-Gg: ASbGncvY05avWdYJEWZWpgyDjq7AO+/LjrZJ9yj0g4K1gpQxtvRecYo275yn0RJlEQ8 3I0dHdXRc7pxGjfBsU17+aKLjAlPpSrDik6tMr6nO0C2WiDdqVLRUotA7st9tJj04uPz2khQsoX P3kQWbIYQ1IdpPk65D3nxGmmj6C+kcUFMQmkSNY9kfi/c/GJ06n64r28ecOO7MXpQifUSJ8Z3Nk wMl0+WLGf1XpDdV5uKbIappxrQXp+ZnojxfJZZP3FFkmNgrUpVnA1aRmYN0lxBoxb/M30sePwz4 Aqj//bLLXvllrLBv5rHSu2RxrBHii8PKF0aR4W2cIeiatTmzRtSF X-Received: by 2002:a17:902:c9c4:b0:240:967a:fec3 with SMTP id d9443c01a7336-24096b039f9mr76706175ad.29.1753968142852; Thu, 31 Jul 2025 06:22:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdkzv0UB8hZXAZNJSRx7fvrF+ghTAzkodbggF+7N8UOp1sMJVjt16NRYmz0GBc/Cz9C+ISqg== X-Received: by 2002:a17:902:c9c4:b0:240:967a:fec3 with SMTP id d9443c01a7336-24096b039f9mr76705475ad.29.1753968142140; Thu, 31 Jul 2025 06:22:22 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:43 +0530 Subject: [PATCH v8 03/27] migration: push Error **errp into qemu_loadvm_state_header() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-3-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=2889; i=armenon@redhat.com; h=from:subject:message-id; bh=YBAjAcKtlsbciFxmGnkfeB1uVPx9vchbnxKKM6HF8XY=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37tPSbuNstgctzZpSO1f6u+12faQ+90rjv4+CPKavb 5892d7aUcrCIMbFICumyNLwNUC2KaAwItL25XWYOaxMIEMYuDgFYCKpygx/uP3+lG7f2hY5a463 8XLD91KbTQ3rruVcnXgw6k/G55v1kxkZrm1ZtWjP24AMlu60jGlbE1zd96T9u38/5tap58LH7Nd zMwMA 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971798639116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that qemu_loadvm_state_header() must report an error in errp, in case of failure. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/savevm.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index ab947620f724874f325fb9fb59bef50b7c16fb51..842ff3dc6d5ccb05f7d33cef9f7= 319b141419501 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2814,35 +2814,44 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t t= ype) return 0; } =20 -static int qemu_loadvm_state_header(QEMUFile *f) +static int qemu_loadvm_state_header(QEMUFile *f, Error **errp) { unsigned int v; int ret; =20 v =3D qemu_get_be32(f); if (v !=3D QEMU_VM_FILE_MAGIC) { - error_report("Not a migration stream"); + error_setg(errp, "Not a migration stream, magic: %x !=3D %x", + v, QEMU_VM_FILE_MAGIC); return -EINVAL; } =20 v =3D qemu_get_be32(f); if (v =3D=3D QEMU_VM_FILE_VERSION_COMPAT) { - error_report("SaveVM v2 format is obsolete and don't work anymore"= ); + error_setg(errp, + "SaveVM v2 format is obsolete and no longer supported, " + "file version %x !=3D %x", + v, QEMU_VM_FILE_VERSION_COMPAT); + return -ENOTSUP; } if (v !=3D QEMU_VM_FILE_VERSION) { - error_report("Unsupported migration stream version"); + error_setg(errp, "Unsupported migration stream version, " + "file version %x !=3D %x", + v, QEMU_VM_FILE_VERSION); return -ENOTSUP; } =20 if (migrate_get_current()->send_configuration) { - if (qemu_get_byte(f) !=3D QEMU_VM_CONFIGURATION) { - error_report("Configuration section missing"); + v =3D qemu_get_byte(f); + if (v !=3D QEMU_VM_CONFIGURATION) { + error_setg(errp, "Configuration section missing, %x !=3D %x", + v, QEMU_VM_CONFIGURATION); return -EINVAL; } - ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0, - NULL); =20 + ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0, + errp); if (ret) { return ret; } @@ -3119,7 +3128,7 @@ int qemu_loadvm_state(QEMUFile *f) =20 qemu_loadvm_thread_pool_create(mis); =20 - ret =3D qemu_loadvm_state_header(f); + ret =3D qemu_loadvm_state_header(f, NULL); if (ret) { return ret; } --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971706; cv=none; d=zohomail.com; s=zohoarc; b=W28Zeq+34sZ957+MCgGuBn/AO8l6skg5ANKi5+AXUqi++OGDyy/dAjQBKuDS3DJeKZqZQqoMzUReyCVaPgjQ9mdjsh00dpEXUqf//tQ7Rci73nYTLUOCYnrIso2JBchA0AHu9/wt0tacpHac1XxBwDcfz8W2ZJ4a+SISBn0TSYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971706; 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=o9J1Tq4hSBT5sDELmai4TDUPEnf2TI6fwgtJw67ORFg=; b=hU79sVTySVI9ZQRpYA2cXxDerRPnH8sy9HVrOEmUbqJTZuVbdZS6h57YaqFiVs7XrVaq2wa3wxe0sJ561Ny2R4/an//XEK7tgK8SC2xPOxBxSsSG5jzZ+IOA/DOCTY1MEcE+JAZuaYCUc5RIRRQM9leYM2aMRx9vS02nPIKzKwY= 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 1753971706207249.32744465545318; Thu, 31 Jul 2025 07:21:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU5P-0007t7-4h; Thu, 31 Jul 2025 10:17:00 -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 1uhTF0-0004Ti-60 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:40 -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 1uhTEy-00088T-3I for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:37 -0400 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-LVkWuZjzMFqpL6bhtu--5A-1; Thu, 31 Jul 2025 09:22:32 -0400 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-313d6d671ffso1021407a91.2 for ; Thu, 31 Jul 2025 06:22:32 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968155; 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=o9J1Tq4hSBT5sDELmai4TDUPEnf2TI6fwgtJw67ORFg=; b=XY/8Ehzbj1it9/sPZvmNNnqI38WvMdk5JH1JBhcKplghYCgn/LctrzyAybzFEIjCfDSa+l fVq4eAITAz2rTMpjIjYA+NyTsH7hf3/mGx4jeeifj9LjrW7vr9EQcuRKJGG9Ohdbesj2pa YJXv3ZVRgRLhxRId8eBhRf0dmJ6jVHg= X-MC-Unique: LVkWuZjzMFqpL6bhtu--5A-1 X-Mimecast-MFC-AGG-ID: LVkWuZjzMFqpL6bhtu--5A_1753968152 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968151; x=1754572951; 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=o9J1Tq4hSBT5sDELmai4TDUPEnf2TI6fwgtJw67ORFg=; b=d4QhxlZvQQX6VYc8WZHUE/Cye9xzC/LgvuOhWzULQPT+oPvi9cP9s1NXNpA9CEbNLV JaalqkpuAIzFAoNItE/LL83Fkc2C+ak8vaPxQZ4KaIOqQ9/GmBq+XGmq70tqEJpYDhmJ 9tvXCbZcAdA2bf6a6rlch9jUhHi9HcDOxRcYUAwTlDe119mn2WB2zCv5gTVv0LkT4QiV sVZLg8RkIdQ8ISs5pRFLjnGwyfGOW16tYRFWBZ5ehwVlqEMTSLhNlduHvK+yJEiU+d+k MvyMVVbMBB7UdTqRy8kKe6VCJpMyuPTjCt3imnj1uEErouNWafFjabymQH6IHKUAqLcc o/jQ== X-Gm-Message-State: AOJu0YxZ53z0V4H90NVgFJs6mgEl2P7aJ0BaleKV/j+8TIOTVHONKfz7 D47PITVfIpdcBvIQ4RgEtvzZW4B81o1toI6qOIfI7UPn56OVrglWZ1Ikh0FHSgCRaW72cG6Sh/n pCx/trP7nBe/LZtCntx9S4RAIxlZJLYJHhfnlGRXQxu9EfKvpZyvGEQ1Q5yidCV+yofhQSX1nZe zTxVGR9mpo9EwuSeXqXBfztGm9ZNK4DkUD9/5Ev9LPXg== X-Gm-Gg: ASbGncs4QofZL0mWY7AbNbYfvz5NW3x9MohivGT2+1Qou1mtjSqMntvA4SLXw3vQsQM Pdmp8jVP6IUOg79M72OUxEhL80Owa7oXNiFp3lsQ5Ui9a1lw54DkB5Bp7hG7Ir9FDWku8vnMGhj yg4uU4n1HwWHiuFhHF9QgUONrvTSPpDmHu2mETYiVY8/FAm+bkcY2lReJ8KKH/GEYiVRgdGaMDb 5dNnJcS/4no5Pca2YwtsrGq5ZXtCEK0cu9gBwdlgGY/lUFaLKwzTt8PiwjPKZ95nod9mwAmu/Wa ZUtwi+OxnvwDfD4DI197P3dTvQNvUfwclK8EpF2i8T3OaH4Op1/8 X-Received: by 2002:a17:90b:48cf:b0:2fe:85f0:e115 with SMTP id 98e67ed59e1d1-31f5de6c834mr8973355a91.26.1753968151449; Thu, 31 Jul 2025 06:22:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmNszBsD4ejVXmbDKe0gpXcTf/N5/bNazz9PyWnMpySaHBdThy86NQMlOmdlIWTk4y0AOB+g== X-Received: by 2002:a17:90b:48cf:b0:2fe:85f0:e115 with SMTP id 98e67ed59e1d1-31f5de6c834mr8973289a91.26.1753968150894; Thu, 31 Jul 2025 06:22:30 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:44 +0530 Subject: [PATCH v8 04/27] migration: push Error **errp into vmstate_load() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-4-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=2377; i=armenon@redhat.com; h=from:subject:message-id; bh=R9/G1j+qazRvGzjWA2NYgBZJVWEWhvj63YuptM9QLk8=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37tNAHZ1D6mLlK1501C9NiY5dU+z2LecAQ8tzuad7O UTtOs53lLIwiHExyIopsjR8DZBtCiiMiLR9eR1mDisTyBAGLk4BmEiGNSPDDSE3vwlTmc5+Tjg+ z2X2rupUO/5D0bvnu/DvCauMOdg9leGfrejvv0ky98/vevYlj1lqif60T8y+24O3//0mHsF2PL6 YEwA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971707588116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that vmstate_load() must report an error in errp, in case of failure. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/savevm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 842ff3dc6d5ccb05f7d33cef9f7319b141419501..736410be867a29efa24d749528c= 9bc203a3e8131 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -963,14 +963,20 @@ void vmstate_unregister(VMStateIf *obj, const VMState= Description *vmsd, } } =20 -static int vmstate_load(QEMUFile *f, SaveStateEntry *se) +static int vmstate_load(QEMUFile *f, SaveStateEntry *se, Error **errp) { + int ret; trace_vmstate_load(se->idstr, se->vmsd ? se->vmsd->name : "(old)"); if (!se->vmsd) { /* Old style */ - return se->ops->load_state(f, se->opaque, se->load_version_id); + ret =3D se->ops->load_state(f, se->opaque, se->load_version_id); + if (ret < 0) { + error_setg(errp, "Failed to load VM version_id: '%d', ret: '%d= '", + se->load_version_id, ret); + } + return ret; } return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id, - NULL); + errp); } =20 static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, @@ -2741,7 +2747,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype) start_ts =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); } =20 - ret =3D vmstate_load(f, se); + ret =3D vmstate_load(f, se, NULL); if (ret < 0) { error_report("error while loading state for instance 0x%"PRIx32" o= f" " device '%s'", instance_id, idstr); @@ -2794,7 +2800,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e) start_ts =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); } =20 - ret =3D vmstate_load(f, se); + ret =3D vmstate_load(f, se, NULL); if (ret < 0) { error_report("error while loading state section id %d(%s)", section_id, se->idstr); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971383; cv=none; d=zohomail.com; s=zohoarc; b=XixS2tZmLzUND5R5LYtKNzX21PRyO6hLLChLWm2ZhFbMQE7+tgQTWfUQiQTErI27m+sTPE4D5pjbktmw4akXMaC82UFMZaEwg/rxOHaQQuZaKdVobMT4FSEAzuVKCwyJhdHdOxz6UFierx97BJ7/DA4QH9VbgaV4iZsrpuQXOo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971383; 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=SlHrG8oxZCrSy622JJbRcSdZ7eDi1KQ0TwRagoGzXjQ=; b=UK1djqn/YNXDyE7+/pcf4jDokxf6rZjnLADrXuBVmY7o1Z17Nu+tcwIxdFdrTZOkMEujmFd5/trp4tZW/WgsUGtwydIbHuPsITueLozMLF1CaKpluAT7B8yN1Kt40ivAGJ4fekn/JvSAHTU83rn2Cd/rC55Lxzk2r88pS8PtS7o= 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 1753971383140987.3383279278652; Thu, 31 Jul 2025 07:16:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU20-00066U-9e; Thu, 31 Jul 2025 10:13: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 1uhTF8-0004oB-Oy for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:49 -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 1uhTF5-00089u-UU for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:46 -0400 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-207-GqHtgLj6NhKXrwzYtlBhqg-1; Thu, 31 Jul 2025 09:22:41 -0400 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-3139c0001b5so531423a91.2 for ; Thu, 31 Jul 2025 06:22:41 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968163; 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=SlHrG8oxZCrSy622JJbRcSdZ7eDi1KQ0TwRagoGzXjQ=; b=QStaCZh/ptXUB7oo4r/wLD1Zfai6ZGVLJFoZaotOHfstJuCnbAEjdBRw5Pq81Wf3vXXd1U KRrxYJJqQh4iR8RyP4iOsNz+yWN067W3rTql0sZGmuK0Ibgt4THvr7bsXITbBYg7Yeofzf NMJh233ocM/w4avfeVYAVTBf3a+ty2o= X-MC-Unique: GqHtgLj6NhKXrwzYtlBhqg-1 X-Mimecast-MFC-AGG-ID: GqHtgLj6NhKXrwzYtlBhqg_1753968160 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968160; x=1754572960; 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=SlHrG8oxZCrSy622JJbRcSdZ7eDi1KQ0TwRagoGzXjQ=; b=pHhMdLTb+ugHeL9LApCI/L1rmpbi/b/D9Nq6c1RfrrgiGXocbkGJAC778tErTmMPjH S7W8/dF4SsoQGbnMsKWqH3DuwQkyHeLFHd4XO2huuz3LR6L+bCtoEHbZO93ZE4hUrSuA RO0Sb4Xu6ehDRIwD9yuRhzIMO7jzSzH4p8Xs3a8Y2/UmsX1dAz/ydHbYCwEbAJX9MnpK PUyLD0BNhle0jfINWaMsevHaJYTLxEeOfqRr/pizdRApoWkKNS+qRGnl8BgZPwxjgqxs gFZ6D8WOJPv9tc+0P26RCjDHsc3LkhRnSRcwI0qlfcpbgMsTjVLwoTYa0d7KkOerHrlp K/0A== X-Gm-Message-State: AOJu0YzGuM+Ba6qvGnhhIkAox7XqlWguoOCW6gHZiCBxp9urfUTbKs+Y 4+r5bIMr9AyyBGglFFBbLRB3iSpCB1zjuxX4fbXqnD0OjdURstgF968yYKUAvYJ1dGgaNGACE+G fuCtXs0HUMPKFMgiDvuOpnmXYh9HFAA4DmdSrfUTAze9hHeq7ZcvAvJ3GFld9zKwv2+R4x/AYdG +Ww4CjQG4suk9QHbbyJG13Wp13hOljd+QY/P3tIHDqxQ== X-Gm-Gg: ASbGncuxMlsM7Z8yPl8zvf/pIztOlfAaEG90UowDLIW6iW+o+7b4EyVOSLy3EvjRnHw YKtYJ3F+nbfZoaEBABk+JlNyhclyTs4BNHPBpEK0V8OobWw7E7Jbq0u+H7iKrLvt/npX9SgEv5G hP+6H8ApjQsV7KTbepPytR3FfxzLmqpGMO6FhjD3UPKIjeoAhAbCeRYn7I2Y+oXsrQFX2MO/xoO gZlgflNU05ogW5U9Ycq40IYrUH2RsnzajjyOkTswJ/NPhQtidrzmkcyG5xshv4LMdCRIqCx8bSE rn53vBe0r4EfeE0ZjpR+Oa3YE0/9eG9kWADQ5v9w8V1uwa0Ca/u2 X-Received: by 2002:a17:90a:d40f:b0:313:15fe:4c13 with SMTP id 98e67ed59e1d1-31f5ea4ca16mr11467579a91.27.1753968160039; Thu, 31 Jul 2025 06:22:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOOididryM+uykRBaOc3BpoyDnjn3fRrR7JT6YxNKAi2/Lv+3iT2wY+bmM0OHGi6Cva4FigQ== X-Received: by 2002:a17:90a:d40f:b0:313:15fe:4c13 with SMTP id 98e67ed59e1d1-31f5ea4ca16mr11467504a91.27.1753968159472; Thu, 31 Jul 2025 06:22:39 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:45 +0530 Subject: [PATCH v8 05/27] migration: push Error **errp into qemu_loadvm_section_start_full() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-5-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=4735; i=armenon@redhat.com; h=from:subject:message-id; bh=AkqPKFSHbirygOBveuuipoo1wuWUoKioEwj4RyL290c=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37lPmlXyubm/zLjh9Pc9/uuPo1J9/ztrkvPq9/Xlh4 NwdPssVOkpZGMS4GGTFFFkavgbINgUURkTavrwOM4eVCWQIAxenAExEy5Hhn7kk7/YF4d/aNM5d 23ZBW8/dL2Ny6py73WpG27b+Nmy7l8bwPyPzL+s//btRkT8iS6LjX7nveW0c5rI5KLp2Nleb8af N3AA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971385466116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that qemu_loadvm_section_start_full() must report an error in errp, in case of failure. Signed-off-by: Arun Menon --- migration/savevm.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 736410be867a29efa24d749528c9bc203a3e8131..59751677c1bb7c893b4ba61cbfe= 1f55ade6ad598 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2690,8 +2690,9 @@ static bool check_section_footer(QEMUFile *f, SaveSta= teEntry *se) } =20 static int -qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) +qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type, Error **errp) { + ERRP_GUARD(); bool trace_downtime =3D (type =3D=3D QEMU_VM_SECTION_FULL); uint32_t instance_id, version_id, section_id; int64_t start_ts, end_ts; @@ -2702,8 +2703,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype) /* Read section start */ section_id =3D qemu_get_be32(f); if (!qemu_get_counted_string(f, idstr)) { - error_report("Unable to read ID string for section %u", - section_id); + error_setg(errp, "Unable to read ID string for section %u", + section_id); return -EINVAL; } instance_id =3D qemu_get_be32(f); @@ -2711,8 +2712,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype) =20 ret =3D qemu_file_get_error(f); if (ret) { - error_report("%s: Failed to read instance/version ID: %d", - __func__, ret); + error_setg(errp, "Failed to read instance/version ID: %d", ret); return ret; } =20 @@ -2721,17 +2721,17 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t= type) /* Find savevm section */ se =3D find_se(idstr, instance_id); if (se =3D=3D NULL) { - error_report("Unknown savevm section or instance '%s' %"PRIu32". " - "Make sure that your current VM setup matches your " - "saved VM setup, including any hotplugged devices", - idstr, instance_id); + error_setg(errp, "Unknown savevm section or instance '%s' %"PRIu32= ". " + "Make sure that your current VM setup matches your " + "saved VM setup, including any hotplugged devices", + idstr, instance_id); return -EINVAL; } =20 /* Validate version */ if (version_id > se->version_id) { - error_report("savevm: unsupported version %d for '%s' v%d", - version_id, idstr, se->version_id); + error_setg(errp, "savevm: unsupported version %d for '%s' v%d", + version_id, idstr, se->version_id); return -EINVAL; } se->load_version_id =3D version_id; @@ -2739,7 +2739,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype) =20 /* Validate if it is a device's state */ if (xen_enabled() && se->is_ram) { - error_report("loadvm: %s RAM loading not allowed on Xen", idstr); + error_setg(errp, "loadvm: %s RAM loading not allowed on Xen", idst= r); return -EINVAL; } =20 @@ -2747,10 +2747,11 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t= type) start_ts =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); } =20 - ret =3D vmstate_load(f, se, NULL); + ret =3D vmstate_load(f, se, errp); if (ret < 0) { - error_report("error while loading state for instance 0x%"PRIx32" o= f" - " device '%s'", instance_id, idstr); + error_prepend(errp, + "error while loading state for instance 0x%"PRIx32" = of" + " device '%s': ", instance_id, idstr); return ret; } =20 @@ -2761,6 +2762,9 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype) } =20 if (!check_section_footer(f, se)) { + error_setg(errp, "Reading footer section of instance " + "0x%"PRIx32" of device '%s' for version_id:'%d' failed", + instance_id, idstr, version_id); return -EINVAL; } =20 @@ -3063,7 +3067,7 @@ retry: switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: - ret =3D qemu_loadvm_section_start_full(f, section_type); + ret =3D qemu_loadvm_section_start_full(f, section_type, NULL); if (ret < 0) { goto out; } --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971489; cv=none; d=zohomail.com; s=zohoarc; b=OcNa+ri3V/KIjSurWJDnygJ1ehWLIvOU/F7uoRmFaPcVVqVoqIl5Ztru4k44bUz9VAYo0hJGP0oM4swNAMbdknNREExOzdGKc1Z5GTk9kzXeIPA2WTPeTqh7ICngEYDeK0W4n6r9GE1lXYNPROTeRz3r0jDLSI9Dzsm0z0vcih0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971489; 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=DW1IUpPF5ZiKpDHfiTHo74xptJJXvnHIMV0+ph0+/iw=; b=KCaK/K5DzypT71QxEdziwayUzKAXYNtqlkGnkbICN3doMQ/v+qEquWnz8igpNiCCET1cQLaMrNxk1crRTU3mOmw3iJjnKQ+Hj5I82GihoG/rXF8T9FT/hro4JR/5C8It047kCtlun7Y2DbtlZDCoFcOuhLvlIfoZadhFvEhZ8XQ= 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 1753971489416674.2191846422259; Thu, 31 Jul 2025 07:18:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU65-0000U6-Bi; Thu, 31 Jul 2025 10:17:30 -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 1uhTFM-00055y-4R for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:03 -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 1uhTFG-0008BU-Vb for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:22:57 -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-257-E3dygPL6PDChvr17tGKUiw-1; Thu, 31 Jul 2025 09:22:52 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-31f030b1cb9so1522242a91.2 for ; Thu, 31 Jul 2025 06:22:52 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968173; 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=DW1IUpPF5ZiKpDHfiTHo74xptJJXvnHIMV0+ph0+/iw=; b=J9nyqLOdsw/TcUl8ucWwN7i9X/sK4fxUat9A2AG7zEEmVv/Ph6fpKxrrqjUZUlXuOKnNJp xqEhkPWe73G3EWm2ANjlQlWvHV20hbVB8HJhs1j/ejNpQ4EK3+W4UjonmGsWHUEOma3jA0 M6Bcn3EIpuHWeXNzdKZGMsVkDOiXed4= X-MC-Unique: E3dygPL6PDChvr17tGKUiw-1 X-Mimecast-MFC-AGG-ID: E3dygPL6PDChvr17tGKUiw_1753968171 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968171; x=1754572971; 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=DW1IUpPF5ZiKpDHfiTHo74xptJJXvnHIMV0+ph0+/iw=; b=WBug776i9A86jn5tlr2eVMZjmDWqWFerI0yd7gMyoe/CGiUx6YMZThRZSzQ2uLJRZt clFHK8NnKllt+yOJ5ZPQq8l8BFRsl3o2lCQDiEgX3KKe9iJ8CJ/HnGLyRVCfJawRWW/t 5fNe8/fyaYC39UA1waeDyemgy8wM7o981YVk5rkmBxlY3/uRpyfwfTnHG4MHcPxRfm7Y TXF18elz5pZ3+xz+KFJjaliOobwSZjoT8ZsCLFlSPKANVJX5Hfpj24q2Ks9q7oLVZ/5L xxOpZMtdnlJMe7klH+KoUkyFDDW4cuNur7l9JJtgjAHqQ8t24VhnwzEa2qvnXP98oyWj Aq5g== X-Gm-Message-State: AOJu0Yz2NHCkzdKQThtLuNySbXfu1laIiAs8OQRHgpum5HDMqPrINf4g VMIvXLU6SuFO562bMGtpd3dTlrpyZsp2B0KVA7jJeY8YQZCnPh3oLToPuA/FzaKD2FBkP/2/nDm egnTg2fxXqIRIE0UU6LbTOAGAEWyIXTMi1pXBJdyIfqFXSJuC3XQUWlYyqPwSXSmBaFUpswnmnJ db8GxTglwR+sH8Rq7qKBqjUBEHBzrJCvJ645q7gjoogg== X-Gm-Gg: ASbGncvzVj0YGKn8giJoXQRd1+z63T1HAIo0l+8+knxZ+sgcVvi4VNEQZioqWNpb0aH AHW9cJ5uOzR8acaKPfYl83J2sFpo1fqZsK04gBPa0iel8DukPbaZm+a/fqNh4kSJAX/9fEWBNmG VYFryRmFAv3kbjttx+H3lhrBXytCpBVnVko0a6Txt20lh67HTMbCWxj4pXbhehffmAsqh78SAgo wNOsP+/IAPTKuR/y8s5h6tUsN7/em7iFpExZwQXvYoxVhrfxM95/qmPW5LbRWkpV/tJPE4NKYKS on+QitGHNLq0eQrA5uu+/XcwdGLz1f5iiqoJUfH0QY+XrYRE6R5A X-Received: by 2002:a17:90a:d604:b0:31f:3029:8854 with SMTP id 98e67ed59e1d1-31f5de5561dmr10669280a91.27.1753968171083; Thu, 31 Jul 2025 06:22:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtvBfHfVARD9jLj7SG/M6M71+OByko1bTpA6JOLnZMLl7OINgNwW6E+3ZkshObNVq0e4ueAA== X-Received: by 2002:a17:90a:d604:b0:31f:3029:8854 with SMTP id 98e67ed59e1d1-31f5de5561dmr10669204a91.27.1753968170515; Thu, 31 Jul 2025 06:22:50 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:46 +0530 Subject: [PATCH v8 06/27] migration: push Error **errp into qemu_loadvm_section_part_end() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-6-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=2783; i=armenon@redhat.com; h=from:subject:message-id; bh=GZMrml/XZ+AueUWSK097qKRlu/lpBaqzz/IkCXVxJdE=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37lP2xy8Ku6bv3uvYo7Jv8xVjdgc1h8Cv4ozS2WWb9 5xVSnPsKGVhEONikBVTZGn4GiDbFFAYEWn78jrMHFYmkCEMXJwCMJGEdQz/DE4UsG85baD7Yc0y GW127nW8cU+C7lW3ivomWN48LR9izMhwZuneN4LmL10d7Wv+1X5c8O0zxwyb53HRgpb1ApOUi5i ZAQ== 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971490752116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that qemu_loadvm_section_part_end() must report an error in errp, in case of failure. Signed-off-by: Arun Menon --- migration/savevm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 59751677c1bb7c893b4ba61cbfe1f55ade6ad598..9ed842eb87a019666d4409e1213= c41643a173447 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2772,8 +2772,9 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype, Error **errp) } =20 static int -qemu_loadvm_section_part_end(QEMUFile *f, uint8_t type) +qemu_loadvm_section_part_end(QEMUFile *f, uint8_t type, Error **errp) { + ERRP_GUARD(); bool trace_downtime =3D (type =3D=3D QEMU_VM_SECTION_END); int64_t start_ts, end_ts; uint32_t section_id; @@ -2784,8 +2785,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e) =20 ret =3D qemu_file_get_error(f); if (ret) { - error_report("%s: Failed to read section ID: %d", - __func__, ret); + error_setg(errp, "Failed to read section ID: %d", ret); return ret; } =20 @@ -2796,7 +2796,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e) } } if (se =3D=3D NULL) { - error_report("Unknown savevm section %d", section_id); + error_setg(errp, "Unknown savevm section %d", section_id); return -EINVAL; } =20 @@ -2804,10 +2804,10 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t t= ype) start_ts =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); } =20 - ret =3D vmstate_load(f, se, NULL); + ret =3D vmstate_load(f, se, errp); if (ret < 0) { - error_report("error while loading state section id %d(%s)", - section_id, se->idstr); + error_prepend(errp, "error while loading state section id %d(%s): = ", + section_id, se->idstr); return ret; } =20 @@ -2818,6 +2818,8 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e) } =20 if (!check_section_footer(f, se)) { + error_setg(errp, "Check section footer error, section_id: '%d'", + section_id); return -EINVAL; } =20 @@ -3074,7 +3076,7 @@ retry: break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: - ret =3D qemu_loadvm_section_part_end(f, section_type); + ret =3D qemu_loadvm_section_part_end(f, section_type, NULL); if (ret < 0) { goto out; } --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971620; cv=none; d=zohomail.com; s=zohoarc; b=PHhfeEYf89uhMG6amahSDls4/RCx0b8Rc6WvjZdTxIKGEy4bTEWCq6qBpNtczAMGo9ZtWicDvZNOpSLlaH2L/Bg9EaFjHVvA3agFSGszdGpWeGC6SqN6ympB2kYv3JHxuGZ8hY8RAaKTvG3F/ifks7WfxPC5LZEh3JKPX2rdaLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971620; 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=gWJg29Nx6GQ1ehptzza8ixurpbv7NTpS2owOU8T44PI=; b=ZyKAb1ReNqe+7jPliIzAoRyPbzkKNwPM2YT6+hT7aF6EeKk7jFGtOSl8cMTEpAcvn4ryhhgwZ/uNLgXbH9Qh42YtbTVsi4DhVVB1G0REL+f+c6K1rqI0vHmsQnHlFp3kwkwhSYrbL8a4k/WW+umsxKEl5BMezsw6n5cC25M2eOw= 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 1753971620768808.6118851103299; Thu, 31 Jul 2025 07:20:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU7h-0004Eh-Vm; Thu, 31 Jul 2025 10:19:10 -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 1uhTFY-0006aC-Dn for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTFU-0008Dt-Os for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:12 -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-412-bdrWVZDnObmhjseeCzDlqw-1; Thu, 31 Jul 2025 09:23:06 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-31f3b65ce07so750420a91.1 for ; Thu, 31 Jul 2025 06:23:05 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968187; 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=gWJg29Nx6GQ1ehptzza8ixurpbv7NTpS2owOU8T44PI=; b=RyHKF9fWJVJ4TglzlKO4be+26ltuQtBRCx9SzW1xMCd1QzQiCmctJ2if3LXFvOttPdiRTE ls1OQuN+PoRSjg7qBtYNZhDGujujcYckMAS5NbkYPRCAEK3OYEgqy3Zk5MORK8xODMYasu Pu6frfXq5J9ngy+GbIT+djUq2bzf/4w= X-MC-Unique: bdrWVZDnObmhjseeCzDlqw-1 X-Mimecast-MFC-AGG-ID: bdrWVZDnObmhjseeCzDlqw_1753968185 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968181; x=1754572981; 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=gWJg29Nx6GQ1ehptzza8ixurpbv7NTpS2owOU8T44PI=; b=dE3caUxMfcBodhGxSaA7qSbG/KnlqqrqcBc8LEunkDm5QVQI4vW44FF5bIa8IRfXAc LJ1Www1sOqb9yVHE0NMFAaHDkaZbPhx2h4R0DqUs62T4J8wBUBsbqo3tjfMyLwyM+CDT rKAm5hd63Qz2RTeOkcg8Q9v3F4sbb7W4pqdPRg0jApsa3KLJvRujMjgZm9/zsO/VJW6h UJRvhtnOTKeASf8nYLh24s6p3iGd4twXBxBqURhP0xZbBqdQ3liaz8h6yuKp/zhXDbZ+ 3Xbyi/S3e9RoYlAC2Y2yMc04Ri5rw8N+tQyrk6kmvduEUCKjSAJzrxiXYOolnCR/E+um Smmg== X-Gm-Message-State: AOJu0YzEiNhnwYV+yhlsvFV6/EZTAT+QT81MD7MlzLdoY5wvDzeWM39+ DMuV0zNnH26PxlRR+lZaJIBt9oU1eWP5ojyGno2uKnecaMxmsRampfH2lwdz4ft93xiBccvAPsB ZtAzA7AQFAf7tHYIeDqVgjXmpm/hrB8jjZA8qcOlrOtsPHP3ybqe1XzgDqvfgI7DRMWMzx3TAwG P1dEcBi1e0aJFBagrtgEVfkjuu7aSzaoVLY8N/0dLZWQ== X-Gm-Gg: ASbGncusIwzOEC3I6Slg+uoHsvXaGdK3bJq/HwSVQXbZVKsMSb1FwEO9A7BfgWhzkMc MlArH7FGVzFLxZW5uaJeuHwIbLtWZT8C8uWYuUTUtyfUhGnCHNH5YeXFn/gV99Xz/xITyWSJz4p s4HRTJznxFV49Oi/1wwO4I4oHGUhTet/cVLKxwdlBSGAnqXtlZGh72GCXZmdbVdS3wUBHGZ+bHJ 34WNydel/8VEHMbH3LFGWajARuqVKuN3/BLYFUlqfVDwpJxok3AHqhxnZNti8EcxGGP5t2jYbvF oY7H6PlfOTVJ/extZRcz4WEquBVPFml0UJNrNyFQlRxSd0eZkIBS X-Received: by 2002:a17:90b:4a:b0:31f:42e8:a8a8 with SMTP id 98e67ed59e1d1-31f5dde8a3cmr11108100a91.12.1753968181617; Thu, 31 Jul 2025 06:23:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4kAeC10yMczQRYtdbGt76/eomwbuZsmPWJSVmj7eZdJUuUBWT5Gb8FH628oUNgVjFUEArzw== X-Received: by 2002:a17:90b:4a:b0:31f:42e8:a8a8 with SMTP id 98e67ed59e1d1-31f5dde8a3cmr11108026a91.12.1753968180976; Thu, 31 Jul 2025 06:23:00 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:47 +0530 Subject: [PATCH v8 07/27] migration: Update qemu_file_get_return_path() docs and remove dead checks MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-7-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3844; i=armenon@redhat.com; h=from:subject:message-id; bh=/AWe+X+/WeRjGQrEoVl4cRFi5sWN/sqcOL9pzGajTZ4=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37tMp9+77Fs6M5DeoF33XP/+HoJTw0T7+6Dk8LAfSz uU3fPTtKGVhEONikBVTZGn4GiDbFFAYEWn78jrMHFYmkCEMXJwCMJFjJgw/GafZsma//xYrpX+H VW2v8azvka/qrsR/PFPD9np3gIRoCiPDcSGfJHOTG9q9kjyy60NL+W0C/3Fu8682P3theeyG80E 8AA== 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971622874116600 The documentation of qemu_file_get_return_path() states that it can return NULL on failure. However, a review of the current implementation reveals that it is guaranteed that it will always succeed and will never return NULL. As a result, the NULL checks post calling the function become redundant. This commit updates the documentation for the function and removes all NULL checks throughout the migration code. Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/colo.c | 4 ---- migration/migration.c | 12 ++---------- migration/qemu-file.c | 1 - migration/savevm.c | 4 ---- 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index e0f713c837f5da25d67afbd02ceb6c54024ca3af..981bd4bf9ced8b45b4c5d494aca= e119a174ee974 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -849,10 +849,6 @@ static void *colo_process_incoming_thread(void *opaque) failover_init_state(); =20 mis->to_src_file =3D qemu_file_get_return_path(mis->from_src_file); - if (!mis->to_src_file) { - error_report("COLO incoming thread: Open QEMUFile to_src_file fail= ed"); - goto out; - } /* * Note: the communication between Primary side and Secondary side * should be sequential, we set the fd to unblocked in migration incom= ing diff --git a/migration/migration.c b/migration/migration.c index 10c216d25dec01f206eacad2edd24d21f00e614c..b3bccaeaee806abd01595863f64= 75057049b0688 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2646,12 +2646,9 @@ out: return NULL; } =20 -static int open_return_path_on_source(MigrationState *ms) +static void open_return_path_on_source(MigrationState *ms) { ms->rp_state.from_dst_file =3D qemu_file_get_return_path(ms->to_dst_fi= le); - if (!ms->rp_state.from_dst_file) { - return -1; - } =20 trace_open_return_path_on_source(); =20 @@ -2660,8 +2657,6 @@ static int open_return_path_on_source(MigrationState = *ms) ms->rp_state.rp_thread_created =3D true; =20 trace_open_return_path_on_source_continue(); - - return 0; } =20 /* Return true if error detected, or false otherwise */ @@ -4010,10 +4005,7 @@ void migration_connect(MigrationState *s, Error *err= or_in) * QEMU uses the return path. */ if (migrate_postcopy_ram() || migrate_return_path()) { - if (open_return_path_on_source(s)) { - error_setg(&local_err, "Unable to open return-path for postcop= y"); - goto fail; - } + open_return_path_on_source(s); } =20 /* diff --git a/migration/qemu-file.c b/migration/qemu-file.c index b6ac190034f777dbde0da1598483a892089d7538..f9ccee9a1091ecbd37e6b7d2081= a4446442b544d 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -125,7 +125,6 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bo= ol is_writable) =20 /* * Result: QEMUFile* for a 'return path' for comms in the opposite directi= on - * NULL if not available */ QEMUFile *qemu_file_get_return_path(QEMUFile *f) { diff --git a/migration/savevm.c b/migration/savevm.c index 9ed842eb87a019666d4409e1213c41643a173447..39d6fd5b832971f23afc08100a2= 0bcac045f3904 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2583,10 +2583,6 @@ static int loadvm_process_command(QEMUFile *f) return 0; } mis->to_src_file =3D qemu_file_get_return_path(f); - if (!mis->to_src_file) { - error_report("CMD_OPEN_RETURN_PATH failed"); - return -1; - } =20 /* * Switchover ack is enabled but no device uses it, so send an ACK= to --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971797; cv=none; d=zohomail.com; s=zohoarc; b=k4vg8LqOEQjggCZVIkycYOZzXhpV3z8/opst+MGlXgYNr5jG1Do4HTHBQiygwFlDgcvTIkIe/XZSz5JXLSR4XeJaRjB66V7xsNgW5hGSut3RI7uPozjXrvsh1L1Azn1ydAn8Pc3I+/aUlQqUUkS1U5juG99/6voR8SLDrdvuH70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971797; 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=B2fOYR/9n6os2GWcaytNtOuo9VDsGK864lc8x/7qXR8=; b=ntLT63azGBZdmvBKdK1MBv990dcTspvys5N8YEwzvjcELx2L7H0h5LTQCjNE+8BBiEysoEzVimDeq+Rb7gXfmKYBLE5PFeG29NshZvP3eqKgf9+ddTX8yiKybakYErZjMaB/nflI4J0YNaNmkX0AhavGFwbVo4H8bykJHUGye0k= 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 1753971797902535.0911751986713; Thu, 31 Jul 2025 07:23:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU7m-0004g4-Sf; Thu, 31 Jul 2025 10:19:15 -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 1uhTFh-0007oz-Cp for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTFb-0008FM-4s for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:21 -0400 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-jAvTTJC5PrWbPVmYQss_Dg-1; Thu, 31 Jul 2025 09:23:13 -0400 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-31ea14cc097so431665a91.3 for ; Thu, 31 Jul 2025 06:23:12 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968194; 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=B2fOYR/9n6os2GWcaytNtOuo9VDsGK864lc8x/7qXR8=; b=ZYV/Xwt/3S3nMQj30tWQhL+bTaPnfwY0DBL4lsF6zEhiMt1laBRd4kcZIBuBV3KWc9aJch Wdu/on5AgChDib8T2c91xcf1oFXGHbJXzapNvPJvJevLuNHQ/xBu8WLUs964lfAkJ0NUIH mBaExlTs8C0G+bS53VvjpaLSe+xuwQ0= X-MC-Unique: jAvTTJC5PrWbPVmYQss_Dg-1 X-Mimecast-MFC-AGG-ID: jAvTTJC5PrWbPVmYQss_Dg_1753968192 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968192; x=1754572992; 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=B2fOYR/9n6os2GWcaytNtOuo9VDsGK864lc8x/7qXR8=; b=A/jse/QQWvONGxeTQXHzuqbslAx72y67rtMgRZ4cIitOEk7ltMwegrPc19T0uVBEBx JUj3STemh3zHiosOiTnUqFWddPkBOohvMe0ovHnTVspyuDQGriVT6bq37aYky7HPI+2V 8z9niw0KE3valPaOsR0nFF0GBWG7fdvGlhRi1/N0HMAjowHPLOqXk82GjMNJ9afa6foJ 1Dusm8lymRrnwco3Dwe/wQph4PExWta3gnG2B2mEx9GbAHma518vSOagAmqiqmRTMSL1 ldYpn2rzteS8oss3aRCHEZVB7Nkw2JiPRhX6s3RtXMT8uYp20evtm3BUcbSap8owTjCS VSow== X-Gm-Message-State: AOJu0Yzhz2ggpDkoHD9OVz75moUV02KompClZ0BwC9Adw/P64AfWweaD fWU2kCyVhtr91I3zpf4WQ9JCE5bfd6xcFPRpRhhIwnRkVlq5kIAKRIh13LUa8XSMsa925RzHMaX fhR3H70i/0ejEKYQcGNOOPucSWLqdimlmSZAB1qeq+Wv26WU3SFOm+Uo9o1mbyMsniaXmTfcQR0 CBLEHzcfk7w9BAPP9REIqhs1OBn57TlkNlkimCsmHvmw== X-Gm-Gg: ASbGncv4ALIyePGoh+bpDGKVbdPGeORjFsVTBeGvmYKGj2wiZzN+Kn6XyVYp15eHRYv 67Nmu+o5ATmgWP2Cz/c+a5YsJ6YQ11K45SpSCUee4Ob+fofyfjbrTn4yOOM9quOqMe+9I9c80e5 FYvphxBN3v3kcQFLtYCrROivB3xHsb3MErogwlhFYur1uP40AO4d8FL/KM4MIaXfZ1WIg1EsuZB X5BKRXgO4j+U9LG2TSjPB4o7vjNoUrJp5IVWfy3cz5F9DXp5dnm/aby6Gtq3P5iIIy2CdqQqyYv EosFq2krreQHSpo0V5Kt4UAKAa+6L6WtGxRyxyK+2UAZXoju/9za X-Received: by 2002:a17:90b:3ecb:b0:311:df4b:4b93 with SMTP id 98e67ed59e1d1-31f5dd6b545mr9561677a91.7.1753968191391; Thu, 31 Jul 2025 06:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoCxJT+fLdKKitWpQBr6k882ihhZnhoKB1eGxHAhO6F70iD6P6Anz89O8triJ8PqRaFfbOqQ== X-Received: by 2002:a17:90b:3ecb:b0:311:df4b:4b93 with SMTP id 98e67ed59e1d1-31f5dd6b545mr9561593a91.7.1753968190622; Thu, 31 Jul 2025 06:23:10 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:48 +0530 Subject: [PATCH v8 08/27] migration: make loadvm_postcopy_handle_resume() void MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-8-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2034; i=armenon@redhat.com; h=from:subject:message-id; bh=gZeeufuGJO+jx1CzE6vGy8W4/PdHRl15dQahu1SenoQ=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37tOlx7xvzefuusG31KZv5deC32cDV4bNrN1WVjRj7 RKxlsVdHaUsDGJcDLJiiiwNXwNkmwIKIyJtX16HmcPKBDKEgYtTACYiMJuRYXdOXOX7tVN2TpYQ X5yqVidxvXvZtn8MCecmWMs9dwjlus7w3525VaSqqEAsOyk1m6k+oeFpw7RJia9ezShYedBcokS cGQA= 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971798718116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. Use warn_report() instead of error_report(); it ensures that a resume command received while the migration is not in postcopy recover state is not fatal. It only informs that the command received is unusual, and therefore we should not set errp with the error string. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- migration/savevm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 39d6fd5b832971f23afc08100a20bcac045f3904..dfdb39952b0de12f7a4d6a0850c= 052a50e719925 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2334,12 +2334,12 @@ static void migrate_send_rp_req_pages_pending(Migra= tionIncomingState *mis) } } =20 -static int loadvm_postcopy_handle_resume(MigrationIncomingState *mis) +static void loadvm_postcopy_handle_resume(MigrationIncomingState *mis) { if (mis->state !=3D MIGRATION_STATUS_POSTCOPY_RECOVER) { - error_report("%s: illegal resume received", __func__); + warn_report("%s: illegal resume received", __func__); /* Don't fail the load, only for this. */ - return 0; + return; } =20 /* @@ -2391,8 +2391,6 @@ static int loadvm_postcopy_handle_resume(MigrationInc= omingState *mis) /* Kick the fast ram load thread too */ qemu_sem_post(&mis->postcopy_pause_sem_fast_load); } - - return 0; } =20 /** @@ -2627,7 +2625,8 @@ static int loadvm_process_command(QEMUFile *f) return loadvm_postcopy_ram_handle_discard(mis, len); =20 case MIG_CMD_POSTCOPY_RESUME: - return loadvm_postcopy_handle_resume(mis); + loadvm_postcopy_handle_resume(mis); + return 0; =20 case MIG_CMD_RECV_BITMAP: return loadvm_handle_recv_bitmap(mis, len); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971773; cv=none; d=zohomail.com; s=zohoarc; b=eJu490HSx81RqQXnG6kcyYieR3B+oPw8n9102Tl91+SJNdISLLX8bXx0A68Q3xWURvcXiAfGyNSJ6qOONrUWrz1nXfJSgrVlZD+O/i4m583fCN+sVhgfwVQfIpjFzzwgrOCpbgV3AhPG95BFN3WN9/nzIyOY0y62Ka4KYuOv7TE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971773; 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=pONtifaguG13Cs8t7DIqrtCwScrqhUzIQHS4WT1h7kg=; b=NISY0ur779gNM+qVtmRfkcajj5Hr3la1YbDCRlrgy4kUqBhtGZwaJmlECY5iZJs7r6trXU3WBc26aCOXLCgjIc2ozdER7nlImHRsSgpNIC6ZgeNRodxDyYbc0yJ2GIWiV7XLI5WchkREwiQ3/lyEpkS1mEdrSWM3vGkPiCJzgNU= 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 1753971773402383.0208920642483; Thu, 31 Jul 2025 07:22:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU7T-0002Qk-H7; Thu, 31 Jul 2025 10:18:56 -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 1uhTFq-0008St-Lp for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:35 -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 1uhTFl-0008Gn-Nf for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:30 -0400 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-FlxQRzwYOGqy8qrQMC5_ZQ-1; Thu, 31 Jul 2025 09:23:23 -0400 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-31f2dd30823so1566259a91.0 for ; Thu, 31 Jul 2025 06:23:23 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968204; 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=pONtifaguG13Cs8t7DIqrtCwScrqhUzIQHS4WT1h7kg=; b=SaWNuSNfXnNMXHOYATqoX5L6Lbzl3wQNnaowhhRxHkqiLrCE2U3gHHAjb000cCXsIa+vja /aF1g39ce77iU2V3ETO75BD2Qibt7MDMec5RyMn+6LQ5SWLqNO5+p6r5x3MRr9R+xxZW6v hpERv8NYidX4o1PRwy4igPjthn+szSs= X-MC-Unique: FlxQRzwYOGqy8qrQMC5_ZQ-1 X-Mimecast-MFC-AGG-ID: FlxQRzwYOGqy8qrQMC5_ZQ_1753968202 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968202; x=1754573002; 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=pONtifaguG13Cs8t7DIqrtCwScrqhUzIQHS4WT1h7kg=; b=qdzELSz1C8Z9j5poeY5k7GDQocPeZc1t9+7x0zmn3IFdR5lVTcgEg0C+PWHTgyq+ka TWNT3oe5qxPI306sbVk6xiNfN7WK224OoXews31TQ4I+5eJh4I89alVSjcz8C80SktLV hbHW/zc9cSo5+mMyIaWsU7YAHR0/gajBa6L4hpeLVAN+oaTge1QRkxsJ+Qm4C8qWSS2I A74hWYfmJCOgwbbAF7wyUIuhGIXcGZW58bC3APtgiKcP7RssCznSsCL3ux8XpyuL8ZEO EkxYyKdb9gKZvyPW+jwczUTaCpWmUy77e5lnzLWA2Af+1So3VYKfiXwJcfdDPVr+uhqD +RmQ== X-Gm-Message-State: AOJu0Yw8wwhHMfaOLgC3NaSHuYgGdFZIlAwUj/zmniHes5SKTzOVoPS0 R4feQc6gcwO6jp4Sc8zcNUcw2XXF8KI18RZQq8UJpFcHjna4nwUdctGgOe8bIWvuc6ClqoTE0/5 YR0pCDQd0JsZeWKLrBlCt/siJBH+4rTSlF1T21mcKv+AOMnF6Xjc2CMKXz3SVX4hUFoWZ5Xshbz l5orupJlY3XOu/rLuradK4DgLi+ME5abmOKi2ES9BQhg== X-Gm-Gg: ASbGncvnEn48bCjPhPva6d5njvzDPa23e38XR6mC6wyMBG2hN7FP0Fe/V/y38+BubsU QYr8G5psRViD5zNP5jOFGwJX6y4BLiAgQZuh1rYZEmD+Ci0EZ8dgwNm0BDeO0rk5eIi/ugdANoC 0PESKeC+7xryQzbAxd6mEMrsTsVD9JAsmuPDInCtR+/GuJopWrm8wcjOTXyaqzenGGiaGxz2jFp ZBxya+zi3R/YQhd/TQomwOC/xJa7t9DxnOjmcGwvbYAFObGQYYoDWwB7R6hhiQ1n83q40jLyWZ2 AZQebFqEr9YMM33WwJ1LFqXkmUHGJ+nPHSTHxAMstXGAPL2c4D0S X-Received: by 2002:a17:90b:3f85:b0:313:176b:3d4b with SMTP id 98e67ed59e1d1-31f5de41b53mr7910596a91.22.1753968201843; Thu, 31 Jul 2025 06:23:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYlAZU+FeK9C5a9MgO4n2JW+DkMnm6nP5EXJrVoKQxEivaSPLO7U4Go+biEYCwg5JgsgGRGw== X-Received: by 2002:a17:90b:3f85:b0:313:176b:3d4b with SMTP id 98e67ed59e1d1-31f5de41b53mr7910500a91.22.1753968201062; Thu, 31 Jul 2025 06:23:21 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:49 +0530 Subject: [PATCH v8 09/27] migration: push Error **errp into loadvm_process_command() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-9-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=6004; i=armenon@redhat.com; h=from:subject:message-id; bh=749RqNuXFloBJ+w70Re6iXAcs2gd63UT3Sg410UpJRA=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37lPVR4eyW2YmibokLLWIFfm89Y2rc4/m3ynczA3H2 vJSe793lLIwiHExyIopsjR8DZBtCiiMiLR9eR1mDisTyBAGLk4BmIj7fYZ/VpeynneavIoLdY1X TFoULXzlWLnm11PhzPo8D/6W/DnRw/A/pyTdx9uYT+xu0K7oQHcxIatFrgsXXDV4pvuri8fSvII FAA== 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753971774818116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_process_command() must report an error in errp, in case of failure. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/savevm.c | 72 +++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index dfdb39952b0de12f7a4d6a0850c052a50e719925..280ee92133975913f1d374231b4= 31235a7301b7d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2544,12 +2544,13 @@ static int loadvm_postcopy_handle_switchover_start(= void) * LOADVM_QUIT All good, but exit the loop * <0 Error */ -static int loadvm_process_command(QEMUFile *f) +static int loadvm_process_command(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); uint16_t cmd; uint16_t len; uint32_t tmp32; + int ret; =20 cmd =3D qemu_get_be16(f); len =3D qemu_get_be16(f); @@ -2560,16 +2561,16 @@ static int loadvm_process_command(QEMUFile *f) } =20 if (cmd >=3D MIG_CMD_MAX || cmd =3D=3D MIG_CMD_INVALID) { - error_report("MIG_CMD 0x%x unknown (len 0x%x)", cmd, len); + error_setg(errp, "MIG_CMD 0x%x unknown (len 0x%x)", cmd, len); return -EINVAL; } =20 trace_loadvm_process_command(mig_cmd_args[cmd].name, len); =20 if (mig_cmd_args[cmd].len !=3D -1 && mig_cmd_args[cmd].len !=3D len) { - error_report("%s received with bad length - expecting %zu, got %d", - mig_cmd_args[cmd].name, - (size_t)mig_cmd_args[cmd].len, len); + error_setg(errp, "%s received with bad length - expecting %zu, got= %d", + mig_cmd_args[cmd].name, + (size_t)mig_cmd_args[cmd].len, len); return -ERANGE; } =20 @@ -2588,11 +2589,10 @@ static int loadvm_process_command(QEMUFile *f) * been created. */ if (migrate_switchover_ack() && !mis->switchover_ack_pending_num) { - int ret =3D migrate_send_rp_switchover_ack(mis); + ret =3D migrate_send_rp_switchover_ack(mis); if (ret) { - error_report( - "Could not send switchover ack RP MSG, err %d (%s)", r= et, - strerror(-ret)); + error_setg_errno(errp, -ret, + "Could not send switchover ack RP MSG"); return ret; } } @@ -2602,40 +2602,72 @@ static int loadvm_process_command(QEMUFile *f) tmp32 =3D qemu_get_be32(f); trace_loadvm_process_command_ping(tmp32); if (!mis->to_src_file) { - error_report("CMD_PING (0x%x) received with no return path", - tmp32); + error_setg(errp, "CMD_PING (0x%x) received with no return path= ", + tmp32); return -1; } migrate_send_rp_pong(mis, tmp32); break; =20 case MIG_CMD_PACKAGED: - return loadvm_handle_cmd_packaged(mis); + ret =3D loadvm_handle_cmd_packaged(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; =20 case MIG_CMD_POSTCOPY_ADVISE: - return loadvm_postcopy_handle_advise(mis, len); + ret =3D loadvm_postcopy_handle_advise(mis, len); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; =20 case MIG_CMD_POSTCOPY_LISTEN: - return loadvm_postcopy_handle_listen(mis); + ret =3D loadvm_postcopy_handle_listen(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; =20 case MIG_CMD_POSTCOPY_RUN: - return loadvm_postcopy_handle_run(mis); + ret =3D loadvm_postcopy_handle_run(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; =20 case MIG_CMD_POSTCOPY_RAM_DISCARD: - return loadvm_postcopy_ram_handle_discard(mis, len); + ret =3D loadvm_postcopy_ram_handle_discard(mis, len); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; =20 case MIG_CMD_POSTCOPY_RESUME: loadvm_postcopy_handle_resume(mis); return 0; =20 case MIG_CMD_RECV_BITMAP: - return loadvm_handle_recv_bitmap(mis, len); + ret =3D loadvm_handle_recv_bitmap(mis, len); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; =20 case MIG_CMD_ENABLE_COLO: - return loadvm_process_enable_colo(mis); + ret =3D loadvm_process_enable_colo(mis); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; =20 case MIG_CMD_SWITCHOVER_START: - return loadvm_postcopy_handle_switchover_start(); + ret =3D loadvm_postcopy_handle_switchover_start(); + if (ret < 0) { + error_setg(errp, "Failed to load device state command: %d", re= t); + } + return ret; } =20 return 0; @@ -3077,7 +3109,7 @@ retry: } break; case QEMU_VM_COMMAND: - ret =3D loadvm_process_command(f); + ret =3D loadvm_process_command(f, NULL); trace_qemu_loadvm_state_section_command(ret); if ((ret < 0) || (ret =3D=3D LOADVM_QUIT)) { goto out; --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971300; cv=none; d=zohomail.com; s=zohoarc; b=Q1IXpMOZbkp+rWJnFLcOyxhDC5WGnmAIXgdaMADDCqi7jcgPbfbe0aCwZdDZ7eCTUV0+XQtib8XM7zrK2TyemH2dFLT2/yj4ARFWtqFrL8lceiGTqcsy8bEr1Gm3CDpn1JTI43+0oBtT+y2xmDpSB78Qf1GjzoYNrJhF7tRQaGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971300; 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=y35vdzplFkFTtVXfpintBM0kj+D4txIp+GxRyRVgZoQ=; b=TGhcV7t8rJmxwZ3wZE9C27u4crIFqV7RsDiQJMQU3ASxfFXasnQ5Awp896yhTa/MECRWssBnASuhd2CfIZ1ZFBp4A9E8Jryo6gCHkVEylGSUrkCcO/kS3WEh/EioJKcSxm46YrKY8DGg1cT4XYGtEElHchsaBXo7KKTb2jvFUXA= 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 1753971300324737.8606724098205; Thu, 31 Jul 2025 07:15:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU24-0006pt-97; Thu, 31 Jul 2025 10:13:20 -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 1uhTG4-0000eB-1m for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:44 -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 1uhTFv-0008IY-Q7 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:43 -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-57-nJU-rLEsMdKl-AHdmS1pnw-1; Thu, 31 Jul 2025 09:23:32 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-31f5f70a07bso1712233a91.3 for ; Thu, 31 Jul 2025 06:23:32 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968213; 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=y35vdzplFkFTtVXfpintBM0kj+D4txIp+GxRyRVgZoQ=; b=Qys2d9XpZh4nsq0/GhAkNcft8T6HjWYTTWRiHc/gC0z+h4aTqYIqNJs55slj3AlzMgzOnT CGAP90tXgwMkn+VGdcQUodTGtVUDYPmpTp4OkUjOaOPViu9PFsoGRDuJbGjBWfSA6tifYl S+MyHSr2uwy2bPRYIAL0/BkHzpQauoI= X-MC-Unique: nJU-rLEsMdKl-AHdmS1pnw-1 X-Mimecast-MFC-AGG-ID: nJU-rLEsMdKl-AHdmS1pnw_1753968211 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968211; x=1754573011; 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=y35vdzplFkFTtVXfpintBM0kj+D4txIp+GxRyRVgZoQ=; b=Ns1E0yKrE4b3HiFTLaEgGMjVv1SCwu90dP4nN/G66NJwKgCQy5V+kOkyc2r/Q/HdO+ bfzrRNJwd+ZLZUFdyqQBMwqhvgOSFoISAER9Az+Ulzx/+TmtZVDGtshuWK1bGzrjtEru Vp52A9Ada5VU8yu772RyyS8y6y3a31RX9H6Y08tkKKNwfX2T0LUvZn8ln7sBvYTZUEBp JpuoQmP9t6M6vJd/fJdauK5Z/5a4ncLMku0qLZ9S689GDuBwzF3QmO27HICAde8YqBjc AJzXhxEaAXFPqJ0X9yow8/Sq+YsEMr5U9VMi/H8p5gjP5SFweKu+yL2U8couQkSqHFUA beXQ== X-Gm-Message-State: AOJu0YzcSCwy/27mL53CKA5mUgnR2HqphPKZUH0PsVr7q6QmBAGV0Qqd +8MiONwRSdshb6DMBvijwTmDZ9rUw7RigK+niaOPJueKgW8a5sOT4yV6vBVTUZzL5/OyrkRFsaA eFfC0UqXHIDKAkGOB2prXd5jkmyhgbK0a5LEfCZSnCvBnQuSa2jT7h57osPwHJl8gPURLw6aX5l QN42h/OKV+LlEN9Kvi1u530dho4e2RzUxgvBtKbo5oPw== X-Gm-Gg: ASbGncukHhVgbh7f2dIjtyD1fu4LiHdW8Do1KLydsdPw7oh2QPsLsOvGxqj04PYN/tT SOJG8xWoaDHIHJZvaOMYQvB4sDXpQm2kTb7o+TAC+nWbuhxt627MuU9gGtGW5Sub8bQ0acZRSNr VnAGYmDENNwqG0lb7W6dCUMyCunjO8ikD9YrI+OvNr+i1gv1zDBNZMlN63RRX+QjaWX03taNn3M kb/sK0JDuSBpmYd4BLreyQvpxp+y/BIC3O9IYxIwNDXvJoFRlNSZU3OMfqvlIvDwOe9kCAwhawi TC+rCV7GiMOIwIv8jH81TKmXuFdUhx1nUkxdkok1UW3U0U534+dS X-Received: by 2002:a17:90b:2fd0:b0:31e:e0b7:88ee with SMTP id 98e67ed59e1d1-31f5de96370mr11907404a91.16.1753968210904; Thu, 31 Jul 2025 06:23:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaF0MudpTvnj2d4LKFabmqreIYUx1JMPEme56jWjnHk7zvE7qmHLrVRS5Cb+PHiSK65SwPtw== X-Received: by 2002:a17:90b:2fd0:b0:31e:e0b7:88ee with SMTP id 98e67ed59e1d1-31f5de96370mr11907332a91.16.1753968210466; Thu, 31 Jul 2025 06:23:30 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:50 +0530 Subject: [PATCH v8 10/27] migration: push Error **errp into loadvm_handle_cmd_packaged() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-10-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2724; i=armenon@redhat.com; h=from:subject:message-id; bh=4PohIq4+ZnPybABXSTBOombbTYHtEautdteGAWLIKLY=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37tP2DbX/JCctOeUxY+eS/wkemsVc3HyZaY4c4R0tN /QUW3U7SlkYxLgYZMUUWRq+Bsg2BRRGRNq+vA4zh5UJZAgDF6cATGTXdYZ/WlvdCj/rnPE5snuD +XxDdZumunkN5yYVvv3yVWg/w8spKQz/A6TvuRXHx90RvJRiM5V3TqZOidQlh8duC3g6jYJOnXn HBwA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 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: 1753971302988116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_handle_cmd_packaged() must report an error in errp, in case of failure. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- migration/savevm.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 280ee92133975913f1d374231b431235a7301b7d..f0dac8b13c12a1785c0a293b838= 2641e82ce89d1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2403,7 +2403,7 @@ static void loadvm_postcopy_handle_resume(MigrationIn= comingState *mis) * Returns: Negative values on error * */ -static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis) +static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis, Error *= *errp) { int ret; size_t length; @@ -2413,7 +2413,7 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis) trace_loadvm_handle_cmd_packaged(length); =20 if (length > MAX_VM_CMD_PACKAGED_SIZE) { - error_report("Unreasonably large packaged state: %zu", length); + error_setg(errp, "Unreasonably large packaged state: %zu", length); return -1; } =20 @@ -2424,8 +2424,8 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis) length); if (ret !=3D length) { object_unref(OBJECT(bioc)); - error_report("CMD_PACKAGED: Buffer receive fail ret=3D%d length=3D= %zu", - ret, length); + error_setg(errp, "CMD_PACKAGED: Buffer receive fail ret=3D%d lengt= h=3D%zu", + ret, length); return (ret < 0) ? ret : -EAGAIN; } bioc->usage +=3D length; @@ -2455,6 +2455,9 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis) } while (1); =20 ret =3D qemu_loadvm_state_main(packf, mis); + if (ret < 0) { + error_setg(errp, "VM state load failed: %d", ret); + } trace_loadvm_handle_cmd_packaged_main(ret); qemu_fclose(packf); object_unref(OBJECT(bioc)); @@ -2610,11 +2613,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) break; =20 case MIG_CMD_PACKAGED: - ret =3D loadvm_handle_cmd_packaged(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_handle_cmd_packaged(mis, errp); =20 case MIG_CMD_POSTCOPY_ADVISE: ret =3D loadvm_postcopy_handle_advise(mis, len); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971802; cv=none; d=zohomail.com; s=zohoarc; b=OIVj5HftGe4AI+tJfAKv958pj4W+/SgnSLmCuK+EP0wDn3dOBX6DmDsXGaIc1scaWXTPjzn3zg51cU3DmzGmoNelns+rdbYbfUyGSl1EOLVaHTz1xjjQ5eQd+7GyZ4i+mgpGHHiQjS8LkIRyQtTquwjYqPNwBcY8kVBGfRm0bLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971802; 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=308KU/Yor2fucYzWGHegCEq7pZRYSWVIFS9BSnl6OfU=; b=PO/v/7o7zWMjclMBONtsi7bRaeTDbh7Iv13CjbaTA2Nj9VpQ1MG7CWyEXGZJ/DecTRM1rgbBa2DbJa+o2Y1srEzacmzEpcIhj4npcrsAck7FCQx28c59+bJAbX/rVWVaUh2OLse7FoFzajNmRp0kCBQuebu4SvFvPp4uWMY41rk= 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 1753971802630288.70848944687305; Thu, 31 Jul 2025 07:23:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU8e-0006XZ-RZ; Thu, 31 Jul 2025 10:20:10 -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 1uhTGD-00021x-5C for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:53 -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 1uhTG6-0008KY-MJ for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:52 -0400 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-Y-aCMlzlPjGDw802DFdlRw-1; Thu, 31 Jul 2025 09:23:42 -0400 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-31ea14cc097so432089a91.3 for ; Thu, 31 Jul 2025 06:23:42 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968224; 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=308KU/Yor2fucYzWGHegCEq7pZRYSWVIFS9BSnl6OfU=; b=VA8ATFzYYT21OtYrWyg7YEh1kQqQVFbgZoIgL/GZjO3a6KdR6A3gEm0ChgJlMBOKt8pM/w fCQlMTnuDuyfGrJKdUjEIKeOK7jYvl+HL/7VTD3qWUSRbyk1HEC8oNcUUKeJZWobKNlDQD TbPcWb5iNLL5ZUG9T0Ml/t2IObazw3s= X-MC-Unique: Y-aCMlzlPjGDw802DFdlRw-1 X-Mimecast-MFC-AGG-ID: Y-aCMlzlPjGDw802DFdlRw_1753968222 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968222; x=1754573022; 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=308KU/Yor2fucYzWGHegCEq7pZRYSWVIFS9BSnl6OfU=; b=YpoZ7sybToK9DbLsgpcq5pQXsR70+A24kPDIbr2oVDo9WHMl4p8mV9fM3dkIGCRkm/ MdJ5JRyXi3jGT6eytTLvsikXl3nkEqMZ8bks3FgwRZek+NmBLvN3d5ojvxrloF5x+Oyk V8EA94zPDs/ayQtlEIWW9DEqxze1H+7oa94yL226S/xB9AEn0dkgxRSg/bIlGklm/bIi 6KFBJSFBn38ZOsK2zV4fkvq4frFT+7hZbRjl2GZlpUfYvsLAeTOGjEmNXLZy6DK/E5C7 3wD4rfPfhrccCCqAp/Wo7kGiOBgtJfTnWTqQ+3pt9JCJR6SB35hDXAX0gW9SplaR/IM1 ud8g== X-Gm-Message-State: AOJu0YwUMfIgFHXv2jMLM2sq/oDsuh5bwpZyQwhhluqV62WD7RtB7DL0 dinLWvkxf3GyUyGqd/tUDkRVla5+z8kR1R623gwqY3eOhVkeB+PIN+qG2adalIZN7bOunCx1hrq li6WJS425w1ngoXblHTrr2XyIrZi/gKyoZ/yHayKfoZyGc5b+55oKzPOWUTpFaX9g7qM/6bSc/h 0KmbdHDbeW5f52V3dmq3MpxDi91aPbt+obCVy+oRFIpg== X-Gm-Gg: ASbGnctDEokmG4c01iX204NPGAFzJSxxDp5l5ZMFCvBaMh9ZWu4mnt1mgdjXl24CfUy 0kO1OfukjDzDZwIoVJI1C6eO8K8X9+A2AoZ5MGd0weCen3CypVvZy0oP2Bh7bRs59ZbXutt/0fg MBSBIz2+p/2DKLa3PM1oW1XfjECjx7hxL4cg0UryGxxLGlTv6qb8TYio7p+7td2PIR9Ki9oWybh v8g0Bu2H4cMDq5VbMu5oGeWEj6OmbpW6gJodexop9TMiccbYF9TV36MJShZcoBmpPk69CozRrQ/ aX5JootkxyQY/LyXoSN61esoUEGCtrDJQcFTmyZVsfNalNEbrOKQ X-Received: by 2002:a17:90b:2ecf:b0:312:26d9:d5a7 with SMTP id 98e67ed59e1d1-31f5de2d561mr7184274a91.20.1753968221336; Thu, 31 Jul 2025 06:23:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHD9QCjsBkS/oQsfa5sLmZQlXIUqYBb/wbxX2zcaDthoTuPzSd/6x1GH80VszCY8LFtbLSV0w== X-Received: by 2002:a17:90b:2ecf:b0:312:26d9:d5a7 with SMTP id 98e67ed59e1d1-31f5de2d561mr7184150a91.20.1753968219936; Thu, 31 Jul 2025 06:23:39 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:51 +0530 Subject: [PATCH v8 11/27] migration: push Error **errp into ram_postcopy_incoming_init() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-11-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=4760; i=armenon@redhat.com; h=from:subject:message-id; bh=e6K2XVk2u1ogcPUqKXsJ3y71DmRHAySwomlEZiuuuIc=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37tP3C3om6t9X+1HpYMe46fMSU/6Q28weRvwCdSfTW fYHPBLoKGVhEONikBVTZGn4GiDbFFAYEWn78jrMHFYmkCEMXJwCMBHO7wz/lOO4Gac4LfxylnHu Oo/pc/YvmWN90EV4fvK5+eVH1a/IhTD8T4gK1pu8om7p26tObbZtTE6LJEr8y99mtGbcMtt10ew hAwA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971804911116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that ram_postcopy_incoming_init() must report an error in errp, in case of failure. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/postcopy-ram.c | 9 ++++++--- migration/postcopy-ram.h | 2 +- migration/ram.c | 4 ++-- migration/ram.h | 2 +- migration/savevm.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 45af9a361e8eacaad0fb217a5da2c5004416c1da..05617e5fbcad62226a54fe17d9f= 7d9a316baf1e4 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -681,6 +681,7 @@ out: */ static int init_range(RAMBlock *rb, void *opaque) { + Error **errp =3D opaque; const char *block_name =3D qemu_ram_get_idstr(rb); void *host_addr =3D qemu_ram_get_host_addr(rb); ram_addr_t offset =3D qemu_ram_get_offset(rb); @@ -701,6 +702,8 @@ static int init_range(RAMBlock *rb, void *opaque) * (Precopy will just overwrite this data, so doesn't need the discard) */ if (ram_discard_range(block_name, 0, length)) { + error_setg(errp, "failed to discard RAM block %s len=3D%zu", + block_name, length); return -1; } =20 @@ -749,9 +752,9 @@ static int cleanup_range(RAMBlock *rb, void *opaque) * postcopy later; must be called prior to any precopy. * called from arch_init's similarly named ram_postcopy_incoming_init */ -int postcopy_ram_incoming_init(MigrationIncomingState *mis) +int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp) { - if (foreach_not_ignored_block(init_range, NULL)) { + if (foreach_not_ignored_block(init_range, errp)) { return -1; } =20 @@ -1703,7 +1706,7 @@ bool postcopy_ram_supported_by_host(MigrationIncoming= State *mis, Error **errp) return false; } =20 -int postcopy_ram_incoming_init(MigrationIncomingState *mis) +int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp) { error_report("postcopy_ram_incoming_init: No OS support"); return -1; diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 3852141d7e37ab18bada4b46c137fef0969d0070..ca19433b246893fa5105bcebffb= 442c58a9a4f48 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -30,7 +30,7 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *m= is); * postcopy later; must be called prior to any precopy. * called from ram.c's similarly named ram_postcopy_incoming_init */ -int postcopy_ram_incoming_init(MigrationIncomingState *mis); +int postcopy_ram_incoming_init(MigrationIncomingState *mis, Error **errp); =20 /* * At the end of a migration where postcopy_ram_incoming_init was called. diff --git a/migration/ram.c b/migration/ram.c index 7208bc114fb5c366740db380ee6956a91b3871a0..6a0dcc04f436524a37672c41c38= f201f06773374 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3716,9 +3716,9 @@ static int ram_load_cleanup(void *opaque) * postcopy-ram. postcopy-ram's similarly names * postcopy_ram_incoming_init does the work. */ -int ram_postcopy_incoming_init(MigrationIncomingState *mis) +int ram_postcopy_incoming_init(MigrationIncomingState *mis, Error **errp) { - return postcopy_ram_incoming_init(mis); + return postcopy_ram_incoming_init(mis, errp); } =20 /** diff --git a/migration/ram.h b/migration/ram.h index 921c39a2c5c45bc2344be80854c46e4c10c09aeb..275709a99187f9429ccb4111e05= 281ec268ba0db 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -86,7 +86,7 @@ void ram_postcopy_migrated_memory_release(MigrationState = *ms); void ram_postcopy_send_discard_bitmap(MigrationState *ms); /* For incoming postcopy discard */ int ram_discard_range(const char *block_name, uint64_t start, size_t lengt= h); -int ram_postcopy_incoming_init(MigrationIncomingState *mis); +int ram_postcopy_incoming_init(MigrationIncomingState *mis, Error **errp); int ram_load_postcopy(QEMUFile *f, int channel); =20 void ram_handle_zero(void *host, uint64_t size); diff --git a/migration/savevm.c b/migration/savevm.c index f0dac8b13c12a1785c0a293b8382641e82ce89d1..dc3f66f924dad2691bd87080fbd= fb2fe3d95a51d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1989,7 +1989,7 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis, return -1; } =20 - if (ram_postcopy_incoming_init(mis)) { + if (ram_postcopy_incoming_init(mis, NULL) < 0) { return -1; } =20 --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971709; cv=none; d=zohomail.com; s=zohoarc; b=ZAZwNaNsxBiqcOyJAVWC3cwWZPZyBeTjorYk7UdEJ/Coh7FrCDJVRyU9m7BMm9Kb8cSqfAV/ejIjGxzClu0/BjqONUcDjqp/P7EZVHgNvaqUtQnh4CZpJ6TS48aq1/c8gf5ulUOs0SF+/SmLgOGCd2L26eXmItAQrvzXXXRQSoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971709; 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=hLXryxZ1FJjBfVClnF3sT9k81FHRxYrSdQehTtSnf2s=; b=GCieixkZ6NAx3JY2EwonU2zFyvDywf1/vnm76S+DbLo4+SWFsLPC+E2S3sLHoMXe1x2wOckC5Jj3OHrtdPiBF/Rq4QdSrZcECEcTp2LHTK2/cR24ppm+KwfNq7lvJMqOEhSB9ujdUZ1ASO5SC6P4kLbj/4VN2JPbc6XrTiT8+J4= 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 SMTP id 175397170988590.15944215291393; Thu, 31 Jul 2025 07:21:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU9a-000862-KQ; Thu, 31 Jul 2025 10:21:07 -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 1uhTGH-00029l-Mn for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTGF-0008MF-D0 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:23:57 -0400 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-228-UzoIYSzsPTSYUD8jGvYYMw-1; Thu, 31 Jul 2025 09:23:53 -0400 Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2407248a180so3084465ad.3 for ; Thu, 31 Jul 2025 06:23:53 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968234; 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=hLXryxZ1FJjBfVClnF3sT9k81FHRxYrSdQehTtSnf2s=; b=BjVIcJROSUeKGmiCyfZQsCYfqhl9E5dEm9OOzzmEf6CB07MLsEoDKQlh6ccGGYYduDmpqm 7GtOV2Ij2bSQs6QNuiM520ZCZwYFDgMyQZnIFSOhZWXE+Aw3u3qbktXEreDDdimgJUfDUl VaeDSg5DhxSH5T5XKOPS4zuzSBats+E= X-MC-Unique: UzoIYSzsPTSYUD8jGvYYMw-1 X-Mimecast-MFC-AGG-ID: UzoIYSzsPTSYUD8jGvYYMw_1753968232 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968232; x=1754573032; 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=hLXryxZ1FJjBfVClnF3sT9k81FHRxYrSdQehTtSnf2s=; b=JlmJBCuO6EUpOZwTkgLWA+6p4fxXkvSOd92DgLDscr+o7oNLgqzVRGHO6sdNz2/sSE c+UVU43Z8BwRkWiwNNGaCbocVrljSr9YuHo63Rk+lRP9yVVeJ9LsFlHNSdL6880mBSXn r5htyzZPzxxu/44mTiBeTNdxS3clkHHsTQFdYcLEB368eUton5NemYgnhelCd7Isuq8y FuLKeaufVfLufboPPufjCLdxSD/rCGePdxmIO7P2soHmnKqtdpLZx928Xp32NlxvayZi 7W5fTML7QnZ+YOD5j5mRHh/vWoTkx+UnoI76hIlb5EF010RfUPXIU1SRYqKRJJlx4EXH MWgw== X-Gm-Message-State: AOJu0Yy74STzeR+AItMp4WVhg3L5X1MRUbMAeh83rcrdIkGmMmjjOEzD rgsaCgXRS8Sm0alKQHa/GSSPzEG8BqgDPsH3IAL0zwIg5OgTLx8BAbwYxiNI08Vda3TjSpNjLzT Q0BubUYgsWNR8RJGa1kqjqFCYX4MlAqaWCKg4puw5ixNlT8lUCcu8zTbW9xdA7zZSCJL3vX6tPd FGzre3TQ2ME1PFhgcdJ8cdAkWduGi8PhrzAEB/xb8o+Q== X-Gm-Gg: ASbGncu9YeT1WrZ7QCy5YsfNGcGEFBiOmUA2Dx1/5jDNEPmngratD4tyfzVFDtXbwnB 6hOrr2gchqmx0jt5nXO5kvt7Azt/P1TBZKzZNBQf6YGJ5e8pa/J8isma3NHNUTtvWE87wzxZxrp p7sYt47fk5AzRAdIWm8yyS9SYAlEM01zfeG2SDAUNlVZbCBQKmV17aHcAy39LC6tUuADPdZz5sT 2wofDbRYKQq7uxm+u6ENk3AL4PqPbg3U5YcKyZn9vK/QTkwUN/ghIFqLtaWWG4rZIsLXdi9lUiM G7Dt1k0S+DWFz3diQJsxGmCQa+XZjtB7q62QxSy6KmRVGkK6y5Dj X-Received: by 2002:a17:902:ef07:b0:235:1962:1c13 with SMTP id d9443c01a7336-24096aa119emr89487855ad.14.1753968231861; Thu, 31 Jul 2025 06:23:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3bNJ3DtSHHeYz1saw9FQ6guRc/s/jW3SV1HIWtFtDqa1rOOwTKkmNx3aLt7/VO3SWTRyOIA== X-Received: by 2002:a17:902:ef07:b0:235:1962:1c13 with SMTP id d9443c01a7336-24096aa119emr89486925ad.14.1753968231138; Thu, 31 Jul 2025 06:23:51 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:52 +0530 Subject: [PATCH v8 12/27] migration: push Error **errp into loadvm_postcopy_handle_advise() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-12-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4792; i=armenon@redhat.com; h=from:subject:message-id; bh=8Ki2M5F0tb6h1UZ0KawzzhxN44yn8zuT7ARtJpXCfVw=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rN1k7c5b5C8zJWca2r7IX/pmnm3ugJ2Hf75SvSLS G+ZsHNqRykLgxgXg6yYIkvD1wDZpoDCiEjbl9dh5rAygQxh4OIUgImccWdk2MUk03HlyDHJuk4n sR/5T6vdZ+X3b514bm2Xq/OtAMsF3xgZtly59LBOjfHJsts+kk7e5omi7JrppfoV65VUppo9bav nBAA= 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971715696116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_postcopy_handle_advise() must report an error in errp, in case of failure. Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/savevm.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index dc3f66f924dad2691bd87080fbdfb2fe3d95a51d..dd1629069444f20b035aeffa948= b8edcd7ea6919 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1912,39 +1912,39 @@ enum LoadVMExitCodes { * quickly. */ static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis, - uint16_t len) + uint16_t len, Error **errp) { PostcopyState ps =3D postcopy_state_set(POSTCOPY_INCOMING_ADVISE); uint64_t remote_pagesize_summary, local_pagesize_summary, remote_tps; size_t page_size =3D qemu_target_page_size(); - Error *local_err =3D NULL; =20 trace_loadvm_postcopy_handle_advise(); if (ps !=3D POSTCOPY_INCOMING_NONE) { - error_report("CMD_POSTCOPY_ADVISE in wrong postcopy state (%d)", p= s); + error_setg(errp, "CMD_POSTCOPY_ADVISE in wrong postcopy state (%d)= ", + ps); return -1; } =20 switch (len) { case 0: if (migrate_postcopy_ram()) { - error_report("RAM postcopy is enabled but have 0 byte advise"); + error_setg(errp, "RAM postcopy is enabled but have 0 byte advi= se"); return -EINVAL; } return 0; case 8 + 8: if (!migrate_postcopy_ram()) { - error_report("RAM postcopy is disabled but have 16 byte advise= "); + error_setg(errp, + "RAM postcopy is disabled but have 16 byte advise"); return -EINVAL; } break; default: - error_report("CMD_POSTCOPY_ADVISE invalid length (%d)", len); + error_setg(errp, "CMD_POSTCOPY_ADVISE invalid length (%d)", len); return -EINVAL; } =20 - if (!postcopy_ram_supported_by_host(mis, &local_err)) { - error_report_err(local_err); + if (!postcopy_ram_supported_by_host(mis, errp)) { postcopy_state_set(POSTCOPY_INCOMING_NONE); return -1; } @@ -1967,9 +1967,10 @@ static int loadvm_postcopy_handle_advise(MigrationIn= comingState *mis, * also fails when passed to an older qemu that doesn't * do huge pages. */ - error_report("Postcopy needs matching RAM page sizes (s=3D%" PRIx64 - " d=3D%" PRIx= 64 ")", - remote_pagesize_summary, local_pagesize_summary); + error_setg(errp, + "Postcopy needs matching RAM page sizes " + "(s=3D%" PRIx64 " d=3D%" PRIx64 ")", + remote_pagesize_summary, local_pagesize_summary); return -1; } =20 @@ -1979,17 +1980,18 @@ static int loadvm_postcopy_handle_advise(MigrationI= ncomingState *mis, * Again, some differences could be dealt with, but for now keep it * simple. */ - error_report("Postcopy needs matching target page sizes (s=3D%d d= =3D%zd)", - (int)remote_tps, page_size); + error_setg(errp, + "Postcopy needs matching target page sizes (s=3D%d d=3D= %zd)", + (int)remote_tps, page_size); return -1; } =20 - if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_ADVISE, &local_err)) { - error_report_err(local_err); + if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_ADVISE, errp)) { return -1; } =20 - if (ram_postcopy_incoming_init(mis, NULL) < 0) { + if (ram_postcopy_incoming_init(mis, errp) < 0) { + error_prepend(errp, "Postcopy RAM incoming init failed: "); return -1; } =20 @@ -2616,11 +2618,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_handle_cmd_packaged(mis, errp); =20 case MIG_CMD_POSTCOPY_ADVISE: - ret =3D loadvm_postcopy_handle_advise(mis, len); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_postcopy_handle_advise(mis, len, errp); =20 case MIG_CMD_POSTCOPY_LISTEN: ret =3D loadvm_postcopy_handle_listen(mis); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971236; cv=none; d=zohomail.com; s=zohoarc; b=ULQ5MaE44mFKXv8pG3iu0VACvQgJTjH7tNvxByq4iV8rfK7YLr81PCtQB9T6WtVFXdiG7sZ8GSs9PGGkHCkzTE79e567HUHsATfWV8gZe/5U3uSyNCpaIAZ+9BN3EAYCidQwZ58Id3eC59NNeP+DYREaPNK3mT3XB3xL6vH0a1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971236; 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=GXKa1lb2J45tpdGDnPkjHF2vXdNA+ZMoJFnBI21EA70=; b=HmHvBwmAhuDq5QvALyShxUSJLk+Dqm8cY6CJFjIFUriHfenA3tGAS6ruP6HOEs00TB58lTnEyBg/ZFp9JhA8YvAqHwjt1YaPSKtfUPRb8sL8hx/Y771bzWmvOK/vaNtY4wpRinWxCEOxDelO636ZV06yb9dk6zkJ1FOxqZ5UICM= 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 1753971236657674.1887119963336; Thu, 31 Jul 2025 07:13:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU29-0007ev-8K; Thu, 31 Jul 2025 10:13:25 -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 1uhTGR-0003Sb-LI for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:07 -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 1uhTGO-0008Nq-Ib for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:06 -0400 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-301-gPXL4tYbNVWScnA1nBy0lA-1; Thu, 31 Jul 2025 09:24:02 -0400 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-31f3b65ce07so751743a91.1 for ; Thu, 31 Jul 2025 06:24:02 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968243; 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=GXKa1lb2J45tpdGDnPkjHF2vXdNA+ZMoJFnBI21EA70=; b=GcQK/9W/m9QGFNupyniiluKNdd4JNfu8v+nnQ4Ugmug15qKcri/W83mmho2aepdjiH2bco 4aty4h0W2eHRNgnC+kHjrbGbn+K/epVzFmUqkyZtbdCz/e8c6gUwXQryv0RCxRwouTE6Fc BU0DXumotmS4ns4r3GZThuI4MleI/VI= X-MC-Unique: gPXL4tYbNVWScnA1nBy0lA-1 X-Mimecast-MFC-AGG-ID: gPXL4tYbNVWScnA1nBy0lA_1753968241 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968241; x=1754573041; 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=GXKa1lb2J45tpdGDnPkjHF2vXdNA+ZMoJFnBI21EA70=; b=OlEKfsD/QMbAUk+RAOcPNOsfGq5HQgNiHmfEj1FSYCThpC4sq7Le2Frry15gOJGjPG pjQpQCOE5N8HeB4Pi+yB40gQoXWFhiHmpBlJEIAEiLod2o5/BYU77L4jpUg50dMTub+p nKoLThaKz6Hb1Xg7/nJuu4gfkMP/APAp349pkAEt7B3H9+9Yh5H8bY5ElPDOuqihsHrw hU0Fhl89Ybjara2aXUfHRg+nxi3jRGIJtpHkyk0vQjj+RIpQrAy6uHwmRCECn8naa1X+ 0NHjFBF4OahPDn8IY3+dS+TaS7pt19dv/zcmzB2FrhtpUrMgnfFTnWkMu7ACb4aj7oPO vX2A== X-Gm-Message-State: AOJu0Yw0Sn8anxEPzBe60SYrWGGUG1P+I+tt7ezMEL+EmEUKcK0fgrMg OHFwlQLnJK11j38XrnuRIbNvPEs1SHC5Dz9ijj1fWWm9sfUQflI3aTu6B64TpYl1ReuBQ6IIlzm HdqShG932c8wT56f66KWJewN7hCdNjud8w3gb6jyL5wbBEaMa4g7hGtPVCM0uW/MKOVyoPIKrOw xWxq7Cs1/UPz2NvY84NCd6+FFHQtYG8LdvQ8ssWGJ2sA== X-Gm-Gg: ASbGncvHUfnBGltEGwzpY2G+tDOA0/OPuYZS0FP7NqrBDOBL7XMBhF0wrYy7j0145Uu dQLEcfOTws8mVd0tMikvlZ/bs4wHVXEbl0Zl6XNICGGpWL7RC9BGr3rj9vJYz4ACdob3KlD1U20 KLGLZJz6QIjeP2EP62aVp9HEdBu89gR/afbZiDejBzlCPRNnDQxj+zScCKP8dVgakNIQcziCwnY +lpEFwYxynOpp72qjH5eBEz/lwROP39kc3CfhbWzuGO3l5Ym2LNu46QvxwFwMn3FlMbWnOxjGvQ GFgGx+rvSaHfhYf4OyLi3IrgZSTpF8DKjm6Vj1CskbR7K2Txzs3j X-Received: by 2002:a17:90b:184b:b0:31f:20a:b52c with SMTP id 98e67ed59e1d1-31f5dcb65b7mr11628033a91.0.1753968240974; Thu, 31 Jul 2025 06:24:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqYUnWDnKMNcEOKyhBRRKFiZH+sRye9HY1hb24NyJhTSuR6314ALdO0uRURK/Pqp3MFrnogw== X-Received: by 2002:a17:90b:184b:b0:31f:20a:b52c with SMTP id 98e67ed59e1d1-31f5dcb65b7mr11627958a91.0.1753968240514; Thu, 31 Jul 2025 06:24:00 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:53 +0530 Subject: [PATCH v8 13/27] migration: push Error **errp into loadvm_postcopy_handle_listen() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-13-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2705; i=armenon@redhat.com; h=from:subject:message-id; bh=2gJKFMIUThLwW1sVnjuy/TtcWWXZtfyR/RkhmK0ZQq0=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37jPtQKmJgjwZr7nVP+xuqU1tcXr8ddOHBctPdRj/2 JX/ZF1nRykLgxgXg6yYIkvD1wDZpoDCiEjbl9dh5rAygQxh4OIUgIl0dDL8lb6i+jrh2kbl4xap jwuvtt59K5KTfK5jWsqMR9nzl7x7EcDwV/7Ycybpq4Zxq76uvfx+Nt9zb/5XdRJ9r5/vCQ1+N23 tP1YA 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753971238093116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_postcopy_handle_listen() must report an error in errp, in case of failure. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- migration/savevm.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index dd1629069444f20b035aeffa948b8edcd7ea6919..c9ca0628183312e19fc72c06f79= 1dc4d53566c16 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2181,15 +2181,16 @@ static void *postcopy_ram_listen_thread(void *opaqu= e) } =20 /* After this message we must be able to immediately receive postcopy data= */ -static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis) +static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis, + Error **errp) { PostcopyState ps =3D postcopy_state_set(POSTCOPY_INCOMING_LISTENING); - Error *local_err =3D NULL; =20 trace_loadvm_postcopy_handle_listen("enter"); =20 if (ps !=3D POSTCOPY_INCOMING_ADVISE && ps !=3D POSTCOPY_INCOMING_DISC= ARD) { - error_report("CMD_POSTCOPY_LISTEN in wrong postcopy state (%d)", p= s); + error_setg(errp, + "CMD_POSTCOPY_LISTEN in wrong postcopy state (%d)", ps); return -1; } if (ps =3D=3D POSTCOPY_INCOMING_ADVISE) { @@ -2212,14 +2213,14 @@ static int loadvm_postcopy_handle_listen(MigrationI= ncomingState *mis) if (migrate_postcopy_ram()) { if (postcopy_ram_incoming_setup(mis)) { postcopy_ram_incoming_cleanup(mis); + error_setg(errp, "Failed to setup incoming postcopy RAM blocks= "); return -1; } } =20 trace_loadvm_postcopy_handle_listen("after uffd"); =20 - if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_LISTEN, &local_err)) { - error_report_err(local_err); + if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_LISTEN, errp)) { return -1; } =20 @@ -2621,11 +2622,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_postcopy_handle_advise(mis, len, errp); =20 case MIG_CMD_POSTCOPY_LISTEN: - ret =3D loadvm_postcopy_handle_listen(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_postcopy_handle_listen(mis, errp); =20 case MIG_CMD_POSTCOPY_RUN: ret =3D loadvm_postcopy_handle_run(mis); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971907; cv=none; d=zohomail.com; s=zohoarc; b=mEmlQsSPsQwIUKyvbOhYXaCPerF4lNUbHlUIl9racl4ycY6tFDuVa88jUFIztoPy6wp9Q9nHS7if9EHP+dL5+WIyRHsCbbGDOw/hB+aEmDO0Im97hFTc2NogTsiEhh8LugfBoXTJU7am0ldGrj+xFtXUkA/eBObE/zfPsoAtx+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971907; 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=kLghEdi44xi6/POYpygXyfMOGple2iuK5st+VMUWU2k=; b=bIHhDH8VI0qkWL0rcuBSzvF+kfbycgv/cBANP2D4JHSB7oTulSQpKd/PRq3+55TwY6ItTMLbtOQzLDdfiaJjf01crXeAj4ZJLPU+K5jXRmXgFN6e7+nM2+jPCTxExYYxbqKC5Pt7TUSnlRyzizFsuwZSl1Jl6Ld1dO7CihVI8Ow= 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 1753971907403486.22148587514073; Thu, 31 Jul 2025 07:25:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUBZ-0004Z2-NN; Thu, 31 Jul 2025 10:23:09 -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 1uhTGa-0004Bl-1a for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTGY-0008PF-70 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:15 -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-272-wxXdfNJbODiZ1hdiUY_cIw-1; Thu, 31 Jul 2025 09:24:11 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-31ed2a7d475so996748a91.1 for ; Thu, 31 Jul 2025 06:24:11 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968252; 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=kLghEdi44xi6/POYpygXyfMOGple2iuK5st+VMUWU2k=; b=gsNUqZ6o32caURu1PFSbWXMNgXtMSO49ftharIhSscDYCuY2nLUh30Gyzg1HrW5kik9I/U wzJ2LkGyI/Y9UzX1N+rjfIcni9Vzx/QolG2O6j8YeVbEqn5Ca3zSmQTzS4VW/YCoIg5Q1e q0rDO+O53+6pfvl0TudPBzNSj6mu524= X-MC-Unique: wxXdfNJbODiZ1hdiUY_cIw-1 X-Mimecast-MFC-AGG-ID: wxXdfNJbODiZ1hdiUY_cIw_1753968250 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968250; x=1754573050; 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=kLghEdi44xi6/POYpygXyfMOGple2iuK5st+VMUWU2k=; b=nwurGhMnBJG0te+V/CceCVwF8O1DpdEHhSfHgrb4IvqT/kZTbi++6SWAVVHwN/GCTq B1TGWgbXv+H3IGvbGxWP3o/F7rXs7U+gHiJ6r0/tCGQ1Q0m/PEgY5I5nnwbw7gx6rvK+ OdYyeP4TouGWAIDm4Y8uPOo89j5Ti/Wlw14DesIJcLFTGfwS7NKhYvW3KFXngZ6dHUda letfAXIwfR7/J23dG6h1T//KDNjtJpIXknlZw8sAv9rsXnCjtnSLpJ+bD9xlTTUcGOuO MUW/pqXzGaQdZYFbG/kwp9JjWDqWJs3ZzqH57gp9VciW0qDRe/3jZcmmc1SbFTcyzQPd i36g== X-Gm-Message-State: AOJu0YwliBYXfyAD6qmblAWlc6PrHQ+lo8zjXE2umSXawKNHewSL1PeY 07dlG/iscVigXIYFwAfDNzPF6c89anDdh8q0OsqI4lQ23PPI7FfIPP5gk4edxfoqf04nN7ofJGM tSYCv8lfbZNwjMSuAF1vqeOCvbYcDjdH4BUdLrfRN2D+FzQoPqy3pEkCicspfXmaasSASPI9fAx hCMcCLnnhiVYTzfY43L6W8SzgpuO/+v6EN2Gh7LBFHjA== X-Gm-Gg: ASbGncvVr2Uuqyej2NFYGVY0Pfk9l9BWjb0EV23gbDjMpfo0RBb2Wv+nPSleC3M61wH 85GER9kb29ubYxjE5oVFZ6VI89CZCt8BaOXPiKuTKhFKHNG8QamOEQih6hEPiHa0TP02MoWlvkA 5O9IrBP9c6jGSK5rrTTvCOla3gKF7IA9197lMZz4/gEqgy9iysrlThtW+JV6Ye5l9yUuMC8yrQG OIT8sbBwCjyNnQrIwyLqidGaXloxp7vuQCxHNJt3JAyg/3B3qsY+VokTFxA+tGsUpB2GmgaP0dq kRtpgBmmr0siLpvLq9j+1eiITvPhkFwJWsLZmxHLBbr6KD1lO/Pv X-Received: by 2002:a17:90b:4e88:b0:31e:ff94:3fba with SMTP id 98e67ed59e1d1-31f5de73be3mr10968961a91.24.1753968250181; Thu, 31 Jul 2025 06:24:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRJ5xULk/vCXVp+z6uvdiMa1wS24tfrk5Fa3pMGUSobsyYWl/IgpyQYiPt48gJ9f7omyryDQ== X-Received: by 2002:a17:90b:4e88:b0:31e:ff94:3fba with SMTP id 98e67ed59e1d1-31f5de73be3mr10968888a91.24.1753968249545; Thu, 31 Jul 2025 06:24:09 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:54 +0530 Subject: [PATCH v8 14/27] migration: push Error **errp into loadvm_postcopy_handle_run() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-14-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1842; i=armenon@redhat.com; h=from:subject:message-id; bh=WpuifoUIMf3O+h85by3an6J009O2UfK/XwRSBRbjBtA=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rP3vedfZXwJujK3NcT8P7tvdtYH1qBwtScP8t9VB ekzePt0lLIwiHExyIopsjR8DZBtCiiMiLR9eR1mDisTyBAGLk4BmIjMC0aG1qU5R2XLLGyj5irr Tb1s2sb6+t0dFwf2mjOWKQEGzx8wMjK8uPtjR9A8Vl/JNV57O4zbOe9M5DN9MlE4PjjZ6+KVJbe YAA== 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753971908398116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_postcopy_handle_run() must report an error in errp, in case of failure. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- migration/savevm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index c9ca0628183312e19fc72c06f791dc4d53566c16..771c3d2a074d5b6a5ebd3ccf58d= 564d9b4cefb93 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2273,13 +2273,13 @@ static void loadvm_postcopy_handle_run_bh(void *opa= que) } =20 /* After all discards we can start running and asking for pages */ -static int loadvm_postcopy_handle_run(MigrationIncomingState *mis) +static int loadvm_postcopy_handle_run(MigrationIncomingState *mis, Error *= *errp) { PostcopyState ps =3D postcopy_state_get(); =20 trace_loadvm_postcopy_handle_run(); if (ps !=3D POSTCOPY_INCOMING_LISTENING) { - error_report("CMD_POSTCOPY_RUN in wrong postcopy state (%d)", ps); + error_setg(errp, "CMD_POSTCOPY_RUN in wrong postcopy state (%d)", = ps); return -1; } =20 @@ -2625,11 +2625,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_postcopy_handle_listen(mis, errp); =20 case MIG_CMD_POSTCOPY_RUN: - ret =3D loadvm_postcopy_handle_run(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_postcopy_handle_run(mis, errp); =20 case MIG_CMD_POSTCOPY_RAM_DISCARD: ret =3D loadvm_postcopy_ram_handle_discard(mis, len); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753972240; cv=none; d=zohomail.com; s=zohoarc; b=VpbXP0WGQPa1UMRamhtkXmhhgNgSU2eHuhuQkjiccLBsW64BDd91l3SNN2wRNGM15lOZC+syCqiaDCI0BBQRPawdbjS8ns993hVBZ7qRh/5ckciHttcn9UmsFq/M/t5xxihbJ/B/Lj7WVR8VQJvO9eAvW1JQ4BfpVayq4CJxBCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753972240; 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=uuolSDeBSIsoWRBk/Igedb1zB8G7XhbIrcEjsXNUiTA=; b=IKno3PaPi5U3Vq1GyTcfGpFDg4cYOVN7ggNh4lQLDU7R8buCOY5BQWSR3Dlpjg0WwW0BZlTcx11SinbCLKNA/hSKoAWfPK69V+suJvCSjMXI8s2i46deNFRSfPiPDhW7DRddOPrxgeIbZ7Oy5gHzXeQrX1VeBE/8zSTbLMSWeBo= 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 1753972240690692.534278089367; Thu, 31 Jul 2025 07:30:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU7s-00056R-DI; Thu, 31 Jul 2025 10:19:20 -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 1uhTGl-0004iw-94 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:29 -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 1uhTGh-0008Qn-JT for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:26 -0400 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-D4cRlDeMMTaIm2xeG7gclw-1; Thu, 31 Jul 2025 09:24:20 -0400 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2400117dd80so3136515ad.2 for ; Thu, 31 Jul 2025 06:24:20 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968262; 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=uuolSDeBSIsoWRBk/Igedb1zB8G7XhbIrcEjsXNUiTA=; b=WEFajkG7dXfdS1c032A2izgoYwQqaNMWWWQUOTCBWeX7rqdKec4U2ZI6g66r/f6VCY+yP1 JUvh9+1q+rvX19XdXvpet4jNRo8ekWm/LbxdRtUFsf92OGT5da03Wl9BglVnKsFk4VL8YW /jS/4IwejC6IVwhBMNstdGE5TjZMqCI= X-MC-Unique: D4cRlDeMMTaIm2xeG7gclw-1 X-Mimecast-MFC-AGG-ID: D4cRlDeMMTaIm2xeG7gclw_1753968260 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968259; x=1754573059; 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=uuolSDeBSIsoWRBk/Igedb1zB8G7XhbIrcEjsXNUiTA=; b=MwyHz2MiQ/HOmiT/+26nS1kbmTdSxjwW8/Av0tjY1FiCz5+RW7OJDG0PQ/oe/C3ScQ lwA2E4/+9lObeKfBWnQm7AxkJ3dYuCIxYVS1iwUnEWE8Rg5MzJ+sRUECob2kj2/o7sz3 K2c2GeNJ6OWuJkRVIMld4UO4OMJQhGkfb4lRrJeUbIpmWw+p0MMhOsteeTsPPWVJdOeY x0X0ybgz78DTmDLn+tlw35vein5XqU+BUSQ0ChTJ6UEYeU1UHeN7nWdxqMXQA1EJvNFh n7K2o6/9T6pwkqfF9GQMGfRVVfz/Nj0EjlljcI2NuC83I8sWIGZYeltZwmmlU6QkZjdl RV1Q== X-Gm-Message-State: AOJu0Yx6FYCN2rceBeJ+xhaweapIWqYUMh+B9vde1WWSTO/tbPQBqQak TC17SoqW+KMkrCI87VJ5FzMb/tOzSEPHDakETyAjASJr4SPl+2We0D+e+6U+mLP5g1PjK7z3YU0 zSs5Zw15PuoG90k0iqSXZcZud7lVFRr9eBJjCQBikvAUtDZbEL40EWz/Q41HQD7NxOEo8CgrVu2 iGhHsLm60P7Fof7bzycHq6SEkFcJZMps6FtCGUK0lWew== X-Gm-Gg: ASbGnctSgcxnx+dqYG7mT5S6/Y44DzE2mN3oYvNGANou7CMSbvjMD8V3Rcpb1amBjRN A8WrKQAyO6yWc0+ObXvTWBoHCUopT24r8a52T63ybIA5KnuYYFFWbcFpqfwYKHrT9qkKUT83Ako N72NvJLnHp0U9Ll1omWlYjzqUZs2423do8BNVa3e8TfGmeJfGHNazvUi7/XdBNOf1Dteboc3CP+ vjzp3RC4Gdswuht+K7gvqVhW5QoAvB4b2t9VfX5ZTQ4BPmepaSHI7K5WpRTw/HeqqXALs+asXKF QhtQ5ZWI/s5NqYlpilgXRQwsPLUedlqGmq2MKHDtqKmi4HvPKn24 X-Received: by 2002:a17:902:ef11:b0:240:10dc:b7c9 with SMTP id d9443c01a7336-24096a636a5mr116386345ad.9.1753968259600; Thu, 31 Jul 2025 06:24:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+qITmLNK5QEe+dil0WZmO/CnFbUaPuQb+j7HdoaCLoJ2D3chYV/VlWQG4wCweoWFihwksOw== X-Received: by 2002:a17:902:ef11:b0:240:10dc:b7c9 with SMTP id d9443c01a7336-24096a636a5mr116385375ad.9.1753968258967; Thu, 31 Jul 2025 06:24:18 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:55 +0530 Subject: [PATCH v8 15/27] migration: push Error **errp into loadvm_postcopy_ram_handle_discard() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-15-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=4220; i=armenon@redhat.com; h=from:subject:message-id; bh=qD1YsQfRAmA5wSa2RLuVrWzYc9u7dExn+qNTbwVOw9I=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rPbEwI6bl+VFNivYtux7oBTDOuSK2/5lI4dlI7UP ZXwhOlURykLgxgXg6yYIkvD1wDZpoDCiEjbl9dh5rAygQxh4OIUgInk2zD803hldPFSxJlz2Sp/ i9tmv1Sds2H5zMgZN9YsrDWRrDObd5Phf9yqEK83Ls/1fji7z4mUN4z+M/mrcY3NmwQNoe7tCwX /8AEA 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753972242446116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_postcopy_ram_handle_discard() must report an error in errp, in case of failure. Signed-off-by: Arun Menon --- migration/savevm.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 771c3d2a074d5b6a5ebd3ccf58d564d9b4cefb93..2f9105e4a3b3d1a443d44beed1b= 2bb2d876439ec 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2004,7 +2004,7 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis, * There can be 0..many of these messages, each encoding multiple pages. */ static int loadvm_postcopy_ram_handle_discard(MigrationIncomingState *mis, - uint16_t len) + uint16_t len, Error **errp) { int tmp; char ramid[256]; @@ -2017,6 +2017,7 @@ static int loadvm_postcopy_ram_handle_discard(Migrati= onIncomingState *mis, /* 1st discard */ tmp =3D postcopy_ram_prepare_discard(mis); if (tmp) { + error_setg(errp, "Failed to prepare for RAM discard: %d", tmp); return tmp; } break; @@ -2026,8 +2027,9 @@ static int loadvm_postcopy_ram_handle_discard(Migrati= onIncomingState *mis, break; =20 default: - error_report("CMD_POSTCOPY_RAM_DISCARD in wrong postcopy state (%d= )", - ps); + error_setg(errp, + "CMD_POSTCOPY_RAM_DISCARD in wrong postcopy state (%d)", + ps); return -1; } /* We're expecting a @@ -2036,29 +2038,30 @@ static int loadvm_postcopy_ram_handle_discard(Migra= tionIncomingState *mis, * then at least 1 16 byte chunk */ if (len < (1 + 1 + 1 + 1 + 2 * 8)) { - error_report("CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", len); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", l= en); return -1; } =20 tmp =3D qemu_get_byte(mis->from_src_file); if (tmp !=3D postcopy_ram_discard_version) { - error_report("CMD_POSTCOPY_RAM_DISCARD invalid version (%d)", tmp); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD invalid version (%d)", = tmp); return -1; } =20 if (!qemu_get_counted_string(mis->from_src_file, ramid)) { - error_report("CMD_POSTCOPY_RAM_DISCARD Failed to read RAMBlock ID"= ); + error_setg(errp, + "CMD_POSTCOPY_RAM_DISCARD Failed to read RAMBlock ID"); return -1; } tmp =3D qemu_get_byte(mis->from_src_file); if (tmp !=3D 0) { - error_report("CMD_POSTCOPY_RAM_DISCARD missing nil (%d)", tmp); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD missing nil (%d)", tmp); return -1; } =20 len -=3D 3 + strlen(ramid); if (len % 16) { - error_report("CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", len); + error_setg(errp, "CMD_POSTCOPY_RAM_DISCARD invalid length (%d)", l= en); return -1; } trace_loadvm_postcopy_ram_handle_discard_header(ramid, len); @@ -2070,6 +2073,7 @@ static int loadvm_postcopy_ram_handle_discard(Migrati= onIncomingState *mis, len -=3D 16; int ret =3D ram_discard_range(ramid, start_addr, block_length); if (ret) { + error_setg(errp, "Failed to discard RAM range %s: %d", ramid, = ret); return ret; } } @@ -2628,11 +2632,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_postcopy_handle_run(mis, errp); =20 case MIG_CMD_POSTCOPY_RAM_DISCARD: - ret =3D loadvm_postcopy_ram_handle_discard(mis, len); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_postcopy_ram_handle_discard(mis, len, errp); =20 case MIG_CMD_POSTCOPY_RESUME: loadvm_postcopy_handle_resume(mis); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971928; cv=none; d=zohomail.com; s=zohoarc; b=Nm72izroHhDmOOq40ewhdK5RnTaQgMP/8SxvJdh8V52wu5MmAKGLGeklKFX8d5XVKu5LVMzGjBrAjVToh/MlHU535KiAcjBN0Qfy0Z31a8fV1sAC8ZbLdhd3OT8zhjcwKcSMCSuHpSPzDqpHymiSbb3Gijdk+8qXhEkS9Fd+egA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971928; 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=kPlxUATnson/OfqUGGpfiSwGtkiFdFaIwugyp8JmNkM=; b=YS9CDCdUSk6b8vDWpbU23fed4zUexUXDFb/20SKyRM/BYsyh/UlUzXuDVZVOWh6D9pZz26hEGDx7UnIVCahA4aLXnBVQijpUBfyMxYPngiZedeCutJDhMkP5LanF+QlrSaWlB/AgyikrKzP2zvBzxUVKHlLKA1AI0FUfG3h6J2w= 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 17539719285246.023110571269399; Thu, 31 Jul 2025 07:25:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU8A-00065y-92; Thu, 31 Jul 2025 10:19:41 -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 1uhTGw-0005vm-9A for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTGu-0008SK-3r for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:37 -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-522-LU-hpcCRPzGdYyIM6im_Zg-1; Thu, 31 Jul 2025 09:24:30 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-31f2dd307d4so1110092a91.0 for ; Thu, 31 Jul 2025 06:24:30 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968272; 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=kPlxUATnson/OfqUGGpfiSwGtkiFdFaIwugyp8JmNkM=; b=Mv4CX88yx/t3JLJn7G6voUZE9XEr0X787Op3zp6aIbPwnFBJJzwenynCYihvmRHAJg8DJm HEAzWfk2HXJCAS2i6338IY7VOahBT1mFdGPgwuPAtbAPhTT/Yf/Y1rIeoWBfWxLqViERoP YPgM6Rkah4TUZGM9mU9iG6ijBOejWNw= X-MC-Unique: LU-hpcCRPzGdYyIM6im_Zg-1 X-Mimecast-MFC-AGG-ID: LU-hpcCRPzGdYyIM6im_Zg_1753968269 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968269; x=1754573069; 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=kPlxUATnson/OfqUGGpfiSwGtkiFdFaIwugyp8JmNkM=; b=aYkCqdYrs+mO/Q7hdXMH+ikttwZwjJGeU+eSIeQjspYDgxb0b0cmiXKZhseseOE2Gb vVmOZdQhpFmxKtIM7BWcSFoSBVFMgdVYXarZ3OfcNkKvjZqZiXWSUkTwcqutn8z8vHBe HJdxc4mzAUq0RWq6X7qJNeY2D0/YzAn0vElFvV3X3tIJU2uPeu7Xr2ECoIE47UPRtAsU MJA/EfhwFB7W8qaYUpf13848fPg1VrgrJrRljKtUEBMC8kRU83u089mR4i66JiTF3N0e aSfFt6WTi57aavgMYBVf5y4I7NyaC0IgLVEVRTIHAI42IPsVzUlGZ5esb3upwnmr32QU 6qvA== X-Gm-Message-State: AOJu0Yz3BdF5GdWAaGEt5W/AFJEy8Fvn6w7yxQiYAImFypwGb5SXorm9 DfthgpymVI5X7J0IF38H8gHQ3GeYwZqYrez8Bw2CD6Lmo44kFO3erEoUbeSW4PwjdmHANxL8DgT Khe+egsPR/w2iLadEtfoBCr7mf8o9Ftauvdcnj5W6ZfYICCNfHHGlX0abuea3HKp3P/SrK8MGyW lvqOxwwUmBXMXoQlB6RUY2A+Kld80820ODZ8rmkhmYwA== X-Gm-Gg: ASbGnctHSkf4BV+l3guUOpFu6d9S+JmbO02AZl/OxVNC9D+NE597EcGkNVd9fge+xJ6 VXttOgiACpDxHdFqJuLjJbYN7ZGBlCEepAl0/or9Aiueh+gMBDl2a5+/ymrzxHD34rbjg/bv6+s cU6q0HmSGraPjrAjUiSuCsrjAJz8j1c6ZP8yE9LBkhN3kgbE8caRkvkfGFo4MUR/LJOHAHpXo0L c+xBkOSxn4aGYP0/dyyHH5LE4kNtLwvBCtPmOJ+5YBaKgoB8et5JA4jr5q9XV+JMrBONxNtQtYo bvBJR833EWURF/obP/kDIY4T0U8QazRpoGEsAy498UKo9WMDMQmm X-Received: by 2002:a17:90b:3c04:b0:31a:9004:8d36 with SMTP id 98e67ed59e1d1-31f5de54abdmr10222472a91.20.1753968268895; Thu, 31 Jul 2025 06:24:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF28oQZ0p4k4XEz1Z4GzPjUC43COF4UfZLe2qygVaSZ4YPphOwkAAKP19X3nNB7/EVgdzKzg== X-Received: by 2002:a17:90b:3c04:b0:31a:9004:8d36 with SMTP id 98e67ed59e1d1-31f5de54abdmr10222379a91.20.1753968268189; Thu, 31 Jul 2025 06:24:28 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:56 +0530 Subject: [PATCH v8 16/27] migration: push Error **errp into loadvm_handle_recv_bitmap() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-16-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2614; i=armenon@redhat.com; h=from:subject:message-id; bh=x35890LQbgla3cF+l4tZAoC5i9xLCJIObHqhxSSTf4U=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37jPd3K2p+jb6NrU2UXefPvmQOcGr4zb3fPnJUwVnm k8KmvGso5SFQYyLQVZMkaXha4BsU0BhRKTty+swc1iZQIYwcHEKwES2zGBkOLE6+e7MXKNpZf+d //AncTHenv3i1JS+4P91mxq4Gw7k1jL8DzqVzuAX4+/xQFdN1a3vMyeXy7czaczerZ/VAw5dUr7 BAQA= 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753971931426116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_handle_recv_bitmap() must report an error in errp, in case of failure. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- migration/savevm.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 2f9105e4a3b3d1a443d44beed1b2bb2d876439ec..d095ea370464b7098ef37d0ad37= c2fc595edf6ea 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2479,32 +2479,35 @@ static int loadvm_handle_cmd_packaged(MigrationInco= mingState *mis, Error **errp) * len (1 byte) + ramblock_name (<255 bytes) */ static int loadvm_handle_recv_bitmap(MigrationIncomingState *mis, - uint16_t len) + uint16_t len, Error **errp) { QEMUFile *file =3D mis->from_src_file; RAMBlock *rb; char block_name[256]; size_t cnt; + int ret; =20 cnt =3D qemu_get_counted_string(file, block_name); if (!cnt) { - error_report("%s: failed to read block name", __func__); + error_setg(errp, "failed to read block name: %s", block_name); return -EINVAL; } =20 /* Validate before using the data */ - if (qemu_file_get_error(file)) { - return qemu_file_get_error(file); + ret =3D qemu_file_get_error(file); + if (ret < 0) { + error_setg(errp, "migration stream has error: %d", ret); + return ret; } =20 if (len !=3D cnt + 1) { - error_report("%s: invalid payload length (%d)", __func__, len); + error_setg(errp, "invalid payload length (%d)", len); return -EINVAL; } =20 rb =3D qemu_ram_block_by_name(block_name); if (!rb) { - error_report("%s: block '%s' not found", __func__, block_name); + error_setg(errp, "block '%s' not found", block_name); return -EINVAL; } =20 @@ -2639,11 +2642,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return 0; =20 case MIG_CMD_RECV_BITMAP: - ret =3D loadvm_handle_recv_bitmap(mis, len); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_handle_recv_bitmap(mis, len, errp); =20 case MIG_CMD_ENABLE_COLO: ret =3D loadvm_process_enable_colo(mis); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971939; cv=none; d=zohomail.com; s=zohoarc; b=n7a6UZ6j+5+n1lajobHFpDNXSpoukK6TIVyc/iCmf+WiYesGqltNhUi2cjPtLcJNkmkuuy6Xx/SKHUQbjrss4tvIa65jBXFouEVEYtvyd/L/QY1OkdkAV4q4hhiIY/OZeBLADSYMeemdM4XrK1daCK4cHO3yfOLGpHjYMoWr7P4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971939; 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=SxT7t8v3VO+Rr1RL3SBMVQbsB5LGB39zeRYYNnq7mSo=; b=AXEQCsZQVjXQa6EZPkPGJdj4LA3G3Ly27PuyGrB4bBXpq/7Dfekq+d8Siypm/hM09XT4BP+GxTg/iBHU05HDMeYE7a3UuBSC6TnsL/e9MsP1iGTHUT1iGQdUoqg7/iNTARrPdOenZEQZX69OTpM1lPeVKSN8LQuFveuzTG1Boqw= 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 1753971939479226.87043921997383; Thu, 31 Jul 2025 07:25:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUBq-0006Bi-0f; Thu, 31 Jul 2025 10:23:26 -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 1uhTH7-00070p-0e for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:49 -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 1uhTH2-0008U0-9g for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:48 -0400 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-gD5jlRgaM3alThOSS3CjCg-1; Thu, 31 Jul 2025 09:24:42 -0400 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-31effad1358so936331a91.1 for ; Thu, 31 Jul 2025 06:24:41 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968283; 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=SxT7t8v3VO+Rr1RL3SBMVQbsB5LGB39zeRYYNnq7mSo=; b=cA12R42zAQu9mLWKavgreKrS9OlK7mEiSLOAuMnpMwhiEqntsSeA67A6WB73WmqjWP08cZ lVZeXM8Tfrv60kvxqLqAlsQOEPT6C+RN0zH9z2gjR3mhKLZpFSz3GXzcyx0LCJEa5YGjh1 CexLyJFp0qSva74vG+Ddzp2W5q+1g8w= X-MC-Unique: gD5jlRgaM3alThOSS3CjCg-1 X-Mimecast-MFC-AGG-ID: gD5jlRgaM3alThOSS3CjCg_1753968281 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968278; x=1754573078; 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=SxT7t8v3VO+Rr1RL3SBMVQbsB5LGB39zeRYYNnq7mSo=; b=ixMph+v1oJFk9F3Otrj5xDLYG4fANjnXZQfgSPWk/8Q/T3p42LW1imSoR/rnixE9e5 cLMiRso7Hq8NgQY9GvqwUCGLURVCqBKUnMYWaAz6u6Soe+gBW8kd8JOoDQd6ysFUaMLe UR3sR6Rbz+9j6jumD1+P6VctQp7ogHYv1azMd0mvIKMwTwQxnvLavUSn4EDArL5tGYnA m+9YonBhsHovXTJikOMVk5CrLTSyABrVXYH0/Wu/eZODjjJIDNZe4NCQOqrStofqLUCP lojmSy/Rum0NK+i7eZws+/BS1a+qCYpakSZjrDdla6ZK3+pF14/qNPV41q74F7CJwHWk /aDQ== X-Gm-Message-State: AOJu0YwfCwzeFtyh9MIEwwAm13xaOU2nlSallGzcknEPE4ehRcYftxm6 Issx8DTi58JQR/+LOSK/zLSnAGx+Nq1j2ymDRwBkEkeKC+e6eM/dUW1Aw6fb+8lIRq8zKM5r/1U Upd2tkadVbv4B7yJMdpQSrbXZfMC/SL/4RPAOmaEgm/IprrqjG/P7e0V+EYdRj9E3UbWpU1aGUv ijOn8f4X4cfYyZjX2rjH3xxq/Ct0DLlAxT6Tie9lBzng== X-Gm-Gg: ASbGncsfsjxSRuJlSGDAsygddU2T2LOEd0f1gQ4EfCriORy4n7RQYhCX9l+egvZLv8P CIouS+r9lNWQ5Krat5psWVcYuLDoAfUUudil7T1W95oUmqmXhck61U9uWiJxrpJqURo2VjONn/6 g1oZuxY1owqW75LX4/VV2x3mCoQtKt9EFmPIwzacioXHkL6zsX07mYip7XmVibgMU1jPFVl5oDQ SkzlXABD83JQ/C6sgEordOCdAfEjyyNG48xLzEAVsTN4BYQzlsGlhcrOtljPzPU1mRsXqIxhH7/ HMaoaYjurqDw+i1NSfDkVvPSJ/dxfgkKB3l6Y8Gc5dHtEI5o1vQx X-Received: by 2002:a17:90b:1b47:b0:31f:d0:95c4 with SMTP id 98e67ed59e1d1-320da5b4016mr2791179a91.5.1753968277842; Thu, 31 Jul 2025 06:24:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQ6v8Df5t5D3siWuwGvdQky2ausTTtNgryjQzdFUXbZsSavq67Ooh7GbECHJGF4YyG2PxjJA== X-Received: by 2002:a17:90b:1b47:b0:31f:d0:95c4 with SMTP id 98e67ed59e1d1-320da5b4016mr2791087a91.5.1753968277207; Thu, 31 Jul 2025 06:24:37 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:57 +0530 Subject: [PATCH v8 17/27] migration: push Error **errp into loadvm_process_enable_colo() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-17-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=5926; i=armenon@redhat.com; h=from:subject:message-id; bh=P5w2VFa5ILBTWE0/p7n8qWxh210KDW/+EmHaCXDgktA=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rOTv+fNzWT3qzDjco/cecAxpspWUWRlVVBd0o4mV YszUXUdpSwMYlwMsmKKLA1fA2SbAgojIm1fXoeZw8oEMoSBi1MAJmJfxMhwj0V+U8eBpKdzBBTm nOZrMnD+teiDY63A4nsXb05Tf2vgw8hwVu9i+skAV3mP6/4lF++uVZ3f2xB2q1HK6N/6HJOZgvY cAA== 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971940556116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_process_enable_colo() must report an error in errp, in case of failure. Signed-off-by: Arun Menon --- include/migration/colo.h | 2 +- migration/migration.c | 12 ++++++------ migration/ram.c | 8 ++++---- migration/ram.h | 2 +- migration/savevm.c | 26 ++++++++++++++------------ 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index 43222ef5ae6adc3f7d8aa6a48bef79af33d09208..d4fe422e4d335d3bef4f860f564= 00fcd73287a0e 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -25,7 +25,7 @@ void migrate_start_colo_process(MigrationState *s); bool migration_in_colo_state(void); =20 /* loadvm */ -int migration_incoming_enable_colo(void); +int migration_incoming_enable_colo(Error **errp); void migration_incoming_disable_colo(void); bool migration_incoming_colo_enabled(void); bool migration_incoming_in_colo_state(void); diff --git a/migration/migration.c b/migration/migration.c index b3bccaeaee806abd01595863f6475057049b0688..d748a02712dc4ebc2de6b0488fb= 199c92c4d4079 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -623,22 +623,22 @@ void migration_incoming_disable_colo(void) migration_colo_enabled =3D false; } =20 -int migration_incoming_enable_colo(void) +int migration_incoming_enable_colo(Error **errp) { #ifndef CONFIG_REPLICATION - error_report("ENABLE_COLO command come in migration stream, but the " - "replication module is not built in"); + error_setg(errp, "ENABLE_COLO command come in migration stream, but th= e " + "replication module is not built in"); return -ENOTSUP; #endif =20 if (!migrate_colo()) { - error_report("ENABLE_COLO command come in migration stream, but x-= colo " - "capability is not set"); + error_setg(errp, "ENABLE_COLO command come in migration stream" + ", but x-colo capability is not set"); return -EINVAL; } =20 if (ram_block_discard_disable(true)) { - error_report("COLO: cannot disable RAM discard"); + error_setg(errp, "COLO: cannot disable RAM discard"); return -EBUSY; } migration_colo_enabled =3D true; diff --git a/migration/ram.c b/migration/ram.c index 6a0dcc04f436524a37672c41c38f201f06773374..995431c9e320f443c385c29d664= d62e18c1afd90 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3576,7 +3576,7 @@ static void colo_init_ram_state(void) * memory of the secondary VM, it is need to hold the global lock * to call this helper. */ -int colo_init_ram_cache(void) +int colo_init_ram_cache(Error **errp) { RAMBlock *block; =20 @@ -3585,9 +3585,9 @@ int colo_init_ram_cache(void) block->colo_cache =3D qemu_anon_ram_alloc(block->used_length, NULL, false, false); if (!block->colo_cache) { - error_report("%s: Can't alloc memory for COLO cache of blo= ck %s," - "size 0x" RAM_ADDR_FMT, __func__, block->idst= r, - block->used_length); + error_setg(errp, "Can't alloc memory for COLO cache of " + "block %s, size 0x" RAM_ADDR_FMT, + block->idstr, block->used_length); RAMBLOCK_FOREACH_NOT_IGNORED(block) { if (block->colo_cache) { qemu_anon_ram_free(block->colo_cache, block->used_= length); diff --git a/migration/ram.h b/migration/ram.h index 275709a99187f9429ccb4111e05281ec268ba0db..24cd0bf585762cfa1e86834dc03= c6baeea2f0627 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -109,7 +109,7 @@ void ramblock_set_file_bmap_atomic(RAMBlock *block, ram= _addr_t offset, bool set); =20 /* ram cache */ -int colo_init_ram_cache(void); +int colo_init_ram_cache(Error **errp); void colo_flush_ram_cache(void); void colo_release_ram_cache(void); void colo_incoming_start_dirty_log(void); diff --git a/migration/savevm.c b/migration/savevm.c index d095ea370464b7098ef37d0ad37c2fc595edf6ea..eeae34454117fa785a7514ed70b= 11bb712e37d6b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2518,15 +2518,21 @@ static int loadvm_handle_recv_bitmap(MigrationIncom= ingState *mis, return 0; } =20 -static int loadvm_process_enable_colo(MigrationIncomingState *mis) +static int loadvm_process_enable_colo(MigrationIncomingState *mis, + Error **errp) { - int ret =3D migration_incoming_enable_colo(); + ERRP_GUARD(); + int ret; =20 - if (!ret) { - ret =3D colo_init_ram_cache(); - if (ret) { - migration_incoming_disable_colo(); - } + ret =3D migration_incoming_enable_colo(errp); + if (ret < 0) { + return ret; + } + + ret =3D colo_init_ram_cache(errp); + if (ret) { + error_prepend(errp, "failed to init colo RAM cache: %d: ", ret); + migration_incoming_disable_colo(); } return ret; } @@ -2645,11 +2651,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_handle_recv_bitmap(mis, len, errp); =20 case MIG_CMD_ENABLE_COLO: - ret =3D loadvm_process_enable_colo(mis); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_process_enable_colo(mis, errp); =20 case MIG_CMD_SWITCHOVER_START: ret =3D loadvm_postcopy_handle_switchover_start(); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971881; cv=none; d=zohomail.com; s=zohoarc; b=cKf7DYX2MoKXHu+GoNclOG8ixvOg4+L8RHT5nWj9+OYWpsDm335SXMRqp0oi34IVyqAuJLe3js/rXB6uR2bgogCtql/1thAFrOAC4nDRrVs9s5OBWh3NZ9OWHnw+5gJmbK0sXLdl8QJvMWvhuw66Amved5DeSz2tUq44CbUzCmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971881; 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=cYXz+t7lY2pc+w468p7vksRNCF9gH6persDWdh07D1Q=; b=YOpKxrVkrBFFK29FjyoPKWuEY7slqEoyTaQjrWrkz9OWwoRSPgF0miWbbSrcT3RBk3w7+ArTkIt7xse9UD0xjYEdO1OoQVvURUXqmmw2QHzozPVs7K2YIkT/W9Vj/o4v8RhjMjb7Cafa/IreqAJ763BgceTMVpoHdZxbMp9jHAg= 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 1753971880998634.6173061004666; Thu, 31 Jul 2025 07:24:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUBt-0006au-9N; Thu, 31 Jul 2025 10:23:29 -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 1uhTH9-0007BN-LK for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTH7-0008VE-Rm for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:24:51 -0400 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-CrLaG81wNYCVoaDKew_mlA-1; Thu, 31 Jul 2025 09:24:47 -0400 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-31f2dd307d4so1110290a91.0 for ; Thu, 31 Jul 2025 06:24:47 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968289; 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=cYXz+t7lY2pc+w468p7vksRNCF9gH6persDWdh07D1Q=; b=SBn3+ji3yhLLZohrL4Uv7Y6E0XhlJQyZ8X0Ldyg4kRQQeBXkbbAXHe0yKc48PmUNbyfRxV XBV6Iee89k8QXPvSfPc8EuTz7ct2AeUPAF4yeIJ4QntUhuBmKGLbYQnsMUueqV0UKNUR0x N+cAetpeAnHHR+sdzXyxPI8mBvVxKeM= X-MC-Unique: CrLaG81wNYCVoaDKew_mlA-1 X-Mimecast-MFC-AGG-ID: CrLaG81wNYCVoaDKew_mlA_1753968287 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968286; x=1754573086; 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=cYXz+t7lY2pc+w468p7vksRNCF9gH6persDWdh07D1Q=; b=ucXOs2ps7i6FkOzo9njebuzWk22lFikBHL5JZYa3iKD1XeJ4MJe1WS4gee7xXPMZb0 j4ym8KqwRwB2DuBBweeb2J5IWBhL0a2rCpdg5sQ32oehwxyZ7cQZyPpSxBNlthl9VJwt GQ8WpVLOZ1FP7PZ7+YGDnAuEM+kkMPBqxlLXgLwRPnl1TQTISFkepFIsaCUfEJb+PCn2 9SXTT2OV9YNJMy8GnHMXwsSaXJPuMfuM/blEuyqjlGRVoWSyGRq3Iib3ACgjswQcpS8a tUNccPE0Oe9cH/LpX2zdBjq4+NFGD0sY9xQliceuz5MD8Lchiq8qsVsIWAf8gA6baKAA OQCQ== X-Gm-Message-State: AOJu0YyA9Voezu2oAX2t9NtH9PiDt+3kxpi2Qf4+/ERcnxn65q45epx9 SvSZJK9laBfDYQaC+5srUdoYGGkTf2fdPD25kYyyYxbAsh7itMSDlsS/Ycwi1wyDl1EeMEQoYbw 6nWKGRIRcdn8Rak87E4BGKSe8Esi6bqwqNcO8RsT6HkGMoWCWdwqtBOuKXLst/nGsdEgWgt5Y9S 8EAP9T+ASfMaqBSdycg1n1IV94cUBMXomZOlzWs8S5YA== X-Gm-Gg: ASbGncvE131VJ6rjie+l2e2GJ+Eh5kLa+idWGxjQuMwXAUujVjoIJTn3lndUX3eBHeQ HIsgG5+S+Vb63MGmwPb2y7DGBbRev1WaEDGn9LPOUbH/s8Ua6T7Ir3VM6a5yQ9+GD8+c1Wyzb3P llkEUOpSocN0/xcS7ytmmry2w8D0C7ooAX8h+18hhMTPRIFTpYiNirwfn6G6MymiwYx1sJDoO39 GU5O6ZelhJzOnBnfz8925OXkBjlZNJfYi0ZMy2oZuEij0dmeEWRW8qfdihGD5UlePLbenHQYmNg VACICYhjLxb9hw2QoME5Pp2ozg3LpmefeVb7iB+1alK/tmw53xPi X-Received: by 2002:a17:90b:1348:b0:31f:1757:f9f8 with SMTP id 98e67ed59e1d1-31f5de54aa4mr8165238a91.22.1753968286509; Thu, 31 Jul 2025 06:24:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRTdY7Lwpza3rTbYeBSesD15vxKgJmm7CdduM+OWnvie6RHfAAusQZttS32qdY3v2+6/sC5Q== X-Received: by 2002:a17:90b:1348:b0:31f:1757:f9f8 with SMTP id 98e67ed59e1d1-31f5de54aa4mr8165167a91.22.1753968285988; Thu, 31 Jul 2025 06:24:45 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:58 +0530 Subject: [PATCH v8 18/27] migration: push Error **errp into loadvm_postcopy_handle_switchover_start() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-18-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1701; i=armenon@redhat.com; h=from:subject:message-id; bh=cKQFSSzoOVChlG6ImaPlxCUTOALoFJJai4iGUly2L5Y=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37jMlP8a+j2lKJ43/7JhyLdgt0D/y//Zkz8wrat98N RcnqRV0lLIwiHExyIopsjR8DZBtCiiMiLR9eR1mDisTyBAGLk4BuMmrGf478/+Pb0mt0mpyNk/S nXBl9px3MvXe/tlH97jkTz1XsvMCw3+f2IhiAb5F+eXPw7X5uM52HleSVtu3pVxi4qrM3ngxf0Y A 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753971881821116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that loadvm_postcopy_handle_switchover_start() must report an error in errp, in case of failure. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- migration/savevm.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index eeae34454117fa785a7514ed70b11bb712e37d6b..e885f1724f223771d60081fea19= 9320abc549d2f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2537,7 +2537,7 @@ static int loadvm_process_enable_colo(MigrationIncomi= ngState *mis, return ret; } =20 -static int loadvm_postcopy_handle_switchover_start(void) +static int loadvm_postcopy_handle_switchover_start(Error **errp) { SaveStateEntry *se; =20 @@ -2550,6 +2550,7 @@ static int loadvm_postcopy_handle_switchover_start(vo= id) =20 ret =3D se->ops->switchover_start(se->opaque); if (ret < 0) { + error_setg(errp, "Switchover start failed: %d", ret); return ret; } } @@ -2654,11 +2655,7 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) return loadvm_process_enable_colo(mis, errp); =20 case MIG_CMD_SWITCHOVER_START: - ret =3D loadvm_postcopy_handle_switchover_start(); - if (ret < 0) { - error_setg(errp, "Failed to load device state command: %d", re= t); - } - return ret; + return loadvm_postcopy_handle_switchover_start(errp); } =20 return 0; --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971795; cv=none; d=zohomail.com; s=zohoarc; b=aDz5qYNiny/m2JgpICIcl9/bc2P700g408Lruj9a2BUcYidQMspwp+0QNGS7Quk2ZQ2jkPuxsnQfhY1ztVfUSz0Yh7tAReCeHu5KDBe+rR9ZDyePGU5oRQWyb7O6zrUODXbj8khM7yrrvMUvJjWJM9JdcDCYI9HWTitaVWgsVw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971795; 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=T/t4LS9DI4/JXxAHi9YcggnXg5YIOZWzVlbe7P6h3LY=; b=kYBTB9sA3x2ZQZD35jKyM69uDEzq2gy1vfcvUtPPOMd8BNKvLTRZ49UjKcYyuN5sIPgk6Ig7izWUjz1pQCx3DpF3qQMcyfCgpj69oOP/dfB+JhNNUNsNw9m4/khPnjjAQoaaMGRAvrmyOFA8+8cBAh/CB9tVbW4pJroaY0M8//s= 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 1753971795516847.7362650683339; Thu, 31 Jul 2025 07:23:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUAk-000208-Is; Thu, 31 Jul 2025 10:22:19 -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 1uhTHZ-00006k-IW for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:17 -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 1uhTHT-00006v-TN for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:17 -0400 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-499-N5kP44LxML-j7QRBnzCc6g-1; Thu, 31 Jul 2025 09:24:57 -0400 Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-b31ca4b6a8eso306607a12.1 for ; Thu, 31 Jul 2025 06:24:57 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968299; 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=T/t4LS9DI4/JXxAHi9YcggnXg5YIOZWzVlbe7P6h3LY=; b=cJWA5eNBADWJYPicMBc+FcAxCk0rF42n+mqI+FH4hU9VmGR+eufOgr7oTIWNZ3H3De0kPp FF0m/RdEjBtyfoLLg88qA2t+ZlLs1ahaMfUmO1/BuhMV6kNdoqd9yGvszbd5xq175Z1GFO B8yU53dDWSX4DZmh4TWXbrH3IrnAXyo= X-MC-Unique: N5kP44LxML-j7QRBnzCc6g-1 X-Mimecast-MFC-AGG-ID: N5kP44LxML-j7QRBnzCc6g_1753968297 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968296; x=1754573096; 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=T/t4LS9DI4/JXxAHi9YcggnXg5YIOZWzVlbe7P6h3LY=; b=PMq9A+kQpMu0lFdxcjNtHRk85XWDPFSaa59whKu+3NsJjUyK4Za/dwMo8mQYkZ8L/g BuxOoAAG/CaochfEUI4mFtL7gk2e3Wk/XtpjYjZdjiCqrkQbKnqplGkO3gznAH2eXdpk 8yaENbFxZGOOpr1tO88BYscnz9KexFayDOFMuHRSGYnm1UdYX1Y+7aRnC38t2PZM/ajq ulADJ3It1E0C7OFar7anDyfUEuO0C5lamw3KSS2qukQh6GmjcdeqZlGm9u7G/gQts0LJ FJEzfPnuqlzgGW66GsM7DcoQgDrE0elnRekgTezpJh1RjrKyYhsLFSr1bcHGw6Z4sq7G CyNA== X-Gm-Message-State: AOJu0YwWwlxPquQDaaJCq+abUulAyzP59Dg6BmdRu6z6nBONmt94PvOd rsJqcJCoELyKvS4qfIbSQ7KaAVZ9UjlPIuRBEFkH/y3EK07B81b/MGvMM50eEhTrjU5XNCHFAdn jBJiaDcZP0jgK6NnaqVFLCPFT2Ual3JDuRVWqf1JfUB+80uqsuHO7TLDOHAIuKmj7OMG0VuwMnt EjakQYeK9PB2cdUWD1RhH5ttJSoB+HAkz0lTfCmn6N7A== X-Gm-Gg: ASbGnctxJOryJSRB8gnT0O5mJZbBciNi68XH5rKQP0ULHRs36Rtoo6NwfFbSeaXUMCw Vxx/i4CRM/C6Cgm8NdtrKMOk8GYjHrZ10D2JjvuhT8s2dg49rPyo0MhGdxrddRfsvV5G5NRjVi0 zl5h3/OsuFVW5Wvrof/z+VBsAwIec3uSNoY6whE8/ehdDLaGJd4tNlSag/G0x9BqSPs6bjuMsBe wfXYyHepkreT9/r6dMALZYJCoxrhjMEY+DY8N9nd1naTv7W2NT85wws9gsUjsm+KRN4e1MVnEGj RsH/23AdMQ5g+gV4JyjOnyEb15oAjS+iI43FYNYIRMkiA9wViH38 X-Received: by 2002:a17:90b:48cf:b0:31f:28e5:1792 with SMTP id 98e67ed59e1d1-31f5dd6b55fmr10226555a91.3.1753968296452; Thu, 31 Jul 2025 06:24:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKSsYYFL6VdoL3n0qieHccbmw4gYnJyKKowNus5rWnBE+sWv7UryYYLg9VC3wbxafslOBQ0Q== X-Received: by 2002:a17:90b:48cf:b0:31f:28e5:1792 with SMTP id 98e67ed59e1d1-31f5dd6b55fmr10226468a91.3.1753968295795; Thu, 31 Jul 2025 06:24:55 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:50:59 +0530 Subject: [PATCH v8 19/27] migration: push Error **errp into qemu_loadvm_state_main() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-19-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6440; i=armenon@redhat.com; h=from:subject:message-id; bh=lWU+GjdNSyURPgn6NOkpKRQeeZ4WAQUDj0MOi2Wj6qw=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rMox/j9Tw5Nkn3Uv2+hlOvmpYol37c42B3fcPjg+ 0L5ZpeAjhIWBjEuBlkxRZaGrwGyTQGFEZG2L6/DzGFlAhnCwMUpABNJvMzw3XFl+aRtn+arZ7xa 0XzGaFPr1CV5b1gbIx/FvXf6oPN+JsNfyZBq8V2PhW7ktu60OxhTPFHleZnx1MIz9Z4814NEp8/ gBgA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971797129116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that qemu_loadvm_state_main() must report an error in errp, in case of failure. loadvm_process_command also sets the errp object explicitly. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- migration/colo.c | 5 +++-- migration/savevm.c | 27 ++++++++++++++++----------- migration/savevm.h | 3 ++- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 981bd4bf9ced8b45b4c5d494acae119a174ee974..529794dfc8d943b8ba3a25391ee= 2132c0c3f312e 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -659,6 +659,7 @@ void migrate_start_colo_process(MigrationState *s) static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, QEMUFile *fb, QIOChannelBuffer *bioc, Error **errp) { + ERRP_GUARD(); uint64_t total_size; uint64_t value; Error *local_err =3D NULL; @@ -686,11 +687,11 @@ static void colo_incoming_process_checkpoint(Migratio= nIncomingState *mis, =20 bql_lock(); cpu_synchronize_all_states(); - ret =3D qemu_loadvm_state_main(mis->from_src_file, mis); + ret =3D qemu_loadvm_state_main(mis->from_src_file, mis, errp); bql_unlock(); =20 if (ret < 0) { - error_setg(errp, "Load VM's live state (ram) error"); + error_prepend(errp, "Load VM's live state (ram) error: "); return; } =20 diff --git a/migration/savevm.c b/migration/savevm.c index e885f1724f223771d60081fea199320abc549d2f..f5903995edd2b4c4f6c1a214c71= 26d831f10c9f1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2111,7 +2111,7 @@ static void *postcopy_ram_listen_thread(void *opaque) qemu_file_set_blocking(f, true); =20 /* TODO: sanity check that only postcopiable data will be loaded here = */ - load_res =3D qemu_loadvm_state_main(f, mis); + load_res =3D qemu_loadvm_state_main(f, mis, NULL); =20 /* * This is tricky, but, mis->from_src_file can change after it @@ -2412,6 +2412,7 @@ static void loadvm_postcopy_handle_resume(MigrationIn= comingState *mis) */ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis, Error *= *errp) { + ERRP_GUARD(); int ret; size_t length; QIOChannelBuffer *bioc; @@ -2461,9 +2462,9 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis, Error **errp) qemu_coroutine_yield(); } while (1); =20 - ret =3D qemu_loadvm_state_main(packf, mis); + ret =3D qemu_loadvm_state_main(packf, mis, errp); if (ret < 0) { - error_setg(errp, "VM state load failed: %d", ret); + error_prepend(errp, "Loading VM state failed: %d: ", ret); } trace_loadvm_handle_cmd_packaged_main(ret); qemu_fclose(packf); @@ -3066,8 +3067,10 @@ static bool postcopy_pause_incoming(MigrationIncomin= gState *mis) return true; } =20 -int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) +int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, + Error **errp) { + ERRP_GUARD(); uint8_t section_type; int ret =3D 0; =20 @@ -3075,8 +3078,10 @@ retry: while (true) { section_type =3D qemu_get_byte(f); =20 - ret =3D qemu_file_get_error_obj_any(f, mis->postcopy_qemufile_dst,= NULL); + ret =3D qemu_file_get_error_obj_any(f, mis->postcopy_qemufile_dst,= errp); if (ret) { + error_prepend(errp, "Failed to load device state section ID: %= d: ", + ret); break; } =20 @@ -3084,20 +3089,20 @@ retry: switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: - ret =3D qemu_loadvm_section_start_full(f, section_type, NULL); + ret =3D qemu_loadvm_section_start_full(f, section_type, errp); if (ret < 0) { goto out; } break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: - ret =3D qemu_loadvm_section_part_end(f, section_type, NULL); + ret =3D qemu_loadvm_section_part_end(f, section_type, errp); if (ret < 0) { goto out; } break; case QEMU_VM_COMMAND: - ret =3D loadvm_process_command(f, NULL); + ret =3D loadvm_process_command(f, errp); trace_qemu_loadvm_state_section_command(ret); if ((ret < 0) || (ret =3D=3D LOADVM_QUIT)) { goto out; @@ -3107,7 +3112,7 @@ retry: /* This is the end of migration */ goto out; default: - error_report("Unknown savevm section type %d", section_type); + error_setg(errp, "Unknown savevm section type %d", section_typ= e); ret =3D -EINVAL; goto out; } @@ -3171,7 +3176,7 @@ int qemu_loadvm_state(QEMUFile *f) =20 cpu_synchronize_all_pre_loadvm(); =20 - ret =3D qemu_loadvm_state_main(f, mis); + ret =3D qemu_loadvm_state_main(f, mis, NULL); qemu_event_set(&mis->main_thread_load_event); =20 trace_qemu_loadvm_state_post_main(ret); @@ -3245,7 +3250,7 @@ int qemu_load_device_state(QEMUFile *f) int ret; =20 /* Load QEMU_VM_SECTION_FULL section */ - ret =3D qemu_loadvm_state_main(f, mis); + ret =3D qemu_loadvm_state_main(f, mis, NULL); if (ret < 0) { error_report("Failed to load device state: %d", ret); return ret; diff --git a/migration/savevm.h b/migration/savevm.h index 2d5e9c716686f06720325e82fe90c75335ced1de..fd7419e6ff90062970ed246b3ea= 71e6d49a6e372 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -66,7 +66,8 @@ int qemu_save_device_state(QEMUFile *f); =20 int qemu_loadvm_state(QEMUFile *f); void qemu_loadvm_state_cleanup(MigrationIncomingState *mis); -int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); +int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, + Error **errp); int qemu_load_device_state(QEMUFile *f); int qemu_loadvm_approve_switchover(void); int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753972166; cv=none; d=zohomail.com; s=zohoarc; b=E64jWYrO2K8eQzVV4QdkNKU/45kH+EKeFUzF0zlMuotiq2pRuxc0rfKquLrrDHlJcdqvJEwEM0lrgyr2B5uX8aODUOGsuB2zbNjgmVCrPSyhSgvwhBT021qXOJbVnWbMn4zzxzkoKJdvn5XEh7g+WiG21NMH31gCWePzVeTUcjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753972166; 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=bS2TkfZk1qCRGz158i4XqD81xtrwOnWsQ7YYFT4INRg=; b=Y3hG/ecoN21S+4JnTco3GpWAdXn1j9eeU2zBIHkP/6Ma0H6uiQ88Ae9BZDautF+33oUWobP/Bv469TkoVcdwB2522lBQOMI3OfPhOO7ZKCUnrTQyPw1RmCZSnlU1MdiQFJxyGjYRGTwppEuFc3CcZVHBfItvpDUJ8luc+r6aaDY= 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 1753972166888369.6401640457416; Thu, 31 Jul 2025 07:29:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUD8-0001QL-Vm; Thu, 31 Jul 2025 10:24:47 -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 1uhTHY-0008H4-06 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:16 -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 1uhTHT-0000KA-RF for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:15 -0400 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-369-TzvrQtNHPB2UFJJrxK0UTg-1; Thu, 31 Jul 2025 09:25:06 -0400 Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-b4226c60a38so1366014a12.1 for ; Thu, 31 Jul 2025 06:25:06 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968308; 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=bS2TkfZk1qCRGz158i4XqD81xtrwOnWsQ7YYFT4INRg=; b=THD1RgNAeXWkidzT+YxPCEQHKKWIYw25lv5ZuDGgxbpiwUF/kzzXDF9c6riduSOtsnhDZA qiwWs2qQly0eRGNuTGcOu0PJ6GnNFISoOT+r0NmdQaO7Cm8R4pieoo/21z1N3EzCr0BpqZ 9+grmTXIglLhWAJjLMdf2swrM/hMYYs= X-MC-Unique: TzvrQtNHPB2UFJJrxK0UTg-1 X-Mimecast-MFC-AGG-ID: TzvrQtNHPB2UFJJrxK0UTg_1753968306 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968305; x=1754573105; 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=bS2TkfZk1qCRGz158i4XqD81xtrwOnWsQ7YYFT4INRg=; b=FqZXquEHiW2vVKUFNbxef24WdCCD0dJMzcGUqJBANb2BIXt2jgMQwpB0fB48FFJZA7 xHfdRdXtHirjuVazBFDQfiUXUJvqzHdZYQ4nqdScDp9KlQCWEYsTvcd8B6+tll0Wl1kW frU4b5V1V3Yo9Nr+HjlKhnDrPK49PRd54mdFb288a+uE2vZt/S31J+AsdWkw2OakvJmi rlmaa62cORsSWapq5p0xUiOJzjkKPv8nV2bo67ytVi0/sEpMqGw59TAq66Bsacb1AE70 omuK8/A7Q85TntvsN0QoaEXeZHpW2YAfwP5zDJbbsLphYs5c9916BJ4U/RjyRH05Nzzw vRPg== X-Gm-Message-State: AOJu0YyKIL8Cg7tVHUZw5psGODkLgvlimmmOSSmX/BnLz5H9rF+jpxfT mNnLrZOnatDDta83N8nLhQOhDJLiy0RQz61zS7p8ezTxTkjnQeyLXfzFmUv9qsulGCRb2HTS2vN 6874BaISgKuBBwPWlv5k8hnWQJd0mlFvV+7mFufP0RnABcGoiDwi+dwF0ADlHkMJPezym+Fblzz 6yIdIde36lnOYeYcyNCS8IJYcQj0tTqA+eRhMLBe8rFQ== X-Gm-Gg: ASbGncvBq78pJupLkTyOC4srE3UAVpfy5WTfl/DLAZK4nNjwzH/tl96kGoiL1CsCAv/ xWUnM5JIxo/3jjpumuenSuUhr6YKw8bSqueCW0uIihMjdFxuhUewHBE4poY/Z/0BsMPsa5MfMpQ xu3qkCYm4dzY3xDS6Z62vi1hWqW+7dQTeMp/UJHUS5NQwLZR2dw7RGXHsr/W19uPZVOGkLof2uq wl6BCLyikZ8PWzsGl4Lw1zsadyyqda2DLSji9t8mhoNSaPvqNZjZq6h+Noh49JLK7np4REt6v4D riILKK6cVSs3zQYIqrN9h7OIVKA1r5zPASZca1Aw2DUumAQffyFQ X-Received: by 2002:a17:90b:4b82:b0:312:e731:5a66 with SMTP id 98e67ed59e1d1-31f5de1f5bemr10164487a91.3.1753968305172; Thu, 31 Jul 2025 06:25:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1gyei7Qr9iwcdAgdmQAf6gSGZqSIC2/EzUVuLZ/nchblNQTdBjr4pItq4yl6IGaFo/aG4iA== X-Received: by 2002:a17:90b:4b82:b0:312:e731:5a66 with SMTP id 98e67ed59e1d1-31f5de1f5bemr10164406a91.3.1753968304618; Thu, 31 Jul 2025 06:25:04 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:00 +0530 Subject: [PATCH v8 20/27] migration: push Error **errp into qemu_loadvm_state() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-20-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=5530; i=armenon@redhat.com; h=from:subject:message-id; bh=mH0njnF++VC8MNV1Xg4/TUb4R27KWMg3THHAAoR4I/w=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rPjpfZbFp/RNdt39FlAxbnFqYYsLVv3n7uW3e1mv kLadYVzRykLgxgXg6yYIkvD1wDZpoDCiEjbl9dh5rAygQxh4OIUgIksnsLw30G8ea62pM9Ss7j0 W4LJN2dONvjjsnuq2dkjWXNXFYruD2JkeP/nwsOH7zM1GIskGn9anAxk3sb0O3ath7bOnvM+7gZ LOAA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753972169554116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that qemu_loadvm_state() must report an error in errp, in case of failure. Signed-off-by: Arun Menon --- migration/migration.c | 5 +++-- migration/savevm.c | 29 +++++++++++++++++------------ migration/savevm.h | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index d748a02712dc4ebc2de6b0488fb199c92c4d4079..0a5a8d5948b2b0a3f85163795e8= 4f71903870d25 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -881,7 +881,7 @@ process_incoming_migration_co(void *opaque) MIGRATION_STATUS_ACTIVE); =20 mis->loadvm_co =3D qemu_coroutine_self(); - ret =3D qemu_loadvm_state(mis->from_src_file); + ret =3D qemu_loadvm_state(mis->from_src_file, &local_err); mis->loadvm_co =3D NULL; =20 trace_vmstate_downtime_checkpoint("dst-precopy-loadvm-completed"); @@ -908,7 +908,8 @@ process_incoming_migration_co(void *opaque) } =20 if (ret < 0) { - error_setg(&local_err, "load of migration failed: %s", strerror(-r= et)); + error_prepend(&local_err, "load of migration failed: %s: ", + strerror(-ret)); goto fail; } =20 diff --git a/migration/savevm.c b/migration/savevm.c index f5903995edd2b4c4f6c1a214c7126d831f10c9f1..2ac341ed627c4a8db7ba7676363= d305c82ee3437 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3146,27 +3146,24 @@ out: return ret; } =20 -int qemu_loadvm_state(QEMUFile *f) +int qemu_loadvm_state(QEMUFile *f, Error **errp) { MigrationState *s =3D migrate_get_current(); MigrationIncomingState *mis =3D migration_incoming_get_current(); - Error *local_err =3D NULL; int ret; =20 - if (qemu_savevm_state_blocked(&local_err)) { - error_report_err(local_err); + if (qemu_savevm_state_blocked(errp)) { return -EINVAL; } =20 qemu_loadvm_thread_pool_create(mis); =20 - ret =3D qemu_loadvm_state_header(f, NULL); + ret =3D qemu_loadvm_state_header(f, errp); if (ret) { return ret; } =20 - if (qemu_loadvm_state_setup(f, &local_err) !=3D 0) { - error_report_err(local_err); + if (qemu_loadvm_state_setup(f, errp) !=3D 0) { return -EINVAL; } =20 @@ -3176,7 +3173,7 @@ int qemu_loadvm_state(QEMUFile *f) =20 cpu_synchronize_all_pre_loadvm(); =20 - ret =3D qemu_loadvm_state_main(f, mis, NULL); + ret =3D qemu_loadvm_state_main(f, mis, errp); qemu_event_set(&mis->main_thread_load_event); =20 trace_qemu_loadvm_state_post_main(ret); @@ -3194,8 +3191,14 @@ int qemu_loadvm_state(QEMUFile *f) if (migrate_has_error(migrate_get_current()) || !qemu_loadvm_thread_pool_wait(s, mis)) { ret =3D -EINVAL; + error_setg(errp, + "Error while loading VM state: " + "Migration stream has error"); } else { ret =3D qemu_file_get_error(f); + if (ret < 0) { + error_setg(errp, "Error while loading vmstate : %d", ret); + } } } /* @@ -3460,6 +3463,7 @@ void qmp_xen_save_devices_state(const char *filename,= bool has_live, bool live, =20 void qmp_xen_load_devices_state(const char *filename, Error **errp) { + ERRP_GUARD(); QEMUFile *f; QIOChannelFile *ioc; int ret; @@ -3481,10 +3485,10 @@ void qmp_xen_load_devices_state(const char *filenam= e, Error **errp) f =3D qemu_file_new_input(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); =20 - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(f, errp); qemu_fclose(f); if (ret < 0) { - error_setg(errp, "loading Xen device state failed"); + error_prepend(errp, "loading Xen device state failed: "); } migration_incoming_state_destroy(); } @@ -3492,6 +3496,7 @@ void qmp_xen_load_devices_state(const char *filename,= Error **errp) bool load_snapshot(const char *name, const char *vmstate, bool has_devices, strList *devices, Error **errp) { + ERRP_GUARD(); BlockDriverState *bs_vm_state; QEMUSnapshotInfo sn; QEMUFile *f; @@ -3555,13 +3560,13 @@ bool load_snapshot(const char *name, const char *vm= state, ret =3D -EINVAL; goto err_drain; } - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(f, errp); migration_incoming_state_destroy(); =20 bdrv_drain_all_end(); =20 if (ret < 0) { - error_setg(errp, "Error %d while loading VM state", ret); + error_prepend(errp, "Error %d while loading VM state: ", ret); return false; } =20 diff --git a/migration/savevm.h b/migration/savevm.h index fd7419e6ff90062970ed246b3ea71e6d49a6e372..a6df5198f3fe1a39fc0e6ce3e79= cf7a5d8e032db 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -64,7 +64,7 @@ void qemu_savevm_send_colo_enable(QEMUFile *f); void qemu_savevm_live_state(QEMUFile *f); int qemu_save_device_state(QEMUFile *f); =20 -int qemu_loadvm_state(QEMUFile *f); +int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(MigrationIncomingState *mis); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, Error **errp); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971971; cv=none; d=zohomail.com; s=zohoarc; b=WxEie1lrmDeYNy2nyWr0Y+A2/haLjNhn0cceg7Y37LpvKWqXhzyG9sASl1DocGPFqPd+ARAY8NhIqfL5Sqmr/MjJEkRPczfGhyYM04YFTgBNNfEHfvLI15lzWFy3DUgP2jV+viM5wKe4i7AH4cclxxMLdpu9dGy+Hz85nk6f46k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971971; 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=x2tdGwnYvDb9XOQql1y99JooK+eg1CMI9JdS5bG1ZsQ=; b=XV+F+Wgrw2b/q0wE2EObu51L6H3TYLQtM9SNtX28Nwb6/FUrxiVgddH8oOdNCN0JiVf0q0acF5m0eR3gjzSbpssJCXQog4mZAUyl5WZYVdHNGda3mxOTIH9Rj+fb/JkO90VEsmPgO7DElDHMKSj29fLwtX9mZUdg30Q6fI5ayNg= 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 1753971971022246.0814806480688; Thu, 31 Jul 2025 07:26:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUDJ-0002rI-3S; Thu, 31 Jul 2025 10:24: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 1uhTHg-0001aR-02 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:24 -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 1uhTHe-0000Mw-3K for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:23 -0400 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-5MTFgvD7N4mzO7S9WhqbGg-1; Thu, 31 Jul 2025 09:25:18 -0400 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-31eac278794so1013672a91.3 for ; Thu, 31 Jul 2025 06:25:17 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968320; 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=x2tdGwnYvDb9XOQql1y99JooK+eg1CMI9JdS5bG1ZsQ=; b=gIDVHMInX2AO/1B1w/mO+ONJFitD6lKFjitpkLvGBh326rIhOj5s3FPKQqOnTvZ8Lh4KPy OpYOcBU4CSbKPmrc/5gS04V3t1kO3Cj9jDQRclQocoyMJoytt6bOf3TKXPfSWdDYa3Gjyp UotAaQMTDezmsetjqo8jqdxusGA+n28= X-MC-Unique: 5MTFgvD7N4mzO7S9WhqbGg-1 X-Mimecast-MFC-AGG-ID: 5MTFgvD7N4mzO7S9WhqbGg_1753968317 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968316; x=1754573116; 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=x2tdGwnYvDb9XOQql1y99JooK+eg1CMI9JdS5bG1ZsQ=; b=VvMy8AWv+mG+V4o4hSnIA1bw1sDnyAVA6RoVak4CffaSsySDw4+121cSyhClIFgKVJ vjnreiJ9ob5sEx4kymxIUKrQNIP8DWZaK1xGDGLmOeZEGO+yOdC9scrchh10X99DTQVV wiSd5FpciEKwEY7qC56ew0JG/+9zNzU5LgnPFqHKbriDAWEwzySJ/4eS3qVtvc4VHH6h Wk9XFRycuOaSL/A6yj+HUqvRMviau5U189D9aPR86meWEJs4mSaWv60aUSYreA90tPNO Qpwj+g5z/J4DVJgeODIqcFRl6gzo8DmRPg9iCeUYkpGXXrPKwAqRBlj59I3UjbnQgwLb d5lg== X-Gm-Message-State: AOJu0Ywva21llmdBIlLbSENZtLFdjCZC2YEP7U+L3e5BQU6iytgTd5Kq /Mbn2KTWbv01LSKZNMt9K8M/wL/yHQSogZwR2jmGkTsrKuRNCCUn2+4Xv1Y8V6zxHkMviqnQKaf YOMaAGy2sFnwE2l+6lKZmFFE0+/lMFPN2mYHJR1qH28tPHsDo4utottWxQ0ufgrNY0m9xIb6+Nd 241XYTPJmc7WwxZcUieFBGUI8JyuLNMFz7dpj2Xh4Dww== X-Gm-Gg: ASbGnctWGrAxcABNqSx5UQevtR6Ik020u70bBcobwkTKppzHhGf3aBMXjcUiqx1GVKo Zdi/qlBastJYM4SlLVZNw3mq6jyzU5ILHynnGce/ANXY1eO2sfYfBWpOKxKijnemXfJb2/0kWtQ 9Yg/4PxT3vWSHNA8v9IxWTAsiwp1dYhCbZ9CBMlLFQSxLuo3U2fzHkUxPO1Y77UKM7QFlIkpO9d s310hkhEitS8IdKQiqAFWngG/ZMdXqETjJbhthTx5f1wMNs7ykIcR6umo5Ey9splggjGXv9kAhq OwJhjit8k9eH4dqOSHo6+TA80qdqwjYW1hfRNOf4tb6l20HHQCXe X-Received: by 2002:a17:90a:dfc6:b0:312:39c1:c9cf with SMTP id 98e67ed59e1d1-31f5dd7f4e2mr9317176a91.7.1753968316236; Thu, 31 Jul 2025 06:25:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEt+6Rc+NUWBMHtiDdazxUJha459O4+HeE8c1Y9oGsMRHFR76JyojR+cOdvGQgfNZD6F3T6bw== X-Received: by 2002:a17:90a:dfc6:b0:312:39c1:c9cf with SMTP id 98e67ed59e1d1-31f5dd7f4e2mr9317100a91.7.1753968315534; Thu, 31 Jul 2025 06:25:15 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:01 +0530 Subject: [PATCH v8 21/27] migration: push Error **errp into qemu_load_device_state() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-21-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=2682; i=armenon@redhat.com; h=from:subject:message-id; bh=VZWo92MSWBEQmawCHTpfJOnPbor5WfeU0jM5DJ09Evc=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rOkTbNsBEU42yWCg3w2ClRL+r0RsvmXu2Nx7Bvuk KlVxjkdpSwMYlwMsmKKLA1fA2SbAgojIm1fXoeZw8oEMoSBi1MAJrK6g5FhRUDQRJa8xXbpwQq3 2mrrGx/c4VwV+/9tM+/7vomT5qp2MjIsX9h8UdO1euLH7EsHxHdJN4ktqM4P/bFgyiy3Q6+aVqx jBgA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971972964116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that qemu_load_device_state() must report an error in errp, in case of failure. Signed-off-by: Arun Menon --- migration/colo.c | 4 ++-- migration/savevm.c | 7 ++++--- migration/savevm.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 529794dfc8d943b8ba3a25391ee2132c0c3f312e..71842c798a1dbbea6a7ccf8cb64= e2c836c0f574c 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -730,9 +730,9 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, bql_lock(); vmstate_loading =3D true; colo_flush_ram_cache(); - ret =3D qemu_load_device_state(fb); + ret =3D qemu_load_device_state(fb, errp); if (ret < 0) { - error_setg(errp, "COLO: load device state failed"); + error_prepend(errp, "COLO: load device state failed: "); vmstate_loading =3D false; bql_unlock(); return; diff --git a/migration/savevm.c b/migration/savevm.c index 2ac341ed627c4a8db7ba7676363d305c82ee3437..3bc36b92dcfb7c65ef0d312d634= 0dbc73caa6ada 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3247,15 +3247,16 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) return ret; } =20 -int qemu_load_device_state(QEMUFile *f) +int qemu_load_device_state(QEMUFile *f, Error **errp) { + ERRP_GUARD(); MigrationIncomingState *mis =3D migration_incoming_get_current(); int ret; =20 /* Load QEMU_VM_SECTION_FULL section */ - ret =3D qemu_loadvm_state_main(f, mis, NULL); + ret =3D qemu_loadvm_state_main(f, mis, errp); if (ret < 0) { - error_report("Failed to load device state: %d", ret); + error_prepend(errp, "Failed to load device state: %d: ", ret); return ret; } =20 diff --git a/migration/savevm.h b/migration/savevm.h index a6df5198f3fe1a39fc0e6ce3e79cf7a5d8e032db..c337e3e3d111a7f28a57b90f61e= 8f70b71803d4e 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -68,7 +68,7 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(MigrationIncomingState *mis); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, Error **errp); -int qemu_load_device_state(QEMUFile *f); +int qemu_load_device_state(QEMUFile *f, Error **errp); int qemu_loadvm_approve_switchover(void); int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, bool in_postcopy); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971797; cv=none; d=zohomail.com; s=zohoarc; b=OtON+xW0b7VKs89fDPoY0jo58DGeSeXiUf5udsXvvDq7o5I7TEV+4QpDB1zHyMHc8jOJA37KlvYH/ppt9r802yWyp0e8/S3DpBZ/BsdhcKhIlsYKMcyqOMf1uLRiCvb0E4Dx8PcaACVPo2EL7UYX8KLcOtM+cDIg9yD76IC3tt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971797; 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=q41CbZyk6EWJwfzlItcJnMM+40hpq9ZWZ11m7GyTZac=; b=mxHvHOfpozCPQQKg6o+aWg37WseSZLuHvTvVkViM6NNmSE9hi8CipZSoNRYEXXLXd9XUWyKI0sW5Onr329lYQqp+Z6UukXlTleyrVDkx4D6uN5ocLPe/zb5DA1XLJRWjAfV0mBCHaPp7BHUhU+IUY/g7f3rZ3thlB3bYMElO6GM= 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 1753971797874107.11398152072218; Thu, 31 Jul 2025 07:23:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUBR-0003UO-Ip; Thu, 31 Jul 2025 10:23:02 -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 1uhTHm-00023g-L6 for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:30 -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 1uhTHk-0000OE-PK for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:30 -0400 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-ugZcmNlFPmOWctz_4z2whQ-1; Thu, 31 Jul 2025 09:25:26 -0400 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-31ea10f801aso741195a91.3 for ; Thu, 31 Jul 2025 06:25:26 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968327; 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=q41CbZyk6EWJwfzlItcJnMM+40hpq9ZWZ11m7GyTZac=; b=TD7rxkrbHRGUdKJ1QRr3F8QTk7poHVxFrFUK9CxmL1f+SgXRdTQDWoFU2he5hfQyl3nRhz nmwAMRMVGDbnm19/1nhSR2xkpy94qnbjHYzlEpW6qzcTlZM0RLG1j0glWCmYnxqoVfHSEq 6iGB5pCk5VBYZeQbMfXGeyhg0PAMj/I= X-MC-Unique: ugZcmNlFPmOWctz_4z2whQ-1 X-Mimecast-MFC-AGG-ID: ugZcmNlFPmOWctz_4z2whQ_1753968325 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968325; x=1754573125; 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=q41CbZyk6EWJwfzlItcJnMM+40hpq9ZWZ11m7GyTZac=; b=VNed5T4BChJq4ft44DldhpZoaSMCByA4TBpTe5xnMj+7SqfyiMOiodhAreSvyv3u5X VbGiePOAJ/Cu6/C5AQMmeQBxipPELMBYlt2hEAkDpjrF4Ufay/8xJnP9AP+v/fboRN8g Hw44CDVkhPVeL4f/0+B1+dWvSQe9TMDxq4aByLchXrV7RUzLKF6eYTmzxR9IwZaPt1BY HCki/O0WUr8L7/r77iCIe9v9UljlygSnzmJ7mIG3RMHRPDR1i8lNTwtieyWmxc/z4hkN m9bju9h9YVM+qp0SlTeiX3Fw8SEb9iVlmYpg95sz0FO5ng1/9/8hWzTVqCE5uDPZUO4V Fhxg== X-Gm-Message-State: AOJu0YwdDR6gViMirbY6Wx7Kf4d8KqzbpycYtv+dh0/N2DgT+hr6A0tR 9ZXqYMgot2UoDC9eywk8qE5XmKnPqEMDJkM3Ltbqa/dClRzG8GD/eP+GiJT5OQgWvKn0zsr5Syp DT2aoObQPmG1UcjzGlktE8nTSyrZEAjt9bvkwk4SOefP0eXzvDj/q5PDwF+tjC7ghleT/lZhMTc 3ibtjRk1Lv7L6bBlOk3yYiJ/+yONHE/qpu2AB9ANMqEw== X-Gm-Gg: ASbGncvwouZ+09Slx76x2/PhgeiKEPweEpOn5P4kUwmpUOQD7lgBwiFlaF9ihC2TrH0 pmdM+k6B9xVa89FePN8aS+8E0q/YeIe17l2XvY+6iLhTrTKh1Mtj4RVm4HDXf2TIvHi0g2sbjf2 NPWfZ0G2o5KlyB6daPLB6M2fRLatt7DwToP3Yzfs2Ram14OtnS1qo5ytGlVm2UT+sSv7LIdh91r OpLpFjcMbuMkeTcDAANjJ80TUb+s+osE5i1zT8xiQ/ijU37gJd9XImwwG4CweWuTK+KieqcvUYO DbODQWuFWc9724DwSDelPj4HxuTjwRHW8Wuy1z0NfyzOuHkm1kD9 X-Received: by 2002:a17:90b:248a:b0:31f:104f:e4b1 with SMTP id 98e67ed59e1d1-31f5ddb7eb9mr7072053a91.7.1753968324845; Thu, 31 Jul 2025 06:25:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAMvUmxZwZJLMuA+dYDR6MP0W6BsqFWBcJvd8vioaCyBKzR8fJIC9kAOiV8swIYDOq+Fs3Zw== X-Received: by 2002:a17:90b:248a:b0:31f:104f:e4b1 with SMTP id 98e67ed59e1d1-31f5ddb7eb9mr7071995a91.7.1753968324336; Thu, 31 Jul 2025 06:25:24 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:02 +0530 Subject: [PATCH v8 22/27] migration: Capture error in postcopy_ram_listen_thread() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-22-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=3026; i=armenon@redhat.com; h=from:subject:message-id; bh=fBBcHspeBvHFbaQktvvk5fZdIluN9yDL2XhMjVwsdbM=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37rO34SG2n88nrXh9f4H0+Y3dq6cXzFu61039zdWCR IvQ8v4/HaUsDGJcDLJiiiwNXwNkmwIKIyJtX16HmcPKBDKEgYtTACZiJsDIcOUP6+I/06UXaDka py8JfhJ69lfvo70xgg+dOLb9yy/9EMTwP+7vqtQjT5km5qhOMFh+RlRo8Zr01bZp9m3q/lcjjoT NZAIA 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753971798790116600 This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. postcopy_ram_listen_thread() calls qemu_loadvm_state_main() to load the vm, and in case of a failure, it should set the error in the migration object. When postcopy live migration runs, the device states are loaded by both the qemu coroutine process_incoming_migration_co() and the postcopy_ram_listen_thread(). Therefore, it is important that the coroutine also reports the error in case of failure, with error_report_err(). Otherwise, the source qemu will not display any errors before going into the postcopy pause state. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Arun Menon --- migration/migration.c | 2 +- migration/savevm.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0a5a8d5948b2b0a3f85163795e84f71903870d25..4a76d7ed730589bae87115368b0= bf4819f8b161e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -925,7 +925,7 @@ fail: migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); migrate_set_error(s, local_err); - error_free(local_err); + error_report_err(local_err); =20 migration_incoming_state_destroy(); =20 diff --git a/migration/savevm.c b/migration/savevm.c index 3bc36b92dcfb7c65ef0d312d6340dbc73caa6ada..071044921bed02f027571b2a832= f339990e547ee 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2095,6 +2095,7 @@ static void *postcopy_ram_listen_thread(void *opaque) QEMUFile *f =3D mis->from_src_file; int load_res; MigrationState *migr =3D migrate_get_current(); + Error *local_err =3D NULL; =20 object_ref(OBJECT(migr)); =20 @@ -2111,7 +2112,7 @@ static void *postcopy_ram_listen_thread(void *opaque) qemu_file_set_blocking(f, true); =20 /* TODO: sanity check that only postcopiable data will be loaded here = */ - load_res =3D qemu_loadvm_state_main(f, mis, NULL); + load_res =3D qemu_loadvm_state_main(f, mis, &local_err); =20 /* * This is tricky, but, mis->from_src_file can change after it @@ -2137,7 +2138,12 @@ static void *postcopy_ram_listen_thread(void *opaque) __func__, load_res); load_res =3D 0; /* prevent further exit() */ } else { - error_report("%s: loadvm failed: %d", __func__, load_res); + if (local_err !=3D NULL) { + error_prepend(&local_err, + "loadvm failed during postcopy: %d: ", load_= res); + migrate_set_error(migr, local_err); + error_report_err(local_err); + } migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIV= E, MIGRATION_STATUS_FAILED); } --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971593; cv=none; d=zohomail.com; s=zohoarc; b=b2d/Gv4Yi0YplZ4NLv7o5AzQhOCcpcU9nbaP9UPny52T2Y4RLasDqrNaQSDCShkL8ZH/beBfHGJzv2M1qSp/8exHB/vdvYmhRpvfBPkgy8abLelPmK9wUuHzg0DJOkxng3x3RVHViyIXoYG+tzdL7WLGud7Itx79oTft5//kTXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971593; 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=Ie03UL/e0zjWpu2wXMCsfga71bFRAfQb7J1DQVdmwYw=; b=bHolyTBX5sZwdOhTbbut2HH1TpPDodEalqKdMfC4zwD8gkQdPccCmhs8Y83YTt27cXz7bx65A0KzGJ55KX2PFGrOFKdzRq1cVAy26li3EFWcfjR1ilmh1GtHkydisMFw8+fILux+TDKt8XGrBdhPDPe9HjAxmU6luDMc24Lmc8o= 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 1753971593043336.84516358625035; Thu, 31 Jul 2025 07:19:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU2H-0000PU-SZ; Thu, 31 Jul 2025 10:13:33 -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 1uhTIB-0003MH-Cu for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:57 -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 1uhTI5-0000Rp-UX for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:54 -0400 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-xFxDXk7eNCqxAXbAKLDIZQ-1; Thu, 31 Jul 2025 09:25:45 -0400 Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-b42249503c4so1192521a12.0 for ; Thu, 31 Jul 2025 06:25:44 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968346; 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=Ie03UL/e0zjWpu2wXMCsfga71bFRAfQb7J1DQVdmwYw=; b=WE01v8HIEiYk91Ie44CkivP89tfU9AaKVBFRM3xhvCZrR61WR1QWbXmUmbEn/F2os4GpyF MmkrDa689H72c7pL3tHI7iIzoKGBZ8WAimSdLJolMe+y5boWjYIFb8QsYuVxG8mgvW0tix sj/KT2VFtTBVqgvfixeNRUgoCvfcGLA= X-MC-Unique: xFxDXk7eNCqxAXbAKLDIZQ-1 X-Mimecast-MFC-AGG-ID: xFxDXk7eNCqxAXbAKLDIZQ_1753968344 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968344; x=1754573144; 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=Ie03UL/e0zjWpu2wXMCsfga71bFRAfQb7J1DQVdmwYw=; b=TWk6akJBcCBJ5h5PqWlyY+NC7KLs+cqPK1q6Pdpw6l7s69Kzdd0vlPO/AaGtw1Z/vj TPVYGNmnZuUT6SEHkE2EVPg2u7tyFatooJ9xuSTO0sHfRPNnbQoaKo3KXFJcrtI4yyvi leD3ZGKr18aCTKvGvmiNKO0x2wATbEsqmi0v1/Xsu90cFtD1JOBaaaSx20qGD/Fb/k4O R/nM42B8kv4Drvcs9K+VmG/bMTPT4Df4TW5l/w+0vVr7ShmftJajk+F9UsJHgCYn4OsG XMMHRY4vv2j/3K/25bycO8vrvxEnhqEk2RF1y05pU4DlLvVU2EYUI3EvcpduyJXRZtTR DX/Q== X-Gm-Message-State: AOJu0YxROaztSkXXDnacJqws0AgwTPyciFiqz2DPGKRU6TlEg9OigdwQ rnx0g+PRNgj6f2baR6hau7+8+GFsm31tiszWvukkkpu5gcydX1BU6agZ+s3jXX0zWOrfWT9c1RA PWXdrjcn/toaGVzozOEsv7YYPxkkoCfRpihTLWZ+Av1mnlefzzmV9+lRSThl/4/gkJtHn5B8IUs vWzDcfNUqcvW2PYIXI6mvfmgstlJO7iC4iFa3k1s0GGg== X-Gm-Gg: ASbGncvwNzg2QZFRRxCasaen/7iHbU8H/U/QHX7FFjlItmZVCwYJMztP+9g723Vkk28 FqTDgTIeUAfwFxU9WvVhRJbsJrPMiL2LhmmJGINGnr2yxaayfs5azDM2K++xQWCG3oYSXIhTzy4 Siy7E5up8aaFEptCIVoZ1GuI5Mhl4Yb95DkWkbfplYR8SIUeAedLcF0+CfWc/cRDERLfGrVa1tX SGI6AjaDpvMCx9AQCOTAT6Jr2YMxbqeb/u+WcqfydOhEDz8MwUdTZZCprkfPk5YuceyMe1Srkc+ fBauOfiWwV1DVLf3nEzuCkJkoH02gI1JudJ3GyQTpDBoFvNSKmb2 X-Received: by 2002:a17:90b:1e08:b0:312:dbcd:b94f with SMTP id 98e67ed59e1d1-320da5db33bmr3026332a91.11.1753968343463; Thu, 31 Jul 2025 06:25:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFs2qA7ABmrPDlwEuQddok3IMT6nI/WDNfoR5Z1lOvMTTx++entz+1uUqebihTBWx0QRWDazg== X-Received: by 2002:a17:90b:1e08:b0:312:dbcd:b94f with SMTP id 98e67ed59e1d1-320da5db33bmr3025736a91.11.1753968333496; Thu, 31 Jul 2025 06:25:33 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:03 +0530 Subject: [PATCH v8 23/27] migration: Propagate last encountered error in vmstate_save_state_v() function MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-23-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=2534; i=armenon@redhat.com; h=from:subject:message-id; bh=oA7/haUdk80U620L61W03FFxXXZTo082B5XNVpXtEvg=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37nMlyaQM25cZ19e57TT8+lo0NeR8/t6VGyaveDyNQ 04ryyqxo5SFQYyLQVZMkaXha4BsU0BhRKTty+swc1iZQIYwcHEKwERuHGT4K6hybW/Oi0BZxWZ+ 1e4v67I+bi4PjZy+/wHPRYtZDqlPIhgZnm2+vyRRWcxjk5DbfhP7O0/d6x2ehASJlc/a22lwPuo PIwA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971594545116600 Currently post_save hook is called without checking its return. If post_save fails, we need to set an error and propagate it to the caller. Since post_save hook is called regardless of whether there is a preceeding = error, it is possible that we have 2 distict errors, one from the preceeding funct= ion call, and the other from the post_save call. Return the latest error to the caller. Signed-off-by: Arun Menon --- migration/vmstate.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index b725202bfcf69c3c81338f1f5479aa2ddc5db86f..25a819da069b982d4043f287b45= 62ea402d9eb0e 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -418,6 +418,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, void *opaque, JSONWriter *vmdesc, int version_id,= Error **errp) { int ret =3D 0; + int ps_ret =3D 0; const VMStateField *field =3D vmsd->fields; =20 trace_vmstate_save_state_top(vmsd->name); @@ -533,7 +534,14 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDes= cription *vmsd, error_setg(errp, "Save of field %s/%s failed", vmsd->name, field->name); if (vmsd->post_save) { - vmsd->post_save(opaque); + ps_ret =3D vmsd->post_save(opaque); + if (ps_ret) { + ret =3D ps_ret; + error_free_or_abort(errp); + error_setg(errp, + "post-save for %s failed, ret: '%d'= ", + vmsd->name, ret); + } } return ret; } @@ -561,10 +569,12 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); =20 if (vmsd->post_save) { - int ps_ret =3D vmsd->post_save(opaque); - if (!ret && ps_ret) { + ps_ret =3D vmsd->post_save(opaque); + if (ps_ret) { ret =3D ps_ret; - error_setg(errp, "post-save failed: %s", vmsd->name); + error_free_or_abort(errp); + error_setg(errp, "post-save for %s failed, ret: '%d'", + vmsd->name, ret); } } return ret; --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753972027; cv=none; d=zohomail.com; s=zohoarc; b=Vlqk7XXJyb96oMIdbqi4HHMImALxVQ3J/57Co2N9uwvXWlNRdzuTV8vH3ZkYiSYa/uRsEoUSIm2xI176L+MjudCgOOVyZRUOEsZkX4xHYyT/qqPdwP2WsQHfi2qls3sp8gwI5OCiC4DFvTF80Kz3TQhmvqvMWxuUy/tAM1/MfjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753972027; 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=2OrRpnTKSAzXf76/A6MXcginXwGhQ0toXTEhBlZCIns=; b=KnRIh+QOo23scFOlRydIWHTNUgPp/q3DqUr1Dq+u1LXIOnZY6GdICswkMNkmvIjLLdGmwFivm9BsXPPbZX8e7wiP3/chxwzElj11XOSYwPi5FYTEXAbddZViSVeQDtFPwxdFImfz7EZxEJUCf7EAa95/Pd6hh7NQGmA0/6dA6Ys= 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 175397202741166.33250761085048; Thu, 31 Jul 2025 07:27:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUDf-00057l-VM; Thu, 31 Jul 2025 10:25:20 -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 1uhTI6-00031t-Ps for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:51 -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 1uhTI3-0000Rc-Hf for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:25:50 -0400 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-HIBBmfgRMIW1QGmaMtZpkg-1; Thu, 31 Jul 2025 09:25:44 -0400 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-31f65d519d3so726033a91.2 for ; Thu, 31 Jul 2025 06:25:44 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968345; 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=2OrRpnTKSAzXf76/A6MXcginXwGhQ0toXTEhBlZCIns=; b=I9znyoVqXIrx33WyzFizVxGoN21d7QNEmp6B/UmXGgaJxhekmhAX0GvlodpNohngtN2adI 3DeG/V5Vi6voTjYlftdj3Kryh3zGD6qyn2KKQc2zDXclmW1mPwNOXyfv/cvxoT/m3EdM55 /YEWVBHAorjKR3nY+NFkekauX0/I7Hw= X-MC-Unique: HIBBmfgRMIW1QGmaMtZpkg-1 X-Mimecast-MFC-AGG-ID: HIBBmfgRMIW1QGmaMtZpkg_1753968344 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968343; x=1754573143; 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=2OrRpnTKSAzXf76/A6MXcginXwGhQ0toXTEhBlZCIns=; b=aa0skoeR5eplOKtyyJ4SnP6M8unP/Si3Vpsqzesaw3lElMCiTlIvUbE0QkZkaI8KFA 9uEXsxu/qCoKmLGNyEuUFjOkoguSpUMceQZt96E6o3ZHQskg3gj1LSNF0zgyjtZFFVWD oPZs3UefvhxdOIUcH5G5KCYlBb8dltZgVXHrUJn0kiaoaoU6w8sm6iml09yQODpWzpWG 3e1H6UTUrrnzLj8V+uGVYKz16O4X1Z4RZSfQ/KBhDZ4/Ugdy2O6+452QI+UEeBgpNZH2 6PPqOM3ujS3QLIO3YpcMEPqIP3jurf1wGwSf0WHtXbqUb7BCiuwnT+VsseZ0Th0fA51j bccQ== X-Gm-Message-State: AOJu0YyzxLWbvoygTp0Jr+nLV9LEeo1lhxHynuXp1P3zsVHlH5SMGREJ HbFSKKoIkC9v7jSMJ1qokukE0Sq4DRUH9xxJgYAVTDJjZFuWAMZFTu4eMJ94eYqYmbpvbuHKEgh WjvnC77XA8idv4DZCgyld+FXb4OIy/oYHWo90wddQc1GkRMj6mUA+62muZMmrApjA/ilewcVGdY Uc8C+NJz8JJJ3NY7XHrkeGY5R2Vt6Ff1GY3f+UnEq+Lw== X-Gm-Gg: ASbGncvtKftzFHP3AWypMyVjZwlBw6iZ9itKxLVrRNW5KHngDXAz6GlMi+jJk1TrUdY 8jf8oofb7IrSQkR88/UNADfpN+dUaiasUit6kKFuD9l3kGqTv9knzvcBBWNRw8dJTCr7lftS2p6 MIOSmwwHq2bzViphaiQ9ZZrERnFnLax4m+IEwDG/eM04w7Vk89VMmFV18dogQuRiP2K6G76nkxt DqsL8mDoV/NeYmrpKcH9jCOpZwDnirZD7+VnAf5yizWtZVCHXzS/fOVtLrhxZppER66ikMP6qLE Ig/dM7+jrCLW02uLZMciU49tBFckqqvVk30Qharbtvcks1yn7Vme X-Received: by 2002:a17:90b:2b4c:b0:312:e9d:3ffa with SMTP id 98e67ed59e1d1-31f5de95105mr9782283a91.31.1753968343159; Thu, 31 Jul 2025 06:25:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyjxGDiHFSfuB+nPBAd3w21H/IaYZYPlJ/7woa/uq8nbwIo3cP+cY/SCIwIVcr33aD6nd+pA== X-Received: by 2002:a17:90b:2b4c:b0:312:e9d:3ffa with SMTP id 98e67ed59e1d1-31f5de95105mr9782213a91.31.1753968342644; Thu, 31 Jul 2025 06:25:42 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:04 +0530 Subject: [PATCH v8 24/27] migration: Refactor vmstate_save_state_v() function MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-24-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=5112; i=armenon@redhat.com; h=from:subject:message-id; bh=jVkG3CMlD4VGW1wmUquk34ldSco5mD63TT/CrbF8g5g=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37vM1Oebvzt33dprEq7qx300scwvHFbOT3zXFVNawy 4owpR3qKGVhEONikBVTZGn4GiDbFFAYEWn78jrMHFYmkCEMXJwCMBGefkaGhX+PeR5k3yFTZ1/E wbE9IKFRbcbUsyXigYK77CyEXzi/ZGRYl5O3Zl3KepWJMrIyh21s7LJO2Nv+W7pxrugmzfDsrCo 2AA== 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753972029502116600 The original vmstate_save_state_v() function combined multiple responsibilities like calling pre-save hooks, saving the state of the device, handling subsection saves and invoking post-save hooks. This led to a lengthy and less readable function. To address this, introduce wrapper functions for pre-save, post-save and the device-state save functionalities. Signed-off-by: Arun Menon --- migration/vmstate.c | 89 ++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 64 insertions(+), 25 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 25a819da069b982d4043f287b4562ea402d9eb0e..cec1ee2f30d6f0270ee1fd30d29= f6f0f5d20bdb0 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -414,23 +414,43 @@ int vmstate_save_state_with_err(QEMUFile *f, const VM= StateDescription *vmsd, return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_= id, errp); } =20 -int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc, int version_id,= Error **errp) +static int pre_save_dispatch(const VMStateDescription *vmsd, void *opaque, + Error **errp) { int ret =3D 0; - int ps_ret =3D 0; - const VMStateField *field =3D vmsd->fields; - - trace_vmstate_save_state_top(vmsd->name); - if (vmsd->pre_save) { ret =3D vmsd->pre_save(opaque); trace_vmstate_save_state_pre_save_res(vmsd->name, ret); if (ret) { - error_setg(errp, "pre-save failed: %s", vmsd->name); - return ret; + error_setg(errp, "pre-save for %s failed, ret: '%d'", + vmsd->name, ret); } } + return ret; +} + +static int post_save_dispatch(const VMStateDescription *vmsd, void *opaque, + Error **errp) +{ + int ret =3D 0; + if (vmsd->post_save) { + ret =3D vmsd->post_save(opaque); + error_setg(errp, "post-save for %s failed, ret: '%d'", + vmsd->name, ret); + } + return ret; +} + +static int vmstate_save_dispatch(QEMUFile *f, + const VMStateDescription *vmsd, + void *opaque, JSONWriter *vmdesc, + int version_id, Error **errp) +{ + ERRP_GUARD(); + int ret =3D 0; + int ps_ret =3D 0; + Error *local_err =3D NULL; + const VMStateField *field =3D vmsd->fields; =20 if (vmdesc) { json_writer_str(vmdesc, "vmsd_name", vmsd->name); @@ -533,15 +553,11 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, if (ret) { error_setg(errp, "Save of field %s/%s failed", vmsd->name, field->name); - if (vmsd->post_save) { - ps_ret =3D vmsd->post_save(opaque); - if (ps_ret) { - ret =3D ps_ret; - error_free_or_abort(errp); - error_setg(errp, - "post-save for %s failed, ret: '%d'= ", - vmsd->name, ret); - } + ps_ret =3D post_save_dispatch(vmsd, opaque, &local_err= ); + if (ps_ret) { + ret =3D ps_ret; + error_free_or_abort(errp); + error_propagate(errp, local_err); } return ret; } @@ -565,17 +581,40 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, if (vmdesc) { json_writer_end_array(vmdesc); } + return ret; +} =20 - ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); =20 - if (vmsd->post_save) { - ps_ret =3D vmsd->post_save(opaque); - if (ps_ret) { - ret =3D ps_ret; +int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, JSONWriter *vmdesc, int version_id, + Error **errp) +{ + ERRP_GUARD(); + int ret =3D 0; + Error *local_err =3D NULL; + int ps_ret =3D 0; + + trace_vmstate_save_state_top(vmsd->name); + + ret =3D pre_save_dispatch(vmsd, opaque, errp); + if (ret) { + return ret; + } + + ret =3D vmstate_save_dispatch(f, vmsd, opaque, vmdesc, + version_id, errp); + if (ret) { + return ret; + } + + ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); + ps_ret =3D post_save_dispatch(vmsd, opaque, &local_err); + if (ps_ret) { + if (ret) { error_free_or_abort(errp); - error_setg(errp, "post-save for %s failed, ret: '%d'", - vmsd->name, ret); } + ret =3D ps_ret; + error_propagate(errp, local_err); } return ret; } --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971558; cv=none; d=zohomail.com; s=zohoarc; b=Ed0NnaiLyxvj5HHrBlfUrkXMgAjwWdrMey7RO+aBnNI0s9U8nJKdAsvYFea2Zd9kmX3nHwHtpFlY2EJOW7oGGOwuD0te7AuKly5aOlhjY/FuP8mzbgwshH7t7XONpKwK7peDrLfTxp1RqyMY6QdGFNLzbHpeYt+BqXeMLZ01FNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971558; 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=9hLeYli4yMzuLz88VWY5zdey8bg/KPTb0xmUuak2Q1o=; b=KKV7+dOtMkSsNJws7oXbagYZ64DhhDxO7VRuyHXbMNP66oBiybz50v8ydrbLjAkksukr8wP5HXZ8zaWb1tP6gIlcbLZJIrgGY4QVapYDfB8tX8/svTyG8iEaNYZnbbnN+2Lewo4mL7x4fARPPty4YG9SRSXmvsHkxcOu93d/4a8= 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 1753971558124897.6603012209001; Thu, 31 Jul 2025 07:19:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhU2K-0000lF-4z; Thu, 31 Jul 2025 10:13:36 -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 1uhTIJ-00042S-Nt for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:26:03 -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 1uhTIF-0000UO-8J for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:26:03 -0400 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-wgFLM0PpMyGUDQX1rsE_Wg-1; Thu, 31 Jul 2025 09:25:56 -0400 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-b2c00e965d0so785531a12.2 for ; Thu, 31 Jul 2025 06:25:56 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968358; 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=9hLeYli4yMzuLz88VWY5zdey8bg/KPTb0xmUuak2Q1o=; b=Q7DTfPAr6FtHzCq1ADwZm93OmcWZ3siNf5nGxyB+1jCeC7tId5fA2bKcYrrVksrpzmPk7H QCnnI/9B3MDac9rgoqk50Z79y950FHbpBTzW4d/OukAPnxm1sSBBL5Yf/Ee5jsMbnaDF8u cgvjO3CgkZoCcnijaW3u9IDqaEe6fPQ= X-MC-Unique: wgFLM0PpMyGUDQX1rsE_Wg-1 X-Mimecast-MFC-AGG-ID: wgFLM0PpMyGUDQX1rsE_Wg_1753968356 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968355; x=1754573155; 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=9hLeYli4yMzuLz88VWY5zdey8bg/KPTb0xmUuak2Q1o=; b=X5C6pTyysW6gLQ9wZV9nM/q/Q/4xskUXCq2R1aVlSW2UXNd35A6Z/GuqhUK8P6khJM 1W4S18lul5yL2GI70tdpCjmlRVtbNZQNaFlr5wMNAUd8MtMO7FN1P4en9EmEepbDRFrl OAlRM3MLsw4+TNSw7PsWVivvdxCrNzbt1LpnhJgcBPV6ePzqJtsaSldJbcTBfvgqiVc2 1bTRCsQbzdokTo89IfWawqhqGjZpYim5jpvLQrE92dg4BRruFcWnnDjFsZ9Q0chOnwkT IrKcaiSh/uZYozdgTqymaNsbzOYzf3mYqIfNeHMMQRn05WNs3bTiclyb4w1DiQPGHY++ +ifQ== X-Gm-Message-State: AOJu0YxHHX0Y0j1JCWxsBQBqK1y5ddQ7+FhGMxLlq5vfGGf9ljfrX2te oCWID8oxLPdOA7vzXwi9YBQOjngmbsarQrTprvIky2uVNl+aY86XSmI7WfdLVyheqJRZMRliie5 YklZ5vNYcarSebx8KvjftKsTjSAjceOH3H+4xxlJk2v9OnuitDP6R7W5y/KJxuQ1RB+tz/43vWp O+/yt8H4JdBzDrIZT4xbO5osGbZV/31IxlFFw0C5tdDg== X-Gm-Gg: ASbGncuNMfN/BusAxF7v3S4FAZYNjwZRyn30gewS7lH5Zq46k5PtxZuczporVDEtsUw KDW8xf7ccfGDUc8nRd/HB79jtkm1k0YM4h+ynwOisor8iEfSubpttlykCZnSo7/J+9v5qWPjlgI +4d52k8Oi4+i1b+bTdUSftP7gegn7QTA/dSqPua1BLxTlWJw+JmwwpUIw5GxJGuPAJV2y6iu6lw ATueJPL2Tnv33xrLfEDfcIKW/rv16/scrBBS4ltDncVzl80PWLH7D4sqGHUZxttEHQuq+MpmfY1 OdZLDGyEApdaCQY8a/SNSiLRq3r+8pH/co4NosoKrOQeSH5bOUs1 X-Received: by 2002:a17:90b:2885:b0:31f:210e:e34a with SMTP id 98e67ed59e1d1-31f5dd9dcb4mr10912191a91.8.1753968354942; Thu, 31 Jul 2025 06:25:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQgfpK9ufUhX9ovLfYZHkqVTRJtWPwQoOcv4kMxw54B4u7Tauc58eiOcnFhf/aLgpp/LfC7A== X-Received: by 2002:a17:90b:2885:b0:31f:210e:e34a with SMTP id 98e67ed59e1d1-31f5dd9dcb4mr10912089a91.8.1753968354083; Thu, 31 Jul 2025 06:25:54 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:05 +0530 Subject: [PATCH v8 25/27] migration: Remove error variant of vmstate_save_state() function MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-25-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=16946; i=armenon@redhat.com; h=from:subject:message-id; bh=bERyEzs/IGj8/4W6+DY5ZoqFTGezaBYQ5VJKOpmSUrA=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37nOeNUJ/nkTekHZZaOkpavvegKW8SrTMUNdLw/HWz a9tKlM7SlkYxLgYZMUUWRq+Bsg2BRRGRNq+vA4zh5UJZAgDF6cATOTFEkaG7w9K+q32Ltkhpcmx 1DO98VnCmwMrb117qrWx78G0o26OEQz/vfe+/XRo8r2vUSK9YbO6FRT8gvJ0PvzTOSRg//LK/zk WPAA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971560495116600 This commit removes the redundant vmstate_save_state_with_err() function. Previously, commit 969298f9d7 introduced vmstate_save_state_with_err() to handle error propagation, while vmstate_save_state() existed for non-error scenarios. This is because there were code paths where vmstate_save_state_v() (called internally by vmstate_save_state) did not explicitly set errors on failure. This change unifies error handling by - updating vmstate_save_state() to accept an Error **errp argument. - vmstate_save_state_v() ensures errors are set directly within the errp object, eliminating the need for two separate functions. Specifically errors are handled by storing them in errp in vmstate_save_dispatch() All calls to vmstate_save_state_with_err() are replaced with vmstate_save_state(). This simplifies the API and improves code maintainability. Signed-off-by: Arun Menon --- hw/display/virtio-gpu.c | 3 ++- hw/pci/pci.c | 2 +- hw/s390x/virtio-ccw.c | 2 +- hw/scsi/spapr_vscsi.c | 2 +- hw/vfio/pci.c | 4 ++-- hw/virtio/virtio-mmio.c | 2 +- hw/virtio/virtio-pci.c | 2 +- hw/virtio/virtio.c | 4 ++-- include/migration/vmstate.h | 2 -- migration/cpr.c | 5 +++-- migration/savevm.c | 7 ++++--- migration/vmstate-types.c | 12 +++++++----- migration/vmstate.c | 18 ++++++++---------- tests/unit/test-vmstate.c | 6 +++--- ui/vdagent.c | 3 ++- 15 files changed, 38 insertions(+), 36 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5ff9f5e6dc0b6b112e36170318c900f893a73c5e..bddb26fa21312e5d0b2b6412cdf= 2a6c28dd06eb3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1246,7 +1246,8 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque,= size_t size, } qemu_put_be32(f, 0); /* end of list */ =20 - return vmstate_save_state(f, &vmstate_virtio_gpu_scanouts, g, NULL); + return vmstate_save_state(f, &vmstate_virtio_gpu_scanouts, g, NULL, + &error_warn); } =20 static bool virtio_gpu_load_restore_mapping(VirtIOGPU *g, diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 80545189980f176ca6a3dc9abce7043c8bc2708c..f7fb3931ff190c25ffa665ba80a= be7737dbefdb6 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -926,7 +926,7 @@ void pci_device_save(PCIDevice *s, QEMUFile *f) * This makes us compatible with old devices * which never set or clear this bit. */ s->config[PCI_STATUS] &=3D ~PCI_STATUS_INTERRUPT; - vmstate_save_state(f, &vmstate_pci_device, s, NULL); + vmstate_save_state(f, &vmstate_pci_device, s, NULL, &error_warn); /* Restore the interrupt status bit. */ pci_update_irq_status(s); } diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index bafcb9b76d81749925e31b5a0a1320b3332ad2cf..14304fd3e8901d28a7788266df2= c7ef7334b691c 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1130,7 +1130,7 @@ static int virtio_ccw_load_queue(DeviceState *d, int = n, QEMUFile *f) static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev =3D VIRTIO_CCW_DEVICE(d); - vmstate_save_state(f, &vmstate_virtio_ccw_dev, dev, NULL); + vmstate_save_state(f, &vmstate_virtio_ccw_dev, dev, NULL, &error_warn); } =20 static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index a4812afd0cc7c495080ef03a531c7d279af29b33..2204beb40c7cdc827db2bf86fb8= 612d8c09999ed 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -630,7 +630,7 @@ static void vscsi_save_request(QEMUFile *f, SCSIRequest= *sreq) vscsi_req *req =3D sreq->hba_private; assert(req->active); =20 - vmstate_save_state(f, &vmstate_spapr_vscsi_req, req, NULL); + vmstate_save_state(f, &vmstate_spapr_vscsi_req, req, NULL, &error_warn= ); =20 trace_spapr_vscsi_save_request(req->qtag, req->cur_desc_num, req->cur_desc_offset); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 04d385d7674f444844beeee7364ee0424f762758..8e2b6d611de8efdf98235355226= f5e5a6fd87b19 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2780,8 +2780,8 @@ static int vfio_pci_save_config(VFIODevice *vbasedev,= QEMUFile *f, Error **errp) { VFIOPCIDevice *vdev =3D container_of(vbasedev, VFIOPCIDevice, vbasedev= ); =20 - return vmstate_save_state_with_err(f, &vmstate_vfio_pci_config, vdev, = NULL, - errp); + return vmstate_save_state(f, &vmstate_vfio_pci_config, vdev, NULL, + errp); } =20 static int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index f14f0487fec3ed30d2cc3aec96950c2121265716..58957990743f061e78d0eafcfcb= 6cc5989252edc 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -613,7 +613,7 @@ static void virtio_mmio_save_extra_state(DeviceState *o= paque, QEMUFile *f) { VirtIOMMIOProxy *proxy =3D VIRTIO_MMIO(opaque); =20 - vmstate_save_state(f, &vmstate_virtio_mmio, proxy, NULL); + vmstate_save_state(f, &vmstate_virtio_mmio, proxy, NULL, &error_warn); } =20 static int virtio_mmio_load_extra_state(DeviceState *opaque, QEMUFile *f) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 07f144d6d1bfbb561b28015de71762601080dc23..0826399cdfbf09b5b3f9acd9967= de3417858c9d2 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -154,7 +154,7 @@ static void virtio_pci_save_extra_state(DeviceState *d,= QEMUFile *f) { VirtIOPCIProxy *proxy =3D to_virtio_pci_proxy(d); =20 - vmstate_save_state(f, &vmstate_virtio_pci, proxy, NULL); + vmstate_save_state(f, &vmstate_virtio_pci, proxy, NULL, &error_warn); } =20 static int virtio_pci_load_extra_state(DeviceState *d, QEMUFile *f) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index aac317a93c3cd55ece9b0fd858c7b2459f8242f9..552e167529e9c22fb4cba2b445f= fad85fef619f3 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3025,14 +3025,14 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) } =20 if (vdc->vmsd) { - int ret =3D vmstate_save_state(f, vdc->vmsd, vdev, NULL); + int ret =3D vmstate_save_state(f, vdc->vmsd, vdev, NULL, &error_wa= rn); if (ret) { return ret; } } =20 /* Subsections */ - return vmstate_save_state(f, &vmstate_virtio, vdev, NULL); + return vmstate_save_state(f, &vmstate_virtio, vdev, NULL, &error_warn); } =20 /* A wrapper for use as a VMState .put function */ diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 056781b1c21e737583f081594d9f88b32adfd674..5fe9bbf39058d0cf97c1adab54c= c516dbe8dc32a 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1198,8 +1198,6 @@ extern const VMStateInfo vmstate_info_qlist; int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id, Error **errp); int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc); -int vmstate_save_state_with_err(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc, Error **errp); int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc, diff --git a/migration/cpr.c b/migration/cpr.c index bdb24736f44e91ba59b6e622a315597c97e7f64d..d48f013dac21b531e41a26f4bb3= 3eefe32097757 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -163,6 +163,7 @@ bool cpr_is_incoming(void) =20 int cpr_state_save(MigrationChannel *channel, Error **errp) { + ERRP_GUARD(); int ret; QEMUFile *f; MigMode mode =3D migrate_mode(); @@ -182,9 +183,9 @@ int cpr_state_save(MigrationChannel *channel, Error **e= rrp) qemu_put_be32(f, QEMU_CPR_FILE_MAGIC); qemu_put_be32(f, QEMU_CPR_FILE_VERSION); =20 - ret =3D vmstate_save_state(f, &vmstate_cpr_state, &cpr_state, 0); + ret =3D vmstate_save_state(f, &vmstate_cpr_state, &cpr_state, 0, errp); if (ret) { - error_setg(errp, "vmstate_save_state error %d", ret); + error_prepend(errp, "vmstate_save_state error %d: ", ret); qemu_fclose(f); return ret; } diff --git a/migration/savevm.c b/migration/savevm.c index 071044921bed02f027571b2a832f339990e547ee..495f87654a206594503eee186aa= a3da47a0cb35b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1056,8 +1056,8 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *= se, JSONWriter *vmdesc, if (!se->vmsd) { vmstate_save_old_style(f, se, vmdesc); } else { - ret =3D vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdes= c, - errp); + ret =3D vmstate_save_state(f, se->vmsd, se->opaque, vmdesc, + errp); if (ret) { return ret; } @@ -1303,7 +1303,8 @@ void qemu_savevm_state_header(QEMUFile *f) json_writer_start_object(vmdesc, "configuration"); } =20 - vmstate_save_state(f, &vmstate_configuration, &savevm_state, vmdes= c); + vmstate_save_state(f, &vmstate_configuration, &savevm_state, vmdes= c, + &error_warn); =20 if (vmdesc) { json_writer_end_object(vmdesc); diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index e2020a733d0921d748b6f832a193e5de8d302d5f..2b88dc145ab32072f09845cee95= b79aad7ac3cb2 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -564,7 +564,7 @@ static int put_tmp(QEMUFile *f, void *pv, size_t size, =20 /* Writes the parent field which is at the start of the tmp */ *(void **)tmp =3D pv; - ret =3D vmstate_save_state(f, vmsd, tmp, vmdesc); + ret =3D vmstate_save_state(f, vmsd, tmp, vmdesc, &error_warn); g_free(tmp); =20 return ret; @@ -675,7 +675,7 @@ static int put_qtailq(QEMUFile *f, void *pv, size_t unu= sed_size, =20 QTAILQ_RAW_FOREACH(elm, pv, entry_offset) { qemu_put_byte(f, true); - ret =3D vmstate_save_state(f, vmsd, elm, vmdesc); + ret =3D vmstate_save_state(f, vmsd, elm, vmdesc, &error_warn); if (ret) { return ret; } @@ -712,7 +712,8 @@ static gboolean put_gtree_elem(gpointer key, gpointer v= alue, gpointer data) if (!capsule->key_vmsd) { qemu_put_be64(f, (uint64_t)(uintptr_t)(key)); /* direct key */ } else { - ret =3D vmstate_save_state(f, capsule->key_vmsd, key, capsule->vmd= esc); + ret =3D vmstate_save_state(f, capsule->key_vmsd, key, capsule->vmd= esc, + &error_warn); if (ret) { capsule->ret =3D ret; return true; @@ -720,7 +721,8 @@ static gboolean put_gtree_elem(gpointer key, gpointer v= alue, gpointer data) } =20 /* put the data */ - ret =3D vmstate_save_state(f, capsule->val_vmsd, value, capsule->vmdes= c); + ret =3D vmstate_save_state(f, capsule->val_vmsd, value, capsule->vmdes= c, + &error_warn); if (ret) { capsule->ret =3D ret; return true; @@ -856,7 +858,7 @@ static int put_qlist(QEMUFile *f, void *pv, size_t unus= ed_size, trace_put_qlist(field->name, vmsd->name, vmsd->version_id); QLIST_RAW_FOREACH(elm, pv, entry_offset) { qemu_put_byte(f, true); - ret =3D vmstate_save_state(f, vmsd, elm, vmdesc); + ret =3D vmstate_save_state(f, vmsd, elm, vmdesc, &error_warn); if (ret) { error_report("%s: failed to save %s (%d)", field->name, vmsd->name, ret); diff --git a/migration/vmstate.c b/migration/vmstate.c index cec1ee2f30d6f0270ee1fd30d29f6f0f5d20bdb0..07b192fa090e95ea80b642cff39= 82cefa65287a4 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -403,12 +403,6 @@ bool vmstate_section_needed(const VMStateDescription *= vmsd, void *opaque) =20 =20 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, NULL); -} - -int vmstate_save_state_with_err(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc_id, Error **errp) { return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_= id, errp); @@ -530,7 +524,7 @@ static int vmstate_save_dispatch(QEMUFile *f, =20 if (inner_field->flags & VMS_STRUCT) { ret =3D vmstate_save_state(f, inner_field->vmsd, - curr_elem, vmdesc_loop); + curr_elem, vmdesc_loop, errp); } else if (inner_field->flags & VMS_VSTRUCT) { ret =3D vmstate_save_state_v(f, inner_field->vmsd, curr_elem, vmdesc_loop, @@ -539,6 +533,10 @@ static int vmstate_save_dispatch(QEMUFile *f, } else { ret =3D inner_field->info->put(f, curr_elem, size, inner_field, vmdesc_loop); + if (ret) { + error_setg(errp, "Save of field %s failed", + inner_field->name); + } } =20 written_bytes =3D qemu_file_transferred(f) - old_offset; @@ -551,8 +549,8 @@ static int vmstate_save_dispatch(QEMUFile *f, } =20 if (ret) { - error_setg(errp, "Save of field %s/%s failed", - vmsd->name, field->name); + error_prepend(errp, "Save of field %s/%s failed: ", + vmsd->name, field->name); ps_ret =3D post_save_dispatch(vmsd, opaque, &local_err= ); if (ps_ret) { ret =3D ps_ret; @@ -720,7 +718,7 @@ static int vmstate_subsection_save(QEMUFile *f, const V= MStateDescription *vmsd, qemu_put_byte(f, len); qemu_put_buffer(f, (uint8_t *)vmsdsub->name, len); qemu_put_be32(f, vmsdsub->version_id); - ret =3D vmstate_save_state_with_err(f, vmsdsub, opaque, vmdesc= , errp); + ret =3D vmstate_save_state(f, vmsdsub, opaque, vmdesc, errp); if (ret) { return ret; } diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 807deb3531f3079864ac99567d4dece7122571dd..a7a1596998a8c4b0f9060856421= 8ff0cd158baed 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -69,7 +69,7 @@ static void save_vmstate(const VMStateDescription *desc, = void *obj) QEMUFile *f =3D open_test_file(true); =20 /* Save file with vmstate */ - int ret =3D vmstate_save_state(f, desc, obj, NULL); + int ret =3D vmstate_save_state(f, desc, obj, NULL, NULL); g_assert(!ret); qemu_put_byte(f, QEMU_VM_EOF); g_assert(!qemu_file_get_error(f)); @@ -429,7 +429,7 @@ static void test_save_noskip(void) QEMUFile *fsave =3D open_test_file(true); TestStruct obj =3D { .a =3D 1, .b =3D 2, .c =3D 3, .d =3D 4, .e =3D 5,= .f =3D 6, .skip_c_e =3D false }; - int ret =3D vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL); + int ret =3D vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL, N= ULL); g_assert(!ret); g_assert(!qemu_file_get_error(fsave)); =20 @@ -451,7 +451,7 @@ static void test_save_skip(void) QEMUFile *fsave =3D open_test_file(true); TestStruct obj =3D { .a =3D 1, .b =3D 2, .c =3D 3, .d =3D 4, .e =3D 5,= .f =3D 6, .skip_c_e =3D true }; - int ret =3D vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL); + int ret =3D vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL, N= ULL); g_assert(!ret); g_assert(!qemu_file_get_error(fsave)); =20 diff --git a/ui/vdagent.c b/ui/vdagent.c index b9a22a689d9acfeafb862ae73308db6fbd52331e..e0fc7ff71468bfe667613853876= 53c742c375f05 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -992,7 +992,8 @@ static int put_cbinfo(QEMUFile *f, void *pv, size_t siz= e, } } =20 - return vmstate_save_state(f, &vmstate_cbinfo_array, &cbinfo, vmdesc); + return vmstate_save_state(f, &vmstate_cbinfo_array, &cbinfo, vmdesc, + &error_warn); } =20 static int get_cbinfo(QEMUFile *f, void *pv, size_t size, --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971975; cv=none; d=zohomail.com; s=zohoarc; b=iGYA/t6uFOIshD/hkTI9o247AsnP1nlbFJQddlmMlF79reF2KQPW/YEKFNqsbhxhp+BgiRCbY2i2Y0fvfydoI2NUKqYyzGnJiOmAYSVq0ibt8N+DbCTjViIw9CeANKq0xci/6yskcCbGCbjLNFPKd9/fkyOn8Vig8ZMOTus0ZTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971975; 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=SBfQJK2JW5W8/viknmh/y+5CyIVaxDMmsG4Tihgbhek=; b=j+7tzuBthVe2GmVs/uS6DcfMndpsr7PHC5qY/LLZPLUbsAxI6+zrlakb8L8ayNnW9X1JamM0+8YD7TrK+tABoyd9oh57TS7LKXCPk+yZQsi4cmxKW88TMhj4VdgVn9xyG1/oEAkxUNuLz+YWGCNfzH3RsgzbBVFqzQZJWTJTPR8= 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 1753971975314823.0612102042826; Thu, 31 Jul 2025 07:26:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUCx-0000cd-J6; Thu, 31 Jul 2025 10:24:39 -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 1uhTIQ-0004qS-6z for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:26:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhTIN-0000Vx-NU for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:26:09 -0400 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-zoRf8r0oOdyyDBWfAuJrAg-1; Thu, 31 Jul 2025 09:26:05 -0400 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2400cbd4241so12627685ad.3 for ; Thu, 31 Jul 2025 06:26:05 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968366; 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=SBfQJK2JW5W8/viknmh/y+5CyIVaxDMmsG4Tihgbhek=; b=V8jU/Q8lIK4U6RMEBDxCtMiDdebvVQSOTzHNVWfKN2k/4ZOALrFr0W2BtXe+qtO5n1bVuW I+3cbFMfWFTb95Uw/FDGDQXzUE4Jy2TDChg8WpSUp2hIMarSe52Z/sFc7sfpYHEwSsbH2O lTW6WIJDbT7SPoTuh5Q257VEOvl1lGU= X-MC-Unique: zoRf8r0oOdyyDBWfAuJrAg-1 X-Mimecast-MFC-AGG-ID: zoRf8r0oOdyyDBWfAuJrAg_1753968364 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968364; x=1754573164; 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=SBfQJK2JW5W8/viknmh/y+5CyIVaxDMmsG4Tihgbhek=; b=g5b702g7ctiYxo5Tvx4u2niHfZx86rOP8xcuElykacVE1prEDfzOLweyB4FnLoDm/c QDt3SybcsmzWmt+WJg3lzzZua4/wXQDpTuyESDIi6CAN43wt/26vsjIyq85WmjQB33jv z2Y+VHGHevfVOfQtshON+jyQbX73FnvU9NkIJ8cIvDUickPGiWn/rQpHjJWhB+b9PtjR znOk5AnMBYOGFtwN2npfb9oxpG4EAhPdJESEYpybKeVGledL6N32vq8+Z3pyH2M7m3bx 1VtfB0vVjS50bv+wg/vreaXNPfFBTbvB/9ShVpUhvqEYfe+o0i6pA96MlmE7sEdGgEed fBHg== X-Gm-Message-State: AOJu0YxmK3/q/1yi9SXtE/A4HTAmvFrWrBoxcGJqx+TkXAxx/X5kOVb9 Ch3bymea35IcoTf2WBloMkgWagFYHCuwUKaIySLlAsqSSm50i8/HLCq+KkLuct1BSoIe2No4Kdq HgdyymneDll+/B/ddHXOFxCvT9Z2iEmMgUy0LQPLWgnwz8yW11LrWGq0sFTW1sPE0xxBhazXAJA T4nbnXuoJQtVwxDVYwNrK6ARib1E0zoidIb+QPSrKkbA== X-Gm-Gg: ASbGncsnesA2fOaN4LueumFmKrGOF2s4uWSQOw9R1bDpIQk+HOq4G1nLhfgfSbeKt57 3NKKAs6UcixUa31qzCLNvavQp3kVqThyHkJ/qnJ8IFJUOuAHGANwppZSDhdH/w9f9zjNypqSJ+N UZgQsBFO/j62ivzqEYVYU7esNdsnKT5WiYnkoZIMD8HJhDeHeBc3iEmiolua+Sf3euY3vlwmSOz cPWAfff3E/7gQt/r2vplXw06hAmGtEjarM+K/ht21AIO/pLeoduroDEFL8oRH0GEXp3EGQkEGr3 NCpydlcEOohmwfv0SE2QpzbUYpl4X1Wkg/kNNmmASPQqR23woxcd X-Received: by 2002:a17:902:cec8:b0:23c:863d:2989 with SMTP id d9443c01a7336-24096a4f7d8mr105790375ad.3.1753968363761; Thu, 31 Jul 2025 06:26:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBZBgxWbcJRWUd5yjJBg0dpCTCzKtCqttCXHPU+6p/L2gDR3xDp2xFUvr5O/PK6PAXx/uW0Q== X-Received: by 2002:a17:902:cec8:b0:23c:863d:2989 with SMTP id d9443c01a7336-24096a4f7d8mr105789285ad.3.1753968362878; Thu, 31 Jul 2025 06:26:02 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:06 +0530 Subject: [PATCH v8 26/27] 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: <20250731-propagate_tpm_error-v8-26-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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=7163; i=armenon@redhat.com; h=from:subject:message-id; bh=UoofvziF9RyLHTE6L38QBQQxwIyZ0DMu/eAi69s1Tco=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37vPQVx9nHSyV7Vn58PCL635LN0/8s1gvSEo/43i7O eev3j6PjlIWBjEuBlkxRZaGrwGyTQGFEZG2L6/DzGFlAhnCwMUpABeZxMhwmN+8SnO2e7eB8ex3 frssfuzwun36Qsv75X1i87KXtiw0YWTok1pYfvGo3v7JrhsmnCiYMW3f7T6xhwc5zXRua8k9KC9 nBwA= 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.133.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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753971977067116600 - 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 --- docs/devel/migration/main.rst | 24 ++++++++++++++++++++++++ include/migration/vmstate.h | 15 +++++++++++++++ migration/vmstate.c | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 6493c1d2bca48a2fa34d92f6c0979c215c56b8d5..35bf5ae26c87f3c82964eb15618= be373ab5a41fc 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -444,6 +444,30 @@ The functions to do that are inside a vmstate definiti= on, and are called: This function is called after we save the state of one device (even upon failure, unless the call to pre_save returned an error). =20 +Following are the errp variants of these functions. + +- ``int (*pre_load_errp)(void *opaque, Error **errp);`` + + This function is called before we load the state of one device. + +- ``int (*post_load_errp)(void *opaque, int version_id, Error **errp);`` + + This function is called after we load the state of one device. + +- ``int (*pre_save_errp)(void *opaque, Error **errp);`` + + This function is called before we save the state of one device. + +- ``int (*post_save_errp)(void *opaque, Error **errp);`` + + This function is called after we save the state of one device + (even upon failure, unless the call to pre_save returned an error). + +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. + Example: You can look at hpet.c, that uses the first three functions to massage the state that is transferred. =20 diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 5fe9bbf39058d0cf97c1adab54cc516dbe8dc32a..51baf6c7f9d061ee33949d7e798= f2184e50b4cbf 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -200,15 +200,30 @@ 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. + * + * For the errp variants, + * Returns: 0 on success, + * <0 on error where -value is an error number from errno.h */ + 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 07b192fa090e95ea80b642cff3982cefa65287a4..f6b7d0ff840ea219a77b305e9cd= 622a4c1f61b96 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -152,7 +152,16 @@ 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 for: '%s', " + "version_id: '%d', minimum version_id: '%d', " + "ret: %d: ", vmsd->name, vmsd->version_id, + vmsd->minimum_version_id, ret); + return ret; + } + } else if (vmsd->pre_load) { ret =3D vmsd->pre_load(opaque); if (ret) { error_setg(errp, "VM pre load failed for: '%s', " @@ -242,7 +251,14 @@ 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 for: %s, version_id: = %d, " + "minimum_version: %d, ret: %d: ", vmsd->name, + vmsd->version_id, vmsd->minimum_version_id, ret); + } + } else if (vmsd->post_load) { ret =3D vmsd->post_load(opaque, version_id); if (ret < 0) { error_setg(errp, @@ -411,8 +427,16 @@ int vmstate_save_state(QEMUFile *f, const VMStateDescr= iption *vmsd, static int pre_save_dispatch(const VMStateDescription *vmsd, void *opaque, Error **errp) { + ERRP_GUARD(); int ret =3D 0; - 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 for %s failed, ret: '%d': ", + vmsd->name, ret); + } + } else if (vmsd->pre_save) { ret =3D vmsd->pre_save(opaque); trace_vmstate_save_state_pre_save_res(vmsd->name, ret); if (ret) { @@ -427,7 +451,9 @@ static int post_save_dispatch(const VMStateDescription = *vmsd, void *opaque, Error **errp) { int ret =3D 0; - if (vmsd->post_save) { + if (vmsd->post_save_errp) { + ret =3D vmsd->post_save_errp(opaque, errp); + } else if (vmsd->post_save) { ret =3D vmsd->post_save(opaque); error_setg(errp, "post-save for %s failed, ret: '%d'", vmsd->name, ret); --=20 2.50.0 From nobody Sat Nov 15 07:40:52 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=1753971949; cv=none; d=zohomail.com; s=zohoarc; b=E+vU7jN5Jie5JWWe4iPHY+nab5LuZL/LfWo5jdCTMV5zLo0huWlne1MlDbHs9FDPjuYVnA1LpD3WaIPZlVznNG0H3J7KMYksr/zFv8fE3gCSssClij4w6lACYqFhswiUzlTvpLlJkIL3Kqr8oNNJMTJAq8n+A00WdTY6yWH98Fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753971949; 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=u6Rc3rKiVHHPNot8sDVBjtYRWL2F6FqkzvXToH5KUbo=; b=DG1s7BI7Zrypg6jCWTiEoeyrbpO5UJRmaX97/r1YCPnmBo47TxSQcTBdXPO17mYh2C5eU3fk1wz6AQ7ExFYqGMKyQkzq2wppfSp13aumBBfMUki4at7FgFjQgfXjLEBu+fvwEP79zrdA36CD9aerJfI7o0EHAwRUSC4dO745MT8= 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 1753971949528945.4353546556099; Thu, 31 Jul 2025 07:25:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uhUDb-0004hl-S1; Thu, 31 Jul 2025 10:25: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 1uhTIb-000650-IO for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:26:23 -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 1uhTIX-0000XP-4P for qemu-devel@nongnu.org; Thu, 31 Jul 2025 09:26:21 -0400 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-M6a41YISMUqnbuzfHzrXtA-1; Thu, 31 Jul 2025 09:26:14 -0400 Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-23824a9bc29so21394435ad.3 for ; Thu, 31 Jul 2025 06:26:14 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.99.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3209a84d115sm2007034a91.36.2025.07.31.06.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 06:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753968375; 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=u6Rc3rKiVHHPNot8sDVBjtYRWL2F6FqkzvXToH5KUbo=; b=V87Egz1Of04iZkWvZii4M7SwP1hIXa//tBMzmaYJdTU8ju0rFkGq1qcMFaHaJc0uRU+DVm TI3dmDfJG4ispR2kw5M+cS6ggYjZn7YGd9MAoRiWYnIiTz7lle4Aet3x93hxjwNeYQlw8e JAGioDhW7qEUkZv6TUgJFnBAaZmTLW4= X-MC-Unique: M6a41YISMUqnbuzfHzrXtA-1 X-Mimecast-MFC-AGG-ID: M6a41YISMUqnbuzfHzrXtA_1753968373 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968373; x=1754573173; 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=u6Rc3rKiVHHPNot8sDVBjtYRWL2F6FqkzvXToH5KUbo=; b=cXiSK/pGCP9seU9jH5OXYZL3uFZkj9alFyi1TV5zyOqDBQB3uNyaHA5YzUKl2F4Eda jWqV9wgxCJ34J2hwj35cq71Xhy4GN3m4//yT3mMtXxGxQhKGqt6/AXLM3UgmLTW+4kyy BGX1QPCWkTMWNleGoq1zGCniGiW5vcXGBupve+O9PHOc6v3jPaXH8YxLWjCPZoGra9qO jb/imE88F61dAahBKJnOztpR+OUWrA/MbBegNuI5crJgh8GCc/6RVZyFoR7bg524FTPM pECJrUGqg6Dszlmb4cWm+wY4ymVSVV1POq8pjDGGOP8/U/t1WSR/LWmJSzWY8vfsSVx4 ILWA== X-Gm-Message-State: AOJu0YxsyM+cSByENbFU2LxwWfsfo+IB80JALqENWcghPSDVaWPDSkU2 wnMAsPHOZ1wPf4h7KEfgQ7lU8h5ec9Pe/wtUZcxwfyZEIqDmZKZGWnq7BHmNUXccfF0BhCS0x4T ZP58xCOzEOlKHHt0ZmcBpeRM1mpnh/6QV19j+ZfNClSYdXj4osO7wxvsFTVS7cZiiUAN3N6SSdB sLYmbxT0gRdRvT8ybz08/0GLSkCXvT0Vz5UT42eXEZHg== X-Gm-Gg: ASbGncsbgNS77aeiUzW2CXm9JRhnJW9hB9zY8Dbr3RICPInuWXT2Wvh7ArD49PdfvHo j8TZ/jzr2GaaJF502HcmskZubTQAM/7zMGtjgmHkT7hROCgqo7v9X4SvnHl+qJ9vt4zFvvQIQ65 Y2VjfUIwuLZyWbaGtqMJQ2FCd6DbB8aAmdmoFbc2FAP6Mh6tbqkMbTAbH0SJnefBzGDYWvei2mn 5rmPJKbJ2XhUmdHDD8tjlq95uRu7XViBsScbiWqAYL3x4TpY8WDuwOZgumZ264rZ7IzxW4XNnQd Etc06HTj1zUujNjN/evmLPKNf1XArSHiJb4C/ZdT5pNqBfF0naBu X-Received: by 2002:a17:902:e844:b0:240:7308:aecb with SMTP id d9443c01a7336-24096b4c4c9mr119011165ad.32.1753968373016; Thu, 31 Jul 2025 06:26:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYNJrqPTWBlNFrAndZGpenhA52bi305AEa5buL6sPMcW8/Y0sMsIAQcHFxvFGad4MTyNgMyQ== X-Received: by 2002:a17:902:e844:b0:240:7308:aecb with SMTP id d9443c01a7336-24096b4c4c9mr119010245ad.32.1753968372394; Thu, 31 Jul 2025 06:26:12 -0700 (PDT) From: Arun Menon Date: Thu, 31 Jul 2025 18:51:07 +0530 Subject: [PATCH v8 27/27] backends/tpm: Propagate vTPM error on migration failure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250731-propagate_tpm_error-v8-27-28fd82fdfdb2@redhat.com> References: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@redhat.com> In-Reply-To: <20250731-propagate_tpm_error-v8-0-28fd82fdfdb2@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 , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Stefan Berger X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6695; i=armenon@redhat.com; h=from:subject:message-id; bh=6Yp9J+EAV6fUpXUkxF9NVzWf0/ddKo0q58dDKmIfE2U=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0Z37nO/GbFPw3MyOy6x9DYkHrKPfPz+qVZS5UljHwX1y GeBU593lLIwiHExyIopsjR8DZBtCiiMiLR9eR1mDisTyBAGLk4BmEjXc4Z/hrOXbTF5PEnNSW6W R9fPGs1vU4SF18wz+v2BVTnsRHdFMCPDZeFtjwLPnLvGm1Qw6+eJpbL70vL7DeZ94+3fu9/V/F8 OJwA= 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1753971950714116600 - When migration of a VM with encrypted vTPM fails on the destination host, (e.g., due to a mismatch in secret values), the error message displayed on the source host is generic and unhelpful. - For example, a typical error looks like this: "operation failed: job 'migration out' failed: Sibling indicated error 1. operation failed: job 'migration in' failed: load of migration failed: Input/output error" - Such generic errors are logged using error_report(), which prints to the console/monitor but does not make the detailed error accessible via the QMP query-migrate command. - This change, along with the set of changes of passing errp Error object to the VM state loading functions, help in addressing the issue. We use the post_load_errp hook of VMStateDescription to propagate errors by setting Error **errp objects in case of failure in the TPM backend. - It can then be retrieved using QMP command: {"execute" : "query-migrate"} Buglink: https://issues.redhat.com/browse/RHEL-82826 Reviewed-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- backends/tpm/tpm_emulator.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index 4a234ab2c0b19b2604bf0dd8cb5f4540c72a9438..dacfca5ab7eb0445ddc1ced9751= 3068501b468bf 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -819,7 +819,8 @@ static int tpm_emulator_get_state_blobs(TPMEmulator *tp= m_emu) static int tpm_emulator_set_state_blob(TPMEmulator *tpm_emu, uint32_t type, TPMSizedBuffer *tsb, - uint32_t flags) + uint32_t flags, + Error **errp) { ssize_t n; ptm_setstate pss; @@ -838,17 +839,18 @@ static int tpm_emulator_set_state_blob(TPMEmulator *t= pm_emu, /* write the header only */ if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_STATEBLOB, &pss, offsetof(ptm_setstate, u.req.data), 0, 0) < 0= ) { - error_report("tpm-emulator: could not set state blob type %d : %s", - type, strerror(errno)); + error_setg_errno(errp, errno, + "tpm-emulator: could not set state blob type %d", + type); return -1; } =20 /* now the body */ n =3D qemu_chr_fe_write_all(&tpm_emu->ctrl_chr, tsb->buffer, tsb->size= ); if (n !=3D tsb->size) { - error_report("tpm-emulator: Writing the stateblob (type %d) " - "failed; could not write %u bytes, but only %zd", - type, tsb->size, n); + error_setg(errp, "tpm-emulator: Writing the stateblob (type %d) " + "failed; could not write %u bytes, but only %zd", + type, tsb->size, n); return -1; } =20 @@ -856,17 +858,17 @@ static int tpm_emulator_set_state_blob(TPMEmulator *t= pm_emu, n =3D qemu_chr_fe_read_all(&tpm_emu->ctrl_chr, (uint8_t *)&pss, sizeof(pss.u.resp)); if (n !=3D sizeof(pss.u.resp)) { - error_report("tpm-emulator: Reading response from writing stateblo= b " - "(type %d) failed; expected %zu bytes, got %zd", type, - sizeof(pss.u.resp), n); + error_setg(errp, "tpm-emulator: Reading response from writing " + "stateblob (type %d) failed; expected %zu bytes, " + "got %zd", type, sizeof(pss.u.resp), n); return -1; } =20 tpm_result =3D be32_to_cpu(pss.u.resp.tpm_result); if (tpm_result !=3D 0) { - error_report("tpm-emulator: Setting the stateblob (type %d) failed= " - "with a TPM error 0x%x %s", type, tpm_result, - tpm_emulator_strerror(tpm_result)); + error_setg(errp, "tpm-emulator: Setting the stateblob (type %d) " + "failed with a TPM error 0x%x %s", type, tpm_result, + tpm_emulator_strerror(tpm_result)); return -1; } =20 @@ -880,7 +882,7 @@ static int tpm_emulator_set_state_blob(TPMEmulator *tpm= _emu, * * Returns a negative errno code in case of error. */ -static int tpm_emulator_set_state_blobs(TPMBackend *tb) +static int tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp) { TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); TPMBlobBuffers *state_blobs =3D &tpm_emu->state_blobs; @@ -894,13 +896,13 @@ static int tpm_emulator_set_state_blobs(TPMBackend *t= b) =20 if (tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_PERMANENT, &state_blobs->permanent, - state_blobs->permanent_flags) < 0 || + state_blobs->permanent_flags, errp) < = 0 || tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_VOLATILE, &state_blobs->volatil, - state_blobs->volatil_flags) < 0 || + state_blobs->volatil_flags, errp) < 0 = || tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_SAVESTATE, &state_blobs->savestate, - state_blobs->savestate_flags) < 0) { + state_blobs->savestate_flags, errp) < = 0) { return -EIO; } =20 @@ -948,12 +950,12 @@ static void tpm_emulator_vm_state_change(void *opaque= , bool running, * * Returns negative errno codes in case of error. */ -static int tpm_emulator_post_load(void *opaque, int version_id) +static int tpm_emulator_post_load(void *opaque, int version_id, Error **er= rp) { TPMBackend *tb =3D opaque; int ret; =20 - ret =3D tpm_emulator_set_state_blobs(tb); + ret =3D tpm_emulator_set_state_blobs(tb, errp); if (ret < 0) { return ret; } @@ -969,7 +971,7 @@ static const VMStateDescription vmstate_tpm_emulator = =3D { .name =3D "tpm-emulator", .version_id =3D 0, .pre_save =3D tpm_emulator_pre_save, - .post_load =3D tpm_emulator_post_load, + .post_load_errp =3D tpm_emulator_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT32(state_blobs.permanent_flags, TPMEmulator), VMSTATE_UINT32(state_blobs.permanent.size, TPMEmulator), --=20 2.50.0