From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659556; cv=none; d=zohomail.com; s=zohoarc; b=WELqhXpg/4xZn1Ncm/PvmwqCUnmN1mHjC0DjjNK0RV1H3EWulNVrMJViHSrCvoIKQr9F/leu+MNrrjbuSbqz4IdmuvXApqGNyNs+ktMvyePXIJZZCGL1ybC0hM9bXRoMFg4wwzOo8tvMSnrXutQKHVhXg25Xphn2mfO+j8pTj14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659556; h=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=b903USOXw+LRA08/3dDz6NTxu0OalX40Au3wN2Ylaks=; b=IdvPq15pfzCM7ziF977H8WFHmQ7q0n/oBB980XNfwChs9dK15JIF0etdppB3Nz9sPSptCeqrXc5X+hvM/p/xCG8qh9J9Wnx0je2yTqWHdREs524P5O9DsLJsAalegSu3o9qzwoR7PVLxVANxbQwxpSg8QL2TaHm6yg0w/IBaUaU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659556924931.1877112148965; Wed, 4 Mar 2026 13:25:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth6-0004os-BE; Wed, 04 Mar 2026 16:23:48 -0500 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 1vxtgb-0004k0-H5 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgW-0003RG-5q for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:16 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 826D8807B5; Thu, 05 Mar 2026 00:23:07 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-KJyIneIV; Thu, 05 Mar 2026 00:23:07 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659387; bh=b903USOXw+LRA08/3dDz6NTxu0OalX40Au3wN2Ylaks=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=tcReHW9qSngPlYuH62BdhkQm/B6m82pe0TUGNTiEhqad/CJs1062RbdQ6iTfXVc+t 3fNoahvzjntYOwkhRodrW3DfcUwqF2b45zFuAa/87Y7yQ9xJRFCH/O0dC65RLPg0Z1 2vZZvFDzdGCNU0+N2cEXMp80+ywDYyHrQm0wBQZs= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 01/18] migration: vmstate_save_state_v: fix double error_setg Date: Thu, 5 Mar 2026 00:22:45 +0300 Message-ID: <20260304212303.667141-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659558052139100 Content-Type: text/plain; charset="utf-8" We may call error_setg twice on same errp if inner vmstate_save_state_v() or vmstate_save_state() call fails. Next we will crash on assertion in error_setv(). Fixes: 848a0503422d043 "migration: Update error description outside migrati= on.c" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/vmstate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 4d28364f7ba..fccd030dfd1 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -539,6 +539,9 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, } else { ret =3D inner_field->info->put(f, curr_elem, size, inner_field, vmdesc_loop); + if (ret < 0) { + error_setg(errp, "put failed"); + } } =20 written_bytes =3D qemu_file_transferred(f) - old_offset; @@ -551,8 +554,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, } =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); if (vmsd->post_save) { vmsd->post_save(opaque); } --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659584; cv=none; d=zohomail.com; s=zohoarc; b=eWDt/T4SjXpsU40v4GlBzac7i33XJFA8Hx4aArMtyFXxN+jxdIywaTHhuMmkCeL7KU5bRM3Juik2sKO/UXCOpGdX7eLdYO+A0dGsGX5h3A86PXm5PI9Hj8jPhu8u72Ype3LNj9ZilEc+fHndqUqwpyjcbgcmTEsa4fpmJJkcxg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659584; h=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=PFEo+iWcsM7d09gvIG/H6iFjNFtCgZGUTh1E4nOFOGY=; b=EYoEns6TZpAxvfZWmj7L/1Qw9+bqQN2L5igUjVIf0pKdbsnPofVjkYgR2e3mJ9qT1VOc42DIopYmz4hctssLqbpchiIIH4BtAiSykt/xWWhJ6aGmR0kcgZmZiM9O87nYsg7QryplHEVYS6xE6B3KIy5IUkifInA/Zzn4+0h0ZSk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659584850495.10647268551327; Wed, 4 Mar 2026 13:26:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxtgy-0004oB-IM; Wed, 04 Mar 2026 16:23:40 -0500 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 1vxtgc-0004k4-Dx for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgW-0003RH-5s for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:18 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 35B87807E8; Thu, 05 Mar 2026 00:23:08 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-pdnkjuNZ; Thu, 05 Mar 2026 00:23:07 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659387; bh=PFEo+iWcsM7d09gvIG/H6iFjNFtCgZGUTh1E4nOFOGY=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=bJj68P/yKbJRh+PkqYZJMaREXdVtXSoziOrMmaEV3a+dagjjnl+luyX1+FuB8aVXy KgmBBNMEDL+Sae1b0ZEfec4JAEh00KhgZYXGgSu+vFuY4HLkY9SjGF0TGssK6z/fV4 8Gno69oO8IQAMdzUe+6LH8b/ETd9mh+1ZbnKcfFA= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 02/18] migration: make vmstate_save_state_v() static Date: Thu, 5 Mar 2026 00:22:46 +0300 Message-ID: <20260304212303.667141-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659586368139100 Content-Type: text/plain; charset="utf-8" It's used only in vmstate.c. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- include/migration/vmstate.h | 3 --- migration/vmstate.c | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 89f9f49d20a..3695afd483f 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1234,9 +1234,6 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, void *opaque, int version_id, Error **errp); int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc, Error **errp); -int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc, - int version_id, Error **errp); =20 bool vmstate_section_needed(const VMStateDescription *vmsd, void *opaque); =20 diff --git a/migration/vmstate.c b/migration/vmstate.c index fccd030dfd1..651c3fe0115 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -420,15 +420,9 @@ bool vmstate_section_needed(const VMStateDescription *= vmsd, void *opaque) return true; } =20 - -int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc_id, Error **errp) -{ - return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_= id, errp); -} - -int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc, int version_id,= Error **errp) +static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, + void *opaque, JSONWriter *vmdesc, + int version_id, Error **errp) { ERRP_GUARD(); int ret =3D 0; @@ -608,6 +602,13 @@ vmstate_get_subsection(const VMStateDescription * cons= t *sub, return NULL; } =20 +int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, JSONWriter *vmdesc_id, Error **errp) +{ + return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_= id, + errp); +} + static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, void *opaque, Error **errp) { --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659498; cv=none; d=zohomail.com; s=zohoarc; b=AFVgx9u4BdhPQldYvzIZ6FYutwJxDBqBe7V2o03vj25LeuB1m+cpCgixEXadX43jG7xuhBs/jxfTtCjTzh5N1sWo639OgGsHdcMwpIybaKbuC8WBD/HIZT+KxAFYCIDjXl1eTYPHTDPJLb5sXkcYjAFG3AmgXHaB1LQzSKsz9Fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659498; h=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=8TqJW7KLyOGPsDaRdrX1G44CVXku6VnJ+G8bo1vDuhM=; b=bmHAC4zBUjwTLrbx8WQFLQcXK/APgaeVPhWNwceXmpC1pqB24PvUB0U5chPDD2ZIvUsecdDNRDn/McY9d5bzkpS6ZCEQQImPWEOjNFNYlAH71KHotb2uQ1LB+xgvm00HWTX1+fLyxeCXm78JcCdQWemZcaM5d1FEPLkGiyZEK5o= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659497762405.75782671620743; Wed, 4 Mar 2026 13:24:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth8-0004ri-V3; Wed, 04 Mar 2026 16:23:50 -0500 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 1vxtgb-0004k3-Hn; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgX-0003RO-RJ; Wed, 04 Mar 2026 16:23:17 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 34BA880809; Thu, 05 Mar 2026 00:23:09 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-q645lfnf; Thu, 05 Mar 2026 00:23:08 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659388; bh=8TqJW7KLyOGPsDaRdrX1G44CVXku6VnJ+G8bo1vDuhM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=dX9anVb6r1fJF6Y6RKCbjksWmwTvtr7zdkfSaAFnNGxaZ1IrvbVNN107sDh3KGp5R c7SvDmgYzhARsY/9+IW/IQjaH07mSRAnwaJV0y3HsryLDiJwgVmrA9Ug/s0NjjaTdg LhOa6aR4Ma0e8+8KzLyEFjqo34TktjkK65Ga4Lj4= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, Pierrick Bouvier , Nicholas Piggin , Harsh Prateek Bora , Peter Maydell , qemu-ppc@nongnu.org (open list:sPAPR (pseries)), qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH v3 03/18] migration: make .post_save() a void function Date: Thu, 5 Mar 2026 00:22:47 +0300 Message-ID: <20260304212303.667141-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659501539139100 Content-Type: text/plain; charset="utf-8" All other handlers now have _errp() variants. Should we go this way for .post_save()? Actually it's rather strange, when the vmstate do successful preparations in .pre_save(), then successfully save all sections and subsections, end then fail when all the state is successfully transferred to the target. Happily, we have only three .post_save() realizations, all always successful. Let's make this a rule. Also note, that we call .post_save() in two places, and handle its (theoretical) failure inconsistently. Fix that too. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Zhao Liu --- docs/devel/migration/main.rst | 2 +- hw/ppc/spapr_pci.c | 3 +-- include/migration/vmstate.h | 8 +++++++- migration/savevm.c | 3 +-- migration/vmstate.c | 12 +++--------- target/arm/machine.c | 4 +--- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 234d280249a..2de70507640 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -439,7 +439,7 @@ The functions to do that are inside a vmstate definitio= n, and are called: =20 This function is called before we save the state of one device. =20 -- ``int (*post_save)(void *opaque);`` +- ``void (*post_save)(void *opaque);`` =20 This function is called after we save the state of one device (even upon failure, unless the call to pre_save returned an error). diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index ea998bdff15..1dc3b02659f 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2093,14 +2093,13 @@ static int spapr_pci_pre_save(void *opaque) return 0; } =20 -static int spapr_pci_post_save(void *opaque) +static void spapr_pci_post_save(void *opaque) { SpaprPhbState *sphb =3D opaque; =20 g_free(sphb->msi_devs); sphb->msi_devs =3D NULL; sphb->msi_devs_num =3D 0; - return 0; } =20 static int spapr_pci_post_load(void *opaque, int version_id) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 3695afd483f..85838a49aee 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -223,7 +223,13 @@ struct VMStateDescription { bool (*post_load_errp)(void *opaque, int version_id, Error **errp); int (*pre_save)(void *opaque); bool (*pre_save_errp)(void *opaque, Error **errp); - int (*post_save)(void *opaque); + + /* + * Unless .pre_save() fails, .post_save() is called after saving + * fields and subsections. It should not fail because at this + * point the state has potentially already been transferred. + */ + void (*post_save)(void *opaque); bool (*needed)(void *opaque); bool (*dev_unplug_pending)(void *opaque); =20 diff --git a/migration/savevm.c b/migration/savevm.c index 3a16c467b25..c5236e71ba1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -321,14 +321,13 @@ static int configuration_pre_save(void *opaque) return 0; } =20 -static int configuration_post_save(void *opaque) +static void configuration_post_save(void *opaque) { SaveState *state =3D opaque; =20 g_free(state->capabilities); state->capabilities =3D NULL; state->caps_count =3D 0; - return 0; } =20 static int configuration_pre_load(void *opaque) diff --git a/migration/vmstate.c b/migration/vmstate.c index 651c3fe0115..5111e7a141f 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -550,10 +550,7 @@ static int vmstate_save_state_v(QEMUFile *f, const VMS= tateDescription *vmsd, if (ret) { error_prepend(errp, "Save of field %s/%s failed: ", vmsd->name, field->name); - if (vmsd->post_save) { - vmsd->post_save(opaque); - } - return ret; + goto out; } =20 /* Compressed arrays only care about the first element */ @@ -578,12 +575,9 @@ static int vmstate_save_state_v(QEMUFile *f, const VMS= tateDescription *vmsd, =20 ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); =20 +out: if (vmsd->post_save) { - int ps_ret =3D vmsd->post_save(opaque); - if (!ret && ps_ret) { - ret =3D ps_ret; - error_setg(errp, "post-save failed: %s", vmsd->name); - } + vmsd->post_save(opaque); } return ret; } diff --git a/target/arm/machine.c b/target/arm/machine.c index bbaae344492..de810220e25 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -993,15 +993,13 @@ static int cpu_pre_save(void *opaque) return 0; } =20 -static int cpu_post_save(void *opaque) +static void cpu_post_save(void *opaque) { ARMCPU *cpu =3D opaque; =20 if (!kvm_enabled()) { pmu_op_finish(&cpu->env); } - - return 0; } =20 static int cpu_pre_load(void *opaque) --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659585; cv=none; d=zohomail.com; s=zohoarc; b=UrMVziHaeoGGhk0F5Z+mMp3poTaaXleWZX/7B70aHbigZzOiAWSNuIQjVjEjCniFbZMMhOjn+cI9if5gSYyPCOoANR65bLvX3gYrqw2y7DuYJgW+mmQ8ePNOp9YIZq3pyL7lopW0sgKyS5/woa3++AW2wULaXJRs5IiD3LzhLhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659585; h=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=zW1uDKfjnTVD0YjhG3GjFT4pda1YwyAiaCR7ZWj6+VU=; b=H8HfNTRn5bS3At/DVILQigXwGSAQRSJc9wOB7pYj3gtcyrVWEF5K/8DPdN+rakiUb0lYiv0xNj2hIfr1uyqnQPigQ0E3N2v+Z+DtPdzgjx5q+JonUclQCKSvTVueVccSjbgpgZdjD/l8vHbKI7jymIAssD52H90fQJOvKqV66PE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177265958552967.68719084109568; Wed, 4 Mar 2026 13:26:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth8-0004qM-0F; Wed, 04 Mar 2026 16:23:50 -0500 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 1vxtgb-0004k1-Hl for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgX-0003RV-HR for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:17 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id C131D807BB; Thu, 05 Mar 2026 00:23:09 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-3eRvfXnG; Thu, 05 Mar 2026 00:23:09 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659389; bh=zW1uDKfjnTVD0YjhG3GjFT4pda1YwyAiaCR7ZWj6+VU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=iJd+RXHvjnxInH/x1B98GsZXxQgc0FZjQ3s2k204h14MhHCLBdanScYEvAzmycaxg JrvG3wSoxxdRf2UcbwnGC95JTl3sPly7V7szfmCmtPt6SteVk4PDacBPLUENYH4HgD je0GWKi98VEcX/jHWxfGQGfJAzsRepEP9aEL1xCs= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 04/18] migration: vmstate_load_state(): add some newlines Date: Thu, 5 Mar 2026 00:22:48 +0300 Message-ID: <20260304212303.667141-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659588447139100 Content-Type: text/plain; charset="utf-8" Split logical blocks by newlines, that simplify reading the code. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/vmstate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/migration/vmstate.c b/migration/vmstate.c index 5111e7a141f..dd7cd279937 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -139,6 +139,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, int ret =3D 0; =20 trace_vmstate_load_state(vmsd->name, version_id); + if (version_id > vmsd->version_id) { error_setg(errp, "%s: incoming version_id %d is too new " "for local version_id %d", @@ -146,6 +147,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, trace_vmstate_load_state_end(vmsd->name, "too new", -EINVAL); return -EINVAL; } + if (version_id < vmsd->minimum_version_id) { error_setg(errp, "%s: incoming version_id %d is too old " "for local minimum version_id %d", @@ -153,6 +155,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL); return -EINVAL; } + if (vmsd->pre_load_errp) { if (!vmsd->pre_load_errp(opaque, errp)) { error_prepend(errp, "pre load hook failed for: '%s', " @@ -171,9 +174,12 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *vmsd, return ret; } } + while (field->name) { bool exists =3D vmstate_field_exists(vmsd, field, opaque, version_= id); + trace_vmstate_load_state_field(vmsd->name, field->name, exists); + if (exists) { void *first_elem =3D opaque + field->offset; int i, n_elems =3D vmstate_n_elems(opaque, field); @@ -184,6 +190,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, first_elem =3D *(void **)first_elem; assert(first_elem || !n_elems || !size); } + for (i =3D 0; i < n_elems; i++) { void *curr_elem =3D first_elem + size * i; const VMStateField *inner_field; @@ -235,6 +242,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, vmsd->name, ret); } } + if (ret < 0) { qemu_file_set_error(f, ret); trace_vmstate_load_field_error(field->name, ret); @@ -249,11 +257,13 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, field++; } assert(field->flags =3D=3D VMS_END); + 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_errp) { if (!vmsd->post_load_errp(opaque, version_id, errp)) { error_prepend(errp, "post load hook failed for: %s, version_id= : " @@ -271,7 +281,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, ret); } } + trace_vmstate_load_state_end(vmsd->name, "end", ret); + return ret; } =20 --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659492; cv=none; d=zohomail.com; s=zohoarc; b=RfxY4QY5fcLV/vBZLb3P/DEej9szc5B04tQFLNABX8yFLLdFzKqJk+GY326xYBSVIQ93e6QSx12eGRX6MiMxUKbTJJ/TCuCf/dxX7fOo4NmoQyHHvaR8M8RSMml9W+vS19b4BLApU30Veab2X9DMWYoJFQ3boLKVf04VGSnP0/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659492; h=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=SFZOucGRtXzagEF8NV4kKKFFi4CqOBo32QGjLx/LfI0=; b=LlzkJR/ZuUrTKAJ3GXKcK5m219Xq8hdn6+v9Xu2ZkEu8rdiF21mLO0Ug9aOt5D1YFcJQriFznKloPs0TCr619LFI55nQhaYB0Zm7Esx96aIhlFpgwJzBl/qqUOLUyVjKERsUDFvmVglNGt36kIrq3L992nBWyJ99Y58sD4kNXB0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659492135278.6951131909134; Wed, 4 Mar 2026 13:24:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxtgy-0004oA-Gc; Wed, 04 Mar 2026 16:23:40 -0500 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 1vxtgc-0004k7-Nh for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgX-0003Rf-I3 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:18 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 66134C01EB; Thu, 05 Mar 2026 00:23:10 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-whb1baJV; Thu, 05 Mar 2026 00:23:09 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659389; bh=SFZOucGRtXzagEF8NV4kKKFFi4CqOBo32QGjLx/LfI0=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=ys5oAZW43N+DiGOQ1YqS2omJH1L3CU6z75jzPniUalJc+S8ZNSAkRDaqIriQ468FN lgrx33nZcHXfbjt1OULmOLk6AtkHPSLkrf0PqNuk3/tLmnSRjxr819Elny31XMpCzR hoLM+zcDkGYPPWkTcqprj4Y/D8WKo5LJu2TBnZa4= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 05/18] migration: vmstate_save/load_state(): refactor tracing errors Date: Thu, 5 Mar 2026 00:22:49 +0300 Message-ID: <20260304212303.667141-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659493725158500 Content-Type: text/plain; charset="utf-8" To simplify further changes (convertion to bool+errp APIs), let's rework some error paths: - get rid of int ret in traces, as we are moving to bool+errp APIs - split traces to _fail / _success (seems better than add boolean result to the message). - prefer short error paths (return immediately on error) - around trace_vmstate_load_field_error(), do not call qemu_file_set_error(), if the erroc comes from qemu_file_get_error() Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/trace-events | 6 ++++-- migration/vmstate.c | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/migration/trace-events b/migration/trace-events index 90629f828f8..0b3f759ccc4 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -57,13 +57,15 @@ postcopy_page_req_sync(void *host_addr) "sync page req = %p" # vmstate.c vmstate_load_field_error(const char *field, int ret) "field \"%s\" load fa= iled, ret =3D %d" vmstate_load_state(const char *name, int version_id) "%s v%d" -vmstate_load_state_end(const char *name, const char *reason, int val) "%s = %s/%d" +vmstate_load_state_fail(const char *name, const char *reason) "%s %s" +vmstate_load_state_success(const char *name) "%s" vmstate_load_state_field(const char *name, const char *field, bool exists)= "%s:%s exists=3D%d" vmstate_n_elems(const char *name, int n_elems) "%s: %d" vmstate_subsection_load(const char *parent) "%s" vmstate_subsection_load_bad(const char *parent, const char *sub, const ch= ar *sub2) "%s: %s/%s" vmstate_subsection_load_good(const char *parent) "%s" -vmstate_save_state_pre_save_res(const char *name, int res) "%s/%d" +vmstate_save_state_pre_save_fail(const char *name) "%s" +vmstate_save_state_pre_save_success(const char *name) "%s" vmstate_save_state_loop(const char *name, const char *field, int n_elems) = "%s/%s[%d]" vmstate_save_state_top(const char *idstr) "%s" vmstate_subsection_save_loop(const char *name, const char *sub) "%s/%s" diff --git a/migration/vmstate.c b/migration/vmstate.c index dd7cd279937..87e1f049592 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -144,7 +144,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, 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); + trace_vmstate_load_state_fail(vmsd->name, "too new"); return -EINVAL; } =20 @@ -152,7 +152,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, 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); + trace_vmstate_load_state_fail(vmsd->name, "too old"); return -EINVAL; } =20 @@ -240,10 +240,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, error_setg(errp, "Failed to load %s state: stream error:= %d", vmsd->name, ret); + trace_vmstate_load_field_error(field->name, ret); + return ret; } - } - - if (ret < 0) { + } else { qemu_file_set_error(f, ret); trace_vmstate_load_field_error(field->name, ret); return ret; @@ -269,7 +269,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, error_prepend(errp, "post load hook failed for: %s, version_id= : " "%d, minimum_version: %d: ", vmsd->name, vmsd->version_id, vmsd->minimum_version_id); - ret =3D -EINVAL; + trace_vmstate_load_state_fail(vmsd->name, "post-load"); + return -EINVAL; } } else if (vmsd->post_load) { ret =3D vmsd->post_load(opaque, version_id); @@ -279,12 +280,14 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, "minimum_version: %d, ret: %d", vmsd->name, vmsd->version_id, vmsd->minimum_version= _id, ret); + trace_vmstate_load_state_fail(vmsd->name, "post-load"); + return ret; } } =20 - trace_vmstate_load_state_end(vmsd->name, "end", ret); + trace_vmstate_load_state_success(vmsd->name); =20 - return ret; + return 0; } =20 static int vmfield_name_num(const VMStateField *start, @@ -444,20 +447,22 @@ static int vmstate_save_state_v(QEMUFile *f, const VM= StateDescription *vmsd, =20 if (vmsd->pre_save_errp) { ret =3D vmsd->pre_save_errp(opaque, errp) ? 0 : -EINVAL; - trace_vmstate_save_state_pre_save_res(vmsd->name, ret); if (ret < 0) { error_prepend(errp, "pre-save for %s failed: ", vmsd->name); + trace_vmstate_save_state_pre_save_fail(vmsd->name); return ret; } } else if (vmsd->pre_save) { ret =3D vmsd->pre_save(opaque); - trace_vmstate_save_state_pre_save_res(vmsd->name, ret); if (ret) { error_setg(errp, "pre-save failed: %s", vmsd->name); + trace_vmstate_save_state_pre_save_fail(vmsd->name); return ret; } } =20 + trace_vmstate_save_state_pre_save_success(vmsd->name); + if (vmdesc) { json_writer_str(vmdesc, "vmsd_name", vmsd->name); json_writer_int64(vmdesc, "version", version_id); --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659466; cv=none; d=zohomail.com; s=zohoarc; b=T2IHfyfg86j2Bcw9K+dGHgLlZ4hQEr0Ceu4+4mh4a/ZW2vIwYjSm/I12z4cRaLiZ9xWVaiQx6aHZSPrzegt2y/qrEASMsTvPQB7ADg+kHfbGAaYVNHebM1szVWvk4fjwM4mz0L2iknCCpYS7rbNHaHLt4TWmRfjaPR2gNlpE7M0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659466; h=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=ieXGioyIM0zmkWgYfFJb49W9g2VLCOkGdaL37EE0fKA=; b=Y8eA1TC7NOxaQd73uFIUTY+WW9IIA2kzv7/ZA/DTlr7xRe7+3aVEfQh1NSOafVe+rbG5u53DK4BBXHl4iCjmMTj9tPHsMAhV1ZTs3agQSd2W4SKxxos5rMZixjKEiQNDlUZkwdRmvX5Z+cS+OlwP9w/wNM0QV8krIT+6K3Dt8zk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659465159598.9199695911435; Wed, 4 Mar 2026 13:24:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxtgw-0004nZ-Iq; Wed, 04 Mar 2026 16:23:38 -0500 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 1vxtgb-0004jz-GW for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgW-0003Rg-71 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:16 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id E939A80853; Thu, 05 Mar 2026 00:23:10 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-nvUkxXb3; Thu, 05 Mar 2026 00:23:10 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659390; bh=ieXGioyIM0zmkWgYfFJb49W9g2VLCOkGdaL37EE0fKA=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=TEOomZA26Wh0qWFhGRNLqBKQ7MMbQc+YYq3gZ2A0GAkkAGOQeWN/9J4V4X/iIpIK1 wRxOy5i89qoK9l4BxKuSk9paxvWRxW6e68DsnS23L8kl2pHPwaQrYvEBnxLQjlbuVl sajee6ya67DVWT8g2yK+LKHLysFZzRCpksXdMTvs= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 06/18] migration: factor out vmstate_pre_save() from vmstate_save_state() Date: Thu, 5 Mar 2026 00:22:50 +0300 Message-ID: <20260304212303.667141-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659471555158500 Content-Type: text/plain; charset="utf-8" Simplify vmstate_save_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/vmstate.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 87e1f049592..605b5c59c76 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -435,6 +435,26 @@ bool vmstate_section_needed(const VMStateDescription *= vmsd, void *opaque) return true; } =20 +static bool vmstate_pre_save(const VMStateDescription *vmsd, void *opaque, + Error **errp) +{ + ERRP_GUARD(); + + if (vmsd->pre_save_errp) { + if (!vmsd->pre_save_errp(opaque, errp)) { + error_prepend(errp, "pre-save for %s failed: ", vmsd->name); + return false; + } + } else if (vmsd->pre_save) { + if (vmsd->pre_save(opaque) < 0) { + error_setg(errp, "pre-save failed: %s", vmsd->name); + return false; + } + } + + return true; +} + static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc, int version_id, Error **errp) @@ -445,20 +465,9 @@ static int vmstate_save_state_v(QEMUFile *f, const VMS= tateDescription *vmsd, =20 trace_vmstate_save_state_top(vmsd->name); =20 - if (vmsd->pre_save_errp) { - ret =3D vmsd->pre_save_errp(opaque, errp) ? 0 : -EINVAL; - if (ret < 0) { - error_prepend(errp, "pre-save for %s failed: ", vmsd->name); - trace_vmstate_save_state_pre_save_fail(vmsd->name); - return ret; - } - } else if (vmsd->pre_save) { - ret =3D vmsd->pre_save(opaque); - if (ret) { - error_setg(errp, "pre-save failed: %s", vmsd->name); - trace_vmstate_save_state_pre_save_fail(vmsd->name); - return ret; - } + if (!vmstate_pre_save(vmsd, opaque, errp)) { + trace_vmstate_save_state_pre_save_fail(vmsd->name); + return -EINVAL; } =20 trace_vmstate_save_state_pre_save_success(vmsd->name); --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659623; cv=none; d=zohomail.com; s=zohoarc; b=amxV6WB2vqSN+h9DGoPZyBVRF8t5EwO2VNZQ9fb8GunTI+iDeshRXy1FQ3FlCp7UXx1rzan6f1g5rTgMBM3lx89rfsYClK0Kdop6b5bCBv2MV/VfS0sWGPJe5Mfzn5Xzbi6M49rtMNo0BcKSHch/7Ee5ALH0O96YE7uXRTOuQOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659623; h=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=zfvpZuOeyFjNmdZf55BCFDQ1eY99UHXuHdSgW5RmBUs=; b=DSHn3FJKc6LBt4wOje2RZ1YgI6BolJpcFkWGiRr6s++eKWjf4sXFYM53nU8QY/CDOjaCYhkb74xHV6Jnqfbc/sDLdp/Wi8uBeZ0w6PCaz4gJY22KOz/eeKBK2g5x47MH9sqYQPeXuqXKXw4Vmo+ce/ltQV4A9+H554cSeBFjdAk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659623673889.833623357982; Wed, 4 Mar 2026 13:27:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth7-0004pF-Hp; Wed, 04 Mar 2026 16:23:49 -0500 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 1vxtgb-0004k2-HY for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgX-0003Ro-Ho for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:16 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 7D26180877; Thu, 05 Mar 2026 00:23:11 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-ir54xSpN; Thu, 05 Mar 2026 00:23:11 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659391; bh=zfvpZuOeyFjNmdZf55BCFDQ1eY99UHXuHdSgW5RmBUs=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=0XZB2ljpgtmiGblBHuTwe+yVogNpxfMNaptPmLRK45osHPXHwzypx0b1dZtCMKOFD mEtPwAGZfrw8rfhVyz+zNs783dTAzTDWzCutWN2wBJKCMitFqnL76aLWFm2z27NYjX v51Z8OUJPA9Nn5YNgEp7jxQ3uEFpEzlTRji37f9I= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 07/18] migration: factor out vmstate_save_field() from vmstate_save_state() Date: Thu, 5 Mar 2026 00:22:51 +0300 Message-ID: <20260304212303.667141-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659626191139100 Content-Type: text/plain; charset="utf-8" Simplify vmstate_save_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/vmstate.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 605b5c59c76..2ce26527124 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -26,6 +26,9 @@ static int vmstate_subsection_save(QEMUFile *f, const VMS= tateDescription *vmsd, Error **errp); static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, void *opaque, Error **errp); +static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, + void *opaque, JSONWriter *vmdesc, + int version_id, Error **errp); =20 /* Whether this field should exist for either save or load the VM? */ static bool @@ -455,6 +458,26 @@ static bool vmstate_pre_save(const VMStateDescription = *vmsd, void *opaque, return true; } =20 +static bool vmstate_save_field(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, + JSONWriter *vmdesc, Error **errp) +{ + if (field->flags & VMS_STRUCT) { + return vmstate_save_state(f, field->vmsd, pv, vmdesc, errp) >=3D 0; + } else if (field->flags & VMS_VSTRUCT) { + return vmstate_save_state_v(f, field->vmsd, pv, vmdesc, + field->struct_version_id, + errp) >=3D 0; + } + + if (field->info->put(f, pv, size, field, vmdesc) < 0) { + error_setg(errp, "put failed"); + return false; + } + + return true; +} + static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc, int version_id, Error **errp) @@ -548,21 +571,8 @@ static int vmstate_save_state_v(QEMUFile *f, const VMS= tateDescription *vmsd, vmsd_desc_field_start(vmsd, vmdesc_loop, inner_field, i, max_elems); =20 - if (inner_field->flags & VMS_STRUCT) { - ret =3D vmstate_save_state(f, inner_field->vmsd, - 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, - inner_field->struct_version= _id, - errp); - } else { - ret =3D inner_field->info->put(f, curr_elem, size, - inner_field, vmdesc_loop); - if (ret < 0) { - error_setg(errp, "put failed"); - } - } + ret =3D vmstate_save_field(f, curr_elem, size, inner_field, + vmdesc_loop, errp) ? 0 : -EINVAL; =20 written_bytes =3D qemu_file_transferred(f) - old_offset; vmsd_desc_field_end(vmsd, vmdesc_loop, inner_field, --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659611; cv=none; d=zohomail.com; s=zohoarc; b=EBzycAiPagd1LnkcrSXsWwmLL4PBgia/NIl1NnLIJGjnvOFTyOVSw5crS7VMAyUJjDgrp7t3UvuX98UcNyOHPhsrHdWUILNL+2YFIFOrQNOhc0GVKV3Cor7e4V43etnBCmW3nOs951HuvO9ihavTw5Y2/UXyTZixnIfxg6sC13k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659611; h=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=yUwaxEoj8/RJhMUIeV+z4vL/mWgiT7aABoMoIYemUT4=; b=FgnE6Txpv2Ur+B5X9Cb239a+EWwf7COXESBribKiaZhAZwG9iIf7oL4VsobT0ML+h8aAevuyWRYWj+hNA6riq40kXx8mhx0pCs6NCquiFdKowH7Z76lPzWJECz59IBPsvjpv8OrgNB5lJSIaWHaPW1I8CXPKN0IWY4E5JEZMScc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659611490335.08435178526076; Wed, 4 Mar 2026 13:26:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth7-0004p0-46; Wed, 04 Mar 2026 16:23:49 -0500 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 1vxtgd-0004kE-Hy for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgZ-0003S8-Ou for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:19 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 08ACC80BAA; Thu, 05 Mar 2026 00:23:12 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-xSnsZKe7; Thu, 05 Mar 2026 00:23:11 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659391; bh=yUwaxEoj8/RJhMUIeV+z4vL/mWgiT7aABoMoIYemUT4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=IW5IgrpJBD7q4uZW9ZJN+ntvNLXap2lbuHJBBhbFwcT/9Y6GPfgWlmI16+38Dlf+p JO5DRNF+bWqgti/jx2VFXVamdrcqvD9UtRUH401dreKOHRkFDORxvMF2T1zVAvSFo2 aSn3sl4mLfc5K/8Sdsye7i5irvAG3u9cidZkfgFg= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 08/18] migration: factor out vmstate_pre_load() from vmstate_load_state() Date: Thu, 5 Mar 2026 00:22:52 +0300 Message-ID: <20260304212303.667141-9-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659613532158500 Content-Type: text/plain; charset="utf-8" Simplify vmstate_load_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/vmstate.c | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 2ce26527124..35dbe1550e9 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -134,6 +134,33 @@ static void vmstate_handle_alloc(void *ptr, const VMSt= ateField *field, } } =20 +static bool vmstate_pre_load(const VMStateDescription *vmsd, void *opaque, + Error **errp) +{ + ERRP_GUARD(); + + if (vmsd->pre_load_errp) { + if (!vmsd->pre_load_errp(opaque, errp)) { + error_prepend(errp, "pre load hook failed for: '%s', " + "version_id: %d, minimum version_id: %d: ", + vmsd->name, vmsd->version_id, + vmsd->minimum_version_id); + return false; + } + } else if (vmsd->pre_load) { + int ret =3D vmsd->pre_load(opaque); + if (ret) { + error_setg(errp, "pre load hook failed for: '%s', " + "version_id: %d, minimum version_id: %d, ret: %d", + vmsd->name, vmsd->version_id, vmsd->minimum_version= _id, + ret); + return false; + } + } + + return true; +} + int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id, Error **errp) { @@ -159,23 +186,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *vmsd, return -EINVAL; } =20 - if (vmsd->pre_load_errp) { - if (!vmsd->pre_load_errp(opaque, errp)) { - error_prepend(errp, "pre load hook failed for: '%s', " - "version_id: %d, minimum version_id: %d: ", - vmsd->name, vmsd->version_id, - vmsd->minimum_version_id); - return -EINVAL; - } - } else if (vmsd->pre_load) { - ret =3D vmsd->pre_load(opaque); - if (ret) { - error_setg(errp, "pre load hook failed for: '%s', " - "version_id: %d, minimum version_id: %d, ret: %d", - vmsd->name, vmsd->version_id, vmsd->minimum_version= _id, - ret); - return ret; - } + if (!vmstate_pre_load(vmsd, opaque, errp)) { + return -EINVAL; } =20 while (field->name) { --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659623; cv=none; d=zohomail.com; s=zohoarc; b=D34XURl69hUr5lsDS0Wptj2Hs87/0z45eD4DbpVOmVmC7a7Qgz1mTkODEYcg7fb7ht3RWZLpBy8+abDGo5AsA3cUdv09sngzMcxVLMxaxVH3hcxelcQSOqMKzODoBZJw4PaXmb68+5thVSyVlJ9Yh9wii+s5rno95N+kN8QEjJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659623; h=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=AYhuDznNbNKEuGRtnHstzOlf8J/9DuMPGwXu4Ztobew=; b=GKzGcMAaqqroAAkntvGz3WcnBeh2A9BSvq7XmpH9wNz5r9hnzPHNckb+tJmvpjSCpeCdObiU5JU+gWdF5ifmZYBhc/jS+8dUEkZ46HEmEMfkhHOk+6xCaqmOuhpqQiefPK/R1mbhMFXq5eZY1IqbwK0I3EQ6eEiE+sz4YxZvIOo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659623944169.185036247393; Wed, 4 Mar 2026 13:27:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth7-0004q9-Rz; Wed, 04 Mar 2026 16:23:49 -0500 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 1vxtgc-0004k6-NF for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgZ-0003S2-NC for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:18 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 8AFFF80866; Thu, 05 Mar 2026 00:23:12 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-aWaeuria; Thu, 05 Mar 2026 00:23:12 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659392; bh=AYhuDznNbNKEuGRtnHstzOlf8J/9DuMPGwXu4Ztobew=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=HGNMhxMWXpLpTNQk6zd2nA7J037HFkZpGG7emzQqQzOokZ5G7XAltKMtvwXg/8rnS K2+unpZJFJy4qIRvKbfkh2XOWxEu9yKLGaXW3YN02LrOpvKSjwOZ7A4yyXdUTjv2tG Hi8uS4HBddolHLt3/82LZoyDkLnkE4RhCShhvXEY= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 09/18] migration: factor out vmstate_load_field() from vmstate_load_state() Date: Thu, 5 Mar 2026 00:22:53 +0300 Message-ID: <20260304212303.667141-10-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659625569158500 Content-Type: text/plain; charset="utf-8" Simplify vmstate_load_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/vmstate.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 35dbe1550e9..32944c04443 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -161,6 +161,27 @@ static bool vmstate_pre_load(const VMStateDescription = *vmsd, void *opaque, return true; } =20 +static bool vmstate_load_field(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) +{ + if (field->flags & VMS_STRUCT) { + return vmstate_load_state(f, field->vmsd, pv, field->vmsd->version= _id, + errp) >=3D 0; + } else if (field->flags & VMS_VSTRUCT) { + return vmstate_load_state(f, field->vmsd, pv, field->struct_versio= n_id, + errp) >=3D 0; + } + + if (field->info->get(f, pv, size, field) < 0) { + error_setg(errp, + "Failed to load element of type %s for %s", + field->info->name, field->name); + return false; + } + + return true; +} + int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id, Error **errp) { @@ -225,24 +246,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *vmsd, inner_field =3D field; } =20 - if (inner_field->flags & VMS_STRUCT) { - ret =3D vmstate_load_state(f, inner_field->vmsd, curr_= elem, - 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, - errp); - } else { - ret =3D inner_field->info->get(f, curr_elem, size, - inner_field); - if (ret < 0) { - error_setg(errp, - "Failed to load element of type %s for = %s: " - "%d", inner_field->info->name, - inner_field->name, ret); - } - } + ret =3D vmstate_load_field(f, curr_elem, size, inner_field, + errp) ? 0 : -EINVAL; =20 /* If we used a fake temp field.. free it now */ if (inner_field !=3D field) { --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659519; cv=none; d=zohomail.com; s=zohoarc; b=AU28ARtu5IYzXhpk/GZ+gGPKu0MYvwxgDH988Btj5NO5U0VZikYr7L0y9NCOnjAE7vWLM9EpAJfvtBp16d56CH3yeEL8z7PllJtwDUDwTSUZlbNTto7r5/8ZqO3BabsfmrFsc/yR3KadfmUjTLYWM7SEjEk1UnclD9/W+CcNsIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659519; h=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=A+WiueIXETLIeMIRZIQgBqkxh+hFRPAHRreOOCK2W/c=; b=l8uEjMI0x+ZNnvM1f150+gGkO6KRcx0L1RmQg2dBbGp0bx/8l/+6/al9lxLpMUdtjUoiFPUhH0gjUrqZhh5D8BsewiwiCd+96rMA6Lg11vubq57A9mJ4dVdaJgA4fJP2Ou8r9dd3PhhF/VDjd9lqUhiW0xnH765BgdH+NGnkSIg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659519214174.4525276244285; Wed, 4 Mar 2026 13:25:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth2-0004oK-AS; Wed, 04 Mar 2026 16:23:46 -0500 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 1vxtgd-0004kF-UE for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgZ-0003SA-O3 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:19 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 27BBF80884; Thu, 05 Mar 2026 00:23:13 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-y3zHomAZ; Thu, 05 Mar 2026 00:23:12 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659392; bh=A+WiueIXETLIeMIRZIQgBqkxh+hFRPAHRreOOCK2W/c=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Ox5aAvEOjhjk6cutgQvi9cq/0CpY38upe73SK5zvh9gLsyfSGshdFQl+Hft2SSsxk IhPnvOGBeNS1e4xqI0nRRbAW4WK9dqZvVBgVhOmvqpo8Me82/dmcBOlnY+ihLKCh2s Yfvbe703bTVVSpHX7LVGqpolDWMeAgqEawGrCyDc= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 10/18] migration: factor out vmstate_post_load() from vmstate_load_state() Date: Thu, 5 Mar 2026 00:22:54 +0300 Message-ID: <20260304212303.667141-11-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659522249158500 Content-Type: text/plain; charset="utf-8" Simplify vmstate_load_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/vmstate.c | 49 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 32944c04443..53b57c09d82 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -182,6 +182,33 @@ static bool vmstate_load_field(QEMUFile *f, void *pv, = size_t size, return true; } =20 +static bool vmstate_post_load(const VMStateDescription *vmsd, + void *opaque, int version_id, Error **errp) +{ + ERRP_GUARD(); + + if (vmsd->post_load_errp) { + if (!vmsd->post_load_errp(opaque, version_id, errp)) { + error_prepend(errp, "post load hook failed for: %s, version_id= : " + "%d, minimum_version: %d: ", vmsd->name, + vmsd->version_id, vmsd->minimum_version_id); + return false; + } + } else if (vmsd->post_load) { + int ret =3D vmsd->post_load(opaque, version_id); + if (ret < 0) { + error_setg(errp, + "post load hook failed for: %s, version_id: %d, " + "minimum_version: %d, ret: %d", + vmsd->name, vmsd->version_id, vmsd->minimum_version= _id, + ret); + return false; + } + } + + return true; +} + int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id, Error **errp) { @@ -284,25 +311,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *vmsd, return ret; } =20 - if (vmsd->post_load_errp) { - if (!vmsd->post_load_errp(opaque, version_id, errp)) { - error_prepend(errp, "post load hook failed for: %s, version_id= : " - "%d, minimum_version: %d: ", vmsd->name, - vmsd->version_id, vmsd->minimum_version_id); - trace_vmstate_load_state_fail(vmsd->name, "post-load"); - return -EINVAL; - } - } else if (vmsd->post_load) { - ret =3D vmsd->post_load(opaque, version_id); - if (ret < 0) { - error_setg(errp, - "post load hook 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_fail(vmsd->name, "post-load"); - return ret; - } + if (!vmstate_post_load(vmsd, opaque, version_id, errp)) { + trace_vmstate_load_state_fail(vmsd->name, "post-load"); + return -EINVAL; } =20 trace_vmstate_load_state_success(vmsd->name); --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659487; cv=none; d=zohomail.com; s=zohoarc; b=KUM14xFc3CfLFYSzvjBOpAyKgGonOhKrxLYINQeVbaF5xj0vhNYQPBeZ1NqlEDdQs+7XotZrgcixEfx7c8ltM4Svakx0uy4Q5FZoemRUGtLazJmSTRx5RzzBBLGlfqGPMnCK1hQrQMpN77zCYiYBBKKb5H5ApRQkHnOB+mobYm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659487; h=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=3PPnchP95MpmjTTGrn5npE4Kd5zzNjZiQiulnkPPyA4=; b=Bmpqq2Xfps4cWclpv04IjKQ+uJ5QOgEcMDnPw3YlnXpGSMafacN4yJACFmfyCxx7TA6Zo0l4Ez5PADzGx8tifVfDFtT01Lh2CkNurtDFuFR2y3wdK7wSR1emPYvpmGJ0ElUInm98BRZxaZ+eW9Oz1jCtQxZkTp9bpxdiwwidkb8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659486717239.19718377547417; Wed, 4 Mar 2026 13:24:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth8-0004r2-G8; Wed, 04 Mar 2026 16:23:50 -0500 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 1vxtge-0004kG-2Z for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgZ-0003SM-Pd for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:19 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id BE04F8086C; Thu, 05 Mar 2026 00:23:13 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-6J8keWck; Thu, 05 Mar 2026 00:23:13 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659393; bh=3PPnchP95MpmjTTGrn5npE4Kd5zzNjZiQiulnkPPyA4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=mL3qInKPrSTSNw9f40SBaEgnEU2thMyjNbNZqHpqfQFC3WkMeIHGSQPBmv2T79hiX 3VlUp9WScuhCBQZSHVUSw0ArY617wcARnIEB3FDcNo/jp+JrJE4Q6Nq0CPk+jgJ/29 sqGOn5XPApYcRGJd8v7KqIYnZ+C9rfhCI5e83eaA= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 11/18] migration: convert vmstate_subsection_save/load functions to bool Date: Thu, 5 Mar 2026 00:22:55 +0300 Message-ID: <20260304212303.667141-12-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659491875139100 Content-Type: text/plain; charset="utf-8" Convert them to bool return value, as preparation to further convertion of vmstate_save/load_state(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/vmstate.c | 57 +++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 53b57c09d82..8825aa3b1f1 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -21,11 +21,11 @@ #include "qemu/error-report.h" #include "trace.h" =20 -static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque, JSONWriter *vmdesc, - Error **errp); -static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque, Error **errp); +static bool vmstate_subsection_save(QEMUFile *f, const VMStateDescription = *vmsd, + void *opaque, JSONWriter *vmdesc, + Error **errp); +static bool vmstate_subsection_load(QEMUFile *f, const VMStateDescription = *vmsd, + void *opaque, Error **errp); static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc, int version_id, Error **errp); @@ -305,10 +305,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *vmsd, } assert(field->flags =3D=3D VMS_END); =20 - ret =3D vmstate_subsection_load(f, vmsd, opaque, errp); - if (ret !=3D 0) { - qemu_file_set_error(f, ret); - return ret; + if (!vmstate_subsection_load(f, vmsd, opaque, errp)) { + qemu_file_set_error(f, -EINVAL); + return -EINVAL; } =20 if (!vmstate_post_load(vmsd, opaque, version_id, errp)) { @@ -637,7 +636,7 @@ static int vmstate_save_state_v(QEMUFile *f, const VMSt= ateDescription *vmsd, json_writer_end_array(vmdesc); } =20 - ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); + ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp) ? 0 : -= EINVAL; =20 out: if (vmsd->post_save) { @@ -667,15 +666,14 @@ int vmstate_save_state(QEMUFile *f, const VMStateDesc= ription *vmsd, errp); } =20 -static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque, Error **errp) +static bool 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) { char idstr[256], *idstr_ret; - int ret; uint8_t version_id, len, size; const VMStateDescription *sub_vmsd; =20 @@ -683,12 +681,12 @@ static int vmstate_subsection_load(QEMUFile *f, const= VMStateDescription *vmsd, if (len < strlen(vmsd->name) + 1) { /* subsection name has to be "section_name/a" */ trace_vmstate_subsection_load_bad(vmsd->name, "(short)", ""); - return 0; + return true; } size =3D qemu_peek_buffer(f, (uint8_t **)&idstr_ret, len, 2); if (size !=3D len) { trace_vmstate_subsection_load_bad(vmsd->name, "(peek fail)", "= "); - return 0; + return true; } memcpy(idstr, idstr_ret, size); idstr[size] =3D 0; @@ -696,41 +694,39 @@ static int vmstate_subsection_load(QEMUFile *f, const= VMStateDescription *vmsd, if (strncmp(vmsd->name, idstr, strlen(vmsd->name)) !=3D 0) { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(prefix)= "); /* it doesn't have a valid subsection name */ - return 0; + return true; } 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; + return false; } qemu_file_skip(f, 1); /* subsection */ qemu_file_skip(f, 1); /* len */ 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, errp); - if (ret) { + if (vmstate_load_state(f, sub_vmsd, opaque, version_id, errp) < 0)= { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(child)"= ); error_prepend(errp, - "Loading VM subsection '%s' in '%s' failed: %d: = ", - idstr, vmsd->name, ret); - return ret; + "Loading VM subsection '%s' in '%s' failed: ", + idstr, vmsd->name); + return false; } } =20 trace_vmstate_subsection_load_good(vmsd->name); - return 0; + return true; } =20 -static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque, JSONWriter *vmdesc, - Error **errp) +static bool vmstate_subsection_save(QEMUFile *f, const VMStateDescription = *vmsd, + void *opaque, JSONWriter *vmdesc, + Error **errp) { const VMStateDescription * const *sub =3D vmsd->subsections; bool vmdesc_has_subsections =3D false; - int ret =3D 0; =20 trace_vmstate_subsection_save_top(vmsd->name); while (sub && *sub) { @@ -754,9 +750,8 @@ 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(f, vmsdsub, opaque, vmdesc, errp); - if (ret) { - return ret; + if (vmstate_save_state(f, vmsdsub, opaque, vmdesc, errp) < 0) { + return false; } =20 if (vmdesc) { @@ -770,5 +765,5 @@ static int vmstate_subsection_save(QEMUFile *f, const V= MStateDescription *vmsd, json_writer_end_array(vmdesc); } =20 - return ret; + return true; } --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659497; cv=none; d=zohomail.com; s=zohoarc; b=jiJtogoi/KF8yKoM0oXQ7ZLcV0liIpsEg/viUhRmTV9PyDIPG3PJj0tQcCr8nxIEIebItgbSndlmVr3OFZ6V5QFSKyad25zqGk+UuRHf7IQs/MraSOpQoZIMGLL5b1VUE50ROi7nVJuotQhk36C5nZTCxoy+gr0VKJpgvUMtCbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659497; h=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=jM+edWLBaGe5x10EknnS2lq0Zw3RvzU/TRD06qcJuJ8=; b=ZdO377Z1mui67Q/zTutc5U6fpuJ3EyNo0iiJ5uaC9k9fG6ZmmCcp5p1jQAJli2rkBbyw5se1wtYlO3YH19g/6R7txoS7u3aGsCtbkhJikS3zPdGWrlKyEfP60Qc5HR4UYPKSpDiVsTbUtb/qPDryKGtSwF7Uo0cPNHpZzo9lkSY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659497337981.1680440549441; Wed, 4 Mar 2026 13:24:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth2-0004oN-BB; Wed, 04 Mar 2026 16:23:46 -0500 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 1vxtgc-0004k5-Lz for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgZ-0003SR-Np for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:18 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 5BFF980885; Thu, 05 Mar 2026 00:23:14 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-BNhmuhJR; Thu, 05 Mar 2026 00:23:13 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659393; bh=jM+edWLBaGe5x10EknnS2lq0Zw3RvzU/TRD06qcJuJ8=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=LkpKhwfJ+D/bKVGvVCk0NX29gPOkNqA7hR9w5pd4i4fuY0XJMw+jrsfvE1kzNPWlI pt+6TodvWTwi6maDNoIs2FvQuiXpndXg47itGco+4ytp6dhNQfc3jsNyjHNEjdXUMC Mh6EU3ms/ZUgm8lr4fqQz8F0XrrE/eXF74EnUEKQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 12/18] migration: VMStateInfo: introduce new handlers with errp Date: Thu, 5 Mar 2026 00:22:56 +0300 Message-ID: <20260304212303.667141-13-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659499456158500 Content-Type: text/plain; charset="utf-8" Add new APIs with errp, to allow handlers report good error messages. We'll convert existing handlers soon. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- include/migration/vmstate.h | 17 ++++++++++++++--- migration/vmstate.c | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 85838a49aee..77d58d27d41 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -32,12 +32,16 @@ typedef struct VMStateInfo VMStateInfo; typedef struct VMStateField VMStateField; =20 -/* VMStateInfo allows customized migration of objects that don't fit in +/* + * VMStateInfo allows customized migration of objects that don't fit in * any category in VMStateFlags. Additional information is always passed - * into get and put in terms of field and vmdesc parameters. However + * into load and save in terms of field and vmdesc parameters. However * these two parameters should only be used in cases when customized * handling is needed, such as QTAILQ. For primitive data types such as - * integer, field and vmdesc parameters should be ignored inside get/put. + * integer, field and vmdesc parameters should be ignored inside load/save. + * + * @get and @put are deprecated copies of @load and @save. For new interfa= ces + * use @load and @save. */ struct VMStateInfo { const char *name; @@ -46,6 +50,13 @@ struct VMStateInfo { int coroutine_mixed_fn (*put)(QEMUFile *f, void *pv, size_t size, const VMStateField *field, JSONWriter *vmdesc); + bool coroutine_mixed_fn (*load)(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, + Error **errp); + bool coroutine_mixed_fn (*save)(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, + JSONWriter *vmdesc, + Error **errp); }; =20 enum VMStateFlags { diff --git a/migration/vmstate.c b/migration/vmstate.c index 8825aa3b1f1..f16626d7d11 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -170,6 +170,8 @@ static bool vmstate_load_field(QEMUFile *f, void *pv, s= ize_t size, } else if (field->flags & VMS_VSTRUCT) { return vmstate_load_state(f, field->vmsd, pv, field->struct_versio= n_id, errp) >=3D 0; + } else if (field->info->load) { + return field->info->load(f, pv, size, field, errp); } =20 if (field->info->get(f, pv, size, field) < 0) { @@ -495,6 +497,8 @@ static bool vmstate_save_field(QEMUFile *f, void *pv, s= ize_t size, return vmstate_save_state_v(f, field->vmsd, pv, vmdesc, field->struct_version_id, errp) >=3D 0; + } else if (field->info->save) { + return field->info->save(f, pv, size, field, vmdesc, errp); } =20 if (field->info->put(f, pv, size, field, vmdesc) < 0) { --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659600; cv=none; d=zohomail.com; s=zohoarc; b=PbmsXvxjQaqbQUC1zvIGu06HFhrN7hBMM1oj4M0aAnWGafOwED0xyUJSiL0WU3Ig+KSf+T+eP7EBGPxvM9mkVoCOv6rxpjxIRp+ygQqpqCWV6/0Yl383xPSWa30WAuMAbS1+1v3fVlnEopL00MP6kG4/bPpWedbVqQc4lwfvayw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659600; h=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=EYjxCP6LDHSYNiuJU2KNhkUbFgypgkNiULYJWHMI+C4=; b=nbLII+HG/PySw2CLgOHd4NbVkBXaXMdEbEt77fp2VAOQMczqvKCntepb4Ds791dCPAcGQIip5I9yew2T6IyTSUIhg89vhMbRiwVYDv6mM1Oywz/cXheSu5bacybu6E5JtI/HOsSCeSffpgzrReyTaRXsQqV+rh9SYt35jfbJSNM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659600712487.62482594314076; Wed, 4 Mar 2026 13:26:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth6-0004ot-B9; Wed, 04 Mar 2026 16:23:48 -0500 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 1vxtgf-0004m0-2t for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:24 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtga-0003Se-Gk for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 1EF738084D; Thu, 05 Mar 2026 00:23:15 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-LigqUzQK; Thu, 05 Mar 2026 00:23:14 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659394; bh=EYjxCP6LDHSYNiuJU2KNhkUbFgypgkNiULYJWHMI+C4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=HlLyDbuRrwcwB+LhV6Bv5cgUmALEJpTAJQjbQYQYRrXeEnA+1QUfuFDxe9fNIyxHq KXXYpd1Ad1nrUUInNKM3/pezrv8dC7zociirZAtEgaN7eae29U0D2xnNy4ln3ETemP XnG/Is8j58MgGl9ifHvtfEqHCPoiPD3b+ar/6mgw= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 13/18] migration: introduce vmstate_load_vmsd() and vmstate_save_vmsd() Date: Thu, 5 Mar 2026 00:22:57 +0300 Message-ID: <20260304212303.667141-14-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659601514158500 Content-Type: text/plain; charset="utf-8" Introduce new APIs, returning bool. The analysis https://lore.kernel.org/qemu-devel/aQDdRn8t0B8oE3gf@x1.local/ shows, that vmstate_load_state() return value actually only used to check for success, specific errno values doesn't make sense. With this commit we introduce new functions with modern bool interface, and in following commits we'll update the code base to use them, starting from migration/ code, and finally we will remove old vmstate_load_state() and vmstate_save_state(). This patch reworks existing functions to new one, so that old interfaces are simple wrappers, which will be easy to remove later. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- include/migration/vmstate.h | 9 ++++ migration/vmstate.c | 89 ++++++++++++++++++++----------------- 2 files changed, 58 insertions(+), 40 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 77d58d27d41..3c1d84f2d67 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1247,10 +1247,19 @@ extern const VMStateInfo vmstate_info_qlist; .flags =3D VMS_END, \ } =20 +/* + * vmstate_load_state() and vmstate_save_state() are + * depreacated, use vmstate_load_vmsd() and vmstate_save_vmsd() + * instead. + */ 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, Error **errp); +bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, int version_id, Error **errp); +bool vmstate_save_vmsd(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, JSONWriter *vmdesc, Error **errp); =20 bool vmstate_section_needed(const VMStateDescription *vmsd, void *opaque); =20 diff --git a/migration/vmstate.c b/migration/vmstate.c index f16626d7d11..e98b5f5346c 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -26,7 +26,7 @@ static bool vmstate_subsection_save(QEMUFile *f, const VM= StateDescription *vmsd, Error **errp); static bool vmstate_subsection_load(QEMUFile *f, const VMStateDescription = *vmsd, void *opaque, Error **errp); -static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, +static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc, int version_id, Error **errp); =20 @@ -165,11 +165,11 @@ static bool vmstate_load_field(QEMUFile *f, void *pv,= size_t size, const VMStateField *field, Error **errp) { if (field->flags & VMS_STRUCT) { - return vmstate_load_state(f, field->vmsd, pv, field->vmsd->version= _id, - errp) >=3D 0; + return vmstate_load_vmsd(f, field->vmsd, pv, field->vmsd->version_= id, + errp); } else if (field->flags & VMS_VSTRUCT) { - return vmstate_load_state(f, field->vmsd, pv, field->struct_versio= n_id, - errp) >=3D 0; + return vmstate_load_vmsd(f, field->vmsd, pv, field->struct_version= _id, + errp); } else if (field->info->load) { return field->info->load(f, pv, size, field, errp); } @@ -211,12 +211,11 @@ static bool vmstate_post_load(const VMStateDescriptio= n *vmsd, return true; } =20 -int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, +bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id, Error **errp) { ERRP_GUARD(); const VMStateField *field =3D vmsd->fields; - int ret =3D 0; =20 trace_vmstate_load_state(vmsd->name, version_id); =20 @@ -225,7 +224,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, "for local version_id %d", vmsd->name, version_id, vmsd->version_id); trace_vmstate_load_state_fail(vmsd->name, "too new"); - return -EINVAL; + return false; } =20 if (version_id < vmsd->minimum_version_id) { @@ -233,11 +232,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, "for local minimum version_id %d", vmsd->name, version_id, vmsd->minimum_version_id); trace_vmstate_load_state_fail(vmsd->name, "too old"); - return -EINVAL; + return false; } =20 if (!vmstate_pre_load(vmsd, opaque, errp)) { - return -EINVAL; + return false; } =20 while (field->name) { @@ -257,6 +256,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, } =20 for (i =3D 0; i < n_elems; i++) { + bool ok; void *curr_elem =3D first_elem + size * i; const VMStateField *inner_field; =20 @@ -275,33 +275,32 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, inner_field =3D field; } =20 - ret =3D vmstate_load_field(f, curr_elem, size, inner_field, - errp) ? 0 : -EINVAL; + ok =3D vmstate_load_field(f, curr_elem, size, inner_field,= errp); =20 /* If we used a fake temp field.. free it now */ if (inner_field !=3D field) { g_clear_pointer((gpointer *)&inner_field, g_free); } =20 - if (ret >=3D 0) { - ret =3D qemu_file_get_error(f); + if (ok) { + int ret =3D qemu_file_get_error(f); if (ret < 0) { error_setg(errp, "Failed to load %s state: stream error:= %d", vmsd->name, ret); trace_vmstate_load_field_error(field->name, ret); - return ret; + return false; } } else { - qemu_file_set_error(f, ret); - trace_vmstate_load_field_error(field->name, ret); - return ret; + qemu_file_set_error(f, -EINVAL); + trace_vmstate_load_field_error(field->name, -EINVAL); + return false; } } } else if (field->flags & VMS_MUST_EXIST) { error_setg(errp, "Input validation failed: %s/%s version_id: %= d", vmsd->name, field->name, vmsd->version_id); - return -1; + return false; } field++; } @@ -309,17 +308,16 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, =20 if (!vmstate_subsection_load(f, vmsd, opaque, errp)) { qemu_file_set_error(f, -EINVAL); - return -EINVAL; + return false; } =20 if (!vmstate_post_load(vmsd, opaque, version_id, errp)) { trace_vmstate_load_state_fail(vmsd->name, "post-load"); - return -EINVAL; + return false; } =20 trace_vmstate_load_state_success(vmsd->name); - - return 0; + return true; } =20 static int vmfield_name_num(const VMStateField *start, @@ -492,11 +490,10 @@ static bool vmstate_save_field(QEMUFile *f, void *pv,= size_t size, JSONWriter *vmdesc, Error **errp) { if (field->flags & VMS_STRUCT) { - return vmstate_save_state(f, field->vmsd, pv, vmdesc, errp) >=3D 0; + return vmstate_save_vmsd(f, field->vmsd, pv, vmdesc, errp); } else if (field->flags & VMS_VSTRUCT) { - return vmstate_save_state_v(f, field->vmsd, pv, vmdesc, - field->struct_version_id, - errp) >=3D 0; + return vmstate_save_vmsd_v(f, field->vmsd, pv, vmdesc, + field->struct_version_id, errp); } else if (field->info->save) { return field->info->save(f, pv, size, field, vmdesc, errp); } @@ -509,19 +506,19 @@ static bool vmstate_save_field(QEMUFile *f, void *pv,= size_t size, return true; } =20 -static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, +static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc, int version_id, Error **errp) { ERRP_GUARD(); - int ret =3D 0; + bool ok =3D true; const VMStateField *field =3D vmsd->fields; =20 trace_vmstate_save_state_top(vmsd->name); =20 if (!vmstate_pre_save(vmsd, opaque, errp)) { trace_vmstate_save_state_pre_save_fail(vmsd->name); - return -EINVAL; + return false; } =20 trace_vmstate_save_state_pre_save_success(vmsd->name); @@ -602,8 +599,8 @@ static int vmstate_save_state_v(QEMUFile *f, const VMSt= ateDescription *vmsd, vmsd_desc_field_start(vmsd, vmdesc_loop, inner_field, i, max_elems); =20 - ret =3D vmstate_save_field(f, curr_elem, size, inner_field, - vmdesc_loop, errp) ? 0 : -EINVAL; + ok =3D vmstate_save_field(f, curr_elem, size, inner_field, + vmdesc_loop, errp); =20 written_bytes =3D qemu_file_transferred(f) - old_offset; vmsd_desc_field_end(vmsd, vmdesc_loop, inner_field, @@ -614,7 +611,7 @@ static int vmstate_save_state_v(QEMUFile *f, const VMSt= ateDescription *vmsd, g_clear_pointer((gpointer *)&inner_field, g_free); } =20 - if (ret) { + if (!ok) { error_prepend(errp, "Save of field %s/%s failed: ", vmsd->name, field->name); goto out; @@ -640,13 +637,13 @@ static int vmstate_save_state_v(QEMUFile *f, const VM= StateDescription *vmsd, json_writer_end_array(vmdesc); } =20 - ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp) ? 0 : -= EINVAL; + ok =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); =20 out: if (vmsd->post_save) { vmsd->post_save(opaque); } - return ret; + return ok; } =20 static const VMStateDescription * @@ -663,11 +660,11 @@ vmstate_get_subsection(const VMStateDescription * con= st *sub, return NULL; } =20 -int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, +bool vmstate_save_vmsd(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc_id, Error **errp) { - return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_= id, - errp); + return vmstate_save_vmsd_v(f, vmsd, opaque, vmdesc_id, vmsd->version_i= d, + errp); } =20 static bool vmstate_subsection_load(QEMUFile *f, const VMStateDescription = *vmsd, @@ -712,7 +709,7 @@ static bool vmstate_subsection_load(QEMUFile *f, const = VMStateDescription *vmsd, qemu_file_skip(f, len); /* idstr */ version_id =3D qemu_get_be32(f); =20 - if (vmstate_load_state(f, sub_vmsd, opaque, version_id, errp) < 0)= { + if (!vmstate_load_vmsd(f, sub_vmsd, opaque, version_id, errp)) { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(child)"= ); error_prepend(errp, "Loading VM subsection '%s' in '%s' failed: ", @@ -754,7 +751,7 @@ static bool vmstate_subsection_save(QEMUFile *f, const = VMStateDescription *vmsd, qemu_put_byte(f, len); qemu_put_buffer(f, (uint8_t *)vmsdsub->name, len); qemu_put_be32(f, vmsdsub->version_id); - if (vmstate_save_state(f, vmsdsub, opaque, vmdesc, errp) < 0) { + if (!vmstate_save_vmsd(f, vmsdsub, opaque, vmdesc, errp)) { return false; } =20 @@ -771,3 +768,15 @@ static bool vmstate_subsection_save(QEMUFile *f, const= VMStateDescription *vmsd, =20 return true; } + +int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, JSONWriter *vmdesc_id, Error **errp) +{ + return vmstate_save_vmsd(f, vmsd, opaque, vmdesc_id, errp) ? 0 : -EINV= AL; +} + +int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, int version_id, Error **errp) +{ + return vmstate_load_vmsd(f, vmsd, opaque, version_id, errp) ? 0 : -EIN= VAL; +} --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659482; cv=none; d=zohomail.com; s=zohoarc; b=Qq3i0+iO9YPU/G8hp52yFnqJao2X7NwExs2b9YHF8f/ZmyvIDmEU8M/Q3uAsacxgRoBfIlU9+JGTBJN9WHSC0AiWmLI6SU36XJpxIcmLJMK0a0PbixePEI1nBBCu7u+oM1b6iNHouf4PPG0LOf3vJv8IrbyeUPuk23W+koVFtKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659482; h=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=B73nPWJcUAv3T4zGXNwZqG1+gDtERH9N2aYgr3lGjlQ=; b=XNQMdmRDoulh0k0R1MzlIa6oQ30p/nlBD9WXjOaPsPdFzOZRgw388wnAx4jFojF766pgFKH0UeZ7RjRiv+y4Ej6rfyf9Xbt412Jn5DApySeDt87xsbxiRLwIYrsXs2kyumR8kYvZeuZekvWazIYDnuYAuDLueayhcmrY2dZk5AM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659482176842.4933298373875; Wed, 4 Mar 2026 13:24:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxtgy-0004o5-DB; Wed, 04 Mar 2026 16:23:40 -0500 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 1vxtgf-0004lz-1c for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:24 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgc-0003TB-Gt for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id ED04680BCD; Thu, 05 Mar 2026 00:23:15 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-NtvCHoHd; Thu, 05 Mar 2026 00:23:15 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659395; bh=B73nPWJcUAv3T4zGXNwZqG1+gDtERH9N2aYgr3lGjlQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=eE3YxCj8iT+MdPZOvPGtAv9i+m3EZnjaH34/4ekqWHOC8w9IxpjLbpx1t1FFk0Ft0 lvnE5wyi/ZrvCq2vkSv9DM8V+erpXTLP9yCYOlPm7GEQOiUf/1sfV9KbUVmgAz5eW4 hsggm1dyEqJE/3qlcJnZoH5pJ1wpDB3LeQoMnwkw= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, Mark Kanda , Ben Chaney Subject: [PATCH v3 14/18] migration/cpr: move to new migration APIs Date: Thu, 5 Mar 2026 00:22:58 +0300 Message-ID: <20260304212303.667141-15-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659488057158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- include/migration/cpr.h | 2 +- migration/cpr.c | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 5850fd1788b..96ce26e7117 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -43,7 +43,7 @@ void cpr_set_incoming_mode(MigMode mode); bool cpr_is_incoming(void); =20 bool cpr_state_save(MigrationChannel *channel, Error **errp); -int cpr_state_load(MigrationChannel *channel, Error **errp); +bool cpr_state_load(MigrationChannel *channel, Error **errp); void cpr_state_close(void); struct QIOChannel *cpr_state_ioc(void); =20 diff --git a/migration/cpr.c b/migration/cpr.c index a0b37007f55..05266dfcfd3 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -178,7 +178,6 @@ bool cpr_is_incoming(void) =20 bool cpr_state_save(MigrationChannel *channel, Error **errp) { - int ret; QEMUFile *f; MigMode mode =3D migrate_mode(); =20 @@ -199,8 +198,7 @@ bool cpr_state_save(MigrationChannel *channel, Error **= errp) 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, errp); - if (ret) { + if (!vmstate_save_vmsd(f, &vmstate_cpr_state, &cpr_state, 0, errp)) { qemu_fclose(f); return false; } @@ -223,9 +221,8 @@ bool cpr_state_save(MigrationChannel *channel, Error **= errp) return true; } =20 -int cpr_state_load(MigrationChannel *channel, Error **errp) +bool cpr_state_load(MigrationChannel *channel, Error **errp) { - int ret; uint32_t v; QEMUFile *f; MigMode mode =3D 0; @@ -241,10 +238,10 @@ int cpr_state_load(MigrationChannel *channel, Error *= *errp) cpr_set_incoming_mode(mode); f =3D cpr_transfer_input(channel, errp); } else { - return 0; + return true; } if (!f) { - return -1; + return false; } =20 trace_cpr_state_load(MigMode_str(mode)); @@ -254,19 +251,18 @@ int cpr_state_load(MigrationChannel *channel, Error *= *errp) if (v !=3D QEMU_CPR_FILE_MAGIC) { error_setg(errp, "Not a migration stream (bad magic %x)", v); qemu_fclose(f); - return -EINVAL; + return false; } v =3D qemu_get_be32(f); if (v !=3D QEMU_CPR_FILE_VERSION) { error_setg(errp, "Unsupported migration stream version %d", v); qemu_fclose(f); - return -ENOTSUP; + return false; } =20 - ret =3D vmstate_load_state(f, &vmstate_cpr_state, &cpr_state, 1, errp); - if (ret) { + if (!vmstate_load_vmsd(f, &vmstate_cpr_state, &cpr_state, 1, errp)) { qemu_fclose(f); - return ret; + return false; } =20 if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { @@ -280,7 +276,7 @@ int cpr_state_load(MigrationChannel *channel, Error **e= rrp) */ cpr_state_file =3D f; =20 - return ret; + return true; } =20 void cpr_state_close(void) --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659624; cv=none; d=zohomail.com; s=zohoarc; b=NgIrfCGkNCa6OJLekpfRLF1lBn/Vk4UqENe3nin8BOYjyDUQqT+iIbJ7RLsLV6l/J0ejFniK9c+i+CPjpNVKhftuo8JDGevPn6vyHINBx0w/6gfc6tQ2TNvMkwvB99L0J8boT3XOXvN++rml9Fuz+LTDW7lMMu5wEkrRyj5e4hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659624; h=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=rZq+2jxkcntS00G/DpIMhzwAYy5l95RJHArfeh2HkZM=; b=JUxY6TP5X0hkOcGtY6IHQKdvggbumk/yLIrUYFKSVIsKqxWj2XcKWsVvWfO5pebIXh9wXu3wcbao0fRl6qF9gJg35HgIh0vVPLGmt3JFOANnbu1DRLw13LUyHaIgwHJT94By5nYu6/F+HC5PHI2TzPNy7In6ggRHJohbxDBh80k= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659624980624.3197840700614; Wed, 4 Mar 2026 13:27:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth7-0004pR-Kz; Wed, 04 Mar 2026 16:23:49 -0500 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 1vxtgf-0004m1-3P for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:25 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgc-0003T8-4V for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:20 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 948A980887; Thu, 05 Mar 2026 00:23:16 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-48L5Tkyt; Thu, 05 Mar 2026 00:23:16 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659396; bh=rZq+2jxkcntS00G/DpIMhzwAYy5l95RJHArfeh2HkZM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=mlTvMs6UGIeHntGYgJUrM6lgckRvUb9oDMbeniQ4IxLqfA9R6u0hMnsLaNUOdlChY AXQeWMAt+SbFrCW0SdYcFrqacTpJdOqGZ0TiSDlXEoXFoFSP6Sv6G3dHwH1PrZXkQI 6yZNoUBeRFKY4M++5IQ4NVzHRO/o0ermnjYpg3KI= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 15/18] migration/savevm: move to new migration APIs Date: Thu, 5 Mar 2026 00:22:59 +0300 Message-ID: <20260304212303.667141-16-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659625690158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/savevm.c | 105 ++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index c5236e71ba1..a4c64dda0a2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -205,27 +205,28 @@ void timer_get(QEMUFile *f, QEMUTimer *ts) * Not in vmstate.c to not add qemu-timer.c as dependency to vmstate.c */ =20 -static int get_timer(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_timer(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { QEMUTimer *v =3D pv; timer_get(f, v); - return 0; + return true; } =20 -static int put_timer(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_timer(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { QEMUTimer *v =3D pv; timer_put(f, v); =20 - return 0; + return true; } =20 const VMStateInfo vmstate_info_timer =3D { .name =3D "timer", - .get =3D get_timer, - .put =3D put_timer, + .load =3D load_timer, + .save =3D save_timer, }; =20 =20 @@ -297,7 +298,7 @@ static uint32_t get_validatable_capabilities_count(void) return result; } =20 -static int configuration_pre_save(void *opaque) +static bool configuration_pre_save(void *opaque, Error **errp) { SaveState *state =3D opaque; const char *current_name =3D MACHINE_GET_CLASS(current_machine)->name; @@ -318,7 +319,7 @@ static int configuration_pre_save(void *opaque) } state->uuid =3D qemu_uuid; =20 - return 0; + return true; } =20 static void configuration_post_save(void *opaque) @@ -330,7 +331,7 @@ static void configuration_post_save(void *opaque) state->caps_count =3D 0; } =20 -static int configuration_pre_load(void *opaque) +static bool configuration_pre_load(void *opaque, Error **errp) { SaveState *state =3D opaque; =20 @@ -339,7 +340,7 @@ static int configuration_pre_load(void *opaque) * minimum possible value for this CPU. */ state->target_page_bits =3D migration_legacy_page_bits(); - return 0; + return true; } =20 static bool configuration_validate_capabilities(SaveState *state) @@ -376,28 +377,31 @@ static bool configuration_validate_capabilities(SaveS= tate *state) return ret; } =20 -static int configuration_post_load(void *opaque, int version_id) +static bool configuration_post_load(void *opaque, int version_id, Error **= errp) { SaveState *state =3D opaque; const char *current_name =3D MACHINE_GET_CLASS(current_machine)->name; - int ret =3D 0; + bool ok =3D true; =20 if (strncmp(state->name, current_name, state->len) !=3D 0) { - error_report("Machine type received is '%.*s' and local is '%s'", - (int) state->len, state->name, current_name); - ret =3D -EINVAL; + error_setg(errp, + "Machine type received is '%.*s' and local is '%s'", + (int) state->len, state->name, current_name); + ok =3D false; goto out; } =20 if (state->target_page_bits !=3D qemu_target_page_bits()) { - error_report("Received TARGET_PAGE_BITS is %d but local is %d", - state->target_page_bits, qemu_target_page_bits()); - ret =3D -EINVAL; + error_setg(errp, + "Received TARGET_PAGE_BITS is %d but local is %d", + state->target_page_bits, qemu_target_page_bits()); + ok =3D false; goto out; } =20 if (!configuration_validate_capabilities(state)) { - ret =3D -EINVAL; + error_setg(errp, "Failed to validate capabilities"); + ok =3D false; goto out; } =20 @@ -409,11 +413,12 @@ out: state->capabilities =3D NULL; state->caps_count =3D 0; =20 - return ret; + return ok; } =20 -static int get_capability(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_capability(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, + Error **errp) { MigrationCapability *capability =3D pv; char capability_str[UINT8_MAX + 1]; @@ -426,15 +431,16 @@ static int get_capability(QEMUFile *f, void *pv, size= _t size, for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { if (!strcmp(MigrationCapability_str(i), capability_str)) { *capability =3D i; - return 0; + return true; } } - error_report("Received unknown capability %s", capability_str); - return -EINVAL; + error_setg(errp, "Received unknown capability %s", capability_str); + return false; } =20 -static int put_capability(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_capability(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { MigrationCapability *capability =3D pv; const char *capability_str =3D MigrationCapability_str(*capability); @@ -443,13 +449,13 @@ static int put_capability(QEMUFile *f, void *pv, size= _t size, =20 qemu_put_byte(f, len); qemu_put_buffer(f, (uint8_t *)capability_str, len); - return 0; + return true; } =20 static const VMStateInfo vmstate_info_capability =3D { .name =3D "capability", - .get =3D get_capability, - .put =3D put_capability, + .load =3D load_capability, + .save =3D save_capability, }; =20 /* The target-page-bits subsection is present only if the @@ -539,9 +545,9 @@ static const VMStateDescription vmstate_uuid =3D { static const VMStateDescription vmstate_configuration =3D { .name =3D "configuration", .version_id =3D 1, - .pre_load =3D configuration_pre_load, - .post_load =3D configuration_post_load, - .pre_save =3D configuration_pre_save, + .pre_load_errp =3D configuration_pre_load, + .post_load_errp =3D configuration_post_load, + .pre_save_errp =3D configuration_pre_save, .post_save =3D configuration_post_save, .fields =3D (const VMStateField[]) { VMSTATE_UINT32(len, SaveState), @@ -969,8 +975,13 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *s= e, Error **errp) } return ret; } - return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id, - errp); + + if (!vmstate_load_vmsd(f, se->vmsd, se->opaque, se->load_version_id, + errp)) { + return -EINVAL; + } + + return 0; } =20 static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, @@ -1028,8 +1039,6 @@ static void save_section_footer(QEMUFile *f, SaveStat= eEntry *se) static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdes= c, Error **errp) { - int ret; - if ((!se->ops || !se->ops->save_state) && !se->vmsd) { return 0; } @@ -1050,10 +1059,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(f, se->vmsd, se->opaque, vmdesc, - errp); - if (ret) { - return ret; + if (!vmstate_save_vmsd(f, se->vmsd, se->opaque, vmdesc, errp)) { + return -EINVAL; } } =20 @@ -1317,8 +1324,8 @@ static void qemu_savevm_send_configuration(MigrationS= tate *s, QEMUFile *f) json_writer_start_object(vmdesc, "configuration"); } =20 - vmstate_save_state(f, &vmstate_configuration, &savevm_state, - vmdesc, &local_err); + vmstate_save_vmsd(f, &vmstate_configuration, &savevm_state, + vmdesc, &local_err); if (local_err) { error_report_err(local_err); } @@ -2748,7 +2755,6 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e, Error **errp) 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) { @@ -2779,10 +2785,9 @@ static int qemu_loadvm_state_header(QEMUFile *f, Err= or **errp) return -EINVAL; } =20 - ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0, - errp); - if (ret) { - return ret; + if (!vmstate_load_vmsd(f, &vmstate_configuration, &savevm_state, 0, + errp)) { + return -EINVAL; } } return 0; --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659501; cv=none; d=zohomail.com; s=zohoarc; b=P0/figIPCxICkgW2luBOU8szhRa5ZqFH6CkNpoMBD3AAeLSe5ocmn2P5ZRxlrGYXNroHMGbRyTe+5IAJCkvN86QgneWDWtIZasR1oanjZngxwMulSZ1JD360Drn4ZAiKGxc6UQkWjFLNQ+0B+fkmd6p/L9TD7lgCDQlitY5QPYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659501; h=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=amU9C2f3rJ88akoLojIH8Spv0Mmp5f3aJg0j9G5aQFQ=; b=ULEgVsXGV+S9xsbUEYZdGlRetEAiaE8ExF9yuRragrTEWZFFkVd0I4FtYJotglXfXOhhkZNVowDFPfinYYaYe2PSy5d1XoxPpA9/A5182OHr3CcDj5cuHeHOSGoE2Bbgbz/wkUJn6EjtCLVIqa8oS+9B59nxJ+uMXOaK7mZkWDY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659501706962.2569221865581; Wed, 4 Mar 2026 13:25:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth4-0004oV-Al; Wed, 04 Mar 2026 16:23:47 -0500 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 1vxtgg-0004m6-Hd; Wed, 04 Mar 2026 16:23:25 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtge-0003Ty-NM; Wed, 04 Mar 2026 16:23:22 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 7027480809; Thu, 05 Mar 2026 00:23:17 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-eBKyXR3h; Thu, 05 Mar 2026 00:23:16 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659396; bh=amU9C2f3rJ88akoLojIH8Spv0Mmp5f3aJg0j9G5aQFQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=JpfjPQsp4t+8GWRCxp9StcVvbXCm1rwsiMAiVv0Iucz2pIz9n+RdcIb/3UO+cAw/J hiZsCpkULwdvzqVHsMjSKtstksuOf8DJxYs+pt2NnVsMaQltzDLKigzfB3sActcSI8 R1JyqswaK1SZhXb5n7ISrCCJ440hYkTM8JTeYkS0= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, Halil Pasic , Christian Borntraeger , Eric Farman , Farhan Ali , Thomas Huth , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Matthew Rosato , qemu-s390x@nongnu.org (open list:S390 channel subs...) Subject: [PATCH v3 16/18] hw/s390x/css: drop use of .err_hint for vmstate Date: Thu, 5 Mar 2026 00:23:00 +0300 Message-ID: <20260304212303.667141-17-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659504331139100 Content-Type: text/plain; charset="utf-8" That's the only usage through the whole base. Doesn't worth keeping the whole complexity. And 2.7 machines were long ago. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Farman Reviewed-by: Peter Xu --- hw/s390x/css.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 04ce3178a0b..df5f0bc27f1 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -192,10 +192,6 @@ static const VMStateDescription vmstate_schdev_orb =3D= { static int subch_dev_post_load(void *opaque, int version_id); static int subch_dev_pre_save(void *opaque); =20 -const char err_hint_devno[] =3D "Devno mismatch, tried to load wrong secti= on!" - " Likely reason: some sequences of plug and unplug can break" - " migration for machine versions prior to 2.7 (known design flaw)."; - const VMStateDescription vmstate_subch_dev =3D { .name =3D "s390_subch_dev", .version_id =3D 1, @@ -203,10 +199,15 @@ const VMStateDescription vmstate_subch_dev =3D { .post_load =3D subch_dev_post_load, .pre_save =3D subch_dev_pre_save, .fields =3D (const VMStateField[]) { - VMSTATE_UINT8_EQUAL(cssid, SubchDev, "Bug!"), - VMSTATE_UINT8_EQUAL(ssid, SubchDev, "Bug!"), + VMSTATE_UINT8_EQUAL(cssid, SubchDev, NULL), + VMSTATE_UINT8_EQUAL(ssid, SubchDev, NULL), VMSTATE_UINT16(migrated_schid, SubchDev), - VMSTATE_UINT16_EQUAL(devno, SubchDev, err_hint_devno), + /* + * If devno mismatch on target, it may be due to some + * sequences of plug and unplug breaks migration for + * machine versions prior to 2.7 (known design flaw). + */ + VMSTATE_UINT16_EQUAL(devno, SubchDev, NULL), VMSTATE_BOOL(thinint_active, SubchDev), VMSTATE_STRUCT(curr_status, SubchDev, 0, vmstate_schib, SCHIB), VMSTATE_UINT8_ARRAY(sense_data, SubchDev, 32), --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659623; cv=none; d=zohomail.com; s=zohoarc; b=ECcNg2htjr7p8lPi9+I66eWdFhFoMqx6tkp67klTUUhgJFiO11k27CDXvyGfFO5DeBDNyhkHQSWw11WBZeyWffBuECemaVvuawF2G9AUjSAszj746d/KF9GnUeCHhZcOR4K4x1kMoG7qMqxv1gt4yPBYLvUx8uKzwitiRFy+ZiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659623; h=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=2+r8N3ETSUrim8PedcZAmsSYgGQ1jO/Vw/eLNDq0igU=; b=BuETxVnufsarX2TEixmn5U7AKAgvS56SgObXMNaQmYySJcM7zs8Ueo3F4G132GdU4isU5seAJGi9HR6BaK8iQ3B7e6ymuHrhB8XFCu4sr7VW+o2AmOPJBTuApAfdv1Smo0NJM2PlkyAXoehjJAuTkY1pBImd4FU63BTPXMQrBkA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772659623944872.8099251495868; Wed, 4 Mar 2026 13:27:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth7-0004p3-5E; Wed, 04 Mar 2026 16:23:49 -0500 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 1vxtgm-0004mL-Kw; Wed, 04 Mar 2026 16:23:30 -0500 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgj-0003Ve-4s; Wed, 04 Mar 2026 16:23:28 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 9362FC01EB; Thu, 05 Mar 2026 00:23:20 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-jDmN2qrO; Thu, 05 Mar 2026 00:23:19 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659399; bh=2+r8N3ETSUrim8PedcZAmsSYgGQ1jO/Vw/eLNDq0igU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=UWAka9Vkp0iZDW+jJ3Why98OHmn4jIvr1yshyuDMlsaOmWzFPoiIb3Gy1LOqoHmoL Alnt7n5lA0FKghCvUQNYiRrOFoShLyuJR4mxLgE1VbF6n1akbA4TzZOIGDr6yixdvB 3iwv4FwXHQCvMMZ7GsztXiYkxQWzqedp1SFpO1jg= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, John Snow , Kevin Wolf , Hanna Reitz , Gerd Hoffmann , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Dmitry Fleytman , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Mark Cave-Ayland , Gautam Menghani , Glenn Miles , Nicholas Piggin , Harsh Prateek Bora , Stefan Weil , Halil Pasic , Christian Borntraeger , Eric Farman , Farhan Ali , Matthew Rosato , Ilya Leoshkevich , David Hildenbrand , Thomas Huth , Chinmay Rath , qemu-block@nongnu.org (open list:Floppy), qemu-ppc@nongnu.org (open list:XIVE), qemu-s390x@nongnu.org (open list:S390 channel subs...) Subject: [PATCH v3 17/18] migration: drop VMStateField.err_hint Date: Thu, 5 Mar 2026 00:23:01 +0300 Message-ID: <20260304212303.667141-18-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659626924139100 Content-Type: text/plain; charset="utf-8" The field is unused, all users of VMSTATE_*_EQUAL pass _err_hint=3DNULL. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Eric Farman # s390 Reviewed-by: Akihiko Odaki Reviewed-by: Peter Xu --- hw/block/fdc.c | 2 +- hw/display/qxl.c | 4 ++-- hw/display/vga.c | 2 +- hw/display/virtio-gpu.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/i386/vmmouse.c | 2 +- hw/ide/ahci.c | 2 +- hw/intc/openpic.c | 2 +- hw/intc/spapr_xive.c | 2 +- hw/intc/xics.c | 2 +- hw/intc/xive.c | 2 +- hw/nvram/eeprom93xx.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pcie_aer.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/ppc/spapr_pci.c | 4 ++-- hw/ppc/spapr_vio.c | 4 ++-- hw/s390x/css.c | 6 +++--- hw/usb/hcd-uhci.c | 2 +- include/migration/vmstate.h | 36 +++++++++++++++++------------------- migration/vmstate-types.c | 15 --------------- target/ppc/machine.c | 6 +++--- 22 files changed, 44 insertions(+), 61 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 4585640af92..2c1681b7d0a 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -1051,7 +1051,7 @@ const VMStateDescription vmstate_fdc =3D { VMSTATE_UINT8(config, FDCtrl), VMSTATE_UINT8(lock, FDCtrl), VMSTATE_UINT8(pwrd, FDCtrl), - VMSTATE_UINT8_EQUAL(num_floppies, FDCtrl, NULL), + VMSTATE_UINT8_EQUAL(num_floppies, FDCtrl), VMSTATE_STRUCT_ARRAY(drives, FDCtrl, MAX_FD, 1, vmstate_fdrive, FDrive), VMSTATE_END_OF_LIST() diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 0551b38230b..a63b70f4ebc 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2442,12 +2442,12 @@ static const VMStateDescription qxl_vmstate =3D { VMSTATE_UINT32(last_release_offset, PCIQXLDevice), VMSTATE_UINT32(mode, PCIQXLDevice), VMSTATE_UINT32(ssd.unique, PCIQXLDevice), - VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice, NULL), + VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice), VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS, 0, qxl_memslot, struct guest_slots), VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, 0, qxl_surface, QXLSurfaceCreate), - VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice, NULL), + VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice), VMSTATE_VARRAY_INT32(guest_surfaces.cmds, PCIQXLDevice, ssd.num_surfaces, 0, vmstate_info_uint64, uint64_t), diff --git a/hw/display/vga.c b/hw/display/vga.c index 59a65cbbff5..f936f47ad22 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2160,7 +2160,7 @@ const VMStateDescription vmstate_vga_common =3D { VMSTATE_BUFFER(palette, VGACommonState), =20 VMSTATE_INT32(bank_offset, VGACommonState), - VMSTATE_UINT8_EQUAL(is_vbe_vmstate, VGACommonState, NULL), + VMSTATE_UINT8_EQUAL(is_vbe_vmstate, VGACommonState), VMSTATE_UINT16(vbe_index, VGACommonState), VMSTATE_UINT16_ARRAY(vbe_regs, VGACommonState, VBE_DISPI_INDEX_NB), VMSTATE_UINT32(vbe_start_addr, VGACommonState), diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 643e91ca2a7..9aeeef16410 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1211,7 +1211,7 @@ static const VMStateDescription vmstate_virtio_gpu_sc= anouts =3D { .fields =3D (const VMStateField[]) { VMSTATE_INT32(parent_obj.enable, struct VirtIOGPU), VMSTATE_UINT32_EQUAL(parent_obj.conf.max_outputs, - struct VirtIOGPU, NULL), + struct VirtIOGPU), VMSTATE_STRUCT_VARRAY_UINT32(parent_obj.scanout, struct VirtIOGPU, parent_obj.conf.max_outputs, 1, vmstate_virtio_gpu_scanout, diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index ea7a9fca04e..d97a60cdf75 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -1209,7 +1209,7 @@ static const VMStateDescription vmstate_vmware_vga_in= ternal =3D { .minimum_version_id =3D 0, .post_load =3D vmsvga_post_load, .fields =3D (const VMStateField[]) { - VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s, NULL), + VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s), VMSTATE_INT32(enable, struct vmsvga_state_s), VMSTATE_INT32(config, struct vmsvga_state_s), VMSTATE_INT32(cursor.id, struct vmsvga_state_s), diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index c1aeeca0c9a..417c3aecb92 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -278,7 +278,7 @@ static const VMStateDescription vmstate_vmmouse =3D { .minimum_version_id =3D 0, .post_load =3D vmmouse_post_load, .fields =3D (const VMStateField[]) { - VMSTATE_INT32_EQUAL(queue_size, VMMouseState, NULL), + VMSTATE_INT32_EQUAL(queue_size, VMMouseState), VMSTATE_UINT32_ARRAY(queue, VMMouseState, VMMOUSE_QUEUE_SIZE), VMSTATE_UINT16(nb_queue, VMMouseState), VMSTATE_UINT16(status, VMMouseState), diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 08f51c8e361..c2b4432b947 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1795,7 +1795,7 @@ const VMStateDescription vmstate_ahci =3D { VMSTATE_UINT32(control_regs.impl, AHCIState), VMSTATE_UINT32(control_regs.version, AHCIState), VMSTATE_UINT32(idp_index, AHCIState), - VMSTATE_UINT32_EQUAL(ports, AHCIState, NULL), + VMSTATE_UINT32_EQUAL(ports, AHCIState), VMSTATE_END_OF_LIST() }, }; diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c index cd353a04f53..99d2a1e65ec 100644 --- a/hw/intc/openpic.c +++ b/hw/intc/openpic.c @@ -1477,7 +1477,7 @@ static const VMStateDescription vmstate_openpic =3D { VMSTATE_UINT32(max_irq, OpenPICState), VMSTATE_STRUCT_VARRAY_UINT32(src, OpenPICState, max_irq, 0, vmstate_openpic_irqsource, IRQSource), - VMSTATE_UINT32_EQUAL(nb_cpus, OpenPICState, NULL), + VMSTATE_UINT32_EQUAL(nb_cpus, OpenPICState), VMSTATE_STRUCT_VARRAY_UINT32(dst, OpenPICState, nb_cpus, 0, vmstate_openpic_irqdest, IRQDest), VMSTATE_STRUCT_ARRAY(timers, OpenPICState, OPENPIC_MAX_TMR, 0, diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 76ab476f59a..c30dace4e25 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -578,7 +578,7 @@ static const VMStateDescription vmstate_spapr_xive =3D { .pre_save =3D vmstate_spapr_xive_pre_save, .post_load =3D NULL, /* handled at the machine level */ .fields =3D (const VMStateField[]) { - VMSTATE_UINT32_EQUAL(nr_irqs, SpaprXive, NULL), + VMSTATE_UINT32_EQUAL(nr_irqs, SpaprXive), VMSTATE_STRUCT_VARRAY_POINTER_UINT32(eat, SpaprXive, nr_irqs, vmstate_spapr_xive_eas, XiveEAS), VMSTATE_STRUCT_VARRAY_POINTER_UINT32(endt, SpaprXive, nr_ends, diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 1d40c4386d1..c0a252d0519 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -668,7 +668,7 @@ static const VMStateDescription vmstate_ics =3D { .post_load =3D ics_post_load, .fields =3D (const VMStateField[]) { /* Sanity check */ - VMSTATE_UINT32_EQUAL(nr_irqs, ICSState, NULL), + VMSTATE_UINT32_EQUAL(nr_irqs, ICSState), =20 VMSTATE_STRUCT_VARRAY_POINTER_UINT32(irqs, ICSState, nr_irqs, vmstate_ics_irq, diff --git a/hw/intc/xive.c b/hw/intc/xive.c index d702b58bd0a..f473e6ac77e 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1565,7 +1565,7 @@ static const VMStateDescription vmstate_xive_source = =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { - VMSTATE_UINT32_EQUAL(nr_irqs, XiveSource, NULL), + VMSTATE_UINT32_EQUAL(nr_irqs, XiveSource), VMSTATE_VBUFFER_UINT32(status, XiveSource, 1, NULL, nr_irqs), VMSTATE_END_OF_LIST() }, diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c index a8fd60a8fb5..73b3d248d44 100644 --- a/hw/nvram/eeprom93xx.c +++ b/hw/nvram/eeprom93xx.c @@ -144,7 +144,7 @@ static const VMStateDescription vmstate_eeprom =3D { VMSTATE_UINT8(addrbits, eeprom_t), VMSTATE_UINT16_HACK_TEST(size, eeprom_t, is_old_eeprom_version), VMSTATE_UNUSED_TEST(is_old_eeprom_version, 1), - VMSTATE_UINT16_EQUAL_V(size, eeprom_t, EEPROM_VERSION, NULL), + VMSTATE_UINT16_EQUAL_V(size, eeprom_t, EEPROM_VERSION), VMSTATE_UINT16(data, eeprom_t), VMSTATE_VARRAY_UINT16_UNSAFE(contents, eeprom_t, size, 0, vmstate_info_uint16, uint16_t), diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 90d6d71efdc..8868d6ad387 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -106,7 +106,7 @@ static const VMStateDescription vmstate_pcibus =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { - VMSTATE_INT32_EQUAL(nirq, PCIBus, NULL), + VMSTATE_INT32_EQUAL(nirq, PCIBus), VMSTATE_VARRAY_INT32(irq_count, PCIBus, nirq, 0, vmstate_info_int32, int32_t), diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index 2c85a78fcde..22497b1fd65 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -820,7 +820,7 @@ const VMStateDescription vmstate_pcie_aer_log =3D { .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { VMSTATE_UINT16(log_num, PCIEAERLog), - VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog, NULL), + VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog), VMSTATE_VALIDATE("log_num <=3D log_max", pcie_aer_state_log_num_va= lid), VMSTATE_STRUCT_VARRAY_POINTER_UINT16(log, PCIEAERLog, log_num, vmstate_pcie_aer_err, PCIEAERErr), diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index c2432a0c00c..e6264b07854 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -285,7 +285,7 @@ static const VMStateDescription vmstate_spapr_tce_table= =3D { .post_load =3D spapr_tce_table_post_load, .fields =3D (const VMStateField []) { /* Sanity check */ - VMSTATE_UINT32_EQUAL(liobn, SpaprTceTable, NULL), + VMSTATE_UINT32_EQUAL(liobn, SpaprTceTable), =20 /* IOMMU state */ VMSTATE_UINT32(mig_nb_table, SpaprTceTable), diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 1dc3b02659f..c1d4b7806e4 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2051,7 +2051,7 @@ static const VMStateDescription vmstate_spapr_pci_lsi= =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { - VMSTATE_UINT32_EQUAL(irq, SpaprPciLsi, NULL), + VMSTATE_UINT32_EQUAL(irq, SpaprPciLsi), =20 VMSTATE_END_OF_LIST() }, @@ -2129,7 +2129,7 @@ static const VMStateDescription vmstate_spapr_pci =3D= { .post_save =3D spapr_pci_post_save, .post_load =3D spapr_pci_post_load, .fields =3D (const VMStateField[]) { - VMSTATE_UINT64_EQUAL(buid, SpaprPhbState, NULL), + VMSTATE_UINT64_EQUAL(buid, SpaprPhbState), VMSTATE_STRUCT_ARRAY(lsi_table, SpaprPhbState, PCI_NUM_PINS, 0, vmstate_spapr_pci_lsi, SpaprPciLsi), VMSTATE_INT32(msi_devs_num, SpaprPhbState), diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index 501e82a7665..3f05081bada 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -609,8 +609,8 @@ const VMStateDescription vmstate_spapr_vio =3D { .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { /* Sanity check */ - VMSTATE_UINT32_EQUAL(reg, SpaprVioDevice, NULL), - VMSTATE_UINT32_EQUAL(irq, SpaprVioDevice, NULL), + VMSTATE_UINT32_EQUAL(reg, SpaprVioDevice), + VMSTATE_UINT32_EQUAL(irq, SpaprVioDevice), =20 /* General VIO device state */ VMSTATE_UINT64(signal_state, SpaprVioDevice), diff --git a/hw/s390x/css.c b/hw/s390x/css.c index df5f0bc27f1..ecd28fed5c3 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -199,15 +199,15 @@ const VMStateDescription vmstate_subch_dev =3D { .post_load =3D subch_dev_post_load, .pre_save =3D subch_dev_pre_save, .fields =3D (const VMStateField[]) { - VMSTATE_UINT8_EQUAL(cssid, SubchDev, NULL), - VMSTATE_UINT8_EQUAL(ssid, SubchDev, NULL), + VMSTATE_UINT8_EQUAL(cssid, SubchDev), + VMSTATE_UINT8_EQUAL(ssid, SubchDev), VMSTATE_UINT16(migrated_schid, SubchDev), /* * If devno mismatch on target, it may be due to some * sequences of plug and unplug breaks migration for * machine versions prior to 2.7 (known design flaw). */ - VMSTATE_UINT16_EQUAL(devno, SubchDev, NULL), + VMSTATE_UINT16_EQUAL(devno, SubchDev), VMSTATE_BOOL(thinint_active, SubchDev), VMSTATE_STRUCT(curr_status, SubchDev, 0, vmstate_schib, SCHIB), VMSTATE_UINT8_ARRAY(sense_data, SubchDev, 32), diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index b2224c7f766..a7b9fe13175 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -364,7 +364,7 @@ static const VMStateDescription vmstate_uhci =3D { .post_load =3D uhci_post_load, .fields =3D (const VMStateField[]) { VMSTATE_PCI_DEVICE(dev, UHCIState), - VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState, NULL), + VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState), VMSTATE_STRUCT_ARRAY(ports, UHCIState, UHCI_PORTS, 1, vmstate_uhci_port, UHCIPort), VMSTATE_UINT16(cmd, UHCIState), diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 3c1d84f2d67..ca702765020 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -182,7 +182,6 @@ typedef enum { =20 struct VMStateField { const char *name; - const char *err_hint; size_t offset; size_t size; size_t start; @@ -358,9 +357,8 @@ extern const VMStateInfo vmstate_info_qlist; } =20 #define VMSTATE_SINGLE_FULL(_field, _state, _test, _version, _info, \ - _type, _err_hint) { \ + _type) { \ .name =3D (stringify(_field)), \ - .err_hint =3D (_err_hint), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ .size =3D sizeof(_type), \ @@ -1012,35 +1010,35 @@ extern const VMStateInfo vmstate_info_qlist; =20 #endif =20 -#define VMSTATE_UINT8_EQUAL(_f, _s, _err_hint) \ +#define VMSTATE_UINT8_EQUAL(_f, _s) \ VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ - vmstate_info_uint8_equal, uint8_t, _err_hint) + vmstate_info_uint8_equal, uint8_t) =20 -#define VMSTATE_UINT16_EQUAL(_f, _s, _err_hint) \ +#define VMSTATE_UINT16_EQUAL(_f, _s) \ VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ - vmstate_info_uint16_equal, uint16_t, _err_hint) + vmstate_info_uint16_equal, uint16_t) =20 -#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v, _err_hint) \ +#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \ VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ - vmstate_info_uint16_equal, uint16_t, _err_hint) + vmstate_info_uint16_equal, uint16_t) =20 -#define VMSTATE_INT32_EQUAL(_f, _s, _err_hint) \ +#define VMSTATE_INT32_EQUAL(_f, _s) \ VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ - vmstate_info_int32_equal, int32_t, _err_hint) + vmstate_info_int32_equal, int32_t) =20 -#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v, _err_hint) \ +#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v) \ VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ - vmstate_info_uint32_equal, uint32_t, _err_hint) + vmstate_info_uint32_equal, uint32_t) =20 -#define VMSTATE_UINT32_EQUAL(_f, _s, _err_hint) \ - VMSTATE_UINT32_EQUAL_V(_f, _s, 0, _err_hint) +#define VMSTATE_UINT32_EQUAL(_f, _s) \ + VMSTATE_UINT32_EQUAL_V(_f, _s, 0) =20 -#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v, _err_hint) \ +#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \ VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ - vmstate_info_uint64_equal, uint64_t, _err_hint) + vmstate_info_uint64_equal, uint64_t) =20 -#define VMSTATE_UINT64_EQUAL(_f, _s, _err_hint) \ - VMSTATE_UINT64_EQUAL_V(_f, _s, 0, _err_hint) +#define VMSTATE_UINT64_EQUAL(_f, _s) \ + VMSTATE_UINT64_EQUAL_V(_f, _s, 0) =20 #define VMSTATE_INT32_POSITIVE_LE(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 89cb2114721..033a2685c8f 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -131,9 +131,6 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_= t size, return 0; } error_report("%" PRIx32 " !=3D %" PRIx32, *v, v2); - if (field->err_hint) { - error_printf("%s\n", field->err_hint); - } return -EINVAL; } =20 @@ -280,9 +277,6 @@ static int get_uint32_equal(QEMUFile *f, void *pv, size= _t size, return 0; } error_report("%" PRIx32 " !=3D %" PRIx32, *v, v2); - if (field->err_hint) { - error_printf("%s\n", field->err_hint); - } return -EINVAL; } =20 @@ -391,9 +385,6 @@ static int get_uint64_equal(QEMUFile *f, void *pv, size= _t size, return 0; } error_report("%" PRIx64 " !=3D %" PRIx64, *v, v2); - if (field->err_hint) { - error_printf("%s\n", field->err_hint); - } return -EINVAL; } =20 @@ -417,9 +408,6 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_= t size, return 0; } error_report("%x !=3D %x", *v, v2); - if (field->err_hint) { - error_printf("%s\n", field->err_hint); - } return -EINVAL; } =20 @@ -443,9 +431,6 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size= _t size, return 0; } error_report("%x !=3D %x", *v, v2); - if (field->err_hint) { - error_printf("%s\n", field->err_hint); - } return -EINVAL; } =20 diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 49cfdc6d674..9eae0ff647d 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -564,7 +564,7 @@ static const VMStateDescription vmstate_tlb6xx =3D { .minimum_version_id =3D 1, .needed =3D tlb6xx_needed, .fields =3D (const VMStateField[]) { - VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL), + VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlb6, PowerPCCPU, env.nb_tlb, vmstate_tlb6xx_entry, @@ -603,7 +603,7 @@ static const VMStateDescription vmstate_tlbemb =3D { .minimum_version_id =3D 1, .needed =3D tlbemb_needed, .fields =3D (const VMStateField[]) { - VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL), + VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbe, PowerPCCPU, env.nb_tlb, vmstate_tlbemb_entry, @@ -639,7 +639,7 @@ static const VMStateDescription vmstate_tlbmas =3D { .minimum_version_id =3D 1, .needed =3D tlbmas_needed, .fields =3D (const VMStateField[]) { - VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL), + VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbm, PowerPCCPU, env.nb_tlb, vmstate_tlbmas_entry, --=20 2.52.0 From nobody Fri Mar 27 03:40:38 2026 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1772659543; cv=none; d=zohomail.com; s=zohoarc; b=bjwR4FX3ZypkSgHkk9YoFd+8RLu9VR0jsLhh0FlAkAES97BIO7MUfMy6m5z1GqpSqtRXDJEdAozgxRTNhR2dLRXRSOP2xvlldKQTj9cZcO4Ps1oWML0TOxzNKCR1x7P/UVGh8b1zXio79prPjDH5ktCV1TSuaQsVr3Cp+cZ7TNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772659543; h=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=UtnHbDk48f1TJXfXCu1SF3bXPtua/RuWDioyi3p5LQE=; b=nVPuJ2dplx450TC6pu0lNbvFlPt0GGBwZT3klcsjRhWKlJfzMQvBO2Ec/+zszprNZgIbbDVLM6Bc8UbmMaEy3VqHz6iLuN4BoWOOlaE5WkJ90GOB5cb58hIQ9IAXBygdDgX+NZ5gVqewaDMjxtRvLz+yopOFywfwIz98psGVKJY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177265954218892.32682687498959; Wed, 4 Mar 2026 13:25:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxth8-0004r8-JK; Wed, 04 Mar 2026 16:23:50 -0500 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 1vxtgk-0004mI-Da for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:28 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxtgg-0003Vb-PJ for qemu-devel@nongnu.org; Wed, 04 Mar 2026 16:23:26 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 7CAF9807E8; Thu, 05 Mar 2026 00:23:21 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:921::1:1b]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 5NwBA90AmW20-etuaX0gZ; Thu, 05 Mar 2026 00:23:20 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772659400; bh=UtnHbDk48f1TJXfXCu1SF3bXPtua/RuWDioyi3p5LQE=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=JSAQp8CTkTfRL21RASPAgHmbXjVTaUEVVdXNvIDhTMs+0YuSsxWnjuU0BdbMgPCzn Ha3Np04LOL6KbIYxyLyeaeT9YCdNh1SnMIA5EDe5FVYb8/22y+22mjc2I7DMMgjTgs zQITExP2f1PiaOk5bQj2E3gzJq/9Qt/IlIQURnvE= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [PATCH v3 18/18] migration/vmstate-types: move to new migration APIs Date: Thu, 5 Mar 2026 00:23:02 +0300 Message-ID: <20260304212303.667141-19-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260304212303.667141-1-vsementsov@yandex-team.ru> References: <20260304212303.667141-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @yandex-team.ru) X-ZM-MESSAGEID: 1772659546206139100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu --- migration/trace-events | 24 +- migration/vmstate-types.c | 627 +++++++++++++++++++------------------- 2 files changed, 327 insertions(+), 324 deletions(-) diff --git a/migration/trace-events b/migration/trace-events index 0b3f759ccc4..5fe3cc59c01 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -73,20 +73,20 @@ vmstate_subsection_save_top(const char *idstr) "%s" vmstate_field_exists(const char *vmsd, const char *name, int field_version= , int version, int result) "%s:%s field_version %d version %d result %d" =20 # vmstate-types.c -get_qtailq(const char *name, int version_id) "%s v%d" -get_qtailq_end(const char *name, const char *reason, int val) "%s %s/%d" -put_qtailq(const char *name, int version_id) "%s v%d" -put_qtailq_end(const char *name, const char *reason) "%s %s" +load_qtailq(const char *name, int version_id) "%s v%d" +load_qtailq_end(const char *name) "%s" +save_qtailq(const char *name, int version_id) "%s v%d" +save_qtailq_end(const char *name) "%s" =20 -get_gtree(const char *field_name, const char *key_vmsd_name, const char *v= al_vmsd_name, uint32_t nnodes) "%s(%s/%s) nnodes=3D%d" -get_gtree_end(const char *field_name, const char *key_vmsd_name, const cha= r *val_vmsd_name, int ret) "%s(%s/%s) %d" -put_gtree(const char *field_name, const char *key_vmsd_name, const char *v= al_vmsd_name, uint32_t nnodes) "%s(%s/%s) nnodes=3D%d" -put_gtree_end(const char *field_name, const char *key_vmsd_name, const cha= r *val_vmsd_name, int ret) "%s(%s/%s) %d" +load_gtree(const char *field_name, const char *key_vmsd_name, const char *= val_vmsd_name, uint32_t nnodes) "%s(%s/%s) nnodes=3D%d" +load_gtree_end(const char *field_name, const char *key_vmsd_name, const ch= ar *val_vmsd_name) "%s(%s/%s)" +save_gtree(const char *field_name, const char *key_vmsd_name, const char *= val_vmsd_name, uint32_t nnodes) "%s(%s/%s) nnodes=3D%d" +save_gtree_end(const char *field_name, const char *key_vmsd_name, const ch= ar *val_vmsd_name) "%s(%s/%s)" =20 -get_qlist(const char *field_name, const char *vmsd_name, int version_id) "= %s(%s v%d)" -get_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)" -put_qlist(const char *field_name, const char *vmsd_name, int version_id) "= %s(%s v%d)" -put_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)" +load_qlist(const char *field_name, const char *vmsd_name, int version_id) = "%s(%s v%d)" +load_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)" +save_qlist(const char *field_name, const char *vmsd_name, int version_id) = "%s(%s v%d)" +save_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)" =20 # qemu-file.c qemu_file_fclose(void) "" diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 033a2685c8f..23f34336964 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -23,129 +23,135 @@ =20 /* bool */ =20 -static int get_bool(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_bool(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { bool *v =3D pv; *v =3D qemu_get_byte(f); - return 0; + return true; } =20 -static int put_bool(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_bool(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { bool *v =3D pv; qemu_put_byte(f, *v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_bool =3D { .name =3D "bool", - .get =3D get_bool, - .put =3D put_bool, + .load =3D load_bool, + .save =3D save_bool, }; =20 /* 8 bit int */ =20 -static int get_int8(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_int8(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { int8_t *v =3D pv; qemu_get_s8s(f, v); - return 0; + return true; } =20 -static int put_int8(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_int8(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { int8_t *v =3D pv; qemu_put_s8s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_int8 =3D { .name =3D "int8", - .get =3D get_int8, - .put =3D put_int8, + .load =3D load_int8, + .save =3D save_int8, }; =20 /* 16 bit int */ =20 -static int get_int16(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_int16(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { int16_t *v =3D pv; qemu_get_sbe16s(f, v); - return 0; + return true; } =20 -static int put_int16(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_int16(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { int16_t *v =3D pv; qemu_put_sbe16s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_int16 =3D { .name =3D "int16", - .get =3D get_int16, - .put =3D put_int16, + .load =3D load_int16, + .save =3D save_int16, }; =20 /* 32 bit int */ =20 -static int get_int32(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_int32(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { int32_t *v =3D pv; qemu_get_sbe32s(f, v); - return 0; + return true; } =20 -static int put_int32(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_int32(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { int32_t *v =3D pv; qemu_put_sbe32s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_int32 =3D { .name =3D "int32", - .get =3D get_int32, - .put =3D put_int32, + .load =3D load_int32, + .save =3D save_int32, }; =20 /* 32 bit int. See that the received value is the same than the one in the field */ =20 -static int get_int32_equal(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_int32_equal(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { + ERRP_GUARD(); int32_t *v =3D pv; int32_t v2; qemu_get_sbe32s(f, &v2); =20 if (*v =3D=3D v2) { - return 0; + return true; } - error_report("%" PRIx32 " !=3D %" PRIx32, *v, v2); - return -EINVAL; + + error_setg(errp, "%" PRIx32 " !=3D %" PRIx32, *v, v2); + return false; } =20 const VMStateInfo vmstate_info_int32_equal =3D { .name =3D "int32 equal", - .get =3D get_int32_equal, - .put =3D put_int32, + .load =3D load_int32_equal, + .save =3D save_int32, }; =20 /* 32 bit int. Check that the received value is non-negative * and less than or equal to the one in the field. */ =20 -static int get_int32_le(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_int32_le(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { int32_t *cur =3D pv; int32_t loaded; @@ -153,348 +159,373 @@ static int get_int32_le(QEMUFile *f, void *pv, size= _t size, =20 if (loaded >=3D 0 && loaded <=3D *cur) { *cur =3D loaded; - return 0; + return true; } - error_report("Invalid value %" PRId32 - " expecting positive value <=3D %" PRId32, - loaded, *cur); - return -EINVAL; + + error_setg(errp, "Invalid value %" PRId32 + " expecting positive value <=3D %" PRId32, + loaded, *cur); + return false; } =20 const VMStateInfo vmstate_info_int32_le =3D { .name =3D "int32 le", - .get =3D get_int32_le, - .put =3D put_int32, + .load =3D load_int32_le, + .save =3D save_int32, }; =20 /* 64 bit int */ =20 -static int get_int64(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_int64(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { int64_t *v =3D pv; qemu_get_sbe64s(f, v); - return 0; + return true; } =20 -static int put_int64(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_int64(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { int64_t *v =3D pv; qemu_put_sbe64s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_int64 =3D { .name =3D "int64", - .get =3D get_int64, - .put =3D put_int64, + .load =3D load_int64, + .save =3D save_int64, }; =20 /* 8 bit unsigned int */ =20 -static int get_uint8(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint8(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { uint8_t *v =3D pv; qemu_get_8s(f, v); - return 0; + return true; } =20 -static int put_uint8(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_uint8(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { uint8_t *v =3D pv; qemu_put_8s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_uint8 =3D { .name =3D "uint8", - .get =3D get_uint8, - .put =3D put_uint8, + .load =3D load_uint8, + .save =3D save_uint8, }; =20 /* 16 bit unsigned int */ =20 -static int get_uint16(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint16(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { uint16_t *v =3D pv; qemu_get_be16s(f, v); - return 0; + return true; } =20 -static int put_uint16(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_uint16(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { uint16_t *v =3D pv; qemu_put_be16s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_uint16 =3D { .name =3D "uint16", - .get =3D get_uint16, - .put =3D put_uint16, + .load =3D load_uint16, + .save =3D save_uint16, }; =20 /* 32 bit unsigned int */ =20 -static int get_uint32(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint32(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { uint32_t *v =3D pv; qemu_get_be32s(f, v); - return 0; + return true; } =20 -static int put_uint32(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_uint32(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { uint32_t *v =3D pv; qemu_put_be32s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_uint32 =3D { .name =3D "uint32", - .get =3D get_uint32, - .put =3D put_uint32, + .load =3D load_uint32, + .save =3D save_uint32, }; =20 /* 32 bit uint. See that the received value is the same than the one in the field */ =20 -static int get_uint32_equal(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint32_equal(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { + ERRP_GUARD(); uint32_t *v =3D pv; uint32_t v2; qemu_get_be32s(f, &v2); =20 if (*v =3D=3D v2) { - return 0; + return true; } - error_report("%" PRIx32 " !=3D %" PRIx32, *v, v2); - return -EINVAL; + + error_setg(errp, "%" PRIx32 " !=3D %" PRIx32, *v, v2); + return false; } =20 const VMStateInfo vmstate_info_uint32_equal =3D { .name =3D "uint32 equal", - .get =3D get_uint32_equal, - .put =3D put_uint32, + .load =3D load_uint32_equal, + .save =3D save_uint32, }; =20 /* 64 bit unsigned int */ =20 -static int get_uint64(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint64(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { uint64_t *v =3D pv; qemu_get_be64s(f, v); - return 0; + return true; } =20 -static int put_uint64(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_uint64(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { uint64_t *v =3D pv; qemu_put_be64s(f, v); - return 0; + return true; } =20 const VMStateInfo vmstate_info_uint64 =3D { .name =3D "uint64", - .get =3D get_uint64, - .put =3D put_uint64, + .load =3D load_uint64, + .save =3D save_uint64, }; =20 /* File descriptor communicated via SCM_RIGHTS */ =20 -static int get_fd(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_fd(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { int32_t *v =3D pv; =20 if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { qemu_get_sbe32s(f, v); - return 0; + return true; } =20 - return qemu_file_get_fd(f, v); + return qemu_file_get_fd(f, v) >=3D 0; } =20 -static int put_fd(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_fd(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { int32_t *v =3D pv; + if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { qemu_put_sbe32s(f, v); - return 0; + return true; } - return qemu_file_put_fd(f, *v); + + return qemu_file_put_fd(f, *v) >=3D 0; } =20 const VMStateInfo vmstate_info_fd =3D { .name =3D "fd", - .get =3D get_fd, - .put =3D put_fd, + .load =3D load_fd, + .save =3D save_fd, }; =20 -static int get_nullptr(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_nullptr(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) =20 { if (qemu_get_byte(f) =3D=3D VMS_NULLPTR_MARKER) { - return 0; + return true; } - error_report("vmstate: get_nullptr expected VMS_NULLPTR_MARKER"); - return -EINVAL; + + error_setg(errp, "vmstate: load_nullptr expected VMS_NULLPTR_MARKER"); + return false; } =20 -static int put_nullptr(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_nullptr(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) =20 { if (pv =3D=3D NULL) { qemu_put_byte(f, VMS_NULLPTR_MARKER); - return 0; + return true; } - error_report("vmstate: put_nullptr must be called with pv =3D=3D NULL"= ); - return -EINVAL; + + error_setg(errp, "vmstate: save_nullptr must be called with pv =3D=3D = NULL"); + return false; } =20 const VMStateInfo vmstate_info_nullptr =3D { .name =3D "nullptr", - .get =3D get_nullptr, - .put =3D put_nullptr, + .load =3D load_nullptr, + .save =3D save_nullptr, }; =20 /* 64 bit unsigned int. See that the received value is the same than the o= ne in the field */ =20 -static int get_uint64_equal(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint64_equal(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { + ERRP_GUARD(); uint64_t *v =3D pv; uint64_t v2; + qemu_get_be64s(f, &v2); =20 if (*v =3D=3D v2) { - return 0; + return true; } - error_report("%" PRIx64 " !=3D %" PRIx64, *v, v2); - return -EINVAL; + + error_setg(errp, "%" PRIx64 " !=3D %" PRIx64, *v, v2); + return false; } =20 const VMStateInfo vmstate_info_uint64_equal =3D { .name =3D "int64 equal", - .get =3D get_uint64_equal, - .put =3D put_uint64, + .load =3D load_uint64_equal, + .save =3D save_uint64, }; =20 /* 8 bit int. See that the received value is the same than the one in the field */ =20 -static int get_uint8_equal(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint8_equal(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { + ERRP_GUARD(); uint8_t *v =3D pv; uint8_t v2; + qemu_get_8s(f, &v2); =20 if (*v =3D=3D v2) { - return 0; + return true; } - error_report("%x !=3D %x", *v, v2); - return -EINVAL; + + error_setg(errp, "%x !=3D %x", *v, v2); + return false; } =20 const VMStateInfo vmstate_info_uint8_equal =3D { .name =3D "uint8 equal", - .get =3D get_uint8_equal, - .put =3D put_uint8, + .load =3D load_uint8_equal, + .save =3D save_uint8, }; =20 /* 16 bit unsigned int int. See that the received value is the same than t= he one in the field */ =20 -static int get_uint16_equal(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_uint16_equal(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { + ERRP_GUARD(); uint16_t *v =3D pv; uint16_t v2; + qemu_get_be16s(f, &v2); =20 if (*v =3D=3D v2) { - return 0; + return true; } - error_report("%x !=3D %x", *v, v2); - return -EINVAL; + + error_setg(errp, "%x !=3D %x", *v, v2); + return false; } =20 const VMStateInfo vmstate_info_uint16_equal =3D { .name =3D "uint16 equal", - .get =3D get_uint16_equal, - .put =3D put_uint16, + .load =3D load_uint16_equal, + .save =3D save_uint16, }; =20 /* CPU_DoubleU type */ =20 -static int get_cpudouble(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_cpudouble(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { CPU_DoubleU *v =3D pv; qemu_get_be32s(f, &v->l.upper); qemu_get_be32s(f, &v->l.lower); - return 0; + return true; } =20 -static int put_cpudouble(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_cpudouble(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { CPU_DoubleU *v =3D pv; qemu_put_be32s(f, &v->l.upper); qemu_put_be32s(f, &v->l.lower); - return 0; + return true; } =20 const VMStateInfo vmstate_info_cpudouble =3D { .name =3D "CPU_Double_U", - .get =3D get_cpudouble, - .put =3D put_cpudouble, + .load =3D load_cpudouble, + .save =3D save_cpudouble, }; =20 /* uint8_t buffers */ =20 -static int get_buffer(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_buffer(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { uint8_t *v =3D pv; qemu_get_buffer(f, v, size); - return 0; + return true; } =20 -static int put_buffer(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_buffer(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { uint8_t *v =3D pv; qemu_put_buffer(f, v, size); - return 0; + return true; } =20 const VMStateInfo vmstate_info_buffer =3D { .name =3D "buffer", - .get =3D get_buffer, - .put =3D put_buffer, + .load =3D load_buffer, + .save =3D save_buffer, }; =20 /* unused buffers: space that was used for some fields that are not useful anymore */ =20 -static int get_unused_buffer(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_unused_buffer(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { uint8_t buf[1024]; int block_len; @@ -504,11 +535,13 @@ static int get_unused_buffer(QEMUFile *f, void *pv, s= ize_t size, size -=3D block_len; qemu_get_buffer(f, buf, block_len); } - return 0; + + return true; } =20 -static int put_unused_buffer(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_unused_buffer(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmde= sc, + Error **errp) { static const uint8_t buf[1024]; int block_len; @@ -519,13 +552,13 @@ static int put_unused_buffer(QEMUFile *f, void *pv, s= ize_t size, qemu_put_buffer(f, buf, block_len); } =20 - return 0; + return true; } =20 const VMStateInfo vmstate_info_unused_buffer =3D { .name =3D "unused_buffer", - .get =3D get_unused_buffer, - .put =3D put_unused_buffer, + .load =3D load_unused_buffer, + .save =3D save_unused_buffer, }; =20 /* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate @@ -534,48 +567,34 @@ const VMStateInfo vmstate_info_unused_buffer =3D { * in fields that don't really exist in the parent but need to be in the * stream. */ -static int get_tmp(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_tmp(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { - int ret; - Error *local_err =3D NULL; const VMStateDescription *vmsd =3D field->vmsd; int version_id =3D field->version_id; - void *tmp =3D g_malloc(size); + g_autofree void *tmp =3D g_malloc(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, &local_err); - if (ret < 0) { - error_report_err(local_err); - } - g_free(tmp); - return ret; + return vmstate_load_vmsd(f, vmsd, tmp, version_id, errp); } =20 -static int put_tmp(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_tmp(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { const VMStateDescription *vmsd =3D field->vmsd; - void *tmp =3D g_malloc(size); - int ret; - Error *local_err =3D NULL; + g_autofree void *tmp =3D g_malloc(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, &local_err); - if (ret) { - error_report_err(local_err); - } - g_free(tmp); - - return ret; + return vmstate_save_vmsd(f, vmsd, tmp, vmdesc, errp); } =20 const VMStateInfo vmstate_info_tmp =3D { .name =3D "tmp", - .get =3D get_tmp, - .put =3D put_tmp, + .load =3D load_tmp, + .save =3D save_tmp, }; =20 /* bitmaps (as defined by bitmap.h). Note that size here is the size @@ -585,11 +604,12 @@ const VMStateInfo vmstate_info_tmp =3D { */ /* This is the number of 64 bit words sent over the wire */ #define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, 64) -static int get_bitmap(QEMUFile *f, void *pv, size_t size, - const VMStateField *field) +static bool load_bitmap(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) { unsigned long *bmp =3D pv; int i, idx =3D 0; + for (i =3D 0; i < BITS_TO_U64S(size); i++) { uint64_t w =3D qemu_get_be64(f); bmp[idx++] =3D w; @@ -597,14 +617,17 @@ static int get_bitmap(QEMUFile *f, void *pv, size_t s= ize, bmp[idx++] =3D w >> 32; } } - return 0; + + return true; } =20 -static int put_bitmap(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_bitmap(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { unsigned long *bmp =3D pv; int i, idx =3D 0; + for (i =3D 0; i < BITS_TO_U64S(size); i++) { uint64_t w =3D bmp[idx++]; if (sizeof(unsigned long) =3D=3D 4 && idx < BITS_TO_LONGS(size)) { @@ -613,23 +636,21 @@ static int put_bitmap(QEMUFile *f, void *pv, size_t s= ize, qemu_put_be64(f, w); } =20 - return 0; + return true; } =20 const VMStateInfo vmstate_info_bitmap =3D { .name =3D "bitmap", - .get =3D get_bitmap, - .put =3D put_bitmap, + .load =3D load_bitmap, + .save =3D save_bitmap, }; =20 /* get for QTAILQ * meta data about the QTAILQ is encoded in a VMStateField structure */ -static int get_qtailq(QEMUFile *f, void *pv, size_t unused_size, - const VMStateField *field) +static bool load_qtailq(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field, Error **errp) { - int ret =3D 0; - Error *local_err =3D NULL; const VMStateDescription *vmsd =3D field->vmsd; /* size of a QTAILQ element */ size_t size =3D field->size; @@ -638,80 +659,76 @@ static int get_qtailq(QEMUFile *f, void *pv, size_t u= nused_size, int version_id =3D field->version_id; void *elm; =20 - trace_get_qtailq(vmsd->name, version_id); + trace_load_qtailq(vmsd->name, version_id); if (version_id > vmsd->version_id) { - error_report("%s %s", vmsd->name, "too new"); - trace_get_qtailq_end(vmsd->name, "too new", -EINVAL); - - return -EINVAL; + error_setg(errp, "%s %s", vmsd->name, "too new"); + return false; } if (version_id < vmsd->minimum_version_id) { - error_report("%s %s", vmsd->name, "too old"); - trace_get_qtailq_end(vmsd->name, "too old", -EINVAL); - return -EINVAL; + error_setg(errp, "%s %s", vmsd->name, "too old"); + return false; } =20 while (qemu_get_byte(f)) { elm =3D g_malloc(size); - ret =3D vmstate_load_state(f, vmsd, elm, version_id, &local_err); - if (ret) { - error_report_err(local_err); - return ret; + if (!vmstate_load_vmsd(f, vmsd, elm, version_id, errp)) { + g_free(elm); + return false; } QTAILQ_RAW_INSERT_TAIL(pv, elm, entry_offset); } =20 - trace_get_qtailq_end(vmsd->name, "end", ret); - return ret; + trace_load_qtailq_end(vmsd->name); + return true; } =20 -/* put for QTAILQ */ -static int put_qtailq(QEMUFile *f, void *pv, size_t unused_size, - const VMStateField *field, JSONWriter *vmdesc) +/* save for QTAILQ */ +static bool save_qtailq(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { const VMStateDescription *vmsd =3D field->vmsd; /* offset of the QTAILQ entry in a QTAILQ element*/ size_t entry_offset =3D field->start; void *elm; - int ret; - Error *local_err =3D NULL; =20 - trace_put_qtailq(vmsd->name, vmsd->version_id); + trace_save_qtailq(vmsd->name, vmsd->version_id); =20 QTAILQ_RAW_FOREACH(elm, pv, entry_offset) { qemu_put_byte(f, true); - ret =3D vmstate_save_state(f, vmsd, elm, vmdesc, &local_err); - if (ret) { - error_report_err(local_err); - return ret; + if (!vmstate_save_vmsd(f, vmsd, elm, vmdesc, errp)) { + return false; } } qemu_put_byte(f, false); =20 - trace_put_qtailq_end(vmsd->name, "end"); + trace_save_qtailq_end(vmsd->name); =20 - return 0; + return true; } const VMStateInfo vmstate_info_qtailq =3D { .name =3D "qtailq", - .get =3D get_qtailq, - .put =3D put_qtailq, + .load =3D load_qtailq, + .save =3D save_qtailq, }; =20 -struct put_gtree_data { +struct save_gtree_data { QEMUFile *f; const VMStateDescription *key_vmsd; const VMStateDescription *val_vmsd; JSONWriter *vmdesc; - int ret; + Error **errp; + bool failed; }; =20 -static gboolean put_gtree_elem(gpointer key, gpointer value, gpointer data) +/* + * save_gtree_elem - func for g_tree_foreach, return true to stop + * iteration. + */ +static gboolean save_gtree_elem(gpointer key, gpointer value, gpointer dat= a) { - struct put_gtree_data *capsule =3D (struct put_gtree_data *)data; + struct save_gtree_data *capsule =3D (struct save_gtree_data *)data; QEMUFile *f =3D capsule->f; - int ret; - Error *local_err =3D NULL; =20 qemu_put_byte(f, true); =20 @@ -719,58 +736,56 @@ static gboolean put_gtree_elem(gpointer key, gpointer= value, 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, - &local_err); - if (ret) { - error_report_err(local_err); - capsule->ret =3D ret; + if (!vmstate_save_vmsd(f, capsule->key_vmsd, key, capsule->vmdesc, + capsule->errp)) { + capsule->failed =3D true; return true; } } =20 /* put the data */ - ret =3D vmstate_save_state(f, capsule->val_vmsd, value, capsule->vmdes= c, - &local_err); - if (ret) { - error_report_err(local_err); - capsule->ret =3D ret; + if (!vmstate_save_vmsd(f, capsule->val_vmsd, value, capsule->vmdesc, + capsule->errp)) { + capsule->failed =3D true; return true; } return false; } =20 -static int put_gtree(QEMUFile *f, void *pv, size_t unused_size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_gtree(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { bool direct_key =3D (!field->start); const VMStateDescription *key_vmsd =3D direct_key ? NULL : &field->vms= d[1]; const VMStateDescription *val_vmsd =3D &field->vmsd[0]; const char *key_vmsd_name =3D direct_key ? "direct" : key_vmsd->name; - struct put_gtree_data capsule =3D { + struct save_gtree_data capsule =3D { .f =3D f, .key_vmsd =3D key_vmsd, .val_vmsd =3D val_vmsd, .vmdesc =3D vmdesc, - .ret =3D 0}; + .errp =3D errp, + .failed =3D false}; GTree **pval =3D pv; GTree *tree =3D *pval; uint32_t nnodes =3D g_tree_nnodes(tree); - int ret; =20 - trace_put_gtree(field->name, key_vmsd_name, val_vmsd->name, nnodes); + trace_save_gtree(field->name, key_vmsd_name, val_vmsd->name, nnodes); qemu_put_be32(f, nnodes); - g_tree_foreach(tree, put_gtree_elem, (gpointer)&capsule); + g_tree_foreach(tree, save_gtree_elem, (gpointer)&capsule); qemu_put_byte(f, false); - ret =3D capsule.ret; - if (ret) { - error_report("%s : failed to save gtree (%d)", field->name, ret); + if (capsule.failed) { + trace_save_gtree_end(field->name, key_vmsd_name, val_vmsd->name); + return false; } - trace_put_gtree_end(field->name, key_vmsd_name, val_vmsd->name, ret); - return ret; + + trace_save_gtree_end(field->name, key_vmsd_name, val_vmsd->name); + return true; } =20 -static int get_gtree(QEMUFile *f, void *pv, size_t unused_size, - const VMStateField *field) +static bool load_gtree(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field, Error **errp) { bool direct_key =3D (!field->start); const VMStateDescription *key_vmsd =3D direct_key ? NULL : &field->vms= d[1]; @@ -783,107 +798,97 @@ static int get_gtree(QEMUFile *f, void *pv, size_t u= nused_size, GTree **pval =3D pv; GTree *tree =3D *pval; void *key, *val; - int ret =3D 0; - Error *local_err =3D NULL; =20 /* in case of direct key, the key vmsd can be {}, ie. check fields */ if (!direct_key && version_id > key_vmsd->version_id) { - error_report("%s %s", key_vmsd->name, "too new"); - return -EINVAL; + error_setg(errp, "%s %s", key_vmsd->name, "too new"); + return false; } if (!direct_key && version_id < key_vmsd->minimum_version_id) { - error_report("%s %s", key_vmsd->name, "too old"); - return -EINVAL; + error_setg(errp, "%s %s", key_vmsd->name, "too old"); + return false; } if (version_id > val_vmsd->version_id) { - error_report("%s %s", val_vmsd->name, "too new"); - return -EINVAL; + error_setg(errp, "%s %s", val_vmsd->name, "too new"); + return false; } if (version_id < val_vmsd->minimum_version_id) { - error_report("%s %s", val_vmsd->name, "too old"); - return -EINVAL; + error_setg(errp, "%s %s", val_vmsd->name, "too old"); + return false; } =20 nnodes =3D qemu_get_be32(f); - trace_get_gtree(field->name, key_vmsd_name, val_vmsd->name, nnodes); + trace_load_gtree(field->name, key_vmsd_name, val_vmsd->name, nnodes); =20 while (qemu_get_byte(f)) { if ((++count) > nnodes) { - ret =3D -EINVAL; break; } if (direct_key) { 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, &loca= l_err); - if (ret) { - error_report_err(local_err); + if (!vmstate_load_vmsd(f, key_vmsd, key, version_id, errp)) { goto key_error; } } val =3D g_malloc0(val_size); - ret =3D vmstate_load_state(f, val_vmsd, val, version_id, &local_er= r); - if (ret) { - error_report_err(local_err); + if (!vmstate_load_vmsd(f, val_vmsd, val, version_id, errp)) { goto val_error; } g_tree_insert(tree, key, val); } if (count !=3D nnodes) { - error_report("%s inconsistent stream when loading the gtree", - field->name); - return -EINVAL; + error_setg(errp, "%s inconsistent stream when loading the gtree", + field->name); + return false; } - trace_get_gtree_end(field->name, key_vmsd_name, val_vmsd->name, ret); - return ret; + + trace_load_gtree_end(field->name, key_vmsd_name, val_vmsd->name); + return true; + val_error: g_free(val); + key_error: if (!direct_key) { g_free(key); } - trace_get_gtree_end(field->name, key_vmsd_name, val_vmsd->name, ret); - return ret; + return false; } =20 =20 const VMStateInfo vmstate_info_gtree =3D { .name =3D "gtree", - .get =3D get_gtree, - .put =3D put_gtree, + .load =3D load_gtree, + .save =3D save_gtree, }; =20 -static int put_qlist(QEMUFile *f, void *pv, size_t unused_size, - const VMStateField *field, JSONWriter *vmdesc) +static bool save_qlist(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field, JSONWriter *vmdesc, + Error **errp) { const VMStateDescription *vmsd =3D field->vmsd; /* offset of the QTAILQ entry in a QTAILQ element*/ size_t entry_offset =3D field->start; void *elm; - int ret; - Error *local_err =3D NULL; =20 - trace_put_qlist(field->name, vmsd->name, vmsd->version_id); + trace_save_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, &local_err); - if (ret) { - error_report_err(local_err); - return ret; + if (!vmstate_save_vmsd(f, vmsd, elm, vmdesc, errp)) { + return false; } } qemu_put_byte(f, false); - trace_put_qlist_end(field->name, vmsd->name); + trace_save_qlist_end(field->name, vmsd->name); =20 - return 0; + return true; } =20 -static int get_qlist(QEMUFile *f, void *pv, size_t unused_size, - const VMStateField *field) +static bool load_qlist(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field, Error **errp) { - int ret =3D 0; - Error *local_err =3D NULL; const VMStateDescription *vmsd =3D field->vmsd; /* size of a QLIST element */ size_t size =3D field->size; @@ -892,23 +897,21 @@ static int get_qlist(QEMUFile *f, void *pv, size_t un= used_size, int version_id =3D field->version_id; void *elm, *prev =3D NULL; =20 - trace_get_qlist(field->name, vmsd->name, vmsd->version_id); + trace_load_qlist(field->name, vmsd->name, vmsd->version_id); if (version_id > vmsd->version_id) { - error_report("%s %s", vmsd->name, "too new"); - return -EINVAL; + error_setg(errp, "%s %s", vmsd->name, "too new"); + return false; } if (version_id < vmsd->minimum_version_id) { - error_report("%s %s", vmsd->name, "too old"); - return -EINVAL; + error_setg(errp, "%s %s", vmsd->name, "too old"); + return false; } =20 while (qemu_get_byte(f)) { elm =3D g_malloc(size); - ret =3D vmstate_load_state(f, vmsd, elm, version_id, &local_err); - if (ret) { - error_report_err(local_err); + if (!vmstate_load_vmsd(f, vmsd, elm, version_id, errp)) { g_free(elm); - return ret; + return false; } if (!prev) { QLIST_RAW_INSERT_HEAD(pv, elm, entry_offset); @@ -917,13 +920,13 @@ static int get_qlist(QEMUFile *f, void *pv, size_t un= used_size, } prev =3D elm; } - trace_get_qlist_end(field->name, vmsd->name); + trace_load_qlist_end(field->name, vmsd->name); =20 - return ret; + return true; } =20 const VMStateInfo vmstate_info_qlist =3D { .name =3D "qlist", - .get =3D get_qlist, - .put =3D put_qlist, + .load =3D load_qlist, + .save =3D save_qlist, }; --=20 2.52.0