From nobody Fri Mar 27 05:04:42 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