From nobody Fri Nov 14 21:05:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1761693364; cv=none; d=zohomail.com; s=zohoarc; b=e0NGcb3l31fhUCn3TQB4UqgdMyA5tD3NumplKZzafPRbZgKXWRqBpFVGuiihyUeMllRw/SaOtLrzbuqWsTNtgMxoxcRysFyxy8+mTFbvXoGp4k7cx43tsK5H2oSOzo4LGIZDjiQF5eOg0yq4LTAzfZJ3K0GRKnIke0jK9s0JrO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761693364; 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=d77pOpn706V6UlmPku+gqYZpRBb+6mVRH/UFFJ6GHEo=; b=dQSme++lPPQkwbXDDS4naKvRzHTkhOLfRANqJWGHaqunfsWfls+3FOjuNC9O78QFGV+P57H5V0Vwn1NM7N3WTbCRa600j/tOTKylkiqnHrvP8mQ2fqA8wC4xf1imriyyuc3C/6eObd9jtRIJ3PJkC9i3p1y0szsCych5WyEdUtA= 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 1761693364839913.9620950805344; Tue, 28 Oct 2025 16:16:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDsto-00036c-8R; Tue, 28 Oct 2025 19:14:44 -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 1vDstn-00036M-2c for qemu-devel@nongnu.org; Tue, 28 Oct 2025 19:14:43 -0400 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 1vDstQ-00018p-RC for qemu-devel@nongnu.org; Tue, 28 Oct 2025 19:14:42 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c10:49f:0:640:b99a:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id EF36A8177F; Wed, 29 Oct 2025 02:14:06 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:582::1:19]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id oDnXpg2bCW20-3Q8HwkNU; Wed, 29 Oct 2025 02:14:06 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761693246; bh=d77pOpn706V6UlmPku+gqYZpRBb+6mVRH/UFFJ6GHEo=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=H7mHalUnFQ5rqhAPY19nEp4eSsBXLXFMCfnxTku1sR4bcggzP8orPjS8qHHr6k7Ll JjNpZQnvT3arl8T5siklHC0ds0Xm3Jc2+OoVtDojZb9MayJjQlI8+d8Y6ZUlpozCf9 M09qz3ZW8oloUDYbsK0H5xe9qmSTVmbA8+T0RjYU= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: armbru@redhat.com, vsementsov@yandex-team.ru, qemu-devel@nongnu.org Subject: [RFC 21/22] migration: convert vmstate_subsection_save/load functions to bool Date: Wed, 29 Oct 2025 02:13:45 +0300 Message-ID: <20251028231347.194844-22-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251028231347.194844-1-vsementsov@yandex-team.ru> References: <20251028231347.194844-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: -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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1761693369539154100 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 --- migration/vmstate.c | 55 +++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 6f1e878f36..2298f190de 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); =20 /* Whether this field should exist for either save or load the VM? */ static bool @@ -249,10 +249,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescr= iption *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 (!vmstate_subsection_load(f, vmsd, opaque, errp)) { + qemu_file_set_error(f, -EINVAL); + return false; } if (vmsd->post_load_errp) { if (!vmsd->post_load_errp(opaque, version_id, errp)) { @@ -584,7 +583,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *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 if (vmsd->post_save) { int ps_ret =3D vmsd->post_save(opaque); @@ -610,15 +609,14 @@ vmstate_get_subsection(const VMStateDescription * con= st *sub, return NULL; } =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 @@ -626,12 +624,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; @@ -646,34 +644,32 @@ static int vmstate_subsection_load(QEMUFile *f, const= VMStateDescription *vmsd, 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_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: %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) { @@ -697,9 +693,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_vmsd(f, vmsdsub, opaque, vmdesc, errp)) { + return false; } =20 if (vmdesc) { @@ -713,5 +708,5 @@ static int vmstate_subsection_save(QEMUFile *f, const V= MStateDescription *vmsd, json_writer_end_array(vmdesc); } =20 - return ret; + return true; } --=20 2.48.1