From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <010701a19be2fcb0-7e602d11-756a-4aa2-8fe1-0a2f9660ce0e-000000@eu-central-1.amazonses.com> Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11022126.outbound.protection.outlook.com [52.101.66.126]) by lore.virtuozzo.com (Postfix) with ESMTPS id 516FF8045D for ; Mon, 2 Nov 2026 10:51:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XbJ4aisjus3jsZd6q3B3woDzobn7q4RmZHk785HgEkGpPK/krePpiXUTHCzt2MD7jfzgI+z2KA5YReg7M/+tIKtvk9xSoNJUVwZJqbhs60eJntPQ7HXHmxRnmDwqWRwmnIg0VI+VLpxwPKQ9xOf/XoSIxeYqZWNIp73GqjeUHO4wzDW3WfTO8J/nE2BCzekR5rUbHLM/ga//T7i9UZD+x8V97WfJK1lp4YFOsi1KkB62BpBCkqhVH+GccHzvF1SaXgxCmAb9Ejd6uHQ0TyHrvNaWSjqLBhREVGcPWVwoRT1/8L+Jt1norPH4Lqx8D+GKIZiDLWsaaTyuoTpfAIfOiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZEXnQfEOp2BsNUosEooNMx8aBx6GyFom0+WPgincf8U=; b=fydrKsnBtXubQpzjAYVBek7wuxdgHGr43TWPLEdGTzFVZSsg7vuyvvtczV0ON++Gf3mR2f3zy6L+/C13y0CWvhWQKYQ/+9tW2iMhAqRPeVzVDdJwL58jWQsa4Qua6h6OvOA2zf6qxxgonUGKlubvQyeFRT0Un2Tv58F+hjkt/iLhEXKs9t3xcGjbdLD3EFUuGHsVtGbtGq0id4Nl2RjuyVfbjQVCi/keJ8qZksUk+bKYm1Ti9aJ6X3cOj3eu2DX7saCaxsZzfAKJd3sN1RwkMzC3gJAPZybWh8dICieCckYVnHkKFH4MWcPyaLgtdBRzfzo6cK+A+DblIxrBqWtiPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 69.169.224.1) smtp.rcpttodomain=virtuozzo.com smtp.mailfrom=eu-central-1.amazonses.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=amazonses.com; arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.onmicrosoft.com; s=selector2-virtuozzo-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZEXnQfEOp2BsNUosEooNMx8aBx6GyFom0+WPgincf8U=; b=Kc6zRWmk9P1ILGKAiRl3unuJq4+fo6yRMyCDqvAFfqawgjDf6r5OOTGI7XvshdhzGkagbeZ72e/rx9lmmgSP0HJfM4v7KoIp7yUPmYmnRggsGu2Vwo0LsbZQpBkQpJpLseiZFlyzI++OEyJKga6oElYmPmiGWezmQbSjDL2pOhc= Received: from FR4P281CA0013.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:c8::6) by DB8PR08MB5401.eurprd08.prod.outlook.com (2603:10a6:10:f9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.569.12; Mon, 2 Nov 2026 10:51:47 +0000 Received: from MI3PEPF00008494.eurprd03.prod.outlook.com (2603:10a6:d10:c8:cafe::4f) by FR4P281CA0013.outlook.office365.com (2603:10a6:d10:c8::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.592.8 via Frontend Transport; Mon, 2 Nov 2026 10:51:47 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 69.169.224.1) smtp.mailfrom=eu-central-1.amazonses.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com;dkim=pass (signature was verified) header.d=amazonses.com;dmarc=pass action=none header.from=sashiko.virtuozzo.com; Received-SPF: Pass (protection.outlook.com: domain of eu-central-1.amazonses.com designates 69.169.224.1 as permitted sender) receiver=protection.outlook.com; client-ip=69.169.224.1; helo=b224-1.smtp-out.eu-central-1.amazonses.com; pr=C Received: from b224-1.smtp-out.eu-central-1.amazonses.com (69.169.224.1) by MI3PEPF00008494.mail.protection.outlook.com (10.167.240.155) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.592.5 via Frontend Transport; Mon, 2 Nov 2026 10:51:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=23yjbh4k34hwzfubhuiim7m4inbd3ick; d=sashiko.virtuozzo.com; t=1793616706; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=v/ago1fGJhMEAJRp+I/RsqQbVFwX858iZkHLTbGDnYU=; b=VxJI30TA/Hccoqyze78TFbxLzExOGL6V0lsSiIhCp6KG2DlRdj8oxePR4FivDRtd WO8iKd41XTvC//8KBvMmjXDbm5sOPddd8ROBiBULFVEIzyv4vcq2qY6UKwqqFRkISTB GpscHjQzx2CT/emC1RH7ejidWTFTI+NCnaxGm+rYjEHZkf4lZfobIDx6zYYIiy0P46p BXy3u5HngQIEUr/OGgoQO7awxGI7wGg2LPuINQPmhhZS/vw0QPmVyEIEdLwQTY2ozqB t9piX3Qxc/ic3sz6CMKnTrAvIK6B56VpKQR2SZ3g60It4RyitmX499U5YFG93F0yyVJ 7+LxzVe43w== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qftdzk2dqsatjnlrq4r5brjbihpfcrsh; d=amazonses.com; t=1793616706; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=v/ago1fGJhMEAJRp+I/RsqQbVFwX858iZkHLTbGDnYU=; b=T5VKORWnoYdlD0mDoju7dLsP6/LNflg6ItFuJweG8L2CxHxZClJDGARt3453tgKq HATb/hLpw+K3iVm2Cfz9Pdb9AUCBZCK12ZQEqmR5NKxihuAjYwQz5+Itymo62M89o3c OmKgveoHBdVAg1/uvJkgZBWCkJsBECzKvHnJjMQg= Message-ID: <010701a19be2fcb0-7e602d11-756a-4aa2-8fe1-0a2f9660ce0e-000000@eu-central-1.amazonses.com> From: no-reply@sashiko.virtuozzo.com Subject: Re: [PATCH QEMU HCI-8.1 v6 17/34] migration: vmstate_save_state_v: fix double error_setg To: Andrey Drobyshev , svt-core@virtuozzo.com In-Reply-To: <20261102-vfio_v1-v6-17-9bc7cabc850d@virtuozzo.com> References: <20261102-vfio_v1-v6-0-9bc7cabc850d@virtuozzo.com> <20261102-vfio_v1-v6-17-9bc7cabc850d@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 2 Nov 2026 10:51:46 +0000 Feedback-ID: ::1.eu-central-1.2wRQJBpg9g1fGRYexx3dUuYGS25Bux+2TEOx72/m6U4=:AmazonSES X-SES-Outgoing: 2026.11.02-69.169.224.1 X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MI3PEPF00008494:EE_|DB8PR08MB5401:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 025d1caa-b5bc-49bc-61c5-08df38cf4ab6 X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr X-MS-Exchange-AtpMessageProperties: SA List-Id: svt-core@virtuozzo.com X-MS-Exchange-Transport-Rules-Loop: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|704161411799003|376014|48200799018|61400799027|9140799003|32142699015|4143699003|5063699009|56012099006|261009223027099003|261028144727099003|261026140227099003|261022105027099003|261026121527099003|10067099003|55112099003|18002099003|22082099003|16102099003|5113699003|4113699003|13003099007; X-Microsoft-Antispam-Message-Info: W9ioch+tPeirhUjxrU0+5s4vAgkI2MPU+BSuCvTY+xY2/O+joivcCnC8TdDIiSs/tWpPZTISg8k0V+tl1hYeF9WnjySC+z392ABeIl98jqNLoKYygHaAqj+FBUtxinEdhMUsgdTq3WJt+4MY3/IvppVcukq1hoBjntT8CuW2C7ehAIhHWHdq4/UAi/P+HOOds1houp0dUUKJSqodTpbo+QoWWz704K9ZSEmG8P+niOux/13WRAPzrSIA3U+RDVQxHmEIlNWK2TAU8k65lw2hpTkBFMkzUkKcxthzEWBRRW1xfoiW6I3p3sN1NFU3Gy/Z05vX2aQr+uw94zUS2R23TPLwom0awtc7kWTs2Uq+HNP/EVkgfQ524IXW91WhsrhhdYQjp3/HG6VeXZcFPoMVEMJJnSzhhek+xAiZqa/vOGu0fg47wX+140yfZVmCE2R+hQw3o0PzdRllFqf6AGFdEjQh6NlaH6j/PZGdwBGMrVyTb2XGxs0I8xS7/d9jwSzrI6jzF0OroKmWvKjHw/wNoBtSNiWYPanLHJsrhZVB9FMEiuTwrFdycCIOtJon1J2J6a6F+J0wwvmi6bMxdTqRmZwkrHVET5wk2BmQB+EmYDOKO5lh+H5l5a2R0VQYghX1IDSs65Bo4cQbOgIm1bXh/N1gviU2BqEqrAV6D7FbKocAy7aFBvXDZL4knQOtJ6BHfPs9q/k9FcdDgOkJSVt0R47zodyEU1NtacAUcW5tgYwur4U6E4O/99C15l9WI6VoYYVCrNAYEgZVesH8LJhdTNu3RvBHhqe2TlOhL/wxJ7NxE2Wq8uYbXpIjXDKIbi3qF1yiNlXe2b2xAcQlTtJfHYtxdiu8D9sNLymfMc6bxzlmPB3fqlCRMjXnbTk3dfo2 X-Forefront-Antispam-Report: CIP:69.169.224.1;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:b224-1.smtp-out.eu-central-1.amazonses.com;PTR:b224-1.smtp-out.eu-central-1.amazonses.com;CAT:NONE;SFS:(13230040)(704161411799003)(376014)(48200799018)(61400799027)(9140799003)(32142699015)(4143699003)(5063699009)(56012099006)(261009223027099003)(261028144727099003)(261026140227099003)(261022105027099003)(261026121527099003)(10067099003)(55112099003)(18002099003)(22082099003)(16102099003)(5113699003)(4113699003)(13003099007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TnnxbFFUrtQll9xn09aveMyy58dmEbYaFTRAgQPzTTUq/obiK8PIZtgpgbjf58buXcU2wQKy8tDkX/+tH3u8B6Mk4oL5c5QArB/3Yg/mfnLi9cTqPaOWTYlkIDslaaZ7VreafeT+JGAd1lBb6mDMxu++0h+4MU9rbKUNa1rpYf0V+oI4JPzAR/0fthoGQkQnMlgue6XUreMO7GTCnSqQ0uKkMLE5fzWeoCyKg4utOMVpQtx5f6q/vFeRle7kc/dABKH4zvNq/AfBYJjmW7pgxxypzjs4rzdKZa85ftAUA23NKaBg6QNjbMc/Xx+gMFXKeUJZybd2lH22qE8LedPEFvpupL2GoGyS5OwRepZacY1WjpYAJTSJGjO+hgcv5US7eSK+guUpewS7IX3vS2yFQoQLJ4xsPyJMFXbVtjXA65suyV7lqDLjaUr2wiW1H4HH X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2026 10:51:47.2001 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 025d1caa-b5bc-49bc-61c5-08df38cf4ab6 X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: MI3PEPF00008494.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5401 Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: - [Medium] migration: vmstate_save_state_v() sets Error only for ret < 0 bu= t error_prepend() runs for any ret !=3D 0 -- commit c242dc6e98ee351214e7cbc0d990ad8f5b090974 Author: Vladimir Sementsov-Ogievskiy migration: vmstate_save_state_v: fix double error_setg This patch avoids calling error_setg() twice on the same errp when a nested vmstate_save_state() or vmstate_save_state_v() fails. It sets an Error only when put() returns a negative value, and it changes the common failure branch to use error_prepend(). Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-2-vsementsov= @yandex-team.ru > diff --git a/migration/vmstate.c b/migration/vmstate.c > index aea41c099463..04903131257b 100644 > --- a/migration/vmstate.c > +++ b/migration/vmstate.c [ ... ] > @@ -523,6 +523,9 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, > } else { > ret =3D inner_field->info->put(f, curr_elem, size, > inner_field, vmdesc_loo= p); > + if (ret < 0) { > + error_setg(errp, "put failed"); > + } > } [ ... ] > @@ -535,8 +538,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *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); [Severity: Medium] Can this error_prepend() run with *errp still NULL? The put() branch sets an Error only when ret < 0, but this branch is taken for any non-zero ret: ret =3D inner_field->info->put(f, curr_elem, size, inner_field, vmdesc_loop); if (ret < 0) { error_setg(errp, "put failed"); } ... if (ret) { error_prepend(errp, "Save of field %s/%s failed: ", ...); If put() returns a positive value, error_setg() is skipped. error_prepend() then calls error_vprepend(), which checks only for a NULL errp and not a NULL *errp: if (!errp) { return; } newmsg =3D g_string_new(NULL); g_string_vprintf(newmsg, fmt, ap); g_string_append(newmsg, (*errp)->msg); That would dereference a NULL Error and crash the migration source. The nested paths look similar. put_tmp() in vmstate-types.c reports the inner failure through a local_err and returns the nested ret unchanged: ret =3D vmstate_save_state(f, vmsd, tmp, vmdesc, &local_err); if (ret) { error_report_err(local_err); } g_free(tmp); return ret; put_qtailq(), put_qlist() and put_gtree() behave the same way. If the nested ret is positive, for example from a pre_save callback, it reaches the outer branch with ret < 0 false and *errp unset. I could not find an in-tree put() callback that returns a positive value. The ones I read return 0 or a negative errno. The VMStateInfo.put contract in include/migration/vmstate.h doesn't say that only negative values are allowed. Before this patch, error_setg() ran for any non-zero ret, so this mismatch is new. The pre_save and post_save paths are not affected, because both call error_setg() for any non-zero return. Would it be better to use "if (ret)" instead of "if (ret < 0)" for the put() case, or to normalise ret to a negative value? > if (vmsd->post_save) { > vmsd->post_save(opaque); > } --=20 Sashiko AI review =C2=B7 https://sashiko.vzint.dev/#/patchset/20261102-vfio= _v1-v6-0-9bc7cabc850d@virtuozzo.com?part=3D17