From nobody Sun Sep 28 16:36:35 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758209407; cv=none; d=zohomail.com; s=zohoarc; b=I55vzJdJWXla1Dr5IUHOvJrJvy/57m/o/D13YbpkGIenKUWFLjFaToReCtf8VIyWDcLGMAlfkopX5rnlLdQ+w6RbydggIKan+AJYV7ybcCH5+xfp31yX+xJKFPWOUMX9BieDYaW6SyQhYI9o2NVD3+0AUbLdZimhd+TigS6MpWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758209407; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PaZvHMvq5UGvPHZJTIR0qZ8hdQBkbCFkuOZ3ZxBhp7k=; b=Nun9ul60Q7V5G076hKIfjA0iX4qTbD/mk5XuN0sYwU5RVr8B9BQg/yY8qgHVcyEwlhuCGXaTxdb/N+aWVNLsA1xTBlRDJmZtEmqX+Z4RPkSuWzABsCvWnqeKeNMZLt1W3wf4GIrzf0Q4Cg7eEgl304jXMZXt5lE88iha0zvS4sI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175820940732349.97836524764239; Thu, 18 Sep 2025 08:30:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzGXp-0002yt-NQ; Thu, 18 Sep 2025 11:27:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzGXi-0002nb-OA for qemu-devel@nongnu.org; Thu, 18 Sep 2025 11:27:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzGXf-0003OF-A8 for qemu-devel@nongnu.org; Thu, 18 Sep 2025 11:27:30 -0400 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-krCUzEgVOgmciGei13u-cg-1; Thu, 18 Sep 2025 11:27:25 -0400 Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-77243618babso1175925b3a.0 for ; Thu, 18 Sep 2025 08:27:24 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.110.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-77cfc2481d7sm2675512b3a.32.2025.09.18.08.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Sep 2025 08:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758209246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PaZvHMvq5UGvPHZJTIR0qZ8hdQBkbCFkuOZ3ZxBhp7k=; b=AB+d7a/bv3ypcpBeYRarhrvKRHULIYmXekVCiIIpkGouz3fBIh0DTctQD0cEPBeYBaMnlH jqETshSFdXFA+Zvh5yFpLW3oCq2684pyAYf29nr5r8xM9Rv/y/XDauqAAt5XPUJHO0jk91 UXax0y6skqwMokxtzbfH0sPuJuTZHuk= X-MC-Unique: krCUzEgVOgmciGei13u-cg-1 X-Mimecast-MFC-AGG-ID: krCUzEgVOgmciGei13u-cg_1758209244 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758209244; x=1758814044; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PaZvHMvq5UGvPHZJTIR0qZ8hdQBkbCFkuOZ3ZxBhp7k=; b=IUY/AgSmMx0KfoU+PKhFc2buZS50XZIw/SeOFNRJdTXghE+OC/1oRqUvm258sP6ukR 3LdSmsPUMImeZawNYsRbPIJNLeJzd8rGu7iqqyZHQI7RGh8QsbSgBXyGd86IiiEaXvYf 5tvwEue8ZYkXmHggB8RMz/midEt2h5qdtqrQaPGamwxpTqvmatPvfgfTfpeuEvzTSMyu 5CtBahUqKLBhDgHaW3Vu5MJ4H8JssYGtOzIWtg9vi9h8yXx2h4HGK4bC/hV7htRAy8Uc qtKIoaqW8Nl0uHOWqHsCZrG32T1fYynVGPYtqg3OvoclXI+zNff6m/SLSHO8zfqjZybD xpTA== X-Gm-Message-State: AOJu0YzqW9LSc4HujdL15GaaCiFGkO+KaLOEf2+DaVl2bzY0b4NfwOPK EEqmG1eLr8HRgCgGr0Myol+Yzm3wNH63w+MDT3f9OXoPDtY4YlWx3yQmVplza+sIAC3tUhmZeAJ rQ0zJst0d1wCu87qnJ6ZfKqLaPYalbk2hKa3sDWahPSTQ0iu4PwT6GRe7 X-Gm-Gg: ASbGnctR2yM99hmABXIcSNyui4ZFAQ/ysAlKUJWzdA0UZ6Zg4UDLXwm/I5fa9tpNb8r julBUeQ8Qq/XxJ1obhtx6SunpGJkmx9CIPbSVfBdqHs1s+jgRd8hVYWxH6qslVSD973sejlDREm 9OquN3rX7pjMJQ9MFnwTYHfCXtY7iGuObH7+/VLlrJcTmj28OzFRV9JJ3tT2fiX/gXnNk1Y9BhC gNqwiQ4itf9M4XC2CeRSFW3hgflFsCBwDDcL3X7OyJ0HkY+fvBw3aJGrPoJmbdCUoMfUfMIudw5 QC2PjM0lKzspVI/nC6V9odD/7KzJaY96iQoDQQzLadhwqi72Dx2XBw== X-Received: by 2002:a05:6a00:1395:b0:771:ec42:1c1e with SMTP id d2e1a72fcca58-77bf9274927mr6708383b3a.16.1758209243988; Thu, 18 Sep 2025 08:27:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh4YZXnONzvydcwry0JyJmM1lVvZRxCXhgGiNSZ1r9M4aK4I7jrrnQaVsMUnrkDuoLzzmxbQ== X-Received: by 2002:a05:6a00:1395:b0:771:ec42:1c1e with SMTP id d2e1a72fcca58-77bf9274927mr6708358b3a.16.1758209243574; Thu, 18 Sep 2025 08:27:23 -0700 (PDT) From: Arun Menon Date: Thu, 18 Sep 2025 20:53:42 +0530 Subject: [PATCH v14 25/27] migration: Rename post_save() to cleanup_save() and make it void MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250918-propagate_tpm_error-v14-25-36f11a6fb9d3@redhat.com> References: <20250918-propagate_tpm_error-v14-0-36f11a6fb9d3@redhat.com> In-Reply-To: <20250918-propagate_tpm_error-v14-0-36f11a6fb9d3@redhat.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Thomas Huth , Christian Borntraeger , Matthew Rosato , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Nicholas Piggin , Harsh Prateek Bora , Paolo Bonzini , Fam Zheng , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Steve Sistare , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Hailiang Zhang , Stefan Berger , Peter Maydell , qemu-arm@nongnu.org, Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6500; i=armenon@redhat.com; h=from:subject:message-id; bh=RA0v69F99I5SRsauN9jKQHb/8Bw3uL+HkXH2toG+G78=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ8YZ5Z99Z2Nk0qR3u6uJX1or/zT/UpjUIwuPD3dPah4qM pO6uMK3o5SFQYyLQVZMkaXha4BsU0BhRKTty+swc1iZQIYwcHEKwET4pRkZnnosOmwso8Fre2ZW 3rRDz2dfF39+99iuqttLtj4IvyNet4Lhr0xyylvmcouOf/wS33+sqOfwfNh2NDDORk/RWH+Vljo HFwA= X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armenon@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.005, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1758209409423116600 The post_save() function call is responsible for cleaning up resources after the device state has been saved. Currently it is infallible, and does not return an error. It is called regardless of whether there is a preceding error from save or subsection save. That is, save and post_save() together are considered to be an atomic logical operation. It should not be confused as a counterpart of the post_load() function because post_load() does some sanity checks and returns an error if it fails. This commit, therefore, renames post_save() to cleanup_save() and makes it a void function. Reviewed-by: Fabiano Rosas Suggested-by: Akihiko Odaki Signed-off-by: Arun Menon --- docs/devel/migration/main.rst | 2 +- hw/ppc/spapr_pci.c | 5 ++--- include/migration/vmstate.h | 2 +- migration/savevm.c | 5 ++--- migration/vmstate.c | 12 ++++-------- target/arm/machine.c | 6 ++---- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 6493c1d2bca48a2fa34d92f6c0979c215c56b8d5..a39fec2e21c26c4315c0cf13b10= 5176d70679d4d 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 (*cleanup_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 1ac1185825e84ca908fd878f6cbe7e8cacac1d89..135265f075dff502af59fbc91ba= bca1f9a26c54d 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2118,14 +2118,13 @@ static int spapr_pci_pre_save(void *opaque) return 0; } =20 -static int spapr_pci_post_save(void *opaque) +static void spapr_pci_cleanup_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) @@ -2152,7 +2151,7 @@ static const VMStateDescription vmstate_spapr_pci =3D= { .version_id =3D 2, .minimum_version_id =3D 2, .pre_save =3D spapr_pci_pre_save, - .post_save =3D spapr_pci_post_save, + .cleanup_save =3D spapr_pci_cleanup_save, .post_load =3D spapr_pci_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT64_EQUAL(buid, SpaprPhbState, NULL), diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 5fe9bbf39058d0cf97c1adab54cc516dbe8dc32a..c1d8e5b7a7d9d544fc8ce181372= 660f5538ef66b 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -208,7 +208,7 @@ struct VMStateDescription { int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); int (*pre_save)(void *opaque); - int (*post_save)(void *opaque); + void (*cleanup_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 2c05b763148295d7e2095027aa143f45bc4c4676..693f77b728604f2072fb40bd2ec= 268b217da9727 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -322,14 +322,13 @@ static int configuration_pre_save(void *opaque) return 0; } =20 -static int configuration_post_save(void *opaque) +static void configuration_cleanup_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) @@ -544,7 +543,7 @@ static const VMStateDescription vmstate_configuration = =3D { .pre_load =3D configuration_pre_load, .post_load =3D configuration_post_load, .pre_save =3D configuration_pre_save, - .post_save =3D configuration_post_save, + .cleanup_save =3D configuration_cleanup_save, .fields =3D (const VMStateField[]) { VMSTATE_UINT32(len, SaveState), VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len), diff --git a/migration/vmstate.c b/migration/vmstate.c index ad8e5b71ae2ce78e66a6426602e5c20405ec57c0..a7562a5cfd8627e20c90e286e35= c5e3429c48150 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -529,8 +529,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, if (ret) { error_setg(errp, "Save of field %s/%s failed", vmsd->name, field->name); - if (vmsd->post_save) { - vmsd->post_save(opaque); + if (vmsd->cleanup_save) { + vmsd->cleanup_save(opaque); } return ret; } @@ -557,12 +557,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDes= cription *vmsd, =20 ret =3D vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); =20 - if (vmsd->post_save) { - 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); - } + if (vmsd->cleanup_save) { + vmsd->cleanup_save(opaque); } return ret; } diff --git a/target/arm/machine.c b/target/arm/machine.c index 6666a0c50c45504082f02fab42f499ca58dc3597..cb6b9ee653915cd07b7d93e2c9e= c63be1a3365a0 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -883,15 +883,13 @@ static int cpu_pre_save(void *opaque) return 0; } =20 -static int cpu_post_save(void *opaque) +static void cpu_cleanup_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) @@ -1028,7 +1026,7 @@ const VMStateDescription vmstate_arm_cpu =3D { .version_id =3D 22, .minimum_version_id =3D 22, .pre_save =3D cpu_pre_save, - .post_save =3D cpu_post_save, + .cleanup_save =3D cpu_cleanup_save, .pre_load =3D cpu_pre_load, .post_load =3D cpu_post_load, .fields =3D (const VMStateField[]) { --=20 2.51.0