From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972044; cv=none; d=zohomail.com; s=zohoarc; b=YMmN8PUmS+Ly6WkgQwhV0HlbPl47goj8CShbSuCxr5Y3fzjg4RqWH1D40jgT3szv7qwWDeW7Ts6oyhI5ytfHY6Jtl6ydmpjaNhglBHScOtSyQLNMJY8N8fDrqaRzIkFA2ouBpAHD0Q96W2Sw+v41KJpB92N6qVbmEz/+l+uVFDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972044; 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=peXunn/MN+tBFALwrP477y2MzLSfJFHU+HL5cvVNS1M=; b=CvFRFV4w/z+GIzVZs7FUqpYXrGTjFV1AcrijrPq2nO/RP6rGJnup032cxs36kn4ECxMegCmJmT1pppZUS8OlTidQkZsf7QqQVN8wgwua2Jr7RBQcPSRQl5ALffApcHBCVQyi1qvgNTkAt/97oCEZ/mgeipNn+jBx2YQ6ONv0H6Q= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972044530853.1660046983088; Thu, 23 Apr 2026 12:20:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzaq-0001ky-QD; Thu, 23 Apr 2026 15:20:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzao-0001hE-Px for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:06 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzam-0001Xo-P5 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:06 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E0A335BD43; Thu, 23 Apr 2026 19:20:02 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A9267593A3; Thu, 23 Apr 2026 19:20:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SAVeHeFw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=peXunn/MN+tBFALwrP477y2MzLSfJFHU+HL5cvVNS1M=; b=mFDNRtuGrREx1/0t9uOVA9/KgqWI6m6cOfupfewhsNIcm9yPXSGi2h+xsFVDwHfhbhsuph XN8Fgzx8ZO3aF9UOA9hcj7aphNBqImvPBkULn3G7sl99hlhTkz3B8RYpWM503aB0WZfsDJ FhTRkF9fw7j/DNAXFJ1ahGEQ9dkw9mk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=peXunn/MN+tBFALwrP477y2MzLSfJFHU+HL5cvVNS1M=; b=Qtnr5nxaEGJrI/ih5IV3LjBRPRsuTtH0XkOHgijfcQyd5Dqqmyd/Jn4GH04LjNiscd3JFq rYl0NtZxe0npbJDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=mFDNRtuG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Qtnr5nxa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=peXunn/MN+tBFALwrP477y2MzLSfJFHU+HL5cvVNS1M=; b=mFDNRtuGrREx1/0t9uOVA9/KgqWI6m6cOfupfewhsNIcm9yPXSGi2h+xsFVDwHfhbhsuph XN8Fgzx8ZO3aF9UOA9hcj7aphNBqImvPBkULn3G7sl99hlhTkz3B8RYpWM503aB0WZfsDJ FhTRkF9fw7j/DNAXFJ1ahGEQ9dkw9mk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=peXunn/MN+tBFALwrP477y2MzLSfJFHU+HL5cvVNS1M=; b=Qtnr5nxaEGJrI/ih5IV3LjBRPRsuTtH0XkOHgijfcQyd5Dqqmyd/Jn4GH04LjNiscd3JFq rYl0NtZxe0npbJDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Markus Armbruster , Kevin Wolf Subject: [PULL 01/43] checkpatch: Allow spaces after all coroutine annotations Date: Thu, 23 Apr 2026 16:19:15 -0300 Message-ID: <20260423191958.1440-2-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid,suse.de:email]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: E0A335BD43 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972045801158500 Content-Type: text/plain; charset="utf-8" The coroutine annotations may be used in the declaration of function pointers, which triggers checkpatch due to the space before the parentheses. E.g: int coroutine_fn (*run)(Job *job, Error **errp); ^ The coroutine_fn annotation is already included in the list of terms where spaces are allowed. Add the other coroutine annotations: coroutine_mixed_fn and no_coroutine_fn. Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf Link: https://lore.kernel.org/qemu-devel/20260420191356.4439-1-farosas@suse= .de Signed-off-by: Fabiano Rosas --- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b77bd69328..e1cf2ff23b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2441,6 +2441,7 @@ sub process { if ($name =3D~ /^(?: if|for|while|switch|return|case| volatile|__volatile__|coroutine_fn| + coroutine_mixed_fn|no_coroutine_fn| __attribute__|format|__extension__| asm|__asm__)$/x) { --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972105; cv=none; d=zohomail.com; s=zohoarc; b=Y0/smftxPOuJFDm8JVewxBTx3ZNWiJSsp3KKsyitKX0iWxxP9QjaBLKDXboUi3QrcoTGahLu6yH0B+pKjttROkd+Wbfx3S0Ci9idXQEwi/9ebV8/Oxna1PG82gX7xXeE2hERO5lS9ffHeEbOH0ZtIvc5+JZERqeR4D++HlcCaMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972105; 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=+xNJmtypGwYb/d/QHNiBiDyOr2yyKzZAVHlgehqrv8c=; b=HIwXZm8l40kAx1fYNdFLOiMSmCeHoMOqHMMCS/gCBtjWMAXbVoT6eIfrVi9q21O11Vddh7e/GWP8mCyCSHtX1if173SDUakWX3xeIukqboiANZya3ti2t03rdvWfx0IYrY9i3rLeQv/K7IrLmjuFJWBZL0+edKy8ABLhvWCHjhY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972104945547.4529125269703; Thu, 23 Apr 2026 12:21:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzaw-0001nl-BY; Thu, 23 Apr 2026 15:20:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzau-0001nP-Cd for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:12 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzas-0001jp-L3 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:12 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 814AB5BD62; Thu, 23 Apr 2026 19:20:04 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 49FA2593A3; Thu, 23 Apr 2026 19:20:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iPIfBuNw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972005; h=from:from:reply-to: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=+xNJmtypGwYb/d/QHNiBiDyOr2yyKzZAVHlgehqrv8c=; b=CIshQmRFdCLaqFzbbTM7hZV3+A+Gw+iy8iVVoOYJJx/vP5Je0md0KtJv6jfgDnPjbyG8GT UZtb71M+bhCWYtpUNg8XQOvQibx4Ejjumj6ZjkLqSa5KYlMsUKGMHj65hRN0qdq57XwKxI AiBb7oINm9Go0JHofUevYBKQ+yCAunQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972005; h=from:from:reply-to: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=+xNJmtypGwYb/d/QHNiBiDyOr2yyKzZAVHlgehqrv8c=; b=gQhH2XfeE3vCewra59rEckHd32w1VGILlPNE5BK4D5J7Ghi28OMCx7XDEn1INKJA/H/YTL vBO1rokeBT1wyXBg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972004; h=from:from:reply-to: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=+xNJmtypGwYb/d/QHNiBiDyOr2yyKzZAVHlgehqrv8c=; b=wInpoDnqhnMaEmKVH6P3rW311GNhbs9WI23Wqs3qRtCNudg2MveSfH/C8yozTwDH8nK/g5 f4mJ0TOSTrnl796ZRodXNQCKWVjGGPlrKSRc6PcRB0WD3LC2vLcRKldPsTxtxs4DVzp0yY M+pQyVxps/YT9QNhLuFG9YTvZGA2hg0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972004; h=from:from:reply-to: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=+xNJmtypGwYb/d/QHNiBiDyOr2yyKzZAVHlgehqrv8c=; b=ytLKHHqm0YUqD3wW5oUH2eSGG8hr2G+rN5QHlXZXItmW5nSV7O0ADen4PN6uaMeA1jGArO KdQcs0KYj2WWQkCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 02/43] tests/functional: Make socat wait longer in migration exec test Date: Thu, 23 Apr 2026 16:19:16 -0300 Message-ID: <20260423191958.1440-3-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[linaro.org:email, suse.de:mid, suse.de:email, imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -3.30 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972105470158500 The migration_with_exec test is failing sporadically for all architectures due to a race when the destination socat process takes too long to start listening while the source process is already issuing connect(). The race is inherent because the exec: migration spawns the to-be-exec'ed command asynchronously and returns from the migrate-incoming command. The localhost-only testcase is not representative of the majority of migrations. In a real scenario between two different hosts that race wouldn't happen. Fix the testcase by configuring the source socat command to wait indefinitely while trying to connect. Reviewed-by: Thomas Huth Reviewed-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Link: https://lore.kernel.org/qemu-devel/20260422230001.3168-1-farosas@suse= .de Signed-off-by: Fabiano Rosas --- tests/functional/migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/migration.py b/tests/functional/migration.py index 144f091ba8..3b7674af3b 100644 --- a/tests/functional/migration.py +++ b/tests/functional/migration.py @@ -85,5 +85,5 @@ def migration_with_exec(self): with Ports() as ports: free_port =3D self._get_free_port(ports) dst_uri =3D 'exec:socat TCP-LISTEN:%u -' % free_port - src_uri =3D 'exec:socat - TCP:localhost:%u' % free_port + src_uri =3D 'exec:socat - TCP:localhost:%u,forever' % free_port self.migrate(dst_uri, src_uri) --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972084; cv=none; d=zohomail.com; s=zohoarc; b=iA60w6WylCHtqzce4siHNVl7JNC2544GQJEwMzp4JLy35/JVQxf6VxD14En6b7G+FFEsNF9JT827xIMTA9bUje6xsS4ECXs5FM/9zLF8n8NQzqDJ3BBpIgUaYDu2h95805bH5zf8k148OErRqJOTH3Zn4rRMRzeLG46ydJfUigA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972084; 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=DHMkoFlbmXpq2TNGiMoLXIsWzV+/cYEgIonbGv81rKQ=; b=AIKd08w1XPQYKlkSgp22O9XZmTMvFDe/8gXfCMQUoeaCFLItqCaaQc6jdxF/JrDfhqnYFSMZaJNpLE2EV9bZGbHampRXNgWSSH8Wl2arXkb05UD/QUcZObe74OGXENVamu4nus7OGju6U/OgDVBQHAEJXe3KUQxuFEskh3QQtNI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972084804194.5502963305105; Thu, 23 Apr 2026 12:21:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzaw-0001no-Cv; Thu, 23 Apr 2026 15:20:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzav-0001nX-3v for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:13 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzat-0001kE-Fe for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:12 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E52C86A891; Thu, 23 Apr 2026 19:20:05 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DF2B5593B0; Thu, 23 Apr 2026 19:20:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iL+IKuRw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972006; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DHMkoFlbmXpq2TNGiMoLXIsWzV+/cYEgIonbGv81rKQ=; b=0rLmIfPbRt1+SkkH5mdKz8D1rLyTk4Z6K9EwiieRmgn7XX/8NB78sEH+z35GaEP4PA78/F 4MAbxs8xMRYKufSKeEm12y0zKieUCVn/e8injGCxia6pUULyghG/Q2HQTynQ9cbv36immX Goq9GnbJ9lQVqYjhOOeLULj79CtCPiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972006; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DHMkoFlbmXpq2TNGiMoLXIsWzV+/cYEgIonbGv81rKQ=; b=kFBN9Vym1uyoSUYV+kDZkjc46NtJqtSzVGdrA40Lh1SSOjWm8WRWET479HosmVmmQ5ZPtU Fxm/0PwMZsxjYdAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972005; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DHMkoFlbmXpq2TNGiMoLXIsWzV+/cYEgIonbGv81rKQ=; b=hpwJBZbA4EOKQ5ZRy3e3MBjOtZPiGtFtM6v9EgZQXW62FZa3ujH5HEnxiRvcom/C49wPAK IUAIIYmg+acRc2mGA+rE976jmXM+UdqwbfAZUNfppcRT1OE7QbeNImuP78SSSWfX/qrmrt oAkjBGR6mnAshGS3+8b6597pzyfmC7E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972005; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DHMkoFlbmXpq2TNGiMoLXIsWzV+/cYEgIonbGv81rKQ=; b=3NjLmc3t9/QRe8bMmIWpbxbBa4i6KIE2Pw6bDNDOB2bLKVLJJUuXD8enRTuXmhvjt0/dTR jL9OP9t7WQ1+kADg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 03/43] migration: vmstate_save_state_v: fix double error_setg Date: Thu, 23 Apr 2026 16:19:17 -0300 Message-ID: <20260423191958.1440-4-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972085537158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-2-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 4d28364f7b..fccd030dfd 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972066; cv=none; d=zohomail.com; s=zohoarc; b=MH7gTpKWMsywfMCYJo3XTUBpuQMUYWmWs95Orvt9LIHnAfk+cidpZVO8m1VfGVor4qyUCliIX9cehYsAZu1knm4dZxC1IWh7EYlqRfK5xii0/czqbTjRX7FpXhPeykiF1ToIC+tDhP5MCKzY2YqGXcH4mVCDyKeBy3+Mz6sskn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972066; 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=m3aWhIjFyONuWGGwD79YRRSoT53jbvuQ0JXXq/gW2Zo=; b=ikVNxQnOe9sfn4tX9uJpgJa0dX/D5hn5Rbyqhh1z1g2DaZ0ZChxlsLS+tP1anLQxaadqWpXL68Vh7QtVFSAVvuMso9Ml1RJQXj22PuoVBWr5nLWG4N8agSCVlpYbwBPrkldZuYc0lciNPU4lkQxtD5DrJ4cKQkCaaXcMnBWtCA8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972066190432.2948926150003; Thu, 23 Apr 2026 12:21:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzb2-0001p2-FA; Thu, 23 Apr 2026 15:20:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzb1-0001od-9q for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:19 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzaz-0001l0-H2 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:18 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 545266A890; Thu, 23 Apr 2026 19:20:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4EABA593A3; Thu, 23 Apr 2026 19:20:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iPZCB+Zw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972007; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m3aWhIjFyONuWGGwD79YRRSoT53jbvuQ0JXXq/gW2Zo=; b=1oI+yadsBuTWk0wch2wEJyW/H2EhxS6hhsaIlpiWrjnWqxvEx024nZgwXG4zujnH5hOybB p1qPsOKcQ4SJpw05Xry3/m30paSgShYTdADgefx3JNjneXPAE6C/CApQ8QOgXY7CGtJdiY 1aYuulusUXFCdofhTCY1I1TSil6Icbg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972007; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m3aWhIjFyONuWGGwD79YRRSoT53jbvuQ0JXXq/gW2Zo=; b=/oFt4a/Du+CiCABpZTzbJgDHqffFpLSoRUmMHA76R5D0M3BQYAET2s0BJii24sV+csxCk6 dK/RQTsofPCa5YBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=1oI+yads; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="/oFt4a/D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972007; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m3aWhIjFyONuWGGwD79YRRSoT53jbvuQ0JXXq/gW2Zo=; b=1oI+yadsBuTWk0wch2wEJyW/H2EhxS6hhsaIlpiWrjnWqxvEx024nZgwXG4zujnH5hOybB p1qPsOKcQ4SJpw05Xry3/m30paSgShYTdADgefx3JNjneXPAE6C/CApQ8QOgXY7CGtJdiY 1aYuulusUXFCdofhTCY1I1TSil6Icbg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972007; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m3aWhIjFyONuWGGwD79YRRSoT53jbvuQ0JXXq/gW2Zo=; b=/oFt4a/Du+CiCABpZTzbJgDHqffFpLSoRUmMHA76R5D0M3BQYAET2s0BJii24sV+csxCk6 dK/RQTsofPCa5YBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 04/43] migration: make vmstate_save_state_v() static Date: Thu, 23 Apr 2026 16:19:18 -0300 Message-ID: <20260423191958.1440-5-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 545266A890 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972069973154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy It's used only in vmstate.c. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-3-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 62c2abd0c4..78d97151bd 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1244,9 +1244,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 fccd030dfd..651c3fe011 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972196; cv=none; d=zohomail.com; s=zohoarc; b=NoPXG8dAo9xFy/b1QOAj6THjiRkVDdt0JwsnqfgC3gN0qTsLtFB1Nr3v6MuEhLB7mO6fGgJOrbmJ98YDmmaUaE5m4jqeTEOmawwkDQT/gWYD/fZ1PwaIU2uX0cB6kyWkqI+reUbgMSz1ksFozMsS9eh30fXqHKFOIokaLW0qmBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972196; 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=SW9G0EYa6E6Tg/mKSmoKUz9WbeXqnsVcQ2JCueVsOkk=; b=PD2ULZXhi5Zk1/HGIQzYlFU7uu+vZkS0qJk9u12Uyj0dYAimteROgem29SUJLHyXiOz3tS0Ww5xgyWBn9Q19XZ9Y/eRP4e5ZncEt/0R9wPJpHmsB3E3zVBeAXxpZKriNeoMn6WwUS9qvuK3OSkOmPKHDn4DMxCo+FLQqGGd/cHs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177697219673876.69077462542623; Thu, 23 Apr 2026 12:23:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzb3-0001p4-7X; Thu, 23 Apr 2026 15:20:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzb2-0001oq-05 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:20 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzaz-0001l6-VB for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:19 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EB1475BD43; Thu, 23 Apr 2026 19:20:08 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B3382593A3; Thu, 23 Apr 2026 19:20:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MIzOH+dw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972009; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SW9G0EYa6E6Tg/mKSmoKUz9WbeXqnsVcQ2JCueVsOkk=; b=V2qU2uqv+P2qtJ49qdNvMTlwDZG8l9Bs6Yrms4Pfwh03JjL1MBGQVLqR/8PyibhfoRPHqq guUqi7a8CxpsuCXaJHjBsLHmS3f7cadcbQgJjJ4W1d3OY7MEEB8ASuN+ctCczI86b59mFZ BABi4+dHFCkbueFPJ7JvZD10E0en3DY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972009; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SW9G0EYa6E6Tg/mKSmoKUz9WbeXqnsVcQ2JCueVsOkk=; b=4OFwzZipFRWthgDNcHG4jFZCzcny01Kr9vkNZc/Tq7DYJt6u44G0hiDLg5ZBoz0eIuzYlG qcnGXd4lFILpqJDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972008; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SW9G0EYa6E6Tg/mKSmoKUz9WbeXqnsVcQ2JCueVsOkk=; b=PlRc8HQ/CrHjCfclTihGf1Pjc24sDvOnZG1vabi1pWFUxhtHWsqaHL6ho1V/zaAdPomLzK E1Fcnyhr/H6HslnUQ+B6RvGJxdgrwSZ6ni6NbMqvJrzjBWoXq34+5s5paIktMQyr3NoqXW iz0pfiGSTyzF6YVVoM3RczMbvolFwjE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972008; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SW9G0EYa6E6Tg/mKSmoKUz9WbeXqnsVcQ2JCueVsOkk=; b=g3xSr8Fd6QhP211N2JbNWBmeF8jaMm/1DLZq8zHLJl9IXfdIh73iboThgHjtcZ52IFcaNN cN0Svvdvzk059BCg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy , Zhao Liu Subject: [PULL 05/43] migration: make .post_save() a void function Date: Thu, 23 Apr 2026 16:19:19 -0300 Message-ID: <20260423191958.1440-6-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,intel.com:email,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972198017158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 #rust Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-4-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 +++--------- rust/migration/src/migratable.rs | 6 ++---- rust/migration/src/vmstate.rs | 12 +++++++----- target/arm/machine.c | 4 +--- 8 files changed, 23 insertions(+), 27 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 234d280249..2de7050764 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 ea998bdff1..1dc3b02659 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 78d97151bd..9d42cf7a64 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 dd58f2a705..699d2c9f8b 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 651c3fe011..5111e7a141 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/rust/migration/src/migratable.rs b/rust/migration/src/migratab= le.rs index 7748aac2f2..b9e5e1fc15 100644 --- a/rust/migration/src/migratable.rs +++ b/rust/migration/src/migratable.rs @@ -406,10 +406,8 @@ fn pre_save(&self) -> Result<(), InvalidError> { Ok(()) } =20 - fn post_save(&self) -> Result<(), InvalidError> { - let state =3D unsafe { Box::from_raw(self.migration_state.replace(= ptr::null_mut())) }; - drop(state); - Ok(()) + fn post_save(&self) { + let _ =3D unsafe { Box::from_raw(self.migration_state.replace(ptr:= :null_mut())) }; } =20 fn pre_load(&self) -> Result<(), InvalidError> { diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index edc7c70265..f34a36f680 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -492,6 +492,11 @@ fn from(_value: InvalidError) -> Errno { into_neg_errno(result) } =20 +unsafe extern "C" fn vmstate_post_save_cb FnCall<(&'a T,), (= )>>(opaque: *mut c_void) { + // SAFETY: the function is used in T's implementation of VMState. + F::call((unsafe { &*(opaque.cast::()) },)); +} + unsafe extern "C" fn vmstate_post_load_cb< T, F: for<'a> FnCall<(&'a T, u8), Result<(), impl Into>>, @@ -597,12 +602,9 @@ pub const fn pre_save FnCall<(&'a T,), Resu= lt<(), impl Into>>> } =20 #[must_use] - pub const fn post_save FnCall<(&'a T,), Result<(), impl Int= o>>>( - mut self, - _f: &F, - ) -> Self { + pub const fn post_save FnCall<(&'a T,), ()>>(mut self, _f: = &F) -> Self { self.0.post_save =3D if F::IS_SOME { - Some(vmstate_no_version_cb::) + Some(vmstate_post_save_cb::) } else { None }; diff --git a/target/arm/machine.c b/target/arm/machine.c index b0e499515c..50d80ffb68 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -998,7 +998,7 @@ 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 @@ -1008,8 +1008,6 @@ static int cpu_post_save(void *opaque) =20 cpu->cpreg_vmstate_indexes =3D NULL; cpu->cpreg_vmstate_values =3D NULL; - - return 0; } =20 static int cpu_pre_load(void *opaque) --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972168; cv=none; d=zohomail.com; s=zohoarc; b=k7MfvbZDF/2SZ531ieM/0+geLJ3O/AWqrTUhzunz752q+zi4ZfsfLpOwWee3cuuePPibFOBYjbhnISS4yeXI8EOTFbaXF8tIIUS43gM6m5qm9t4b2wzwTM9y4fLFF1XFNa2pPUpDcTaZMgkX55e7hgERnWgCSdVQWn2DNKJXnu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972168; 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=xNu+6SUCFbQGXOQhLmMux0cecIlR+BfYVaYKEuipyCA=; b=QSnsmGtDcxjCPaWHQ0ix5fviAaz81ZJ5atzqaIuYBhnvCrnfhENjbCYLWuVlmzzdGuTcggJCx7aQoeKH+FrFjx0W8cNBLIb2fg90Z1skkUX8xLadDHkkUY/AT79tRH4iYTqTXyZxqTDNxB6CqFbUr/RIAj0UAGbISyxGR3OY8hw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972168539400.9187239628193; Thu, 23 Apr 2026 12:22:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzb8-0001q5-Mi; Thu, 23 Apr 2026 15:20:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzb6-0001pp-UG for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:24 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzb5-0001mI-3v for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:24 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5AB1D6A894; Thu, 23 Apr 2026 19:20:10 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 54B2C593B0; Thu, 23 Apr 2026 19:20:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eCjACOlw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972010; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNu+6SUCFbQGXOQhLmMux0cecIlR+BfYVaYKEuipyCA=; b=H7RPSn4fRav4CznEyxhAXNcVZdfxIaxQQ2i2VJiB/WW0r8Rio8eWSvgNPMe/L7Sg2d5BI3 zmN5zruBui79nMP+sRZl5FyJulYcrKGHO5f5UHtKkRtypKIfIizUduOdgnSg6dTWX6tZep TLKGzCO3ZrWvIQmNFNUQd+rWhMKn0oA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972010; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNu+6SUCFbQGXOQhLmMux0cecIlR+BfYVaYKEuipyCA=; b=YILaJC44/jH0bti1B3RAPgL4h1+22OtfcAszH/W3adaJbaVbhFpMYvlgoFSuIabrELioeK N6UK7+le58OAI7CA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=H7RPSn4f; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=YILaJC44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972010; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNu+6SUCFbQGXOQhLmMux0cecIlR+BfYVaYKEuipyCA=; b=H7RPSn4fRav4CznEyxhAXNcVZdfxIaxQQ2i2VJiB/WW0r8Rio8eWSvgNPMe/L7Sg2d5BI3 zmN5zruBui79nMP+sRZl5FyJulYcrKGHO5f5UHtKkRtypKIfIizUduOdgnSg6dTWX6tZep TLKGzCO3ZrWvIQmNFNUQd+rWhMKn0oA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972010; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNu+6SUCFbQGXOQhLmMux0cecIlR+BfYVaYKEuipyCA=; b=YILaJC44/jH0bti1B3RAPgL4h1+22OtfcAszH/W3adaJbaVbhFpMYvlgoFSuIabrELioeK N6UK7+le58OAI7CA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 06/43] migration: vmstate_load_state(): add some newlines Date: Thu, 23 Apr 2026 16:19:20 -0300 Message-ID: <20260423191958.1440-7-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 5AB1D6A894 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972169757158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Split logical blocks by newlines, that simplify reading the code. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-5-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/migration/vmstate.c b/migration/vmstate.c index 5111e7a141..dd7cd27993 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972100; cv=none; d=zohomail.com; s=zohoarc; b=FejIUYZhXmlOLHqD+O2O3wjB1eIHlsLWq8nxPm3nsAe1v+0N51+a2CyfwVcd4b3zwLY4U0lyNvyqW882Yir5tD+6mz9CdSjIFxqGr1701I+6FIgymeAn8L8F1gC/NR914bPTfqO77ItkfUBpDbMSCl9T3MHee3Gn2AHwzs1ByLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972100; 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=6JKcEOnO7xBPxJ/X7f5K350z+JIenmi31J54e57taoM=; b=dc8DlOmDKDqxqThPC8NOaTvH7SwjYrksyH6ZPGQtGmYeKvXiEKuPkTnAIk0DIN5lfNYfWTtmBhLQzMfdmD32yMkonUJ210wgtkiFs2YA8PYbEzrWtb+835w3+MYxDxUrpv9UGNYoaXPYbjIg4pv34QD0PvTx2uRltdVpOtcIDqA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972100689799.517914696033; Thu, 23 Apr 2026 12:21:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzbE-0001r2-84; Thu, 23 Apr 2026 15:20:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbC-0001ql-ST for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:30 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbB-0001mx-1T for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:30 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BEE326A895; Thu, 23 Apr 2026 19:20:11 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B8B61593A3; Thu, 23 Apr 2026 19:20:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sLkzIepw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6JKcEOnO7xBPxJ/X7f5K350z+JIenmi31J54e57taoM=; b=lxywY9JUDE72cjl4oX3pFLZapl/uFpefOKORVaAd8ykWSUpdrG8C0hSHBHU0OxBvPptVBh iwAz2NXCldl0Rs2Co3Xb+W3t3PjIx9L68s/Z/Ht4ornoJLxaPqHFP8G8N2XWY9fTyQrOOE of/hg8f5vv1VDBwCPP+PBZ07zposk7M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6JKcEOnO7xBPxJ/X7f5K350z+JIenmi31J54e57taoM=; b=oatIl6uBesPAcpFUw53Lec7cCwFoW8sMiSBlmkmdPhBWPBmcGIvzDREL7kIgQr17MXTw9i ucVYjSPQ5RzwpiCA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=BuuP4Vqp; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Px0krCV9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972011; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6JKcEOnO7xBPxJ/X7f5K350z+JIenmi31J54e57taoM=; b=BuuP4VqpTzs1ENm5Gfsej0DxXk6NFAb54sduzRF4XrDgThr9hCkC2qPYKfJthWC8HgORwq OdT08X5+7cpTQF2zftbQ9mROPEkQmHSnixlvM6S/fLEu2zYKR9hjEHPcd/KR0GlssU9XW7 t+htG3oUkWQAmhwYoOqUdVrpJncCags= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972011; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6JKcEOnO7xBPxJ/X7f5K350z+JIenmi31J54e57taoM=; b=Px0krCV9EoR80vTQef3UU43ZxbjCQcvFt+KcS3uxA20+JHOY2wgqfl4qxhiV7LBzW/WYXb S9M92aN1UXQXdjBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 07/43] migration: vmstate_save/load_state(): refactor tracing errors Date: Thu, 23 Apr 2026 16:19:21 -0300 Message-ID: <20260423191958.1440-8-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: BEE326A895 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972101964154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-6-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 60e5087e38..27459dfb78 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -56,13 +56,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 dd7cd27993..87e1f04959 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972166; cv=none; d=zohomail.com; s=zohoarc; b=EKRAwsEb1QyEn7F9f8tkpuEiCRhNzAE1G0L83dqxmSktEIILzT4F2R4nUJC5IqEysq35nKRhxyEXxbYNNjJM91Q1jBLRDoGgX2ElHippDvuNyWUyza7CGRFimLqiGxHE+8tlKBjzob1po7WRJLF2lFs0qAj1V7ilP7Wf1+WTtZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972166; 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=DdvgjJWId/ztQjLwsbKadX2Wrh8lXPgRZKBKsMat1oU=; b=LL4mWgrVJ716dlurZv+UcqVVntevkGeHTompfBOvljQwUyZviENWQng1VgpzXtf2aS5NYAkhRgJe0iJe13P5UcP91zuXx6gicw5Uz3rytvrRlhz4cx8GzVOoiQ+83qFn/uCwGMNdLtR0G+mRW30WOzFGLnPp5AsKpuT/F6exbCI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972165998212.49910655214546; Thu, 23 Apr 2026 12:22:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzbK-0001rr-FA; Thu, 23 Apr 2026 15:20:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbI-0001rh-1s for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:36 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbG-0001oY-D0 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:35 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 30BF76A891; Thu, 23 Apr 2026 19:20:13 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 290B9593B0; Thu, 23 Apr 2026 19:20:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mByjOetw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DdvgjJWId/ztQjLwsbKadX2Wrh8lXPgRZKBKsMat1oU=; b=QVaSCSCarNJMYdgTrDl6gebxG74ZzWGywcRFQBTsZxbneQLZIScIpylP02Q1nm40a2Dh6s YAkR7UU2eSiW4Yvt3gIa/dDtfGc7MqJt4YATuIN9JDbDgHHv+2251j02bHPSgOe2iYGbrR U99BcGEjvOshNPuc1pyPZTEQVypPb+8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DdvgjJWId/ztQjLwsbKadX2Wrh8lXPgRZKBKsMat1oU=; b=jVYeFenIA5L+xT/OmTrW8TJV8V/q03tbVY6HBFyLeZO93nrRv5XpLLyicT2FrfLCY5btBs 3rGsDyBka8pYlIDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DdvgjJWId/ztQjLwsbKadX2Wrh8lXPgRZKBKsMat1oU=; b=QVaSCSCarNJMYdgTrDl6gebxG74ZzWGywcRFQBTsZxbneQLZIScIpylP02Q1nm40a2Dh6s YAkR7UU2eSiW4Yvt3gIa/dDtfGc7MqJt4YATuIN9JDbDgHHv+2251j02bHPSgOe2iYGbrR U99BcGEjvOshNPuc1pyPZTEQVypPb+8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DdvgjJWId/ztQjLwsbKadX2Wrh8lXPgRZKBKsMat1oU=; b=jVYeFenIA5L+xT/OmTrW8TJV8V/q03tbVY6HBFyLeZO93nrRv5XpLLyicT2FrfLCY5btBs 3rGsDyBka8pYlIDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 08/43] migration: factor out vmstate_pre_save() from vmstate_save_state() Date: Thu, 23 Apr 2026 16:19:22 -0300 Message-ID: <20260423191958.1440-9-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972167884158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Simplify vmstate_save_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-7-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 87e1f04959..605b5c59c7 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -435,32 +435,41 @@ bool vmstate_section_needed(const VMStateDescription = *vmsd, void *opaque) return true; } =20 -static int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vms= d, - void *opaque, JSONWriter *vmdesc, - int version_id, Error **errp) +static bool vmstate_pre_save(const VMStateDescription *vmsd, void *opaque, + Error **errp) { ERRP_GUARD(); - int ret =3D 0; - const VMStateField *field =3D vmsd->fields; - - 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) { + if (!vmsd->pre_save_errp(opaque, errp)) { error_prepend(errp, "pre-save for %s failed: ", vmsd->name); - trace_vmstate_save_state_pre_save_fail(vmsd->name); - return ret; + return false; } } else if (vmsd->pre_save) { - ret =3D vmsd->pre_save(opaque); - if (ret) { + if (vmsd->pre_save(opaque) < 0) { error_setg(errp, "pre-save failed: %s", vmsd->name); - trace_vmstate_save_state_pre_save_fail(vmsd->name); - return ret; + return false; } } =20 + return true; +} + +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; + const VMStateField *field =3D vmsd->fields; + + trace_vmstate_save_state_top(vmsd->name); + + if (!vmstate_pre_save(vmsd, opaque, errp)) { + trace_vmstate_save_state_pre_save_fail(vmsd->name); + return -EINVAL; + } + trace_vmstate_save_state_pre_save_success(vmsd->name); =20 if (vmdesc) { --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972094; cv=none; d=zohomail.com; s=zohoarc; b=DYdQfOMl2AQNFYvj1vy1MHJoQoRzN00F+7NejJllVklY6j4eDYVEgBIhYAck6NnG1b80OOUkSkcmVkBCLVgkpVr/fc8ew/FNzmpJ+ym5SWD7qfKDmtN4oCKeOIcqTUmZZsIaBksub/HWEt937GlTzv3XTYYLnD1i0scAJmK2N/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972094; 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=18fjL14Ng1FIiFptO1WgrOoN/4au2W6z2AZR18y3h0A=; b=PoZ0gkTkTFbRbawPIVP8lQ3uNcP61k9vGtItvRpfFshlCRBwUhkcOUmiAVlB6+EGFVEmyDuJlAXvnRE9jIHsxoltQNYcmv79Qh1yaHwsgOAL5wSQgz2EIOxnk9tk4SRPdHozZvzMRoSFkiKDF0UCIaoL1i+DzehrmoawniK2pN4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972094710504.9184490792294; Thu, 23 Apr 2026 12:21:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzbv-00022X-UM; Thu, 23 Apr 2026 15:21:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbO-0001sT-Dq for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:45 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbM-0001pw-NI for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:42 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 93D866A8A0; Thu, 23 Apr 2026 19:20:14 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8F19C593A3; Thu, 23 Apr 2026 19:20:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qJqrFu1w6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972014; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=18fjL14Ng1FIiFptO1WgrOoN/4au2W6z2AZR18y3h0A=; b=wEdSQ1+6XsyBH56KSUgfuubFhNmA6gSIN4pJPwwDZqlmWgP+n0R1WmYxh7uajY+htFdz+R Lp2m21eDXIU1LNDr6AZ6PTp2/U+6Uo5TNH6VHsdA78TjbbmmIb2RGcOYfo552AXCgiT5u/ 2GuK/BqDqcLmVKGr/7PPlxGtDRli76Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972014; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=18fjL14Ng1FIiFptO1WgrOoN/4au2W6z2AZR18y3h0A=; b=5/lCWhPZliylw5RcGqx6QdpSzFGSzKuJJhA/O0/p+fiVNQ9WXkFnKucNH3ZOHaViaWrZQg bZ1WQKBmkwLBNEDA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=wEdSQ1+6; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="5/lCWhPZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972014; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=18fjL14Ng1FIiFptO1WgrOoN/4au2W6z2AZR18y3h0A=; b=wEdSQ1+6XsyBH56KSUgfuubFhNmA6gSIN4pJPwwDZqlmWgP+n0R1WmYxh7uajY+htFdz+R Lp2m21eDXIU1LNDr6AZ6PTp2/U+6Uo5TNH6VHsdA78TjbbmmIb2RGcOYfo552AXCgiT5u/ 2GuK/BqDqcLmVKGr/7PPlxGtDRli76Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972014; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=18fjL14Ng1FIiFptO1WgrOoN/4au2W6z2AZR18y3h0A=; b=5/lCWhPZliylw5RcGqx6QdpSzFGSzKuJJhA/O0/p+fiVNQ9WXkFnKucNH3ZOHaViaWrZQg bZ1WQKBmkwLBNEDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 09/43] migration: factor out vmstate_save_field() from vmstate_save_state() Date: Thu, 23 Apr 2026 16:19:23 -0300 Message-ID: <20260423191958.1440-10-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 93D866A8A0 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972095398158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Simplify vmstate_save_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-8-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 605b5c59c7..2ce2652712 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972278; cv=none; d=zohomail.com; s=zohoarc; b=eeq7Y3NQJPEPZPxN+uOGS71P+3XCenLtA+Pzl3ueOeozHvdCGvqdE3pWxW+dXOQ/n4KKbKy+SFIYsunFnnnb9dKvjGBTThnXB9Qr1wIwlD+Wl4bdCMXlbfMj4ky3s0zqthkuYL32pBz0zbpWJkgfGGTntc7gUQ0koEyKLH9PCUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972278; 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=uSfjEcHSbkWGQx9j1sW7ZYtLX+PH2niMjynnIxAOwtQ=; b=Ii/5xfqqMpE4LkK+2UUdESjmE/Z+PlmKL6BY07Yl9RQ3PR02sbBBUaMlIia/TKEuR5s/CkbeS/gmPP6g0GUUNnY5HPvsLap1y8AxFas4bevtuIjEeowy+78NFgjK6FORcBQqiw9kG2D2O8hX0I3VVLKvqfHjD9T4+KJKETgBA30= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972278010408.7980324747624; Thu, 23 Apr 2026 12:24:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcI-0002gJ-F6; Thu, 23 Apr 2026 15:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbZ-0001wf-UF for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:58 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbT-0001rZ-6A for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:49 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 040386A89D; Thu, 23 Apr 2026 19:20:16 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F252A593A3; Thu, 23 Apr 2026 19:20:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +NhAL+5w6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972016; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSfjEcHSbkWGQx9j1sW7ZYtLX+PH2niMjynnIxAOwtQ=; b=cmzDZNio07BV+/+8jpd6DokKIuxsEOPRflKjL6c0K56lJbShWbmOyx3ecetgr/czeJIJXs bzNXuWQwBuDU6fXfJ6SvM46ce0yPjSt17lpRRlxBtJX19wYGPkKUe257rO100efMidqNgy z4tCdDBsCtCDh577mTOcdyk+FuRBChY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972016; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSfjEcHSbkWGQx9j1sW7ZYtLX+PH2niMjynnIxAOwtQ=; b=mz7JxB93VapOHzI9dh25yprpSfeenmWjFhuzAWBEeYVvYBs6k0G2nIhSRGCXhyVn7wfjgW mn893+PPmLnp1fAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972016; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSfjEcHSbkWGQx9j1sW7ZYtLX+PH2niMjynnIxAOwtQ=; b=cmzDZNio07BV+/+8jpd6DokKIuxsEOPRflKjL6c0K56lJbShWbmOyx3ecetgr/czeJIJXs bzNXuWQwBuDU6fXfJ6SvM46ce0yPjSt17lpRRlxBtJX19wYGPkKUe257rO100efMidqNgy z4tCdDBsCtCDh577mTOcdyk+FuRBChY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972016; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSfjEcHSbkWGQx9j1sW7ZYtLX+PH2niMjynnIxAOwtQ=; b=mz7JxB93VapOHzI9dh25yprpSfeenmWjFhuzAWBEeYVvYBs6k0G2nIhSRGCXhyVn7wfjgW mn893+PPmLnp1fAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 10/43] migration: factor out vmstate_pre_load() from vmstate_load_state() Date: Thu, 23 Apr 2026 16:19:24 -0300 Message-ID: <20260423191958.1440-11-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972280519154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Simplify vmstate_load_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-9-vsementsov= @yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 2ce2652712..35dbe1550e 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972079; cv=none; d=zohomail.com; s=zohoarc; b=BI6l5UIwpf7XAp1/b821Ic+5sQFSIls0iJucNRyj2VTUgZRTRXYn6IMs86tkYpx4jqaPjrinoBVtqvqkTI9I5frbcq44Iy2XBsdoEP/Acay9PODQt4oZDK9wyfwBGtNBmvD7WfAWq5ezjdRElAgAbJy+esKC9E6AaKCpxqQ83CY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972079; 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=gLrq5vYRQzUEjpc8nDFyc527zDnf568anUwnKtbHDA4=; b=JgHAmvOz0r4M+387tKksMpNI7U6/gNL3sUXeYQddclX+RpBAhSCq5Swlqvgwiddr1r8M6suxKrHD+Qk198UVPcj8rL73DCVM1Wx8+PsQxOfwGBgA3bM4ReO5eBLPzZGIrELHN382O5C854XKZbDfRKxWJLYVr1iP8vthIS8Mk0w= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972079477595.5674784832092; Thu, 23 Apr 2026 12:21:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzb9-0001qK-2A; Thu, 23 Apr 2026 15:20:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzb7-0001px-Lo for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:25 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzb5-0001mT-Pz for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:25 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 688B15BD72; Thu, 23 Apr 2026 19:20:17 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 61D19593A3; Thu, 23 Apr 2026 19:20:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sJj7C/Bw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972017; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gLrq5vYRQzUEjpc8nDFyc527zDnf568anUwnKtbHDA4=; b=xP5kueji0NMII7sLVqVg+mW2PfP1GRf4lagwzZAB3UjeKsS8yVpDN2BuEkJrvJDSGaG6tY +83FQq7e+g+33FcUJzpJ670+ZOcANtGqLvucIJRn2xD9Cwx/Ca2+q+UfarqT4uQ1zCW5CM qUj+dJQMJDmpFXdQd9R5BuTueLPqyJ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972017; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gLrq5vYRQzUEjpc8nDFyc527zDnf568anUwnKtbHDA4=; b=9LoG355OTy97v8LDlec9/k6vCdXvAKTL4pnpnXGNV5/3DIZiWAZ/KVwB8tJtT1DhmdxOS/ 2U2kHwAT3iVGfQCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=xP5kueji; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=9LoG355O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972017; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gLrq5vYRQzUEjpc8nDFyc527zDnf568anUwnKtbHDA4=; b=xP5kueji0NMII7sLVqVg+mW2PfP1GRf4lagwzZAB3UjeKsS8yVpDN2BuEkJrvJDSGaG6tY +83FQq7e+g+33FcUJzpJ670+ZOcANtGqLvucIJRn2xD9Cwx/Ca2+q+UfarqT4uQ1zCW5CM qUj+dJQMJDmpFXdQd9R5BuTueLPqyJ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972017; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gLrq5vYRQzUEjpc8nDFyc527zDnf568anUwnKtbHDA4=; b=9LoG355OTy97v8LDlec9/k6vCdXvAKTL4pnpnXGNV5/3DIZiWAZ/KVwB8tJtT1DhmdxOS/ 2U2kHwAT3iVGfQCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 11/43] migration: factor out vmstate_load_field() from vmstate_load_state() Date: Thu, 23 Apr 2026 16:19:25 -0300 Message-ID: <20260423191958.1440-12-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 688B15BD72 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972081841154101 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Simplify vmstate_load_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-10-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 35dbe1550e..32944c0444 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972263; cv=none; d=zohomail.com; s=zohoarc; b=aCg27z2rtvRs67JrFnpSns4s1GHuOGUhowJR25yUtRyO1w/N3rE4ELzsT7AolIClaMW3+XY688LLAE7Y/eHgoZH2APPLi0BlH50MBNZZUv8Fy65m/CyjpLzqpVTsaPU4pLjyT6aFebFHusSR5rRXyhGX4ppBXQOmHrYkesEgrgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972263; 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=VO4FB5UiKbt8mkYj7hG80chy6Iihhgx2A40Z9f722UE=; b=ENG477QWCLxPF6ro/rJr1yEKBul+KiQcWzVAaaU7i+pvKAznZRbAtyqp/fWYXH4eS1+cq0sFawuEpIqRQGwPMgM63pQAfvOiCtxJB3BWgeCPFduzmygfN65C1zQihmPXuZtJwzpdhPsm45LMoBWhJy+9wwr24qfn2MJn11XgIEI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17769722632311018.4737978332163; Thu, 23 Apr 2026 12:24:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcI-0002bh-50; Thu, 23 Apr 2026 15:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbf-0001xD-Um for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:06 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbd-0001tF-5o for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:58 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CC24C6A8A3; Thu, 23 Apr 2026 19:20:18 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C68D9593A3; Thu, 23 Apr 2026 19:20:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MKaCJPFw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972018; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VO4FB5UiKbt8mkYj7hG80chy6Iihhgx2A40Z9f722UE=; b=c2kqqVAvbMWjm4o2JBHcP+DWhEHG1tajIHrYj27e1fdCTZb5OwrbhvCmT/7xbCE/PPRwzA 7LX+AJ+OZwDoBa5IZm6oE8Oi7kviZEIWrXUe5Q17spiiX/H28lvkRBADB+V5gdV1/VWrI+ bopWlUrA1CYdF2cfthWKftUrCjljWqw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972018; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VO4FB5UiKbt8mkYj7hG80chy6Iihhgx2A40Z9f722UE=; b=Y5eOnMMO8n58IbruWsEAc9aKEiGF6ZGn1RzyHxoOPeaczU81cmZ5y+iVvKtQCOmlJgGB/S 1QnQvlbuGVpAhSBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=c2kqqVAv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Y5eOnMMO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972018; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VO4FB5UiKbt8mkYj7hG80chy6Iihhgx2A40Z9f722UE=; b=c2kqqVAvbMWjm4o2JBHcP+DWhEHG1tajIHrYj27e1fdCTZb5OwrbhvCmT/7xbCE/PPRwzA 7LX+AJ+OZwDoBa5IZm6oE8Oi7kviZEIWrXUe5Q17spiiX/H28lvkRBADB+V5gdV1/VWrI+ bopWlUrA1CYdF2cfthWKftUrCjljWqw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972018; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VO4FB5UiKbt8mkYj7hG80chy6Iihhgx2A40Z9f722UE=; b=Y5eOnMMO8n58IbruWsEAc9aKEiGF6ZGn1RzyHxoOPeaczU81cmZ5y+iVvKtQCOmlJgGB/S 1QnQvlbuGVpAhSBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 12/43] migration: factor out vmstate_post_load() from vmstate_load_state() Date: Thu, 23 Apr 2026 16:19:26 -0300 Message-ID: <20260423191958.1440-13-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: CC24C6A8A3 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972264277154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Simplify vmstate_load_state() which is rather big, and simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-11-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 49 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 32944c0444..53b57c09d8 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972157; cv=none; d=zohomail.com; s=zohoarc; b=VSbqf7nxSbJnH0rniwe5DElWHhNo5OcQdVstPjUqvwnW+1CxMXcDhVNlu4lq9OjFl1KwDpE4zrYCIt6e7Lo/CIrtdoCrZRRr2ZCw9TNQYiD4kmrLv+7WLi1Mqb1c+vReP/nrWYBqt3roG/XWxbEsKg+LQfRpdaHs8g9EV9dewyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972157; 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=a0ZCd2HuC4Fz3TAvfTlRO8nxqPP6uGkjnV2AsiN6Twc=; b=AUEd+e4gt00voBH34+xtIfSelEsR+cAlBW77ZiI/fwwwXsYfILK2rpQhLcuT83IvPW01W1D/AyO1ZNQTJHSdT8U8NPjw7PFmgHCY9vlj5OJfHTqXQ+d/siSwQRLRBnEVZSwbX9UgbGX0KT7VWzATM4udeIcpbom/P1hEWfMqxgM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972157615522.114434756866; Thu, 23 Apr 2026 12:22:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcH-0002Wc-S4; Thu, 23 Apr 2026 15:21:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbw-0002GB-4n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:19 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbq-0001uD-2E for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:13 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3C0F66A8A4; Thu, 23 Apr 2026 19:20:20 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 36480593A3; Thu, 23 Apr 2026 19:20:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KJZPAfNw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972020; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0ZCd2HuC4Fz3TAvfTlRO8nxqPP6uGkjnV2AsiN6Twc=; b=2QbVNoQXRToWbAnUkQv1+PA9/2sfaC51YMYvaGchpn07AlLEzneen8syMk7OCOCQh7vKKb R6GI6QLa/X0KJK4n9p7Gupq9Un2ISA/caykLb9DNJdLwys1zSxmZYc46NYVrfbPV90mIOB p0pDuD4oKnrr+u7sPcin0AJ5RkFAIsU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972020; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0ZCd2HuC4Fz3TAvfTlRO8nxqPP6uGkjnV2AsiN6Twc=; b=9uvpbc3aV31u/EQWfdamR14HY7omgpQZ6t7sOLEz7+3VMrqHdGLF3opngmU5zlQ0S3udWN hsb+iIsQ+Gn3itDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972020; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0ZCd2HuC4Fz3TAvfTlRO8nxqPP6uGkjnV2AsiN6Twc=; b=2QbVNoQXRToWbAnUkQv1+PA9/2sfaC51YMYvaGchpn07AlLEzneen8syMk7OCOCQh7vKKb R6GI6QLa/X0KJK4n9p7Gupq9Un2ISA/caykLb9DNJdLwys1zSxmZYc46NYVrfbPV90mIOB p0pDuD4oKnrr+u7sPcin0AJ5RkFAIsU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972020; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0ZCd2HuC4Fz3TAvfTlRO8nxqPP6uGkjnV2AsiN6Twc=; b=9uvpbc3aV31u/EQWfdamR14HY7omgpQZ6t7sOLEz7+3VMrqHdGLF3opngmU5zlQ0S3udWN hsb+iIsQ+Gn3itDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 13/43] migration: convert vmstate_subsection_save/load functions to bool Date: Thu, 23 Apr 2026 16:19:27 -0300 Message-ID: <20260423191958.1440-14-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972160699154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-12-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 57 +++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 53b57c09d8..8825aa3b1f 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972272; cv=none; d=zohomail.com; s=zohoarc; b=Bedp0fifrIzcAqnOlMnGmxGQQTJrWXeRN1MJknyRsfDYSqbyjt+TmbZB8C/RlKW/OuxYPYh71IHtIri/Az+JVYx0lzNPEw4I6JtJOaaerYInUfmGV+6cKiBHK344zv6WhAqwEdidjRjGRs9DQ1MszRAKj9CpMikxou8HfNYYHqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972272; 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=xGdNtJD7CyO/idoRU9phWcfMReSkffagymXqK6GhVsU=; b=hUR7WvMBQDil6alIUgcC6LGFSjLnBUvSn+14jimLOMQbewcV4tpuRJJ7ctXwq5eqUtUz9JscmvaDw9qmxvVuZ5+ZqWGCHYtCjImqhUt+rEkgFgu90HL9pY6CjXUa9u3gdUCdYanotf1aPTOE1JjAWxQQCQnJ5/1WLLulw0QefH4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972272168156.09006973938278; Thu, 23 Apr 2026 12:24:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcX-0003wB-Nv; Thu, 23 Apr 2026 15:21:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzc1-0002Ia-VH for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:27 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbz-0001wR-Jq for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:21 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9EF9E6A890; Thu, 23 Apr 2026 19:20:21 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9A19C593A3; Thu, 23 Apr 2026 19:20:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yGSvGfRw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972021; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xGdNtJD7CyO/idoRU9phWcfMReSkffagymXqK6GhVsU=; b=1DVPc85RtisrsI9NqjkZsVJ85y9wNPlHDbXcteboZoD2Ro34YmDgwh3N5qhjWEZO82XSYM JUwe+XnKzKqB4DKp1qi/LnFmkxlXNWi0Ze/rxYELYfg3dBxdxBHZ4emQoIemK7RvRWDSNL Rl7Z1t+9QtrmFaW6LurOx6hKFH6Wu9Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972021; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xGdNtJD7CyO/idoRU9phWcfMReSkffagymXqK6GhVsU=; b=1CrOfGtEwEk3Igzya62gtQTtbAdY9YywBHnIlnXoi58AZnnDYTGx93MyhC+inQEhnOAY5z lNJKFUuDdyqGV9AQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972021; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xGdNtJD7CyO/idoRU9phWcfMReSkffagymXqK6GhVsU=; b=1DVPc85RtisrsI9NqjkZsVJ85y9wNPlHDbXcteboZoD2Ro34YmDgwh3N5qhjWEZO82XSYM JUwe+XnKzKqB4DKp1qi/LnFmkxlXNWi0Ze/rxYELYfg3dBxdxBHZ4emQoIemK7RvRWDSNL Rl7Z1t+9QtrmFaW6LurOx6hKFH6Wu9Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972021; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xGdNtJD7CyO/idoRU9phWcfMReSkffagymXqK6GhVsU=; b=1CrOfGtEwEk3Igzya62gtQTtbAdY9YywBHnIlnXoi58AZnnDYTGx93MyhC+inQEhnOAY5z lNJKFUuDdyqGV9AQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 14/43] migration: VMStateInfo: introduce new handlers with errp Date: Thu, 23 Apr 2026 16:19:28 -0300 Message-ID: <20260423191958.1440-15-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972274209158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-13-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 9d42cf7a64..65683d8d87 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 8825aa3b1f..f16626d7d1 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972295; cv=none; d=zohomail.com; s=zohoarc; b=GvEW4wBf04o+RSEbKuJ8qrDRIVnGHMG3lUYN1BYLA/DW98ogJRpOlvXJaMIxxX5dbH38lZcu8qKULj7+zcllPJIf8EWnoKtNpI1ugIbdiwl1rkey66jTnoQYsoEnOI4LVwKOp4ssKvrNkIgOq09Q9dbo5f65qZmYKWXrvbCAzZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972295; 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=OtUkCGsNiesst2i1bvrl5h5U1TI8T4XQdvIydALDlWc=; b=R9AfTi+dd7E/EKKFAjsLJrzPET2QEu/Bv5GlQATx+vN2t9P+MiAzIH0MQML/0b4NsVcUREVjP+R1RXB41IqDyR5HIyX02ZIKU0gt++m+BtLHpTvI9Ymtso1QSZp8eaEL0HiZGJRHdVZr8o8Gh1uA3lnWjPcaFaQnX1RfN9pGDpM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972295917839.6795917927511; Thu, 23 Apr 2026 12:24:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcM-0003Fj-1C; Thu, 23 Apr 2026 15:21:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzc8-0002O8-V2 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:31 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzc6-0001xm-GJ for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:28 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0F1556A8A6; Thu, 23 Apr 2026 19:20:23 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0A7EA593A3; Thu, 23 Apr 2026 19:20:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kFo4MvVw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972023; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtUkCGsNiesst2i1bvrl5h5U1TI8T4XQdvIydALDlWc=; b=Olxu/mrj4BgxuahMT6bSIpxfh37YAOcjUIsTx3JJGur+/PGdtmYKLHRP49ToY0idscML6C MEFazHSQIripAVg+jY/1I5/TkCThLnPoBkO1+sbAgfREbNmZPnOWO/H+CL05KgcbtvThPd ZejaTL6oAumNg2Jf3DtNlzbJe1K76Es= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972023; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtUkCGsNiesst2i1bvrl5h5U1TI8T4XQdvIydALDlWc=; b=WBszDAVG89IxwatMGXhE3nIegEdZwhtgYiIn6uD+oGy7Qrvqv1JhuAkQJMj643Ld6K91yk DGTW/nsdzDMPu5Ag== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="Olxu/mrj"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WBszDAVG DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972023; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtUkCGsNiesst2i1bvrl5h5U1TI8T4XQdvIydALDlWc=; b=Olxu/mrj4BgxuahMT6bSIpxfh37YAOcjUIsTx3JJGur+/PGdtmYKLHRP49ToY0idscML6C MEFazHSQIripAVg+jY/1I5/TkCThLnPoBkO1+sbAgfREbNmZPnOWO/H+CL05KgcbtvThPd ZejaTL6oAumNg2Jf3DtNlzbJe1K76Es= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972023; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtUkCGsNiesst2i1bvrl5h5U1TI8T4XQdvIydALDlWc=; b=WBszDAVG89IxwatMGXhE3nIegEdZwhtgYiIn6uD+oGy7Qrvqv1JhuAkQJMj643Ld6K91yk DGTW/nsdzDMPu5Ag== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 15/43] migration: introduce vmstate_load_vmsd() and vmstate_save_vmsd() Date: Thu, 23 Apr 2026 16:19:29 -0300 Message-ID: <20260423191958.1440-16-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 0F1556A8A6 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972298928154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-14-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 65683d8d87..66c2e87bd3 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1257,10 +1257,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 f16626d7d1..e98b5f5346 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972074; cv=none; d=zohomail.com; s=zohoarc; b=GNvNsugZEANx7NDbVyC7hLdsZs60cOLAOFB0NPfywE5k9He7muLaM0GhFi4p2X1OgnyRgsOikj5EU9tmb0Ntec4K93gcZee/sh7fzpvvFV09rw8WsfrHki78hVIuokfbD7c5h8cz3600ozuFJxyLAEM8oeHAMJQLuUJ6zuvRGqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972074; 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=hkCfBpNfc54W4lu2o8abv4Mu9Sgre3nkQSL+bsElAQ8=; b=Eb2nfQA6ifnVCwh1bz8axrrlaLMf24pcrzBBq0lvYXVeI7/L0KsScEyb71x+4v8WvflYkFwRTSGzg3aNbNyX4mL8/NhvAsdHR5Fk+84NWXZpT0XAF0izkRCmwm1YmwcxpnJqi8MjO+wZp2iCx09M3wxBj4nPUMtZrJbpeWgYgok= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972074926466.0764424179853; Thu, 23 Apr 2026 12:21:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzbF-0001rO-Pb; Thu, 23 Apr 2026 15:20:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbD-0001qu-Rh for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:31 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbC-0001n3-5P for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:31 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 75AA85BD7F; Thu, 23 Apr 2026 19:20:24 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6E0EA593A3; Thu, 23 Apr 2026 19:20:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gCnoDvdw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hkCfBpNfc54W4lu2o8abv4Mu9Sgre3nkQSL+bsElAQ8=; b=Q81xwtoM3+0WicRjQq9bdjIio9ASt/oyTV5fnQ9RZmApVhLgPNLvSId4E9Pz0rSFva+4nF R7ZFw1aySyimjlhLEXycoWajYW7Zf6LZoqDUCOtzPACUJ9pr94vboF7RDDWvcQ7PacHPei p6z/k5Hczo5hQ45Tg4YZq9BYnwL2GnQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hkCfBpNfc54W4lu2o8abv4Mu9Sgre3nkQSL+bsElAQ8=; b=vH7k1NqTQJqjSbGh4wItlJhFKG+4DQYvvfY/xi3TfOOLe34g37S8Mig0WHostRbJV0nHIW Ma/V8SOVix1yDFDg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hkCfBpNfc54W4lu2o8abv4Mu9Sgre3nkQSL+bsElAQ8=; b=Q81xwtoM3+0WicRjQq9bdjIio9ASt/oyTV5fnQ9RZmApVhLgPNLvSId4E9Pz0rSFva+4nF R7ZFw1aySyimjlhLEXycoWajYW7Zf6LZoqDUCOtzPACUJ9pr94vboF7RDDWvcQ7PacHPei p6z/k5Hczo5hQ45Tg4YZq9BYnwL2GnQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972024; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hkCfBpNfc54W4lu2o8abv4Mu9Sgre3nkQSL+bsElAQ8=; b=vH7k1NqTQJqjSbGh4wItlJhFKG+4DQYvvfY/xi3TfOOLe34g37S8Mig0WHostRbJV0nHIW Ma/V8SOVix1yDFDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 16/43] migration/cpr: move to new migration APIs Date: Thu, 23 Apr 2026 16:19:30 -0300 Message-ID: <20260423191958.1440-17-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972075945158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-15-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 5850fd1788..96ce26e711 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 a0b37007f5..05266dfcfd 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972267; cv=none; d=zohomail.com; s=zohoarc; b=cL2lC25QETrNyi4um7L8dTq80+nqCodQwrWxzyknxJSXtybrQv79M7UQFCQZL3oomcnYrzI9ahtuxf+peBKQvPu1AsaJBa8gjKdTu7cImz+hy0dlxh0Q+Wl1yUfdfEFQW2AZ2/R7QJkfYLgj8ugjXw6b4UEYAM84U/fODCq8p1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972267; 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=YjeGSJmCeH6X7iob4o4x+DB7RJK/iTyXeF+vFeqKpmo=; b=T0ygTCOwAPCiqiuNuKuTC0q+3i8gaEOs+GnJg7rA085BiD2P5H6uwciuAvzXvzTK1/rHEmd+ioOdntdCRIGh0SSOKXfpDfhAiiwRNY67atwO6gP9XTtLe4R2InOelp1sFEawXTdgazjqVgKSFRvOIDJ9NJrDbc4X0o4ZUICa9XI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972267952246.96292577183158; Thu, 23 Apr 2026 12:24:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcM-0003HC-Gd; Thu, 23 Apr 2026 15:21:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcF-0002X6-Df for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:37 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcD-00025B-7t for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:35 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DBE0B6A8A8; Thu, 23 Apr 2026 19:20:25 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D3CB1593A3; Thu, 23 Apr 2026 19:20:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id wDe9J/hw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972025; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YjeGSJmCeH6X7iob4o4x+DB7RJK/iTyXeF+vFeqKpmo=; b=J6+gqmpQwbLzAXMnnt66q8Ki8nS1CFtjJ85JSrFZfZDqvrE/6QRgXJQoCMqLxS+yTquwt+ rfrJgjMtMnFS9Db+CSzx1jJXjJteLGbDn4rzUaSfK3fllfo7mJhiGgLpqPMxFoRPDQo1ie dyGUuT8QmFY4s01IQRoA78rpaAIS5ZU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972025; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YjeGSJmCeH6X7iob4o4x+DB7RJK/iTyXeF+vFeqKpmo=; b=4yvQQDrGa4eap6OKRxyt0Lq8kqnjoaRO1j/La5VPfnwWhrZE1ICgnhcozjcJioFil7o/wd Tiiy3KHipAWnVxCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972025; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YjeGSJmCeH6X7iob4o4x+DB7RJK/iTyXeF+vFeqKpmo=; b=J6+gqmpQwbLzAXMnnt66q8Ki8nS1CFtjJ85JSrFZfZDqvrE/6QRgXJQoCMqLxS+yTquwt+ rfrJgjMtMnFS9Db+CSzx1jJXjJteLGbDn4rzUaSfK3fllfo7mJhiGgLpqPMxFoRPDQo1ie dyGUuT8QmFY4s01IQRoA78rpaAIS5ZU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972025; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YjeGSJmCeH6X7iob4o4x+DB7RJK/iTyXeF+vFeqKpmo=; b=4yvQQDrGa4eap6OKRxyt0Lq8kqnjoaRO1j/La5VPfnwWhrZE1ICgnhcozjcJioFil7o/wd Tiiy3KHipAWnVxCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 17/43] migration/savevm: move to new migration APIs Date: Thu, 23 Apr 2026 16:19:31 -0300 Message-ID: <20260423191958.1440-18-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972270486154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-16-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- migration/savevm.c | 105 ++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 699d2c9f8b..8115203b51 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 @@ -1311,8 +1318,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); } @@ -2721,7 +2728,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) { @@ -2752,10 +2758,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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972093; cv=none; d=zohomail.com; s=zohoarc; b=Ihu7mtJKacJVMhxfwy4+BULBUgSErVAUxb1lZvZgfw60iYsex+VQpDPOIJgWwL2nPdzsvAE4rBvd5pEAcexkq5LP+7m1QCvdW7MAdvwki+/YE43v3740rI28rs/H4ZMwHahqlws0vAGGKCtDWDxjR7AgmJV/zh7eZmRtR5BmxWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972093; 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=Yxq0LxrbCY14GhKOCjKifdrJXwZdHE2lOdV7GNZfWs4=; b=aDF15vLv1irx6SO22E3b4GlDWxCyfEjqKTMrussh/L4z1tNte1mMPGGOELeO4NE26/O6Hja46x2iaXg+K08ycRnt5VKTu2k2djS5XYiRqVrL4Rum0vNHDL/PQG8ws43kWqTioPpSGfkhiCoNan0JoWFXcyjJL/zV51kQRqPLKss= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972093165191.61785592197464; Thu, 23 Apr 2026 12:21:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzbS-0001sM-Fp; Thu, 23 Apr 2026 15:20:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbJ-0001rp-VY for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:38 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbH-0001ol-OL for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:37 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7CCB45BD62; Thu, 23 Apr 2026 19:20:27 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4666A593A3; Thu, 23 Apr 2026 19:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sElHBfpw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972027; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yxq0LxrbCY14GhKOCjKifdrJXwZdHE2lOdV7GNZfWs4=; b=BN71xsWwAQ8pN3eHB7sY+LKBlJ+F55ln1ldFXop2XMh9PB8KKwHROdkqv5zmc8WF+bNsxr bn/NJPwjcYN5I+j6rmO9q8DrAWksmBdP/dfAq8jYmGiIBsAN2fggqJpBDddJaJkIW8E/WX srUjdmTtfqVEzI8KT5ufJ96NyCpATeE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972027; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yxq0LxrbCY14GhKOCjKifdrJXwZdHE2lOdV7GNZfWs4=; b=bjcJ9gfGxKkT9LddZlItAnGUSTEnB04IqfJUgKkTe2VLi+uMHB5hJtIAVuGCAaazz/3oZ1 rGSOvr5RSJdVYwAw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972027; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yxq0LxrbCY14GhKOCjKifdrJXwZdHE2lOdV7GNZfWs4=; b=BN71xsWwAQ8pN3eHB7sY+LKBlJ+F55ln1ldFXop2XMh9PB8KKwHROdkqv5zmc8WF+bNsxr bn/NJPwjcYN5I+j6rmO9q8DrAWksmBdP/dfAq8jYmGiIBsAN2fggqJpBDddJaJkIW8E/WX srUjdmTtfqVEzI8KT5ufJ96NyCpATeE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972027; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yxq0LxrbCY14GhKOCjKifdrJXwZdHE2lOdV7GNZfWs4=; b=bjcJ9gfGxKkT9LddZlItAnGUSTEnB04IqfJUgKkTe2VLi+uMHB5hJtIAVuGCAaazz/3oZ1 rGSOvr5RSJdVYwAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy , Eric Farman Subject: [PULL 18/43] hw/s390x/css: drop use of .err_hint for vmstate Date: Thu, 23 Apr 2026 16:19:32 -0300 Message-ID: <20260423191958.1440-19-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972095611154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-17-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 04ce3178a0..df5f0bc27f 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972242; cv=none; d=zohomail.com; s=zohoarc; b=bbccWDvUyFUr6FQabfDED+KXvpKk4ld82senEdliCwIK+wNBZ1Oz1LPLkYj6IzOMbS9VKucqPQ8oXU6lkLO5/q6YPQxEW403KxoB+iwhXoYqe2LAkJUoGmZ6lCwkL9MqqlaQIDBqEDyW4o16ubIrc5tXBu/fzEv8RR7iKCO7bJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972242; 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=ueTjPgmSW7EvLie0P/K66Rj7p5HsTRZ1DFjF4HaBNKE=; b=gkEf7biW05EXlc/MbZE/NmLY1LhrApLHlhDI0r4LBGJKXR2apV506gzxAk4uVAZ1OaTm7t6JOzyoLG3XV1iV0IVeh36FNjEqRWd3RjV+SIoS9G/+E/c4qcVd58YVEunYzUFGKcT/XbbRaE0KTsaPghHyXKmhzMNpKxison0KFRk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972242609951.2161104172391; Thu, 23 Apr 2026 12:24:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcb-00048P-VH; Thu, 23 Apr 2026 15:21:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcN-0003P8-Sy for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:45 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcJ-00027L-BG for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:43 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4F6F16A8AA; Thu, 23 Apr 2026 19:20:29 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DBEE1593A3; Thu, 23 Apr 2026 19:20:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AIa+Kftw6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972029; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ueTjPgmSW7EvLie0P/K66Rj7p5HsTRZ1DFjF4HaBNKE=; b=xb6yACTeFWMGD5IrtZ0Qqe2l3Y/BoZCfJzwXIRRvWtuQdkcyrnFsqxEGL38J5OZuLODZIL 1s4ZIg2LaJfWwGLGEVP2BFaM1x8Yc+W7I+h2foBbFdvT98NBymX6u34DrfxRYPBPrcge2A f2b7tUP0xkJPV/Dn4jUaWjlA5fuorc4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972029; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ueTjPgmSW7EvLie0P/K66Rj7p5HsTRZ1DFjF4HaBNKE=; b=9Gw/GePneQPoIEMQTpcAh2pYt7gnW/JZ+YzMUllr6l0xEDLP+EOlII6kelY4BdS47eE4CP 6xYDLFvWDkG1DFAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=xb6yACTe; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="9Gw/GePn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972029; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ueTjPgmSW7EvLie0P/K66Rj7p5HsTRZ1DFjF4HaBNKE=; b=xb6yACTeFWMGD5IrtZ0Qqe2l3Y/BoZCfJzwXIRRvWtuQdkcyrnFsqxEGL38J5OZuLODZIL 1s4ZIg2LaJfWwGLGEVP2BFaM1x8Yc+W7I+h2foBbFdvT98NBymX6u34DrfxRYPBPrcge2A f2b7tUP0xkJPV/Dn4jUaWjlA5fuorc4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972029; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ueTjPgmSW7EvLie0P/K66Rj7p5HsTRZ1DFjF4HaBNKE=; b=9Gw/GePneQPoIEMQTpcAh2pYt7gnW/JZ+YzMUllr6l0xEDLP+EOlII6kelY4BdS47eE4CP 6xYDLFvWDkG1DFAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy , Eric Farman , Akihiko Odaki Subject: [PULL 19/43] migration: drop VMStateField.err_hint Date: Thu, 23 Apr 2026 16:19:33 -0300 Message-ID: <20260423191958.1440-20-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 4F6F16A8AA X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972244794158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-18-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 4585640af9..2c1681b7d0 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 3d4b563556..f8fd7ee069 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 ee7d97b5c2..0d69a53f27 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 b998ce8324..dbb72bbb22 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1223,7 +1223,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 c2c6bc76e9..2b95787ddf 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 c1aeeca0c9..417c3aecb9 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 08f51c8e36..c2b4432b94 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 cd353a04f5..99d2a1e65e 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 76ab476f59..c30dace4e2 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 1d40c4386d..c0a252d051 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 d702b58bd0..f473e6ac77 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 a8fd60a8fb..73b3d248d4 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 2c3657d00d..a0dbb81fd9 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -105,7 +105,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 2c85a78fcd..22497b1fd6 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 c2432a0c00..e6264b0785 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 1dc3b02659..c1d4b7806e 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 501e82a766..3f05081bad 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 df5f0bc27f..ecd28fed5c 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 b2224c7f76..a7b9fe1317 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 66c2e87bd3..d4a39aa794 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), \ @@ -1022,35 +1020,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 89cb211472..033a2685c8 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 49cfdc6d67..9eae0ff647 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972111; cv=none; d=zohomail.com; s=zohoarc; b=GbRUlSqa5yN06iVo8X/50n2k6JzTMwPPPCK95NAzi51MxbiHafXs3CcjKfcIxdy9rIzfBm5qh7SBgse/k+GS72JtBrPEJ+9rwkoaLVOx5WNnLWNERX7phHlOsEZAv2JEpcs7rjfCZgqLc8GV0hb2v+gRz2nnMUhFBj1s7A7hZQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972111; 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=pcCcuTbEOlR9w8pwI9GDj+DpaZHeIUQXxMTqcYKhQvI=; b=cLHHCiViD122ZAwBsYpxgc4XpeCusSk+g4VKp73pliipWCo6ao19YetWKfCRRHgyU08oAuOmsbdt/uwEUMEdZmamsjFcpaTOt0TuYuzYn4wFEAOzPq/mgfa1+LfZlNa/2pPyO5gTwneOffA2kGd2Qga+/iI/9V6c5H42gQwSMqk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972111232885.4137142942908; Thu, 23 Apr 2026 12:21:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcD-0002Pl-W6; Thu, 23 Apr 2026 15:21:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbT-0001wF-Ee for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:50 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbN-0001rK-8j for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:45 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E44615BD72; Thu, 23 Apr 2026 19:20:30 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AF1A4593A3; Thu, 23 Apr 2026 19:20:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +DXWHv1w6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972031; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pcCcuTbEOlR9w8pwI9GDj+DpaZHeIUQXxMTqcYKhQvI=; b=ehlTngYPnDkhzCt+wCbDTipcef4yFYJTpaf5Pyc2XXaH1PwI3vqlwdbVWABhV6lylbToND 5gNnJipcUJZkHcn9+whQ8iC220Th/MfDP9f4YztvHZezPc3t0D3YcNs/B9YGGoupqYI5XH KCOdOHbMRVgfqaaqejo3Ie0xorVtENk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972031; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pcCcuTbEOlR9w8pwI9GDj+DpaZHeIUQXxMTqcYKhQvI=; b=FL2/1vsCI0+1wGE2QtNDFZYH9RePWkZjJ1wtVZvbpbw8Ui+VljEZp5J1fZGZAa1EVIEHNX 8Ke0cTBURRnUajAA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972030; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pcCcuTbEOlR9w8pwI9GDj+DpaZHeIUQXxMTqcYKhQvI=; b=snKioVjWETJV4nM7OTMP01r8fIiAfwgYVy0SSDKGtiQ/gEEpr2QM3mHHTxKD4dQQ1M48AV /B2cM0fwqyDkqrItuiGenEzDg1XkglBacfI6KsnJn2q8zp3fUXC8CxcA/D03NW2CFdA8gz huJCvMh65feCu8gRVXwweg80j7lb9Vc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972030; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pcCcuTbEOlR9w8pwI9GDj+DpaZHeIUQXxMTqcYKhQvI=; b=9EtWJ9h2/YHPnhrP9YD5FYulOpSd1+hlc1lZtOL/pjBx61/BnVI+53dm7toKgc0QHJFQaA yYXwVuuCtg60IRBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Vladimir Sementsov-Ogievskiy Subject: [PULL 20/43] migration/vmstate-types: move to new migration APIs Date: Thu, 23 Apr 2026 16:19:34 -0300 Message-ID: <20260423191958.1440-21-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972111604158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-19-vsementso= v@yandex-team.ru Signed-off-by: Fabiano Rosas --- 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 27459dfb78..34143b14b4 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -72,20 +72,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 033a2685c8..23f3433696 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.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972115; cv=none; d=zohomail.com; s=zohoarc; b=hCdE4BfJB4TNJioS34ibV67KsyF9KpV3jE55uvw9rjriD+8TXwE849Ldt+nmD8pmj4pt1pu1PcFhlzvNlprZW5JMf6399gY8fePqZgOapZ7YQIgoNbyQ3bhD7Jn9FTK45QrZGIEab6+Rw2soOh7l9gDgNEL5M3NZrBmM+VnzBa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972115; 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=KFl2lXzzw1kO8royMrKNf1hQ1CfZzjVi8tPrRSJHjfg=; b=EM/WnLQbDjQ2OE0ExWAd2wFZpb9YbPLhGsxrV+WRK8IRMx8SitLZwCLX8sHjCcyCxFnk2cjXJR2ZgpqONzmjTZAkHlyBKeMvfKyqAZmPzBAS8QeicdmlU5cMO8J8KoW4yy/dqh5ecMDpPiQDC+1+XaA/yps1BfSQS/j4MYyeq0M= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972115217464.0808683205711; Thu, 23 Apr 2026 12:21:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcL-00038t-0x; Thu, 23 Apr 2026 15:21:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbc-0001wo-Br for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:00 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbZ-0001sf-MY for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:20:56 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 542BF5BD73; Thu, 23 Apr 2026 19:20:32 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4EF57593A3; Thu, 23 Apr 2026 19:20:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id oPFXB/9w6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972032; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFl2lXzzw1kO8royMrKNf1hQ1CfZzjVi8tPrRSJHjfg=; b=Zb6u6dTxvAE1SUvg+6A04e2Fv4mzu4BO9vF6eVFSJtXdzRPNdlso2nVDRFCslpbk+ASSkr YE3f7TtYS8KsClajwyQm/F5YtxjMH5/EkcjrapxKx/DuCyvJsoyGwUA2irF3zdeeild8iB p3v1mNVJJqwkajlII3HgSdvncmgEKB8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972032; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFl2lXzzw1kO8royMrKNf1hQ1CfZzjVi8tPrRSJHjfg=; b=X/X+q2KtFETfQtyMqe825/XWX4aM68wVae31pZ8rUTXfMr00LOX80AfgZAjFc4XlmME95k Xd4GTaOaPnbMqlBQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Zb6u6dTx; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="X/X+q2Kt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972032; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFl2lXzzw1kO8royMrKNf1hQ1CfZzjVi8tPrRSJHjfg=; b=Zb6u6dTxvAE1SUvg+6A04e2Fv4mzu4BO9vF6eVFSJtXdzRPNdlso2nVDRFCslpbk+ASSkr YE3f7TtYS8KsClajwyQm/F5YtxjMH5/EkcjrapxKx/DuCyvJsoyGwUA2irF3zdeeild8iB p3v1mNVJJqwkajlII3HgSdvncmgEKB8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972032; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFl2lXzzw1kO8royMrKNf1hQ1CfZzjVi8tPrRSJHjfg=; b=X/X+q2KtFETfQtyMqe825/XWX4aM68wVae31pZ8rUTXfMr00LOX80AfgZAjFc4XlmME95k Xd4GTaOaPnbMqlBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Markus Armbruster Subject: [PULL 21/43] migration: Tweak description of migration property multifd-compression Date: Thu, 23 Apr 2026 16:19:35 -0300 Message-ID: <20260423191958.1440-22-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-2.97 / 50.00]; BAYES_HAM(-2.96)[99.84%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 542BF5BD73 X-Spam-Score: -2.97 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972118020154100 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster Help for the migration pseudo-device shows property "multifd-compression" like this: multifd-compression=3D - multifd_compression values (= none/zlib/zstd/qpl/uadk/qatzip) (default: none) Change it to multifd-compression=3D - multifd compression method (= none/zlib/zstd/qpl/uadk/qatzip) (default: none) Signed-off-by: Markus Armbruster Link: https://lore.kernel.org/qemu-devel/20260326074247.188674-4-armbru@red= hat.com Signed-off-by: Fabiano Rosas --- hw/core/qdev-properties-system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index a805ee2e1f..5bfdfe1ab9 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -681,7 +681,7 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { =20 const PropertyInfo qdev_prop_multifd_compression =3D { .type =3D "MultiFDCompression", - .description =3D "multifd_compression values" + .description =3D "multifd compression method" " (none/zlib/zstd/qpl/uadk/qatzip)", .enum_table =3D &MultiFDCompression_lookup, .get =3D qdev_propinfo_get_enum, --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972323; cv=none; d=zohomail.com; s=zohoarc; b=ZT7ffk0jKWUCoBB6ET0e7m+PjBVpMKKJs2fEmwJtjQ22Dg3A9BdZHSCFztF9UXRZV2Oaae3Yl+a46a4t5/jvBRAariA+8QHc8GkohMVGlU0OFAocR2Amfyg5zSe27uf029sI/1wLoH9H4f9FK3kcmUbalrIAUvHICLaKoJM9Kn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972323; 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=DKT9Q2zKT+GEZGSWOgGSeMo9cBOjOzFrkFs3s/aOn2w=; b=EoVZDqiRnU39Snok5FJ2btSWZONuAgd4dmfTo39KfiUMF1MGrEL1pDOpqaoLVDO+BaTdNp+rbOF9AJTLgy/exIlecVnxQj2qSDtU9atG/LVwnphrqTrK1uvLxZWw7GuaFjKq9yeyQy+ZmlprrVScL5cVeZeGmMJrjYMOL/hx7yc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972323518686.6518330654898; Thu, 23 Apr 2026 12:25:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcI-0002lf-Tx; Thu, 23 Apr 2026 15:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzbs-0002Ao-GD for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:15 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbm-0001tc-FI for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:11 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BBA075BD7F; Thu, 23 Apr 2026 19:20:33 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B2AE3593A3; Thu, 23 Apr 2026 19:20:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +PWwHwBx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972033; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DKT9Q2zKT+GEZGSWOgGSeMo9cBOjOzFrkFs3s/aOn2w=; b=mczSZtBJFb4qz6lr61OcO958JQFAhJmxwaDYJNnSDjAIzZ4kSyJFjBazXzMkoYW6MbH9u1 xdwHtyxK/rebeiWI1JQAi3EafELvsTcaqOrsFYib9q1BKhwPXUtXwNFB6NDmVJHlWmD7bQ 3ofFjoEBXwkxHVNrPp9jBu1zWtVBfDU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972033; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DKT9Q2zKT+GEZGSWOgGSeMo9cBOjOzFrkFs3s/aOn2w=; b=EeXZv1Q88HlTobtfUCZ0M5ze4VisB/Y5fnBvW5hMyDe3RMeB2eICEAQj3/ffshCQmlyVd3 WAwIc9k+Y1HzykDQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=mczSZtBJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EeXZv1Q8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972033; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DKT9Q2zKT+GEZGSWOgGSeMo9cBOjOzFrkFs3s/aOn2w=; b=mczSZtBJFb4qz6lr61OcO958JQFAhJmxwaDYJNnSDjAIzZ4kSyJFjBazXzMkoYW6MbH9u1 xdwHtyxK/rebeiWI1JQAi3EafELvsTcaqOrsFYib9q1BKhwPXUtXwNFB6NDmVJHlWmD7bQ 3ofFjoEBXwkxHVNrPp9jBu1zWtVBfDU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972033; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DKT9Q2zKT+GEZGSWOgGSeMo9cBOjOzFrkFs3s/aOn2w=; b=EeXZv1Q88HlTobtfUCZ0M5ze4VisB/Y5fnBvW5hMyDe3RMeB2eICEAQj3/ffshCQmlyVd3 WAwIc9k+Y1HzykDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Takeru Hayasaka Subject: [PULL 22/43] tests/qtest/migration: Add mapped-ram/postcopy validation test Date: Thu, 23 Apr 2026 16:19:36 -0300 Message-ID: <20260423191958.1440-23-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Queue-Id: BBA075BD7F X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972324448158500 Content-Type: text/plain; charset="utf-8" From: Takeru Hayasaka The migration capability checks reject enabling postcopy-ram together with mapped-ram, but there is no qtest covering this incompatibility. Add a validation test that verifies QMP rejects the combination in both capability ordering cases and returns the expected error. This keeps the existing capability boundary covered without changing migration behavior. Signed-off-by: Takeru Hayasaka Link: https://lore.kernel.org/qemu-devel/20260327164705.1990226-1-hayatake3= 96@gmail.com [unlink src_serial] Signed-off-by: Fabiano Rosas --- tests/qtest/migration/misc-tests.c | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/mis= c-tests.c index 196f1ca842..e114ac5972 100644 --- a/tests/qtest/migration/misc-tests.c +++ b/tests/qtest/migration/misc-tests.c @@ -215,6 +215,55 @@ static void do_test_validate_uri_channel(MigrateCommon= *args) migrate_end(from, to, false); } =20 +static void validate_caps_pair(QTestState *from, + const char *first_capability, + const char *second_capability, + const char *expected_error) +{ + QDict *rsp; + const char *error_desc; + + migrate_set_capability(from, first_capability, true); + + rsp =3D qtest_qmp_assert_failure_ref( + from, + "{ 'execute': 'migrate-set-capabilities'," + " 'arguments': { 'capabilities': [ { " + " 'capability': %s, 'state': true } ] } }", + second_capability); + + error_desc =3D qdict_get_str(rsp, "desc"); + g_assert_cmpstr(error_desc, =3D=3D, expected_error); + qobject_unref(rsp); + + migrate_set_capability(from, first_capability, false); +} + +static void test_validate_caps_pair(char *test_path, MigrateCommon *args) +{ + g_autofree char *serial_path =3D g_strconcat(tmpfs, "/src_serial", NUL= L); + g_autofree char *cap_pair =3D g_path_get_basename(test_path); + QTestState *from, *to; + + args->start.hide_stderr =3D true; + args->start.only_source =3D true; + + if (migrate_start(&from, &to, "defer", &args->start)) { + return; + } + + if (g_str_equal(cap_pair, "mapped_ram_postcopy")) { + const char *error =3D + "Mapped-ram migration is incompatible with postcopy"; + + validate_caps_pair(from, "mapped-ram", "postcopy-ram", error); + validate_caps_pair(from, "postcopy-ram", "mapped-ram", error); + } + + qtest_quit(from); + unlink(serial_path); +} + static void test_validate_uri_channels_both_set(char *name, MigrateCommon = *args) { args->listen_uri =3D "defer", @@ -276,4 +325,7 @@ void migration_test_add_misc(MigrationTestEnv *env) test_validate_uri_channels_both_set); migration_test_add("/migration/validate_uri/channels/none_set", test_validate_uri_channels_none_set); + migration_test_add_suffix("/migration/validate_caps/", + "mapped_ram_postcopy", + test_validate_caps_pair); } --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972135; cv=none; d=zohomail.com; s=zohoarc; b=Iu/I8xvJ/n2DlmxvdPAAXwLGO0yCXj+Du3Tj270sHZRYap1nwo1rc+yYPCq1C49kRBSw8i12r62JwSh7ZH7iNdNeQ5myMVmK0eeaQ27YCxlJcqHYIG8ssECCHcq/yaC/92TngIVB6pVRWD84IjRxRKE4qATkotg/RgU0vr5WH+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972135; 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=9+dWxIjEbtZWJM6lJ1p1SMQ30hrcIj1G1U4aBy3qzDI=; b=PMOY/S7OHqYsPRbNbTGwtjTqYQkgaByM1g679fGx24RqksEEHSKyPEIx593JBXzjno2dtc3D7kwokxtmKD6j4VigbwwDeO9suWcGDZZCDA/cjkjsvViRHX1b8NZxIADAWs38CyOWM6tSPDfxT1i3wFhsKIkxTXctIe8EQGktcR0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972135723827.5888231827536; Thu, 23 Apr 2026 12:22:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcJ-0002rS-CD; Thu, 23 Apr 2026 15:21:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzc0-0002IJ-4q for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:27 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzbw-0001ve-G5 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:19 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2BD575BD80; Thu, 23 Apr 2026 19:20:35 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 26249593A3; Thu, 23 Apr 2026 19:20:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uBP2OAFx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972035; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9+dWxIjEbtZWJM6lJ1p1SMQ30hrcIj1G1U4aBy3qzDI=; b=Ku/6DBjMRxNiD9US9YvoKTBQBhk4U3F5gF2346lfP+wLOSmAS5KX2f5Yv4LWsgpru+rrh+ u6vhAZffKBSh3ntJdpQHFiD0VroJIb/1rCMkeH11ycEHTiDzQ3GHBYQNUFEI/67zz/jVl8 JMTdycS49gTRm0dFMuBeV8BBa7Tv99w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972035; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9+dWxIjEbtZWJM6lJ1p1SMQ30hrcIj1G1U4aBy3qzDI=; b=trog1vFoWLnLJRghEK47xStnTzIrsQqMU1G6xOHRUWAnshA50vnHlpy7jkw6YbM/w5ZWle bF3DEZlSzK9pYKDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972035; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9+dWxIjEbtZWJM6lJ1p1SMQ30hrcIj1G1U4aBy3qzDI=; b=Ku/6DBjMRxNiD9US9YvoKTBQBhk4U3F5gF2346lfP+wLOSmAS5KX2f5Yv4LWsgpru+rrh+ u6vhAZffKBSh3ntJdpQHFiD0VroJIb/1rCMkeH11ycEHTiDzQ3GHBYQNUFEI/67zz/jVl8 JMTdycS49gTRm0dFMuBeV8BBa7Tv99w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972035; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9+dWxIjEbtZWJM6lJ1p1SMQ30hrcIj1G1U4aBy3qzDI=; b=trog1vFoWLnLJRghEK47xStnTzIrsQqMU1G6xOHRUWAnshA50vnHlpy7jkw6YbM/w5ZWle bF3DEZlSzK9pYKDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Trieu Huynh Subject: [PULL 23/43] migration: fix QIOChannelFile leak on error in file_connect_outgoing Date: Thu, 23 Apr 2026 16:19:37 -0300 Message-ID: <20260423191958.1440-24-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972138293154100 Content-Type: text/plain; charset="utf-8" From: Trieu Huynh Commit 03a680c978 changed g_autoptr(QIOChannelFile) to a plain pointer but failed to restore the necessary object_unref() calls on error paths. Previously, these were handled implicitly by the g_autoptr cleanup mechanism. Two error paths currently leak the QIOChannelFile object and its underlying file descriptor: 1. When ftruncate() fails (e.g., on character or block devices). 2. When qio_channel_io_seek() fails after the channel is created. In environments that retry migration automatically (e.g., libvirt), these FDs accumulate until QEMU hits RLIMIT_NOFILE and fails with EMFILE (Too many open files). Add the missing object_unref() calls to both error paths to ensure resources are properly released. Signed-off-by: Trieu Huynh Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260328121215.159532-1-vikingtc4@= gmail.com Signed-off-by: Fabiano Rosas --- migration/file.c | 2 ++ tests/qtest/migration/file-tests.c | 48 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/migration/file.c b/migration/file.c index 5618aced49..962b4b3a1b 100644 --- a/migration/file.c +++ b/migration/file.c @@ -112,6 +112,7 @@ QIOChannel *file_connect_outgoing(MigrationState *s, error_setg_errno(errp, errno, "failed to truncate migration file to offset %" P= RIx64, offset); + object_unref(OBJECT(fioc)); goto out; } =20 @@ -119,6 +120,7 @@ QIOChannel *file_connect_outgoing(MigrationState *s, =20 ioc =3D QIO_CHANNEL(fioc); if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) { + object_unref(OBJECT(fioc)); ioc =3D NULL; goto out; } diff --git a/tests/qtest/migration/file-tests.c b/tests/qtest/migration/fil= e-tests.c index 5d1b861cf6..fef172068f 100644 --- a/tests/qtest/migration/file-tests.c +++ b/tests/qtest/migration/file-tests.c @@ -20,6 +20,51 @@ =20 static char *tmpfs; =20 +static int count_proc_fds(pid_t pid) +{ + g_autofree char *fddir =3D g_strdup_printf("/proc/%d/fd", (int)pid); + GDir *dir =3D g_dir_open(fddir, 0, NULL); + int count =3D 0; + + if (!dir) { + return -1; + } + while (g_dir_read_name(dir)) { + count++; + } + g_dir_close(dir); + return count; +} + +static void test_file_connect_outgoing_fd_leak(char *name, MigrateCommon *= args) +{ + QTestState *from, *to; + int fd_before, fd_after; + const int retries =3D 5; + int i; + if (!g_file_test("/dev/full", G_FILE_TEST_EXISTS)) { + g_test_skip("/dev/full not available"); + return; + } + + args->listen_uri =3D "defer"; + if (migrate_start(&from, &to, args->listen_uri, &args->start)) { + return; + } + + fd_before =3D count_proc_fds(qtest_pid(from)); + g_assert_cmpint(fd_before, >, 0); + for (i =3D 0; i < retries; i++) { + migrate_qmp_fail(from, "file:/dev/full", NULL, "{}"); + migration_event_wait(from, "failed"); + } + + fd_after =3D count_proc_fds(qtest_pid(from)); + g_assert_cmpint(fd_after, >, 0); + g_assert_cmpint(fd_after, =3D=3D, fd_before); + migrate_end(from, to, false); +} + static void test_precopy_file(char *name, MigrateCommon *args) { g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, @@ -314,6 +359,9 @@ void migration_test_add_file(MigrationTestEnv *env) migration_test_add("/migration/precopy/file/offset/bad", test_precopy_file_offset_bad); =20 + migration_test_add("/migration/precopy/file/connect-outgoing-fd-leak", + test_file_connect_outgoing_fd_leak); + migration_test_add("/migration/precopy/file/mapped-ram", test_precopy_file_mapped_ram); migration_test_add("/migration/precopy/file/mapped-ram/live", --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972262; cv=none; d=zohomail.com; s=zohoarc; b=P5N8s8Qg8Y12oeM7gtCB4AX8lFA99/zSH0T4uouPHOsHEe3NKSKFYgxo1fv7Ya+DNK2g42dPv6jiLHaeo9obw8IvpVTTesE68aJ5JUA6AXmPuPWEC2Cz8URD1UYy6tMyWB5MQdXlejacgt4xH/09vHlN4HNIUPjxZk3vTdaKo4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972262; 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=Zv0ZUnC0KXVCWHLwyLSI86WolEvBSu09bCwPnFXhLdI=; b=g2b0bt6NyK4GVzzN9s69U8fbU5Dnfn3kNjFmB5PaJJm/07kg06gdXkbazGXg0eWL2Esafu4Jhr42G7rLgTY37x/GnN1uZsiDeZV1on8ngyeiRd4INjrT0Y5cg7SuTrr2GrpcShiLfgOKQkcsc1RoZwKM2sXAD4vqizMSh9qh8kM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972262704121.01442983100162; Thu, 23 Apr 2026 12:24:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcK-00031Y-7k; Thu, 23 Apr 2026 15:21:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzc5-0002KX-1K for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:29 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzc3-0001xF-A6 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:24 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F1C785BD84; Thu, 23 Apr 2026 19:20:36 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8A6CF593A3; Thu, 23 Apr 2026 19:20:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qMLUFQNx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972037; h=from:from:reply-to: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=Zv0ZUnC0KXVCWHLwyLSI86WolEvBSu09bCwPnFXhLdI=; b=b9vUtcWzSzbWIpFdUY4lUidO1UiuiHIgLSLYOXQxQipZ9Sqi9UXncFycTitvUOIUKT4ilh N7dODebk5hAiGR/YSVTW+7bhybCYcT7tRTUNkoJwWJawuRpme/Kgl0NQSb9+gpoLzbRa9T 4nDzCREXC33rABgLQddFOhw7YyIeRSs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972037; h=from:from:reply-to: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=Zv0ZUnC0KXVCWHLwyLSI86WolEvBSu09bCwPnFXhLdI=; b=/WqziteLmD8zx4LX780jqxO65EqwXwttc1+SwmPmpbjb9Zz7FIXF9ZqvN1KLOOAxnMu64z 5NsVsEo/ujv+s0Cw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=tAuNIMlS; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=VzP1gKTO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972036; h=from:from:reply-to: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=Zv0ZUnC0KXVCWHLwyLSI86WolEvBSu09bCwPnFXhLdI=; b=tAuNIMlS7F7LPFSz4kBpL1HWJ7AE4vj1hqngLyRfLjLOm0mvr57kL0DcecFtXH6/ioutS0 d5TWUfk0yxV+leR9jwSWJ1RObWEGQgTv7Ci2xJoW34REDregnzbrrgHE7j3/uXlfyP7amm EU6UaljjeftWVyfdOfYUCFIR/+62rqY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972036; h=from:from:reply-to: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=Zv0ZUnC0KXVCWHLwyLSI86WolEvBSu09bCwPnFXhLdI=; b=VzP1gKTO8l62aMbyR1WfBMPcJFCXQao/z1HfZYaI4llMlVRwtKLAGX3Hz8KHQpHHPo8rJt TisLYiADujLCTKDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juraj Marcin Subject: [PULL 24/43] vmstate: Pass in struct itself for VMSTATE_ARRAY_OF_POINTER Date: Thu, 23 Apr 2026 16:19:38 -0300 Message-ID: <20260423191958.1440-25-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[linaro.org:email,suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: F1C785BD84 X-Spam-Score: -3.51 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972264286154100 From: Peter Xu Passing in a pointer almost never helps. Convert it to pass in struct for further refactoring on VMS_ARRAY_OF_POINTER. Reviewed-by: Alexander Mikhalitsyn Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-2-peterx@red= hat.com [delete spurious hunk touching roms/seabios] Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 6 +++--- tests/unit/test-vmstate.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index d4a39aa794..d4880e75c2 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -547,9 +547,9 @@ extern const VMStateInfo vmstate_info_qlist; .version_id =3D (_version), \ .num =3D (_num), \ .info =3D &(_info), \ - .size =3D sizeof(_type), \ + .size =3D sizeof(_type *), \ .flags =3D VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ - .offset =3D vmstate_offset_array(_state, _field, _type, _num), \ + .offset =3D vmstate_offset_array(_state, _field, _type *, _num), \ } =20 #define VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, _v, _vmsd, _type) {= \ @@ -1093,7 +1093,7 @@ extern const VMStateInfo vmstate_info_qlist; VMSTATE_TIMER_PTR_V(_f, _s, 0) =20 #define VMSTATE_TIMER_PTR_ARRAY(_f, _s, _n) \ - VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer = *) + VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer) =20 #define VMSTATE_TIMER_TEST(_f, _s, _test) \ VMSTATE_SINGLE_TEST(_f, _s, _test, 0, vmstate_info_timer, QEMUTimer) diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index cadbab3c5e..6a42cc1a4e 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -668,7 +668,7 @@ const VMStateDescription vmsd_arpp =3D { .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { VMSTATE_ARRAY_OF_POINTER(ar, TestArrayOfPtrToInt, - AR_SIZE, 0, vmstate_info_int32, int32_t*), + AR_SIZE, 0, vmstate_info_int32, int32_t), VMSTATE_END_OF_LIST() } }; --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972330; cv=none; d=zohomail.com; s=zohoarc; b=NzzgSlux2O4AEC1FZlSrnjvKND93iyQHZ3GV9RrXmslSw696oktSt81w7q0bchAMspLAAXMQttOdr2oltbn6oQxyW9VDO3ri5LW6ZEUvSNw9tqqRTGIisv/B9we2A2FzlezhhhS4fIceu0pxLZUF6wCF5MgL/8wBCaCAlPG7JFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972330; 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=H3tdehQEFkrIn/2FNGCIRkVgGSAZaOiQ4sokOcOKXPw=; b=K62GIkg2j/PJDsMKvMw34Eeny0bfYcHMMx4DMx6J9BtHndR/Cy99jr1GfD7SR+B/mT4V9zYmE5KD/T22gcr+XUHROQqf3SdSlk87RAcQId266ShpdDZTEWqPBUZ8q1ozGvO4UJiiS5ArVay+GMwrUQvDwYmF+9LuVri1GMBSD2g= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972330061427.8281165280732; Thu, 23 Apr 2026 12:25:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcu-0004xc-GF; Thu, 23 Apr 2026 15:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcA-0002OC-1i for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:31 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzc8-0001y8-Cu for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:29 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C3A6B5BD62; Thu, 23 Apr 2026 19:20:38 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5C105593A3; Thu, 23 Apr 2026 19:20:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UGyOCgVx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972038; h=from:from:reply-to: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=H3tdehQEFkrIn/2FNGCIRkVgGSAZaOiQ4sokOcOKXPw=; b=qpUgwWCDtw11grVlzevzRdW6SbtQQdQtqfPI3udSn80ywu5W4YRilwBuCmz234qFXKc1Rs tZuBbo0ZPlY0hMj1byLwt49cAzmkTaKaJCR0K5to3uYpRHgPOBxfpmbHZZFAYkjFlqf/c9 GZFifW1auWCmB1/q16Oq5ZFYbUOt3PU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972038; h=from:from:reply-to: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=H3tdehQEFkrIn/2FNGCIRkVgGSAZaOiQ4sokOcOKXPw=; b=cwS0bR33Mk3jIMfQogvN32ivVso9ohCgGI+tipQQfaoncbErk4dY6TFB2S5i3zRsKj4rTD SHq2YnNW7IFJGPDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=qpUgwWCD; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=cwS0bR33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972038; h=from:from:reply-to: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=H3tdehQEFkrIn/2FNGCIRkVgGSAZaOiQ4sokOcOKXPw=; b=qpUgwWCDtw11grVlzevzRdW6SbtQQdQtqfPI3udSn80ywu5W4YRilwBuCmz234qFXKc1Rs tZuBbo0ZPlY0hMj1byLwt49cAzmkTaKaJCR0K5to3uYpRHgPOBxfpmbHZZFAYkjFlqf/c9 GZFifW1auWCmB1/q16Oq5ZFYbUOt3PU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972038; h=from:from:reply-to: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=H3tdehQEFkrIn/2FNGCIRkVgGSAZaOiQ4sokOcOKXPw=; b=cwS0bR33Mk3jIMfQogvN32ivVso9ohCgGI+tipQQfaoncbErk4dY6TFB2S5i3zRsKj4rTD SHq2YnNW7IFJGPDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juraj Marcin Subject: [PULL 25/43] vmstate: Pass in struct itself for VMSTATE_VARRAY_OF_POINTER_UINT32 Date: Thu, 23 Apr 2026 16:19:39 -0300 Message-ID: <20260423191958.1440-26-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[linaro.org:email,suse.de:mid,suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Score: -3.51 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: C3A6B5BD62 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972331303154100 From: Peter Xu Passing in a pointer almost never helps. Convert it to pass in struct for further refactoring on VMS_ARRAY_OF_POINTER. Reviewed-by: Alexander Mikhalitsyn Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-3-peterx@red= hat.com Signed-off-by: Fabiano Rosas --- include/hw/intc/riscv_aclint.h | 6 +++--- include/migration/vmstate.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hw/intc/riscv_aclint.h b/include/hw/intc/riscv_aclint.h index 5310615cbf..0e0b98acb0 100644 --- a/include/hw/intc/riscv_aclint.h +++ b/include/hw/intc/riscv_aclint.h @@ -80,8 +80,8 @@ enum { RISCV_ACLINT_SWI_SIZE =3D 0x4000 }; =20 -#define VMSTATE_TIMER_PTR_VARRAY(_f, _s, _f_n) \ -VMSTATE_VARRAY_OF_POINTER_UINT32(_f, _s, _f_n, 0, vmstate_info_timer, \ - QEMUTimer *) +#define VMSTATE_TIMER_PTR_VARRAY(_f, _s, _f_n) \ + VMSTATE_VARRAY_OF_POINTER_UINT32(_f, _s, _f_n, 0, vmstate_info_timer, \ + QEMUTimer) =20 #endif diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index d4880e75c2..32bb8e8ebc 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -567,9 +567,9 @@ extern const VMStateInfo vmstate_info_qlist; .version_id =3D (_version), = \ .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), = \ .info =3D &(_info), = \ - .size =3D sizeof(_type), = \ + .size =3D sizeof(_type *), = \ .flags =3D VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER= , \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), = \ + .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ } =20 #define VMSTATE_STRUCT_SUB_ARRAY(_field, _state, _start, _num, _version, _= vmsd, _type) { \ --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972144; cv=none; d=zohomail.com; s=zohoarc; b=Q65q9ydfqzhhBTIMERCWzCSbQvLUr/4ET7Pl8kuG0qec46Oa5PnGWu1Z8tj8Eh5v43xNI7R1vUT/srkvHYvpUTqYL6HQ+F8JHpmLt6UnYXWS/+DFnXV94ei/BKW00hBQAAdA9g4W5cnkHHmgNmEkLCNlEkUDlv2TodCWSQ0QbvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972144; 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=cps/+TDf6sawK3UL3T3/BEb1DwFfw9hUVfjlHW+dVCE=; b=jafsBqdwC8C3NM6lwB6/QoQ4ZKX5Y5ZgTGr1qsOZ2xJllY8yaBP6Dc4FOeKYONTEQggjteGN8QktgB3IxYu4pIVTrbA0MU0GwRM+LCQgLxBBaQMw+kNnCcAbmgzArcUAWr100aDotYDwIWEnsUfLb0Xrjo3/IX0aJBGeumay+vM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972144280366.89988151251646; Thu, 23 Apr 2026 12:22:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcg-0004Uz-2H; Thu, 23 Apr 2026 15:22:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcT-0003pW-OE for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:51 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcR-00029P-OT for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:49 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9727A6A891; Thu, 23 Apr 2026 19:20:40 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2E7FD593A3; Thu, 23 Apr 2026 19:20:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WIcDOwZx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972040; h=from:from:reply-to: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=cps/+TDf6sawK3UL3T3/BEb1DwFfw9hUVfjlHW+dVCE=; b=d0ewgjhfU8Ehs3zaqPzUkOn/yphPywdhWVZi/HhaSmXzYkD5Xm53Qp++Crs8lTG9c9/OE0 aX2lzN1V/4ljESipXaKAIPuxjlyU4yiHGgvGMiy6eEKib+ghoSziO3kJ4BqA4YtXmLMiO4 NMdOIyS1it0TNNHFI0xluOKhs5Cc+2s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972040; h=from:from:reply-to: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=cps/+TDf6sawK3UL3T3/BEb1DwFfw9hUVfjlHW+dVCE=; b=x3pVkF6eogbORMINI5+BE6oYdrUjEzF6z+xfEUuusuednmMnCFjcskF1FjNq5pfs+d1kwj sUNbRJJ0np4GGgDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=d0ewgjhf; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=x3pVkF6e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972040; h=from:from:reply-to: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=cps/+TDf6sawK3UL3T3/BEb1DwFfw9hUVfjlHW+dVCE=; b=d0ewgjhfU8Ehs3zaqPzUkOn/yphPywdhWVZi/HhaSmXzYkD5Xm53Qp++Crs8lTG9c9/OE0 aX2lzN1V/4ljESipXaKAIPuxjlyU4yiHGgvGMiy6eEKib+ghoSziO3kJ4BqA4YtXmLMiO4 NMdOIyS1it0TNNHFI0xluOKhs5Cc+2s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972040; h=from:from:reply-to: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=cps/+TDf6sawK3UL3T3/BEb1DwFfw9hUVfjlHW+dVCE=; b=x3pVkF6eogbORMINI5+BE6oYdrUjEzF6z+xfEUuusuednmMnCFjcskF1FjNq5pfs+d1kwj sUNbRJJ0np4GGgDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juraj Marcin Subject: [PULL 26/43] vmstate: Do not set size for VMS_ARRAY_OF_POINTER Date: Thu, 23 Apr 2026 16:19:40 -0300 Message-ID: <20260423191958.1440-27-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,linaro.org:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 9727A6A891 X-Spam-Score: -3.51 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972146445154100 From: Peter Xu When VMS_ARRAY_OF_POINTER is specified, it means the vmstate field is an array of pointers. The size of the element is not relevant to whatever it is stored inside: it is always the host pointer size. Let's reserve the "size" field in this case for future use, update vmstate_size() so as to make it still work for array of pointers properly. When at this, provide rich documentation on how size / size_offset works in vmstate. Reviewed-by: Alexander Mikhalitsyn Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-4-peterx@red= hat.com Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 20 ++++++++++++++++---- migration/savevm.c | 3 +++ migration/vmstate.c | 10 +++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 32bb8e8ebc..350e62a55a 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -183,11 +183,26 @@ typedef enum { struct VMStateField { const char *name; size_t offset; + + /* + * @size or @size_offset specifies the size of the element embeded in + * the field. Only one of them should be present never both. When + * @size_offset is used together with VMS_VBUFFER, it means the size is + * dynamic calculated instead of a constant. + * + * When the field is an array of any type, this stores the size of one + * element of the array. + * + * NOTE: even if VMS_POINTER or VMS_ARRAY_OF_POINTER may be specified, + * this parameter always reflects the real size of the objects that a + * pointer point to. + */ size_t size; + size_t size_offset; + size_t start; int num; size_t num_offset; - size_t size_offset; const VMStateInfo *info; enum VMStateFlags flags; const VMStateDescription *vmsd; @@ -547,7 +562,6 @@ extern const VMStateInfo vmstate_info_qlist; .version_id =3D (_version), \ .num =3D (_num), \ .info =3D &(_info), \ - .size =3D sizeof(_type *), \ .flags =3D VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ .offset =3D vmstate_offset_array(_state, _field, _type *, _num), \ } @@ -557,7 +571,6 @@ extern const VMStateInfo vmstate_info_qlist; .version_id =3D (_v), \ .num =3D (_n), \ .vmsd =3D &(_vmsd), \ - .size =3D sizeof(_type *), \ .flags =3D VMS_ARRAY|VMS_STRUCT|VMS_ARRAY_OF_POINTER, \ .offset =3D vmstate_offset_array(_s, _f, _type*, _n), \ } @@ -567,7 +580,6 @@ extern const VMStateInfo vmstate_info_qlist; .version_id =3D (_version), = \ .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), = \ .info =3D &(_info), = \ - .size =3D sizeof(_type *), = \ .flags =3D VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER= , \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ } diff --git a/migration/savevm.c b/migration/savevm.c index 8115203b51..f5a6fd0c66 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -868,6 +868,9 @@ static void vmstate_check(const VMStateDescription *vms= d) =20 if (field) { while (field->name) { + if (field->flags & VMS_ARRAY_OF_POINTER) { + assert(field->size =3D=3D 0); + } if (field->flags & (VMS_STRUCT | VMS_VSTRUCT)) { /* Recurse to sub structures */ vmstate_check(field->vmsd); diff --git a/migration/vmstate.c b/migration/vmstate.c index e98b5f5346..e29a8c3f49 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -110,13 +110,21 @@ static int vmstate_n_elems(void *opaque, const VMStat= eField *field) =20 static int vmstate_size(void *opaque, const VMStateField *field) { - int size =3D field->size; + int size; =20 if (field->flags & VMS_VBUFFER) { size =3D *(int32_t *)(opaque + field->size_offset); if (field->flags & VMS_MULTIPLY) { size *=3D field->size; } + } else if (field->flags & VMS_ARRAY_OF_POINTER) { + /* + * For an array of pointer, the each element is always size of a + * host pointer. + */ + size =3D sizeof(void *); + } else { + size =3D field->size; } =20 return size; --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972309; cv=none; d=zohomail.com; s=zohoarc; b=WWV7rRQJGO0XRXkYJQjRSmaF2KnDxIyusRUqZKl2CRzuPrtBniaJMmBaGdJsxpTL54tZWVoYE/gzY8YonWAyeDxYhoGMCEtk5s7VHC27XjirvBzPR6j/TLFpEqXa4mvAem49Nbrrpp8vPH7dcoEMbK+j4DhutudxprWIetZyjzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972309; 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=LL30Z+MBwjm49fC4Nr5CADY5IMbB82ISYMgKmmKxuMY=; b=D8xH6I8RSg8WppSjHBbTkKRzmCjw8Yj/rkx6J58bhdYGJMD3AWRSjkMYF+glP0WGHV1k/rTv8pMdYU4BTohLuBGrzDkoI+IeZ/MBIS2rTi26CNP76CyfrgpXybcyo+2r6NBtWVQie/FN3ONUaeRiwGvRiFw5coeWPqPlLAEfED8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972309543863.064200437706; Thu, 23 Apr 2026 12:25:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcN-0003OI-TC; Thu, 23 Apr 2026 15:21:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcF-0002X5-DG for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:37 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcD-00026E-IK for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:35 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3882F5BD87; Thu, 23 Apr 2026 19:20:42 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 01EA4593A3; Thu, 23 Apr 2026 19:20:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id wB8OMAhx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972042; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LL30Z+MBwjm49fC4Nr5CADY5IMbB82ISYMgKmmKxuMY=; b=z4liShONaU6QQ6hciT+8ERNq93Xu7+xGmlVIbTytXoU11tOEPzp3cuxYlDZU/SgWrI+i1X zoSB2eEJ4q0ku9Rrh48VnsRdJy9DLBhR7YKPtqrfalRJjYKpl/SJyjs+jBZZX7NNHwi0zo uWxwdPaewXJMWLp4uzD2xX8lJ6CahxY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972042; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LL30Z+MBwjm49fC4Nr5CADY5IMbB82ISYMgKmmKxuMY=; b=H0pUESxtM0xeU3IIWdCoRSvHvUN+fNenE/EoU3PFGoYB7wcaxTwvhms97uhw0IKjLuKan1 fpxBWd7ZftJMY/CA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972042; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LL30Z+MBwjm49fC4Nr5CADY5IMbB82ISYMgKmmKxuMY=; b=z4liShONaU6QQ6hciT+8ERNq93Xu7+xGmlVIbTytXoU11tOEPzp3cuxYlDZU/SgWrI+i1X zoSB2eEJ4q0ku9Rrh48VnsRdJy9DLBhR7YKPtqrfalRJjYKpl/SJyjs+jBZZX7NNHwi0zo uWxwdPaewXJMWLp4uzD2xX8lJ6CahxY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972042; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LL30Z+MBwjm49fC4Nr5CADY5IMbB82ISYMgKmmKxuMY=; b=H0pUESxtM0xeU3IIWdCoRSvHvUN+fNenE/EoU3PFGoYB7wcaxTwvhms97uhw0IKjLuKan1 fpxBWd7ZftJMY/CA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , Juraj Marcin Subject: [PULL 27/43] vmstate: Update max_elems early and check field compressable once Date: Thu, 23 Apr 2026 16:19:41 -0300 Message-ID: <20260423191958.1440-28-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972310992154100 Content-Type: text/plain; charset="utf-8" From: Peter Xu QEMU has a trick in vmstate_save_vmsd_v(), where it will try to compress multiple JSON entries into one with a count to avoid duplicated entries. That only applies to the cases where vmsd_can_compress() should return true. For example, vmsd_desc_field_start() later (who will take the updated max_elems as the last parameter) will ignore the value passed in when vmsd_can_compress() returns false. Do that check once at the start of loop, and use it to update max_elems, so that max_elems keeps 1 for uncompressable VMSD fields, which is more straightforward. This also paves way to make this counter work for ptr marker VMSD fields too. No functional change intended in this patch alone. Reviewed-by: Fabiano Rosas Reviewed-by: Alexander Mikhalitsyn Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-5-peterx@red= hat.com Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index e29a8c3f49..05badef42f 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -556,7 +556,8 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, void *curr_elem =3D first_elem + size * i; const VMStateField *inner_field; bool is_null; - int max_elems =3D n_elems - i; + /* maximum number of elements to compress in the JSON blob= */ + int max_elems =3D vmsd_can_compress(field) ? (n_elems - i)= : 1; =20 old_offset =3D qemu_file_transferred(f); if (field->flags & VMS_ARRAY_OF_POINTER) { @@ -587,7 +588,8 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, * vs. nullptr). Search ahead for the next null/non-null e= lement * and start a new compressed array if found. */ - if (vmdesc && (field->flags & VMS_ARRAY_OF_POINTER) && + if (vmdesc && max_elems > 1 && + (field->flags & VMS_ARRAY_OF_POINTER) && is_null !=3D is_prev_null) { =20 is_prev_null =3D is_null; @@ -626,7 +628,7 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, } =20 /* Compressed arrays only care about the first element */ - if (vmdesc_loop && vmsd_can_compress(field)) { + if (vmdesc_loop && max_elems > 1) { vmdesc_loop =3D NULL; } } --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972302; cv=none; d=zohomail.com; s=zohoarc; b=nxv8aSBmejQYjE2gJnCb7HRMgha9swyltP4TDpZowiipfoKG6TCo2c9wpnVOqUzHUoZU+qSAnEAC7iJachsA8GB9LZtO0nryPBdkzwBRfSSk2RJfnyyr/KeIB3SFjk7gtXNyEqIMzoYBff0shi8INqSlKzEs1DD/HlEPoR5wCIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972302; 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=HTPFHDxtJ9FnO+BjlFenJ4bFm2rrC6F0pyANu2MHGgQ=; b=dL50g9r3lpzrqDk56m4vkDsm4KfV1pOzU4sHGGjTSqyoSQr1hCVnWLRxOi7z7SXBKiT7/k4aTygNfCJ4Sl0NzwVBxpCeVX7cU6w+Bra6nDfuQ7p5sGou4HdaIwH8edaVd+IxlzWwyCUxtKECKDgQlmT/Fye4tCwz4M0kcSHm6GM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972302868556.9323610502142; Thu, 23 Apr 2026 12:25:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdE-0005kl-0p; Thu, 23 Apr 2026 15:22:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcb-0004L9-Ic for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:57 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcY-0002Af-2Y for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:55 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0A4E06A894; Thu, 23 Apr 2026 19:20:44 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 971BC593A3; Thu, 23 Apr 2026 19:20:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8JzwGApx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972044; h=from:from:reply-to: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=HTPFHDxtJ9FnO+BjlFenJ4bFm2rrC6F0pyANu2MHGgQ=; b=mOA0EGxLByaYagKQPOT69mnk/ESKNJWTKAbEuZ6QfWC9kMe8G62X/8rQdSsiN5hZ2VrSM+ 1EZCq/EGF+am2t7bZ91H0nDFn/yjHibxvNt/OvpTfQwrRxux6OR1Aa3nziSzqN6GaoMDuJ /16hxIfaHuHAQBZ42s2r01rYgxDagLg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972044; h=from:from:reply-to: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=HTPFHDxtJ9FnO+BjlFenJ4bFm2rrC6F0pyANu2MHGgQ=; b=nZOpcn6egVYNO3J0jILBSY+c10dg0qxTnLjO9Z/GpIGMhCbj0qQSE4tqzH4t2X0xvQi8ld Y/MP6FsyaOd8WRCQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=mOA0EGxL; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nZOpcn6e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972044; h=from:from:reply-to: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=HTPFHDxtJ9FnO+BjlFenJ4bFm2rrC6F0pyANu2MHGgQ=; b=mOA0EGxLByaYagKQPOT69mnk/ESKNJWTKAbEuZ6QfWC9kMe8G62X/8rQdSsiN5hZ2VrSM+ 1EZCq/EGF+am2t7bZ91H0nDFn/yjHibxvNt/OvpTfQwrRxux6OR1Aa3nziSzqN6GaoMDuJ /16hxIfaHuHAQBZ42s2r01rYgxDagLg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972044; h=from:from:reply-to: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=HTPFHDxtJ9FnO+BjlFenJ4bFm2rrC6F0pyANu2MHGgQ=; b=nZOpcn6egVYNO3J0jILBSY+c10dg0qxTnLjO9Z/GpIGMhCbj0qQSE4tqzH4t2X0xvQi8ld Y/MP6FsyaOd8WRCQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juraj Marcin Subject: [PULL 28/43] vmstate: Rename VMS_NULLPTR_MARKER to VMS_MARKER_PTR_NULL Date: Thu, 23 Apr 2026 16:19:42 -0300 Message-ID: <20260423191958.1440-29-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[linaro.org:email,suse.de:mid,suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Score: -3.51 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 0A4E06A894 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972304417158500 From: Peter Xu Prepare for a new MARKER for non-NULL pointer. Reviewed-by: Alexander Mikhalitsyn Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-6-peterx@red= hat.com Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 2 +- migration/vmstate-types.c | 4 ++-- tests/unit/test-vmstate.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 350e62a55a..7396e38531 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -283,7 +283,7 @@ extern const VMStateInfo vmstate_info_uint64; extern const VMStateInfo vmstate_info_fd; =20 /** Put this in the stream when migrating a null pointer.*/ -#define VMS_NULLPTR_MARKER (0x30U) /* '0' */ +#define VMS_MARKER_PTR_NULL (0x30U) /* '0' */ extern const VMStateInfo vmstate_info_nullptr; =20 extern const VMStateInfo vmstate_info_cpudouble; diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 23f3433696..7622cf8f01 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -363,7 +363,7 @@ 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) { + if (qemu_get_byte(f) =3D=3D VMS_MARKER_PTR_NULL) { return true; } =20 @@ -377,7 +377,7 @@ static bool save_nullptr(QEMUFile *f, void *pv, size_t = size, =20 { if (pv =3D=3D NULL) { - qemu_put_byte(f, VMS_NULLPTR_MARKER); + qemu_put_byte(f, VMS_MARKER_PTR_NULL); return true; } =20 diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 6a42cc1a4e..dae15786aa 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -620,7 +620,7 @@ static void test_arr_ptr_str_no0_load(void) =20 static uint8_t wire_arr_ptr_0[] =3D { 0x00, 0x00, 0x00, 0x00, - VMS_NULLPTR_MARKER, + VMS_MARKER_PTR_NULL, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, QEMU_VM_EOF --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972245; cv=none; d=zohomail.com; s=zohoarc; b=f7Mqvx7x4XGVTW4/wyctjPRHR7Xlh5bscQjdq5vCrGyTCs5wMOHVRIe+126fo8sC/k/vXXCazcmuR+mU4HEZFgIo1k1MeqtELQtDEaIfszHuPJc5YGiJsV/QyacPU16R3sbTstfQJ8dssNb+tjiWOMLUY3vWQcAuS2MmKAsKL2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972245; 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=QtD9R39osz5Yw6zLx6fAJZEvdDrA61iRI14Z4AjFJ4o=; b=oBJD/9xDcCOMz0Yfz7MJplbl0UAD0p+HBJCH+bqLI+S36zJaXxE436Js9gl49cet1UM23Fb5JhUkJ0X5Bsjevgm05uWAkl0b3d8qFDvKtpBZnwvufS3fDDWK7gVaq+GeuWhT5EqwUk+TaZubdiVvFhA/T0agXvFkdUTnMQMEJ60= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972245740628.992924504269; Thu, 23 Apr 2026 12:24:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdR-0007Iw-Ln; Thu, 23 Apr 2026 15:22:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcf-0004b9-BB for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:02 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcd-0002Hm-KR for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:01 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9E8596A895; Thu, 23 Apr 2026 19:20:45 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 68639593A3; Thu, 23 Apr 2026 19:20:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ALqNDQxx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QtD9R39osz5Yw6zLx6fAJZEvdDrA61iRI14Z4AjFJ4o=; b=rNAXuRoBklZ+75BBhEHndV6JLBQ33xVsBJ2ZG36875NFaFlHSGurFn/UyRFK8T6kOynCWn C2+fSxuKmG/zCWH8Sjovp2LJbdNp9TIwwb/8kBoVfPF9C1f0tBfqC2K+oo0fdcV3OLlg6Y PzckwjO1027/W2QFtbtuvIoR/ZGuw9s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QtD9R39osz5Yw6zLx6fAJZEvdDrA61iRI14Z4AjFJ4o=; b=iez0f+7PgTF3m3LxR7WmCa429+RAVQZvNLj6tOJv63l+othUuzRl/KLoE3ePswLKVZThid ez8mv0AyLXWqMsBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=rNAXuRoB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=iez0f+7P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QtD9R39osz5Yw6zLx6fAJZEvdDrA61iRI14Z4AjFJ4o=; b=rNAXuRoBklZ+75BBhEHndV6JLBQ33xVsBJ2ZG36875NFaFlHSGurFn/UyRFK8T6kOynCWn C2+fSxuKmG/zCWH8Sjovp2LJbdNp9TIwwb/8kBoVfPF9C1f0tBfqC2K+oo0fdcV3OLlg6Y PzckwjO1027/W2QFtbtuvIoR/ZGuw9s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QtD9R39osz5Yw6zLx6fAJZEvdDrA61iRI14Z4AjFJ4o=; b=iez0f+7PgTF3m3LxR7WmCa429+RAVQZvNLj6tOJv63l+othUuzRl/KLoE3ePswLKVZThid ez8mv0AyLXWqMsBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , Juraj Marcin Subject: [PULL 29/43] vmstate: Introduce vmstate_save_field_with_vmdesc() Date: Thu, 23 Apr 2026 16:19:43 -0300 Message-ID: <20260423191958.1440-30-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid,suse.de:email]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 9E8596A895 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972246084158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Introduce a helper to do both the JSON blob generations and save vmstate. This further shrinks the function a bit. More importantly, we'll need to save two fields in one loop very soon in the future with the JSON blob. Reviewed-by: Alexander Mikhalitsyn Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-7-peterx@red= hat.com Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 05badef42f..b274204e66 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -514,6 +514,35 @@ static bool vmstate_save_field(QEMUFile *f, void *pv, = size_t size, return true; } =20 +/* + * Save a whole VMSD field, including its JSON blob separately when @vmdesc + * is specified. + */ +static inline bool +vmstate_save_field_with_vmdesc(QEMUFile *f, void *pv, size_t size, + const VMStateDescription *vmsd, + const VMStateField *field, JSONWriter *vmde= sc, + int i, int max, Error **errp) +{ + uint64_t old_offset, written_bytes; + bool ok; + + vmsd_desc_field_start(vmsd, vmdesc, field, i, max); + + old_offset =3D qemu_file_transferred(f); + ok =3D vmstate_save_field(f, pv, size, field, vmdesc, errp); + written_bytes =3D qemu_file_transferred(f) - old_offset; + + vmsd_desc_field_end(vmsd, vmdesc, field, written_bytes); + + if (!ok) { + error_prepend(errp, "Save of field %s/%s failed: ", + vmsd->name, field->name); + } + + return ok; +} + static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vms= d, void *opaque, JSONWriter *vmdesc, int version_id, Error **errp) @@ -542,7 +571,6 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, void *first_elem =3D opaque + field->offset; int i, n_elems =3D vmstate_n_elems(opaque, field); int size =3D vmstate_size(opaque, field); - uint64_t old_offset, written_bytes; JSONWriter *vmdesc_loop =3D vmdesc; bool is_prev_null =3D false; =20 @@ -559,7 +587,6 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, /* maximum number of elements to compress in the JSON blob= */ int max_elems =3D vmsd_can_compress(field) ? (n_elems - i)= : 1; =20 - old_offset =3D qemu_file_transferred(f); if (field->flags & VMS_ARRAY_OF_POINTER) { assert(curr_elem); curr_elem =3D *(void **)curr_elem; @@ -606,15 +633,9 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMS= tateDescription *vmsd, } } =20 - vmsd_desc_field_start(vmsd, vmdesc_loop, inner_field, - i, max_elems); - - ok =3D vmstate_save_field(f, curr_elem, size, inner_field, - vmdesc_loop, errp); - - written_bytes =3D qemu_file_transferred(f) - old_offset; - vmsd_desc_field_end(vmsd, vmdesc_loop, inner_field, - written_bytes); + ok =3D vmstate_save_field_with_vmdesc(f, curr_elem, size, = vmsd, + inner_field, vmdesc_lo= op, + i, max_elems, errp); =20 /* If we used a fake temp field.. free it now */ if (is_null) { @@ -622,8 +643,6 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, } =20 if (!ok) { - error_prepend(errp, "Save of field %s/%s failed: ", - vmsd->name, field->name); goto out; } =20 --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972241; cv=none; d=zohomail.com; s=zohoarc; b=NbHBnX4sP7BD8W2creU5t7a0tZCeVZSr+S8eLm+l5i+DET32hgSnaHUuNh1GUjokX2YlQbr1Lsw3EHjziN1a1XcdVV/TDBBkqQYtwqi1sAcQw/IptSnTgne+beg37Xrp+b2WJImP0huaF5cMSMJcAeapiOtFVTqfQ4PxW3WKYn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972241; 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=cEY8XD3xBrJLvWZZxM6SWztn1MCt3QZRKtvPcKEo8uk=; b=IGe1GC2IeIRT8O06GPMEJ96TOG+KyMnB7U9lU9CUgWJYTKbsthxCig98EMrFowrxL/iYiD16IqQCRdO41JPqLm4MvOTGbm+jJ9Nut55+MwW2JgvANNOytvYGCWz0wFe7y6CMCWvVJ17uh6RupbREv3lAZ4OXfLhhMLzzgWaZOHs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972241945452.8613528030029; Thu, 23 Apr 2026 12:24:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdJ-0006AN-Es; Thu, 23 Apr 2026 15:22:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcm-0004jX-5D for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:11 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcj-0002Ji-TC for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:07 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 465876A8AB; Thu, 23 Apr 2026 19:20:47 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 097BF593A3; Thu, 23 Apr 2026 19:20:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mDj4MQ1x6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972047; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cEY8XD3xBrJLvWZZxM6SWztn1MCt3QZRKtvPcKEo8uk=; b=IGMohvtOH5DUa+hN+f0aQzeMICyN7UZmmviOIUpmUNCop9aSiJRBQvpixlxsVg9RvH2dtP MorXgwpSr8PU7kzt06XuwQEJEYkeab8jajan9mGWzKyFDISvManHzEIoea9DOXNPNbkh5h Nf1ImxUPldQcw7yJ5/equz3uZO+usZQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972047; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cEY8XD3xBrJLvWZZxM6SWztn1MCt3QZRKtvPcKEo8uk=; b=wMVwALrUh4v++CbqwZx6Ye7u9WydyDriXrIIua7e4uKHUJWIaxgIMIIXzqwK5k59kEBz4H /8a61Z98tJVgBwBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972047; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cEY8XD3xBrJLvWZZxM6SWztn1MCt3QZRKtvPcKEo8uk=; b=IGMohvtOH5DUa+hN+f0aQzeMICyN7UZmmviOIUpmUNCop9aSiJRBQvpixlxsVg9RvH2dtP MorXgwpSr8PU7kzt06XuwQEJEYkeab8jajan9mGWzKyFDISvManHzEIoea9DOXNPNbkh5h Nf1ImxUPldQcw7yJ5/equz3uZO+usZQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972047; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cEY8XD3xBrJLvWZZxM6SWztn1MCt3QZRKtvPcKEo8uk=; b=wMVwALrUh4v++CbqwZx6Ye7u9WydyDriXrIIua7e4uKHUJWIaxgIMIIXzqwK5k59kEBz4H /8a61Z98tJVgBwBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , Juraj Marcin Subject: [PULL 30/43] vmstate: Allow vmstate_info_nullptr to emit non-NULL markers Date: Thu, 23 Apr 2026 16:19:44 -0300 Message-ID: <20260423191958.1440-31-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972244039154100 Content-Type: text/plain; charset="utf-8" From: Peter Xu We used to have one vmstate called "nullptr" which is only used to generate one-byte hint to say one pointer is NULL. Let's extend its use so that it will generate another byte to say the pointer is non-NULL. With that, the name of the info struct (or functions) do not apply anymore. Update correspondingly. Update analyze-migration.py to work with the new layout. No functional change intended yet. Reviewed-by: Fabiano Rosas Reviewed-by: Alexander Mikhalitsyn Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-8-peterx@red= hat.com Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 9 +++++++-- migration/vmstate-types.c | 34 ++++++++++++++++------------------ migration/vmstate.c | 25 +++++++++++++------------ scripts/analyze-migration.py | 22 ++++++++++++---------- 4 files changed, 48 insertions(+), 42 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 7396e38531..492069b8d2 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -282,9 +282,14 @@ extern const VMStateInfo vmstate_info_uint32; extern const VMStateInfo vmstate_info_uint64; extern const VMStateInfo vmstate_info_fd; =20 -/** Put this in the stream when migrating a null pointer.*/ +/* + * Put this in the stream when migrating a pointer to reflect either a NULL + * or valid pointer. + */ #define VMS_MARKER_PTR_NULL (0x30U) /* '0' */ -extern const VMStateInfo vmstate_info_nullptr; +#define VMS_MARKER_PTR_VALID (0x31U) /* '1' */ + +extern const VMStateInfo vmstate_info_ptr_marker; =20 extern const VMStateInfo vmstate_info_cpudouble; =20 diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 7622cf8f01..b31689fc3c 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -359,36 +359,34 @@ const VMStateInfo vmstate_info_fd =3D { .save =3D save_fd, }; =20 -static bool load_nullptr(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, Error **errp) +static bool load_ptr_marker(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, Error **errp) =20 { - if (qemu_get_byte(f) =3D=3D VMS_MARKER_PTR_NULL) { + int byte =3D qemu_get_byte(f); + + if (byte =3D=3D VMS_MARKER_PTR_NULL || byte =3D=3D VMS_MARKER_PTR_VALI= D) { + /* TODO: process PTR_VALID case */ return true; } =20 - error_setg(errp, "vmstate: load_nullptr expected VMS_NULLPTR_MARKER"); + error_setg(errp, "%s: unexpected ptr marker: %d", __func__, byte); return false; } =20 -static bool save_nullptr(QEMUFile *f, void *pv, size_t size, - const VMStateField *field, JSONWriter *vmdesc, - Error **errp) +static bool save_ptr_marker(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_MARKER_PTR_NULL); - return true; - } - - error_setg(errp, "vmstate: save_nullptr must be called with pv =3D=3D = NULL"); - return false; + qemu_put_byte(f, pv ? VMS_MARKER_PTR_VALID : VMS_MARKER_PTR_NULL); + return true; } =20 -const VMStateInfo vmstate_info_nullptr =3D { - .name =3D "nullptr", - .load =3D load_nullptr, - .save =3D save_nullptr, +const VMStateInfo vmstate_info_ptr_marker =3D { + .name =3D "ptr-marker", + .load =3D load_ptr_marker, + .save =3D save_ptr_marker, }; =20 /* 64 bit unsigned int. See that the received value is the same than the o= ne diff --git a/migration/vmstate.c b/migration/vmstate.c index b274204e66..b333aa1744 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -55,12 +55,12 @@ vmstate_field_exists(const VMStateDescription *vmsd, co= nst VMStateField *field, } =20 /* - * Create a fake nullptr field when there's a NULL pointer detected in the + * Create a ptr marker field when there's a NULL pointer detected in the * array of a VMS_ARRAY_OF_POINTER VMSD field. It's needed because we * can't dereference the NULL pointer. */ static const VMStateField * -vmsd_create_fake_nullptr_field(const VMStateField *field) +vmsd_create_ptr_marker_field(const VMStateField *field) { VMStateField *fake =3D g_new0(VMStateField, 1); =20 @@ -71,12 +71,12 @@ vmsd_create_fake_nullptr_field(const VMStateField *fiel= d) fake->name =3D field->name; fake->version_id =3D field->version_id; =20 - /* Do not need "field_exists" check as it always exists (which is null= ) */ + /* Do not need "field_exists" check as it always exists */ fake->field_exists =3D NULL; =20 - /* See vmstate_info_nullptr - use 1 byte to represent nullptr */ + /* See vmstate_info_ptr_marker - use 1 byte to represent ptr status */ fake->size =3D 1; - fake->info =3D &vmstate_info_nullptr; + fake->info =3D &vmstate_info_ptr_marker; fake->flags =3D VMS_SINGLE; =20 /* All the rest fields shouldn't matter.. */ @@ -278,7 +278,7 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescri= ption *vmsd, * an array of pointers), use null placeholder and do * not follow. */ - inner_field =3D vmsd_create_fake_nullptr_field(field); + inner_field =3D vmsd_create_ptr_marker_field(field); } else { inner_field =3D field; } @@ -583,26 +583,27 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VM= StateDescription *vmsd, for (i =3D 0; i < n_elems; i++) { void *curr_elem =3D first_elem + size * i; const VMStateField *inner_field; - bool is_null; /* maximum number of elements to compress in the JSON blob= */ int max_elems =3D vmsd_can_compress(field) ? (n_elems - i)= : 1; + bool use_marker_field, is_null; =20 if (field->flags & VMS_ARRAY_OF_POINTER) { assert(curr_elem); curr_elem =3D *(void **)curr_elem; } =20 - if (!curr_elem && size) { + is_null =3D !curr_elem && size; + use_marker_field =3D is_null; + + if (use_marker_field) { /* * If null pointer found (which should only happen in * an array of pointers), use null placeholder and do * not follow. */ - inner_field =3D vmsd_create_fake_nullptr_field(field); - is_null =3D true; + inner_field =3D vmsd_create_ptr_marker_field(field); } else { inner_field =3D field; - is_null =3D false; } =20 /* @@ -638,7 +639,7 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, i, max_elems, errp); =20 /* If we used a fake temp field.. free it now */ - if (is_null) { + if (use_marker_field) { g_clear_pointer((gpointer *)&inner_field, g_free); } =20 diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py index e81deab8f9..1771ff781b 100755 --- a/scripts/analyze-migration.py +++ b/scripts/analyze-migration.py @@ -469,26 +469,26 @@ def __init__(self, desc, file): super(VMSDFieldIntLE, self).__init__(desc, file) self.dtype =3D ' (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972234563158.33766605596338; Thu, 23 Apr 2026 12:23:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcs-0004qo-BL; Thu, 23 Apr 2026 15:22:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcL-0003Bw-9j for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:41 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcJ-00027I-Bg for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:41 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E4C285BD8F; Thu, 23 Apr 2026 19:20:48 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A6E5B593A3; Thu, 23 Apr 2026 19:20:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GIN6HA9x6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972049; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GSE7um/bB6HXlabEMCP8ZpFG/3SzyZrOvtKbDelG4/g=; b=o2J3aGfmZrO8yh6aDcv9ff7buX3QlbDEBonPG7UnG0wPxMI2WYpIZ/sKGo/cV7r+DCr2EE +PjBPaza5Tz76micM2Nc6oiW054pRiXAmZpg5N+/bH0Fo1llj18xtrsQ/6YD2oEczVDtrl 54mkQAGlaD4bikw+kZUB9k6ELQnFXlQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972049; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GSE7um/bB6HXlabEMCP8ZpFG/3SzyZrOvtKbDelG4/g=; b=/4FPKCk+YBvFb24jd+ChoIULklyhObYhr3lRxBwy9ncCWhUV8t08eIDCtiSbuQNbNiaDWC qfysEbH6ONqi4BAg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RvJIVEsP; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0bwMSfnS DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972048; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GSE7um/bB6HXlabEMCP8ZpFG/3SzyZrOvtKbDelG4/g=; b=RvJIVEsPBlRoKPePNWvKgbxYG0xvvLra6kYvpIy5GxvvSZKqapamBD4S3rCOw1GPF+7h12 bcSX6wIOlNWYCqlpWLAO8F3iFN1HsMS33fuJZk/NX/eEm/1VUt0oRIOSiWV7DqUiKkM4LP GjxyOMB0KWHwdtY+e2i4nqHGJq9lF9o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972048; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GSE7um/bB6HXlabEMCP8ZpFG/3SzyZrOvtKbDelG4/g=; b=0bwMSfnS4ePHW0wIZpOdQJb3k/ww/47H3kZm04bZV2Oo0Yb41z4iAPljC3VZa+RkSSxZ4z 8jQzSHHhEHpGCzDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , Juraj Marcin Subject: [PULL 31/43] vmstate: Implement load of ptr marker in vmstate core Date: Thu, 23 Apr 2026 16:19:45 -0300 Message-ID: <20260423191958.1440-32-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: E4C285BD8F X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972235883154100 Content-Type: text/plain; charset="utf-8" From: Peter Xu The loader side of ptr marker is pretty straightforward, instead of playing the inner_field trick, just do the load manually assuming the marker layout is a stable ABI (which it is true already). This will remove some logic while loading VMSD, and hopefully it makes it slightly easier to read. Unfortunately, we still need to keep the sender side because of the JSON blob we're maintaining.. This paves way for future processing of non-NULL markers as well. When at it, not check "size" anymore for existing NULL markers, and move it under the same VMS_ARRAY_OF_POINTER section because that's the only place that NULL marker can happen (which guarantess size=3D=3Dhost ptr size, whic= h is non-zero). Reviewed-by: Fabiano Rosas Reviewed-by: Alexander Mikhalitsyn Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-9-peterx@red= hat.com Signed-off-by: Fabiano Rosas --- migration/vmstate-types.c | 12 ++++------ migration/vmstate.c | 46 ++++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index b31689fc3c..ae465c5c2c 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -363,14 +363,10 @@ static bool load_ptr_marker(QEMUFile *f, void *pv, si= ze_t size, const VMStateField *field, Error **errp) =20 { - int byte =3D qemu_get_byte(f); - - if (byte =3D=3D VMS_MARKER_PTR_NULL || byte =3D=3D VMS_MARKER_PTR_VALI= D) { - /* TODO: process PTR_VALID case */ - return true; - } - - error_setg(errp, "%s: unexpected ptr marker: %d", __func__, byte); + /* + * Load is done in vmstate core, see vmstate_ptr_marker_load(). + */ + g_assert_not_reached(); return false; } =20 diff --git a/migration/vmstate.c b/migration/vmstate.c index b333aa1744..47812eb882 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -142,6 +142,21 @@ static void vmstate_handle_alloc(void *ptr, const VMSt= ateField *field, } } =20 +static bool vmstate_ptr_marker_load(QEMUFile *f, bool *load_field, + Error **errp) +{ + int byte =3D qemu_get_byte(f); + + if (byte =3D=3D VMS_MARKER_PTR_NULL) { + /* When it's a null ptr marker, do not continue the load */ + *load_field =3D false; + return true; + } + + error_setg(errp, "Unexpected ptr marker: %d", byte); + return false; +} + static bool vmstate_pre_load(const VMStateDescription *vmsd, void *opaque, Error **errp) { @@ -264,30 +279,25 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDesc= ription *vmsd, } =20 for (i =3D 0; i < n_elems; i++) { - bool ok; + /* If we will process the load of field? */ + bool load_field =3D true; + bool ok =3D true; void *curr_elem =3D first_elem + size * i; - const VMStateField *inner_field; =20 if (field->flags & VMS_ARRAY_OF_POINTER) { curr_elem =3D *(void **)curr_elem; + if (!curr_elem) { + /* Read the marker instead of VMSD itself */ + if (!vmstate_ptr_marker_load(f, &load_field, errp)= ) { + trace_vmstate_load_field_error(field->name, + -EINVAL); + return false; + } + } } =20 - if (!curr_elem && size) { - /* - * If null pointer found (which should only happen in - * an array of pointers), use null placeholder and do - * not follow. - */ - inner_field =3D vmsd_create_ptr_marker_field(field); - } else { - inner_field =3D field; - } - - ok =3D vmstate_load_field(f, curr_elem, size, inner_field,= errp); - - /* If we used a fake temp field.. free it now */ - if (inner_field !=3D field) { - g_clear_pointer((gpointer *)&inner_field, g_free); + if (load_field) { + ok =3D vmstate_load_field(f, curr_elem, size, field, e= rrp); } =20 if (ok) { --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972253; cv=none; d=zohomail.com; s=zohoarc; b=PWQ4OGhQB1/DbkSIe3xrm3uICTmvHKgsh/DEii9IoQ6yl5Ef8byZyV0+KtmrVTG/RsFzW14Q3/ov4x3thglGr8CyRASTiXLloD+KEGpSTe977SzMqVYlduHW3zWsQoK54JUSSgZ0NFGCZMM33sp9ekQeoSWAbqfpCFfAsVD22Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972253; 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=CPuRrUsaEYWsuQOW5Bg2WU0kkK7920z9rqtJrvE9AB8=; b=msRBZWxozHoW/pSi22WMzaaFIz+dTEc74A5Js+3qewh8pqHcr8oIaueVHB7FScVxU30ww9Z0jr0yLac28j8G5yPiOewFP/lrnsjfXeAwa5Q4/FoG5Pf2uIlJd6B6gISxpm6wtOj2AZMtfrDsWpRniSPHMeaTv+/stOTNfxohFk8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177697225306446.667247583698895; Thu, 23 Apr 2026 12:24:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdL-0006RU-0c; Thu, 23 Apr 2026 15:22:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzct-00050P-Bj for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:16 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcp-0002PF-WC for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:15 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 905376A8E3; Thu, 23 Apr 2026 19:20:50 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 52646593A3; Thu, 23 Apr 2026 19:20:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sHfaBxFx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972050; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPuRrUsaEYWsuQOW5Bg2WU0kkK7920z9rqtJrvE9AB8=; b=gGzSVAFhRR5ZQSTYuNgsVFvd709hVdKH2dtEGhtGFwQS4V3Ze7Vgq9Yfx9icaOdesoRi4D WIjeDwO1OYBUlp9F3GM917NLT7b0xjygT99svQCHYB9ioO21MMfcxyq6GLHhAyhf/I8Ljq SS9pQUFSpHnpXdUnmHN00/5vQHpSS8s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972050; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPuRrUsaEYWsuQOW5Bg2WU0kkK7920z9rqtJrvE9AB8=; b=HwQjmtMPEhCf4PPx44uQpS4hu/6KnBNPZuEB+hzAlCs9JwlQQvc15smDJJJF/F2HoYAYWc 9DdBHeU2+IUPzHAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=gGzSVAFh; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=HwQjmtMP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972050; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPuRrUsaEYWsuQOW5Bg2WU0kkK7920z9rqtJrvE9AB8=; b=gGzSVAFhRR5ZQSTYuNgsVFvd709hVdKH2dtEGhtGFwQS4V3Ze7Vgq9Yfx9icaOdesoRi4D WIjeDwO1OYBUlp9F3GM917NLT7b0xjygT99svQCHYB9ioO21MMfcxyq6GLHhAyhf/I8Ljq SS9pQUFSpHnpXdUnmHN00/5vQHpSS8s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972050; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPuRrUsaEYWsuQOW5Bg2WU0kkK7920z9rqtJrvE9AB8=; b=HwQjmtMPEhCf4PPx44uQpS4hu/6KnBNPZuEB+hzAlCs9JwlQQvc15smDJJJF/F2HoYAYWc 9DdBHeU2+IUPzHAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , Juraj Marcin Subject: [PULL 32/43] vmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC Date: Thu, 23 Apr 2026 16:19:46 -0300 Message-ID: <20260423191958.1440-33-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; R_RATELIMIT(0.00)[to_ip_from(RLjefarcnsteocuw7wptuakujg)]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, suse.de:mid, suse.de:email, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Queue-Id: 905376A8E3 X-Spam-Score: -3.01 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972254211154100 Content-Type: text/plain; charset="utf-8" From: Peter Xu Introduce a new flag, VMS_ARRAY_OF_POINTER_AUTO_ALLOC, for VMSD field. It must be used together with VMS_ARRAY_OF_POINTER. It can be used to allow migration of an array of pointers where the pointers may point to NULLs. Note that we used to allow migration of a NULL pointer within an array that is being migrated. That corresponds to the code around vmstate_info_nullptr where we may get/put one byte showing that the element of an array is NULL. That usage is fine but very limited, it's because even if it will migrate a NULL pointer with a marker, it still works in a way that both src and dest QEMUs must know exactly which elements of the array are non-NULL, so instead of dynamically loading an array (which can have NULL pointers), it actually only verifies the known NULL pointers are still NULL pointers after migration. Also, in that case since dest QEMU knows exactly which element is NULL, which is not NULL, dest QEMU's device code will manage all allocations for the elements before invoking vmstate_load_vmsd(). That's not enough per evolving needs of new device states that may want to provide real dynamic array of pointers, like what Alexander proposed here with the NVMe device migration: https://lore.kernel.org/r/20260317102708.126725-1-alexander@mihalicyn.com This patch is an alternative approach to address the problem. Along with the flag, introduce two new macros: VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT{8|32}_ALLOC() Which will be used very soon in the NVMe series. Reviewed-by: Alexander Mikhalitsyn Tested-by: Alexander Mikhalitsyn Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-10-peterx@re= dhat.com Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 51 ++++++++++++- migration/savevm.c | 27 ++++++- migration/vmstate.c | 145 ++++++++++++++++++++++++++++++------ 3 files changed, 199 insertions(+), 24 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 492069b8d2..28e3640e60 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -161,8 +161,21 @@ enum VMStateFlags { * structure we are referencing to use. */ VMS_VSTRUCT =3D 0x8000, =20 + /* + * This is a sub-flag for VMS_ARRAY_OF_POINTER. When this flag is set, + * VMS_ARRAY_OF_POINTER must also be set. When set, it means array + * elements can contain either valid or NULL pointers, vmstate core + * will be responsible for synchronizing the pointer status, providing + * proper memory allocations on the pointer when it is populated on the + * source QEMU. It also means the user of the field must make sure all + * the elements in the array are NULL pointers before loading. This + * should also work with VMS_ALLOC when the array itself also needs to + * be allocated. + */ + VMS_ARRAY_OF_POINTER_AUTO_ALLOC =3D 0x10000, + /* Marker for end of list */ - VMS_END =3D 0x10000 + VMS_END =3D 0x20000, }; =20 typedef enum { @@ -580,6 +593,42 @@ extern const VMStateInfo vmstate_info_qlist; .offset =3D vmstate_offset_array(_s, _f, _type*, _n), \ } =20 +/* + * For migrating a dynamically allocated uint{8,32}-indexed array of + * pointers to structures (with NULL entries and with auto memory + * allocation). + * + * _type: type of structure pointed to + * _vmsd: VMSD for structure _type (when VMS_STRUCT is set) + * _info: VMStateInfo for _type (when VMS_STRUCT is not set) + * start: size of (_type) pointed to (for auto memory allocation) + */ +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT8_ALLOC(\ + _field, _state, _field_num, _version, _vmsd, _type) { \ + .name =3D (stringify(_field)), \ + .version_id =3D (_version), \ + .num_offset =3D vmstate_offset_value(_state, _field_num, uint8_t), \ + .vmsd =3D &(_vmsd), \ + .size =3D sizeof(_type), \ + .flags =3D VMS_POINTER | VMS_VARRAY_UINT8 | \ + VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ + VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ + .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ +} + +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC(\ + _field, _state, _field_num, _version, _vmsd, _type) { \ + .name =3D (stringify(_field)), \ + .version_id =3D (_version), \ + .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), \ + .vmsd =3D &(_vmsd), \ + .size =3D sizeof(_type), \ + .flags =3D VMS_POINTER | VMS_VARRAY_UINT32 | \ + VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ + VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ + .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ +} + #define VMSTATE_VARRAY_OF_POINTER_UINT32(_field, _state, _field_num, _vers= ion, _info, _type) { \ .name =3D (stringify(_field)), = \ .version_id =3D (_version), = \ diff --git a/migration/savevm.c b/migration/savevm.c index f5a6fd0c66..765df8ce2d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -869,8 +869,33 @@ static void vmstate_check(const VMStateDescription *vm= sd) if (field) { while (field->name) { if (field->flags & VMS_ARRAY_OF_POINTER) { - assert(field->size =3D=3D 0); + if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) { + /* + * Size must be provided because dest QEMU needs that + * info to know what to allocate + */ + assert(field->size || field->size_offset); + } else { + /* + * Otherwise size info isn't useful (because it's + * always the size of host pointer), detect accidental + * setup of sizes in this case. + */ + assert(field->size =3D=3D 0 && field->size_offset =3D= =3D 0); + } + /* + * VMS_ARRAY_OF_POINTER must be used only together with one + * of VMS_(V)ARRAY* flags. + */ + assert(field->flags & (VMS_ARRAY | VMS_VARRAY_INT32 | + VMS_VARRAY_UINT16 | VMS_VARRAY_UINT= 8 | + VMS_VARRAY_UINT32)); } + + if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) { + assert(field->flags & VMS_ARRAY_OF_POINTER); + } + if (field->flags & (VMS_STRUCT | VMS_VSTRUCT)) { /* Recurse to sub structures */ vmstate_check(field->vmsd); diff --git a/migration/vmstate.c b/migration/vmstate.c index 47812eb882..de2ad822e8 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -153,6 +153,12 @@ static bool vmstate_ptr_marker_load(QEMUFile *f, bool = *load_field, return true; } =20 + if (byte =3D=3D VMS_MARKER_PTR_VALID) { + /* We need to load the field right after the marker */ + *load_field =3D true; + return true; + } + error_setg(errp, "Unexpected ptr marker: %d", byte); return false; } @@ -234,6 +240,76 @@ static bool vmstate_post_load(const VMStateDescription= *vmsd, return true; } =20 +/* + * Try to prepare loading the next element, the object pointer to be put + * into @next_elem. When @next_elem is NULL, it means we should skip + * loading this element. + * + * Returns false for errors, in which case *errp will be set, migration + * must be aborted. + */ +static bool vmstate_load_next(QEMUFile *f, const VMStateField *field, + void *first_elem, void **next_elem, + int size, int i, Error **errp) +{ + bool auto_alloc =3D field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC; + void *ptr =3D first_elem + size * i, **pptr; + bool load_field; + + if (!(field->flags & VMS_ARRAY_OF_POINTER)) { + /* Simplest case, no pointer involved */ + *next_elem =3D ptr; + return true; + } + + /* + * We're loading an array of pointers, switch to use pptr to make it + * easier to read later + */ + pptr =3D (void **)ptr; + + /* + * If auto_alloc is on, making sure the user provided an array of NULL + * pointers to start with + */ + assert(!auto_alloc || *pptr =3D=3D NULL); + + /* + * When pointer is null, we must expect a ptr marker first. Use cases: + * + * (1) _AUTO_ALLOC implies a ptr marker will always exist, or, + * + * (2) the element on destination is NULL, which expects the src to se= nd a + * NULL-only marker. + * + * Here, checking against a NULL pointer will work for both. + */ + if (!*pptr) { + if (!vmstate_ptr_marker_load(f, &load_field, errp)) { + trace_vmstate_load_field_error(field->name, -EINVAL); + return false; + } + + /* + * If loading is needed, do pre-allocation first (otherwise keeping + * *pptr=3D=3DNULL to imply a skip below) + */ + if (load_field) { + /* Only applies when auto_alloc=3Don on the field */ + assert(auto_alloc); + /* + * NOTE: do not use vmstate_size() here, because we need the + * object size, not entry size of the array. + */ + *pptr =3D g_malloc0(field->size); + } + } + + /* Move the cursor to the next element for loading */ + *next_elem =3D *pptr; + return true; +} + bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id, Error **errp) { @@ -279,27 +355,22 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDesc= ription *vmsd, } =20 for (i =3D 0; i < n_elems; i++) { - /* If we will process the load of field? */ - bool load_field =3D true; - bool ok =3D true; - void *curr_elem =3D first_elem + size * i; + void *curr_elem; + bool ok; =20 - if (field->flags & VMS_ARRAY_OF_POINTER) { - curr_elem =3D *(void **)curr_elem; - if (!curr_elem) { - /* Read the marker instead of VMSD itself */ - if (!vmstate_ptr_marker_load(f, &load_field, errp)= ) { - trace_vmstate_load_field_error(field->name, - -EINVAL); - return false; - } - } + ok =3D vmstate_load_next(f, field, first_elem, &curr_elem, + size, i, errp); + if (!ok) { + return false; } =20 - if (load_field) { - ok =3D vmstate_load_field(f, curr_elem, size, field, e= rrp); + if (!curr_elem) { + /* Implies a skip */ + continue; } =20 + ok =3D vmstate_load_field(f, curr_elem, size, field, errp); + if (ok) { int ret =3D qemu_file_get_error(f); if (ret < 0) { @@ -397,6 +468,16 @@ static bool vmsd_can_compress(const VMStateField *fiel= d) return false; } =20 + if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) { + /* + * This may involve two VMSD fields to be saved, one for the + * marker to show if the pointer is NULL, followed by the real + * vmstate object. To make it simple at least for now, skip + * compression for this one. + */ + return false; + } + if (field->flags & VMS_STRUCT) { const VMStateField *sfield =3D field->vmsd->fields; while (sfield->name) { @@ -583,6 +664,12 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMS= tateDescription *vmsd, int size =3D vmstate_size(opaque, field); JSONWriter *vmdesc_loop =3D vmdesc; bool is_prev_null =3D false; + /* + * When this is enabled, it means we will always push a ptr + * marker first for each element saying if it's populated. + */ + bool use_dynamic_array =3D + field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC; =20 trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems= ); if (field->flags & VMS_POINTER) { @@ -603,14 +690,9 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMS= tateDescription *vmsd, } =20 is_null =3D !curr_elem && size; - use_marker_field =3D is_null; + use_marker_field =3D use_dynamic_array || is_null; =20 if (use_marker_field) { - /* - * If null pointer found (which should only happen in - * an array of pointers), use null placeholder and do - * not follow. - */ inner_field =3D vmsd_create_ptr_marker_field(field); } else { inner_field =3D field; @@ -657,6 +739,25 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMS= tateDescription *vmsd, goto out; } =20 + /* + * If we're using dynamic array and the element is + * populated, save the real object right after the marker. + */ + if (use_dynamic_array && curr_elem) { + /* + * NOTE: do not use vmstate_size() here because we want + * to save the real VMSD object now. + */ + ok =3D vmstate_save_field_with_vmdesc(f, curr_elem, + field->size, vmsd, + field, vmdesc_loop, + i, max_elems, errp= ); + + if (!ok) { + goto out; + } + } + /* Compressed arrays only care about the first element */ if (vmdesc_loop && max_elems > 1) { vmdesc_loop =3D NULL; --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972272; cv=none; d=zohomail.com; s=zohoarc; b=FOs1zFWDw9wcTSppCzkQwDfJNJiGFH1YKJUZ+yUFPDMDZohJCnCIX6djW9JriCUl0OVom9v5TazNzPdQCtPVwTN55FIXX+J8ILxI0KY2PqpPihghHJHP3j0I5xhYEoSAPrKaLDVsEuDw/cnxxFtGjhUNG9/UsJINlH5E6cWczSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972272; 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=19X46RwGFhFvW8EdV8DjKxaImRSBzz6vf350t61S6aE=; b=S81Af4RroJVrE/TZP68pDUUwjc5z75dVTazopsHSvqmIp+4HfN5Nd61eBmv1dtpOJdhTOj/DaICKD+GMFIaE3zVTZFnkJPjVRWO3ClyN6fQNaY+Z4UD9OktXJrG+wqYMzNOVHy9xfPmUkJNK5NMV9MeWV2JB5EUlNKmS8xz+ED8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177697227223799.00210148017766; Thu, 23 Apr 2026 12:24:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzcl-0004ef-U5; Thu, 23 Apr 2026 15:22:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcR-0003lL-OI for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:49 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcP-00028s-K7 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:47 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3CAAA5BD97; Thu, 23 Apr 2026 19:20:52 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F2031593A3; Thu, 23 Apr 2026 19:20:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SOPNLhJx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972052; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=19X46RwGFhFvW8EdV8DjKxaImRSBzz6vf350t61S6aE=; b=Q64HXixu/APX4mM0rpQRWF1Sir56/9oeSoqwfqEvtg/uyF7VsvLo4jXnyKz3Dg1mU5FOPw o3BmjOoZq4k+g3wLQnbn5h6QnIsZDQU+Z1xDOL0YjuK7tuDoFuemvifhYi98K55fuSYHxx mje684vhTPlTNHNk5+KWo+ygS7O1dVo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972052; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=19X46RwGFhFvW8EdV8DjKxaImRSBzz6vf350t61S6aE=; b=NvjPkTOHY19XrNc2FF4uAXmXZpQicbM8Ss9cgQHOb7PutKVzrtLdacLH1TqsyeyX58ZZmN pNnpPC+1hCOQwKDQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Q64HXixu; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=NvjPkTOH DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972052; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=19X46RwGFhFvW8EdV8DjKxaImRSBzz6vf350t61S6aE=; b=Q64HXixu/APX4mM0rpQRWF1Sir56/9oeSoqwfqEvtg/uyF7VsvLo4jXnyKz3Dg1mU5FOPw o3BmjOoZq4k+g3wLQnbn5h6QnIsZDQU+Z1xDOL0YjuK7tuDoFuemvifhYi98K55fuSYHxx mje684vhTPlTNHNk5+KWo+ygS7O1dVo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972052; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=19X46RwGFhFvW8EdV8DjKxaImRSBzz6vf350t61S6aE=; b=NvjPkTOHY19XrNc2FF4uAXmXZpQicbM8Ss9cgQHOb7PutKVzrtLdacLH1TqsyeyX58ZZmN pNnpPC+1hCOQwKDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , Juraj Marcin Subject: [PULL 33/43] vmstate: Stop checking size for nullptr compression Date: Thu, 23 Apr 2026 16:19:47 -0300 Message-ID: <20260423191958.1440-34-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; R_RATELIMIT(0.00)[to_ip_from(RLjefarcnsteocuw7wptuakujg)]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid, suse.de:dkim, suse.de:email, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 3CAAA5BD97 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972274189158500 Content-Type: text/plain; charset="utf-8" The NULL pointer marker code applies only to VMS_ARRAY_OF_POINTER, where the size is never NULL. Move the setting of is_null under VMS_ARRAY_OF_POINTER, so we can stop checking the size. Reviewed-by: Alexander Mikhalitsyn Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-11-peterx@re= dhat.com Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index de2ad822e8..2f13b48a37 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -682,14 +682,14 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VM= StateDescription *vmsd, const VMStateField *inner_field; /* maximum number of elements to compress in the JSON blob= */ int max_elems =3D vmsd_can_compress(field) ? (n_elems - i)= : 1; - bool use_marker_field, is_null; + bool use_marker_field, is_null =3D false; =20 if (field->flags & VMS_ARRAY_OF_POINTER) { assert(curr_elem); curr_elem =3D *(void **)curr_elem; + is_null =3D !curr_elem; } =20 - is_null =3D !curr_elem && size; use_marker_field =3D use_dynamic_array || is_null; =20 if (use_marker_field) { @@ -717,7 +717,7 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, =20 for (int j =3D i + 1; j < n_elems; j++) { void *elem =3D *(void **)(first_elem + size * j); - bool elem_is_null =3D !elem && size; + bool elem_is_null =3D !elem; =20 if (is_null !=3D elem_is_null) { max_elems =3D j - i; --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972265; cv=none; d=zohomail.com; s=zohoarc; b=VzP1YHAhgFN2g1lTAjwOAHenBSvWpqFdEJ3OneUWDC7CdDtyxLSTq6xvZuyco3m3GH285m2Tdh9EAeWRDDI+T5kx7Wuvam0+skLYrsmtQEOTzt7FjMchJhStGqYQjUgG/xX/tJO+jiTuXG08Nj0eaoJmSGzKtDsE+k5eBZtuDsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972265; 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=HvefdpONNcFqysntqs+juTRcEx4K1r24uMyjySuc3B4=; b=d/8B6Ag2RmsJnjNP9zD5Sqqhf+05n5JsvCpMGkXbGqKyHWyd7M6c9vk80fd3SQZ33R5yDs1h/r+ryTQNu2AntJgDQTupP/lzyAjQAUmjzXEDQqjX6KY/WZx68Wjsd6JA9AoLMQf3Cn5cvwM2B81wekU71o39i2/sHmFuRUALjwI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972265272493.26068819321165; Thu, 23 Apr 2026 12:24:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdL-0006a4-Ts; Thu, 23 Apr 2026 15:22:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzd0-0005FA-7z for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:25 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcx-0002TE-E6 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:20 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DC3C86A89D; Thu, 23 Apr 2026 19:20:53 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9D43C593A3; Thu, 23 Apr 2026 19:20:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qLgRGhRx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972054; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HvefdpONNcFqysntqs+juTRcEx4K1r24uMyjySuc3B4=; b=HfWpPyWVopg946KlLkNC1v7DYtrHkvWa4ki5W0wM6JfeCCs9ofHdWwSPjdjlgdd+ps5aS8 hA7dhLokseSV2vO//1ZLc5uorLB8ueB+iFsfNCz3UdZQcyQ9phZ9KxQgaSnYsdjrhR8Wwl yfmLnPkyEmsz+WgxYqkFLxcaXaUQMDo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972054; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HvefdpONNcFqysntqs+juTRcEx4K1r24uMyjySuc3B4=; b=84as9E81YOdwTP+XnBXGo3NLp0/8jnLyIVKjzEnmaC5DQnJSe+sOChWe3pv6tbbxJ/GkTN 0q/XwawXza4rz+Dg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972053; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HvefdpONNcFqysntqs+juTRcEx4K1r24uMyjySuc3B4=; b=D5MXxWtpZy2xg66vILptiBg1Fu9LBzIAuB4o8Sm9gsW+b81v5JK+mlll83TOSED0yzI582 TY7mpqpF1+YDuzg552/Exq+VmDXhq8hnMdHuIdYUMK0sAwLzW4fJhI1QzbYoTxKh3PQH8L kOKF5N7J+nRKw6G9KEt+992IAcq2xsM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972053; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HvefdpONNcFqysntqs+juTRcEx4K1r24uMyjySuc3B4=; b=kaYG5hGsYumIMgGwvSyaM2G8b+1iYKZ+7wRXyswl+Zi9697hZqtsm1HeM+30fu67hOjUh7 AsazX5xdDbXh6iBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Alexander Mikhalitsyn , Juraj Marcin Subject: [PULL 34/43] tests/unit/test-vmstate: add tests for VMS_ARRAY_OF_POINTER_AUTO_ALLOC Date: Thu, 23 Apr 2026 16:19:48 -0300 Message-ID: <20260423191958.1440-35-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972266212158500 Content-Type: text/plain; charset="utf-8" From: Alexander Mikhalitsyn Add tests for VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC. Signed-off-by: Alexander Mikhalitsyn [peterx: Removed two tests due to macro not used, rebase, fix warning] Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Link: https://lore.kernel.org/qemu-devel/20260401202844.673494-12-peterx@re= dhat.com Signed-off-by: Fabiano Rosas --- tests/unit/test-vmstate.c | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index dae15786aa..df1fb4c778 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -702,6 +702,88 @@ static void test_arr_ptr_prim_0_load(void) } } =20 +static uint8_t wire_arr_ptr_with_nulls[] =3D { + VMS_MARKER_PTR_VALID, + 0x00, 0x00, 0x00, 0x00, + VMS_MARKER_PTR_NULL, + VMS_MARKER_PTR_VALID, + 0x00, 0x00, 0x00, 0x02, + VMS_MARKER_PTR_VALID, + 0x00, 0x00, 0x00, 0x03, + QEMU_VM_EOF +}; + +typedef struct { + uint32_t ar_items_num; + TestStructTriv **ar; +} TestVArrayOfPtrToStuctWithNULLs; + +const VMStateDescription vmsd_arps_with_nulls =3D { + .name =3D "test/arps_with_nulls", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC( + ar, TestVArrayOfPtrToStuctWithNULLs, ar_items_num, + 0, vmsd_tst, TestStructTriv), + VMSTATE_END_OF_LIST() + } +}; + +static void test_arr_ptr_nulls_str_save(void) +{ + TestStructTriv ar[AR_SIZE] =3D { {.i =3D 0}, {.i =3D 1}, {.i =3D 2}, {= .i =3D 3} }; + TestVArrayOfPtrToStuctWithNULLs sample =3D {}; + int idx; + + sample.ar_items_num =3D AR_SIZE; + sample.ar =3D g_new0(TestStructTriv*, sample.ar_items_num); + sample.ar[0] =3D g_new0(TestStructTriv, 1); + *sample.ar[0] =3D ar[0]; + /* note, sample.ar[1] remains NULL */ + sample.ar[2] =3D g_new0(TestStructTriv, 1); + *sample.ar[2] =3D ar[2]; + sample.ar[3] =3D g_new0(TestStructTriv, 1); + *sample.ar[3] =3D ar[3]; + + save_vmstate(&vmsd_arps_with_nulls, &sample); + compare_vmstate(wire_arr_ptr_with_nulls, sizeof(wire_arr_ptr_with_null= s)); + + for (idx =3D 0; idx < AR_SIZE; ++idx) { + g_free(sample.ar[idx]); + } + g_free(sample.ar); +} + +static void test_arr_ptr_nulls_str_load(void) +{ + TestStructTriv ar_gt[AR_SIZE] =3D {{.i =3D 0}, {.i =3D 0}, {.i =3D 2},= {.i =3D 3} }; + TestVArrayOfPtrToStuctWithNULLs obj =3D {}; + int idx; + + obj.ar_items_num =3D AR_SIZE; + obj.ar =3D g_new0(TestStructTriv*, obj.ar_items_num); + + save_buffer(wire_arr_ptr_with_nulls, sizeof(wire_arr_ptr_with_nulls)); + SUCCESS(load_vmstate_one( + &vmsd_arps_with_nulls, &obj, 1, + wire_arr_ptr_with_nulls, sizeof(wire_arr_ptr_with_nulls))); + + for (idx =3D 0; idx < AR_SIZE; ++idx) { + if (idx =3D=3D 1) { + g_assert_cmpint((uintptr_t)(obj.ar[idx]), =3D=3D, 0); + } else { + /* compare the target array ar with the ground truth array ar_= gt */ + g_assert_cmpint(ar_gt[idx].i, =3D=3D, obj.ar[idx]->i); + } + } + + for (idx =3D 0; idx < AR_SIZE; ++idx) { + g_free(obj.ar[idx]); + } + g_free(obj.ar); +} + /* test QTAILQ migration */ typedef struct TestQtailqElement TestQtailqElement; =20 @@ -1568,6 +1650,10 @@ int main(int argc, char **argv) test_arr_ptr_prim_0_save); g_test_add_func("/vmstate/array/ptr/prim/0/load", test_arr_ptr_prim_0_load); + g_test_add_func("/vmstate/array/ptr-nulls/str/save", + test_arr_ptr_nulls_str_save); + g_test_add_func("/vmstate/array/ptr-nulls/str/load", + test_arr_ptr_nulls_str_load); g_test_add_func("/vmstate/qtailq/save/saveq", test_save_q); g_test_add_func("/vmstate/qtailq/load/loadq", test_load_q); g_test_add_func("/vmstate/gtree/save/savedomain", test_gtree_save_doma= in); --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972245; cv=none; d=zohomail.com; s=zohoarc; b=m9892PKWL1BYF/RKGQ0B75AJH37hU9wSp1VdEd+xPi0dsIHugV9X1ba1oecmKjyWs+0ratfNwVlewmCz9h4Bmp5k8gRKqbIAb0zFs+XV9B1dZB19LR0i/jcYrQH62IBxCEDcGi8QjATJ14dmrIdlSxO+UtQs86ReV7k0vMA4Bj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972245; 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=bsC0tAJU0vPUAdnXpmAN2YzSuLZ8Ne5Etd51mKJ9OnE=; b=mQEeM3cnJgadJPv9d+W5hqO5vStsswSpaLTAS6Fl2MIkrJ15XjplAnUGraDLNjfPx3GP2fpBKxAhW1j1M8xv3DwXu2TWPRxUIp1M+MoACoNnLzxgIrmnNiRPzfHtP9ivCLN3V7s9koLNcSLyKZHSnAdIv5Poh9wcY9Edg+Za4nk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972245293305.73779515739864; Thu, 23 Apr 2026 12:24:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdK-0006Qa-JI; Thu, 23 Apr 2026 15:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzd7-0005PX-Vr for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:31 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzd5-0002Tv-Ay for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:28 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 566AB6A8B0; Thu, 23 Apr 2026 19:20:55 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 49699593A3; Thu, 23 Apr 2026 19:20:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kCaoBRZx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972055; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bsC0tAJU0vPUAdnXpmAN2YzSuLZ8Ne5Etd51mKJ9OnE=; b=JpIV7OW1MnIZkmAFwYZOyVotq/KrMRFP2Dk9JMty+LMdFKiKKWpm7EvkWFnG9Ixpw7XqKS GNqg0rZ7MquIlSWh2juHkP7zdUD8WioEZVHgE/pA8pRJn4+BLy2jzJQsOjNviqXFhkwQKu pfUlYJPBwuxz0PGYVw/0E5poccUmR1Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972055; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bsC0tAJU0vPUAdnXpmAN2YzSuLZ8Ne5Etd51mKJ9OnE=; b=zyolQZB/q8PtIQk5sdD1mJbyuuqDzQ0/hB7BfbTrBnkQdzfdjaXmrDEQK7cSu6ui2c1V/y 5fZaZ5HzjOZ1D2DA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=JpIV7OW1; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="zyolQZB/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972055; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bsC0tAJU0vPUAdnXpmAN2YzSuLZ8Ne5Etd51mKJ9OnE=; b=JpIV7OW1MnIZkmAFwYZOyVotq/KrMRFP2Dk9JMty+LMdFKiKKWpm7EvkWFnG9Ixpw7XqKS GNqg0rZ7MquIlSWh2juHkP7zdUD8WioEZVHgE/pA8pRJn4+BLy2jzJQsOjNviqXFhkwQKu pfUlYJPBwuxz0PGYVw/0E5poccUmR1Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972055; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bsC0tAJU0vPUAdnXpmAN2YzSuLZ8Ne5Etd51mKJ9OnE=; b=zyolQZB/q8PtIQk5sdD1mJbyuuqDzQ0/hB7BfbTrBnkQdzfdjaXmrDEQK7cSu6ui2c1V/y 5fZaZ5HzjOZ1D2DA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Trieu Huynh Subject: [PULL 35/43] migration: validate page_size in mapped-ram header before use Date: Thu, 23 Apr 2026 16:19:49 -0300 Message-ID: <20260423191958.1440-36-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:dkim,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 566AB6A8B0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972248017154100 Content-Type: text/plain; charset="utf-8" From: Trieu Huynh mapped_ram_read_header() reads page_size from the migration stream and stores it in MappedRamHeader, but does not validate that the value is non-zero before it is later used in parse_ramblock_mapped_ram(): num_pages =3D length / header.page_size; If a corrupted or malformed migration stream provides invalid, guest resumes either with corrupted memory or crashes unexpectedly (eg. page_size =3D 0) Add validation in mapped_ram_read_header() to reject invalid page_size values early and return an error instead of continuing with an invalid header. Steps to reproduce: Create a migration snapshot with mapped-ram enabled: (qemu) migrate_set_capability mapped-ram on (qemu) migrate file:/tmp/qemu-snapshots/snapshot.bin Modify the snapshot so that MappedRamHeader.page_size becomes diff with target psize. (0/512/8192/1GB). Restore the snapshot: (qemu) migrate_set_capability mapped-ram on (qemu) migrate_incoming file:/tmp/qemu-snapshots/snapshot.bin As-is: * [0]: Floating point exception (core dumped) * [512/8192]: Silent corruption * [1GB]: "post load hook failed for: kvm-tpr-opt" (EPERM) To-be: * All: qemu-system-x86_64: Migration mapped-ram header has invalid page_size [val] (expected 4096) Signed-off-by: Trieu Huynh Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260405094447.11347-1-viking4@gma= il.com Signed-off-by: Fabiano Rosas --- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 979751f61b..2046f16caa 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3088,6 +3088,12 @@ static bool mapped_ram_read_header(QEMUFile *file, M= appedRamHeader *header, } =20 header->page_size =3D be64_to_cpu(header->page_size); + if (header->page_size !=3D TARGET_PAGE_SIZE) { + error_setg(errp, "Migration mapped-ram header has invalid " + "page_size %" PRIu64 " (expected %d)", + header->page_size, TARGET_PAGE_SIZE); + return false; + } header->bitmap_offset =3D be64_to_cpu(header->bitmap_offset); header->pages_offset =3D be64_to_cpu(header->pages_offset); =20 --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972336; cv=none; d=zohomail.com; s=zohoarc; b=H0zdtMuAE0hQwS7AE/yIlZliwkx/4WhB3X7hCjj9/H0jfEh7UjiZWiU6yLfi+qhdMzmNBoUiZcrm0/avB/E6M3XUVxHcVeApGm1HV77DfRoxF+y7NhJrNxfOre5hJNT7R1/JKCcKBsEkB5oBZ8xwu/mTn6hVsI62ghEMZNMCqSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972336; 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=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=; b=DMXiT94VYGGkV9Cx9rIMTAUwbFzkkrW8UQwghJYjME3eBb1wZBE3mMD7hBfzr+8dgq77fuVIPvMitH+AhDwU6DoPJOxAUpZXaJdeO2CBhxfo5tM3vMzLOzuW2s6I4anNxzCWUb3ToR8wZ8+cHaNHGFMgQXnUD0q1H/buT13T/3c= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972336234507.65220490301544; Thu, 23 Apr 2026 12:25:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdO-0006vr-Us; Thu, 23 Apr 2026 15:22:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzdE-0005uc-7C for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:36 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzdB-0002VM-Qo for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:35 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 012C56A8B4; Thu, 23 Apr 2026 19:20:57 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B71A1593A3; Thu, 23 Apr 2026 19:20:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8OF2IBdx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972057; h=from:from:reply-to: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=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=; b=XQEfy1juH85LgKZZv6iSuBE8F1xm1+l659RfLkVe0OIc2hxwcQL8qEoYj8BeJj6K/OGhfm RyyImYIKYd6xH+P26TprReDhdjJsGLBWrEH0RKaidYiBQrv7aS2Bf0huYETAa3K9QGb/Pu fz4tBuAPh80Du5mnOdbwongJkO505OU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972057; h=from:from:reply-to: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=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=; b=EMut86uE2uFJ6aHGMIi42qR+myN554jrTlS/XZR5YNX7NjANWv726+3sj7rxvyqtTW6tQu 0V3vjyqQvTJZAACA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=XQEfy1ju; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EMut86uE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972057; h=from:from:reply-to: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=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=; b=XQEfy1juH85LgKZZv6iSuBE8F1xm1+l659RfLkVe0OIc2hxwcQL8qEoYj8BeJj6K/OGhfm RyyImYIKYd6xH+P26TprReDhdjJsGLBWrEH0RKaidYiBQrv7aS2Bf0huYETAa3K9QGb/Pu fz4tBuAPh80Du5mnOdbwongJkO505OU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972057; h=from:from:reply-to: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=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=; b=EMut86uE2uFJ6aHGMIi42qR+myN554jrTlS/XZR5YNX7NjANWv726+3sj7rxvyqtTW6tQu 0V3vjyqQvTJZAACA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Junjie Cao , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 36/43] io/channel: introduce qio_channel_pread{v, }_all{, _eof}() Date: Thu, 23 Apr 2026 16:19:50 -0300 Message-ID: <20260423191958.1440-37-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,intel.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Score: -3.51 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 012C56A8B4 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972337642154100 From: Junjie Cao qio_channel_pread() and qio_channel_preadv() perform a single positioned read and may return a short result. Callers that need all bytes currently have to open-code a retry loop or simply treat a short read as an error. Introduce four new helpers following the existing read_all / readv_all pattern: qio_channel_preadv_all_eof() -- retry loop; returns 1 on success, 0 on clean EOF, -1 on error. qio_channel_preadv_all() -- wraps _eof; treats early EOF as error; returns 0 / -1. qio_channel_pread_all_eof() -- single-buffer convenience wrapper around preadv_all_eof(). qio_channel_pread_all() -- single-buffer convenience wrapper around preadv_all(). These advance the file offset internally after each partial read. All four are marked coroutine_mixed_fn, consistent with the existing _all helpers. Suggested-by: Peter Xu Signed-off-by: Junjie Cao Reviewed-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 Acked-by: Daniel P. Berrang=C3=A9 Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-2-junjie.cao= @intel.com Signed-off-by: Fabiano Rosas --- include/io/channel.h | 92 ++++++++++++++++++++++++++++++++++++++++++++ io/channel.c | 91 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) diff --git a/include/io/channel.h b/include/io/channel.h index 1b02350437..47af409ede 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -634,6 +634,98 @@ ssize_t qio_channel_preadv(QIOChannel *ioc, const stru= ct iovec *iov, ssize_t qio_channel_pread(QIOChannel *ioc, void *buf, size_t buflen, off_t offset, Error **errp); =20 +/** + * qio_channel_preadv_all_eof: + * @ioc: the channel object + * @iov: the array of memory regions to read data into + * @niov: the length of the @iov array + * @offset: the starting offset in the channel to read from + * @errp: pointer to a NULL-initialized error object + * + * Reads @iov, possibly blocking or (if the channel is non-blocking) + * yielding from the current coroutine multiple times until the entire + * content is read. If end-of-file occurs immediately it is not an + * error, but if it occurs after data has been read it will return + * an error rather than a short-read. Otherwise behaves as + * qio_channel_preadv(). + * + * Returns: 1 if all bytes were read, 0 if end-of-file occurs + * without data, or -1 on error + */ +int coroutine_mixed_fn qio_channel_preadv_all_eof(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp); + +/** + * qio_channel_preadv_all: + * @ioc: the channel object + * @iov: the array of memory regions to read data into + * @niov: the length of the @iov array + * @offset: the starting offset in the channel to read from + * @errp: pointer to a NULL-initialized error object + * + * Reads @iov, possibly blocking or (if the channel is non-blocking) + * yielding from the current coroutine multiple times until the entire + * content is read. If end-of-file occurs before all requested data + * has been read, an error will be reported. Otherwise behaves as + * qio_channel_preadv(). + * + * Returns: 0 if all bytes were read, or -1 on error + */ +int coroutine_mixed_fn qio_channel_preadv_all(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp); + +/** + * qio_channel_pread_all_eof: + * @ioc: the channel object + * @buf: the memory region to read data into + * @buflen: the number of bytes to read into @buf + * @offset: the starting offset in the channel to read from + * @errp: pointer to a NULL-initialized error object + * + * Reads @buflen bytes, possibly blocking or (if the channel is + * non-blocking) yielding from the current coroutine multiple times + * until the entire content is read. If end-of-file occurs + * immediately it is not an error, but if it occurs after data has + * been read it will return an error rather than a short-read. + * Otherwise behaves as qio_channel_pread(). + * + * Returns: 1 if all bytes were read, 0 if end-of-file occurs + * without data, or -1 on error + */ +int coroutine_mixed_fn qio_channel_pread_all_eof(QIOChannel *ioc, + void *buf, + size_t buflen, + off_t offset, + Error **errp); + +/** + * qio_channel_pread_all: + * @ioc: the channel object + * @buf: the memory region to read data into + * @buflen: the number of bytes to read into @buf + * @offset: the starting offset in the channel to read from + * @errp: pointer to a NULL-initialized error object + * + * Reads @buflen bytes, possibly blocking or (if the channel is + * non-blocking) yielding from the current coroutine multiple times + * until the entire content is read. If end-of-file occurs before + * all requested data has been read, an error will be reported. + * Otherwise behaves as qio_channel_pread(). + * + * Returns: 0 if all bytes were read, or -1 on error + */ +int coroutine_mixed_fn qio_channel_pread_all(QIOChannel *ioc, + void *buf, + size_t buflen, + off_t offset, + Error **errp); + /** * qio_channel_shutdown: * @ioc: the channel object diff --git a/io/channel.c b/io/channel.c index cc02d997a4..52c1abfcbc 100644 --- a/io/channel.c +++ b/io/channel.c @@ -507,6 +507,97 @@ ssize_t qio_channel_pread(QIOChannel *ioc, void *buf, = size_t buflen, return qio_channel_preadv(ioc, &iov, 1, offset, errp); } =20 +int coroutine_mixed_fn qio_channel_preadv_all_eof(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp) +{ + int ret =3D -1; + struct iovec *local_iov =3D g_new(struct iovec, niov); + struct iovec *local_iov_head =3D local_iov; + unsigned int nlocal_iov =3D niov; + bool partial =3D false; + + nlocal_iov =3D iov_copy(local_iov, nlocal_iov, + iov, niov, + 0, iov_size(iov, niov)); + + while (nlocal_iov > 0) { + ssize_t len; + len =3D qio_channel_preadv(ioc, local_iov, nlocal_iov, offset, err= p); + + if (len =3D=3D QIO_CHANNEL_ERR_BLOCK) { + qio_channel_wait_cond(ioc, G_IO_IN); + continue; + } + + if (len =3D=3D 0) { + if (!partial) { + ret =3D 0; + goto cleanup; + } + error_setg(errp, + "Unexpected end-of-file before all data were read"); + goto cleanup; + } + + if (len < 0) { + goto cleanup; + } + + partial =3D true; + offset +=3D len; + iov_discard_front(&local_iov, &nlocal_iov, len); + } + + ret =3D 1; + + cleanup: + g_free(local_iov_head); + return ret; +} + +int coroutine_mixed_fn qio_channel_preadv_all(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp) +{ + int ret =3D qio_channel_preadv_all_eof(ioc, iov, niov, offset, errp); + + if (ret =3D=3D 0) { + error_setg(errp, + "Unexpected end-of-file before all data were read"); + return -1; + } + if (ret =3D=3D 1) { + return 0; + } + + return ret; +} + +int coroutine_mixed_fn qio_channel_pread_all_eof(QIOChannel *ioc, + void *buf, + size_t buflen, + off_t offset, + Error **errp) +{ + struct iovec iov =3D { .iov_base =3D buf, .iov_len =3D buflen }; + return qio_channel_preadv_all_eof(ioc, &iov, 1, offset, errp); +} + +int coroutine_mixed_fn qio_channel_pread_all(QIOChannel *ioc, + void *buf, + size_t buflen, + off_t offset, + Error **errp) +{ + struct iovec iov =3D { .iov_base =3D buf, .iov_len =3D buflen }; + return qio_channel_preadv_all(ioc, &iov, 1, offset, errp); +} + int qio_channel_shutdown(QIOChannel *ioc, QIOChannelShutdown how, Error **errp) --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972161; cv=none; d=zohomail.com; s=zohoarc; b=c6gOMaEpnpJQ537rboew2hRNlFrvWXzTLvY7lSmdTPoQdIJQmBN4R8CSloQaa8D/X/pMBv/JtuSluZmjDWDPcoPtEHdgYblSYcxW1LlGuk5pMC1kwMooTnVWGfUQ8gM3LWMOabKjrqu2Reuah6hLwuw/pYcRSPfmkC8IhKmF8/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972161; 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=GmWBn+PWgun7VfH09Qi3uCBSo1bZ1EKgN6Mqu3svIfM=; b=Mz4fgUqOWOZyJchMBVLAGTMAMdiBPa97ydfXmZYWbRPgtwiPVYTYVKc/q/sECa9jlC8sWT+1/aMjGrNwSzCg/AcJb9tqqYmHtTyK6tbS8P/wKvW2/+t/UKfcx0KveyCsG4Qyy8Mo3dA9D6ZxBLL33xInJ8dNccWyQ8RYny/VKbk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972161778891.8744884352191; Thu, 23 Apr 2026 12:22:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdB-0005Nf-Rd; Thu, 23 Apr 2026 15:22:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcX-00041k-FQ for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:53 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcV-0002AG-Kj for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:53 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6E0195BD73; Thu, 23 Apr 2026 19:20:58 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 62023593A3; Thu, 23 Apr 2026 19:20:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AHikCxlx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972058; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GmWBn+PWgun7VfH09Qi3uCBSo1bZ1EKgN6Mqu3svIfM=; b=aBbgE4Jhbsi6YZCrr8QAsh6x2yMG1B66DSugVDU+Z/26Ck6XVMBoEdskh6LsPtj+UuvltE SQfQkJqDpjzNo9jQgT4jZQbwTwfTTFQZO7HYDZBlqDGD2PecjwwhqkMD68GGpwQo0T64Z+ P3YcnJILHCJzIwZOba2vYpPVvQto9YI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972058; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GmWBn+PWgun7VfH09Qi3uCBSo1bZ1EKgN6Mqu3svIfM=; b=HljIdD+8BWd9YXy5rQoBDFyMrP6dxncEfy4HvO2KnW3yz9ZMCRvI74fpOzTdayxHPGsUSQ 9gpApERDUz6h4sCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972058; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GmWBn+PWgun7VfH09Qi3uCBSo1bZ1EKgN6Mqu3svIfM=; b=aBbgE4Jhbsi6YZCrr8QAsh6x2yMG1B66DSugVDU+Z/26Ck6XVMBoEdskh6LsPtj+UuvltE SQfQkJqDpjzNo9jQgT4jZQbwTwfTTFQZO7HYDZBlqDGD2PecjwwhqkMD68GGpwQo0T64Z+ P3YcnJILHCJzIwZOba2vYpPVvQto9YI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972058; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GmWBn+PWgun7VfH09Qi3uCBSo1bZ1EKgN6Mqu3svIfM=; b=HljIdD+8BWd9YXy5rQoBDFyMrP6dxncEfy4HvO2KnW3yz9ZMCRvI74fpOzTdayxHPGsUSQ 9gpApERDUz6h4sCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Junjie Cao Subject: [PULL 37/43] io/channel: introduce qio_channel_pwrite{v,}_all() Date: Thu, 23 Apr 2026 16:19:51 -0300 Message-ID: <20260423191958.1440-38-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,intel.com:email,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972163702158500 Content-Type: text/plain; charset="utf-8" From: Junjie Cao Add positioned write helpers that retry on short writes, matching the pread_all family from the previous patch. qio_channel_pwritev_all() -- retry loop; returns 0 on success, -1 on error. qio_channel_pwrite_all() -- single-buffer convenience wrapper. Signed-off-by: Junjie Cao Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-3-junjie.cao= @intel.com Signed-off-by: Fabiano Rosas --- include/io/channel.h | 41 +++++++++++++++++++++++++++++++++++++ io/channel.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/include/io/channel.h b/include/io/channel.h index 47af409ede..287d10cd6f 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -598,6 +598,47 @@ ssize_t qio_channel_pwritev(QIOChannel *ioc, const str= uct iovec *iov, ssize_t qio_channel_pwrite(QIOChannel *ioc, void *buf, size_t buflen, off_t offset, Error **errp); =20 +/** + * qio_channel_pwritev_all: + * @ioc: the channel object + * @iov: the array of memory regions to write data from + * @niov: the length of the @iov array + * @offset: the starting offset in the channel to write to + * @errp: pointer to a NULL-initialized error object + * + * Writes @iov, possibly blocking or (if the channel is non-blocking) + * yielding from the current coroutine multiple times until the entire + * content is written. Otherwise behaves as qio_channel_pwritev(). + * + * Returns: 0 if all bytes were written, or -1 on error + */ +int coroutine_mixed_fn qio_channel_pwritev_all(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp); + +/** + * qio_channel_pwrite_all: + * @ioc: the channel object + * @buf: the memory region to write data from + * @buflen: the number of bytes to write from @buf + * @offset: the starting offset in the channel to write to + * @errp: pointer to a NULL-initialized error object + * + * Writes @buflen bytes from @buf, possibly blocking or (if the + * channel is non-blocking) yielding from the current coroutine + * multiple times until the entire content is written. Otherwise + * behaves as qio_channel_pwrite(). + * + * Returns: 0 if all bytes were written, or -1 on error + */ +int coroutine_mixed_fn qio_channel_pwrite_all(QIOChannel *ioc, + const void *buf, + size_t buflen, + off_t offset, + Error **errp); + /** * qio_channel_preadv * @ioc: the channel object diff --git a/io/channel.c b/io/channel.c index 52c1abfcbc..2853dadb68 100644 --- a/io/channel.c +++ b/io/channel.c @@ -478,6 +478,54 @@ ssize_t qio_channel_pwrite(QIOChannel *ioc, void *buf,= size_t buflen, return qio_channel_pwritev(ioc, &iov, 1, offset, errp); } =20 +int coroutine_mixed_fn qio_channel_pwritev_all(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp) +{ + int ret =3D -1; + struct iovec *local_iov =3D g_new(struct iovec, niov); + struct iovec *local_iov_head =3D local_iov; + unsigned int nlocal_iov =3D niov; + + nlocal_iov =3D iov_copy(local_iov, nlocal_iov, + iov, niov, + 0, iov_size(iov, niov)); + + while (nlocal_iov > 0) { + ssize_t len; + + len =3D qio_channel_pwritev(ioc, local_iov, nlocal_iov, offset, er= rp); + + if (len =3D=3D QIO_CHANNEL_ERR_BLOCK) { + qio_channel_wait_cond(ioc, G_IO_OUT); + continue; + } + if (len < 0) { + goto cleanup; + } + + offset +=3D len; + iov_discard_front(&local_iov, &nlocal_iov, len); + } + + ret =3D 0; + cleanup: + g_free(local_iov_head); + return ret; +} + +int coroutine_mixed_fn qio_channel_pwrite_all(QIOChannel *ioc, + const void *buf, + size_t buflen, + off_t offset, + Error **errp) +{ + struct iovec iov =3D { .iov_base =3D (char *)buf, .iov_len =3D buflen = }; + return qio_channel_pwritev_all(ioc, &iov, 1, offset, errp); +} + ssize_t qio_channel_preadv(QIOChannel *ioc, const struct iovec *iov, size_t niov, off_t offset, Error **errp) { --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972315; cv=none; d=zohomail.com; s=zohoarc; b=A5kz4lX0IdNZ7mi9ucHUkneR4fLVxQ/hr0QOS0Gv7Esf1Xqbe72Bd1CiPaQPv2O8GREvDu1Wyd9mv4MG5WcUiFQJFUIcNUPBV+AGNqiIE7zDnHYXAfWdaoF2nKKSaVS+b9sbKgTOEt/+YU3E9BGhhsQmyPHScaGBapLt4S0GQNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972315; 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=/FKBYTvXSGjAZfvLVAh1z1tx4IgLgeuK7f7Tnrh6f+4=; b=LEgqvW7XLzXR77r7RjvzXi58N4nzaxLgpzmTVzrz5K8W9NVxr2+0McWYjckesbGpSTllF1k2yziDAlyucDq4lmkYSUNZUeX+IOY98tfYiUs7g1i5jP6qcAldUpJogOF4WncTbD2I+O18KaF32zyjFB9Wf7gvE5pHzJRcY0YU4p0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17769723151809.698524883691675; Thu, 23 Apr 2026 12:25:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdN-0006gQ-3K; Thu, 23 Apr 2026 15:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzdK-0006Om-5M for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:42 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzdI-0002Vw-4h for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:41 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 182176A8A0; Thu, 23 Apr 2026 19:21:00 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CEDC7593A3; Thu, 23 Apr 2026 19:20:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iDU6Jhpx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:20:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972060; h=from:from:reply-to: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=/FKBYTvXSGjAZfvLVAh1z1tx4IgLgeuK7f7Tnrh6f+4=; b=pcUfbC2a+AG2sgMrsWDueQc4p513eGgT8sZPE1139usEC/F/BzhC/YRMKlXS94xbY9Dc6z T1GGBLSVfKUpYj0+v7wvKrsSTbA52BAuRejeD+jFWGS0i29/VeS7WNkIVn+sZ1jOpSegRD LU2efdJ/AWS3GCeRjX56L8+EOHQjdAk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972060; h=from:from:reply-to: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=/FKBYTvXSGjAZfvLVAh1z1tx4IgLgeuK7f7Tnrh6f+4=; b=3jwYFQsDTiJa9Bk0MGRYLr8wAKu+lie4+KdfvRtE8mZCKVw8dLT8xINbp29Y5ECnoKAUwN yFrJ8PR0kJXGUlDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972060; h=from:from:reply-to: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=/FKBYTvXSGjAZfvLVAh1z1tx4IgLgeuK7f7Tnrh6f+4=; b=pcUfbC2a+AG2sgMrsWDueQc4p513eGgT8sZPE1139usEC/F/BzhC/YRMKlXS94xbY9Dc6z T1GGBLSVfKUpYj0+v7wvKrsSTbA52BAuRejeD+jFWGS0i29/VeS7WNkIVn+sZ1jOpSegRD LU2efdJ/AWS3GCeRjX56L8+EOHQjdAk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972060; h=from:from:reply-to: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=/FKBYTvXSGjAZfvLVAh1z1tx4IgLgeuK7f7Tnrh6f+4=; b=3jwYFQsDTiJa9Bk0MGRYLr8wAKu+lie4+KdfvRtE8mZCKVw8dLT8xINbp29Y5ECnoKAUwN yFrJ8PR0kJXGUlDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Junjie Cao , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 38/43] migration/file: fix type mismatch and NULL deref in multifd_file_recv_data Date: Thu, 23 Apr 2026 16:19:52 -0300 Message-ID: <20260423191958.1440-39-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, suse.de:mid, suse.de:email, intel.com:email] X-Spam-Score: -3.30 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972316416158501 From: Junjie Cao multifd_file_recv_data() stores the return value of qio_channel_pread() (ssize_t) in a size_t variable. On I/O error the -1 return value wraps to SIZE_MAX, producing a nonsensical read size in the error message. More critically, a short read (0 <=3D ret < data->size) is possible when the migration file is truncated. In that case qio_channel_pread() returns a non-negative value without setting *errp. The function then calls error_prepend(errp, ...) which dereferences *errp -- a NULL pointer -- crashing QEMU. Fix both issues by switching to qio_channel_pread_all() introduced in a previous patch, which retries on short reads and treats end-of-file as an error, so the caller no longer needs to check the byte count manually. Add ERRP_GUARD() so that error_prepend() works correctly even when errp is &error_fatal or NULL. Fixes: a49d15a38d3d ("migration/multifd: Support incoming mapped-ram stream= format") Suggested-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Junjie Cao Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-4-junjie.cao= @intel.com Signed-off-by: Fabiano Rosas --- migration/file.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/migration/file.c b/migration/file.c index 962b4b3a1b..4e2524e548 100644 --- a/migration/file.c +++ b/migration/file.c @@ -256,15 +256,16 @@ int file_write_ramblock_iov(QIOChannel *ioc, const st= ruct iovec *iov, =20 int multifd_file_recv_data(MultiFDRecvParams *p, Error **errp) { + ERRP_GUARD(); MultiFDRecvData *data =3D p->data; - size_t ret; + int ret; =20 - ret =3D qio_channel_pread(p->c, (char *) data->opaque, - data->size, data->file_offset, errp); - if (ret !=3D data->size) { + ret =3D qio_channel_pread_all(p->c, (char *) data->opaque, + data->size, data->file_offset, errp); + if (ret !=3D 0) { error_prepend(errp, - "multifd recv (%u): read 0x%zx, expected 0x%zx", - p->id, ret, data->size); + "multifd recv (%u): ", + p->id); return -1; } =20 --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972245; cv=none; d=zohomail.com; s=zohoarc; b=CrjdYFHFlrgAy29k8cIyPHOi4i++bb1O1KeHYpCxVWOCU/+HBCVIG3Nr/5qeSncz60roPisworUoHNhBMuO/jLm3rP4qLAkyOn45fQyIopZuSnFrXJtcPFmyImeHOSuxrp9FJEYIm8SNjJjsiG+dhI1OCHYAdmGNrFGIB7D5xIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972245; 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=K9h1RGVUintiLczHJ0lwPb10uCyBb8GYOF4K4VgEEz8=; b=HIHWmut6AAZfoorjTJEgg9D+cN/nygXpYZJ1w3xzqvsg7kVt7zQ984a9cDHi//Rs3W0gRqBOf/RGbOjuANStDHlz426k2CsD8ryE85AbAj22rNA3tR6JmBH82LG3tNWkW/cELtw2Zmy8PEuRTDdXUluVX7RUjySEoqqXtxnSyCk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972245144970.5902335908884; Thu, 23 Apr 2026 12:24:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdo-0008Mp-NM; Thu, 23 Apr 2026 15:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzdR-0007Qr-Qe for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:52 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzdO-0002XA-2o for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:49 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B817A6A8A3; Thu, 23 Apr 2026 19:21:01 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 79FAA593A3; Thu, 23 Apr 2026 19:21:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iJJqERxx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:21:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972061; h=from:from:reply-to: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=K9h1RGVUintiLczHJ0lwPb10uCyBb8GYOF4K4VgEEz8=; b=EdCwKYCgQjR+c33467V+ig3utSpZYmBrd0q/iD96a1C0x/Sj0OT0omZdmIbvcN2MB4RNat U54zTVWn01ExSxrB7Gx4AqpV36jmtFUX9mOqr/wzjfQTtOHiFZOxgakPUQTPXKOi7H0d4u EUC2d+Zng0Oh7cg0ZwzSP+BOSGzmlXc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972061; h=from:from:reply-to: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=K9h1RGVUintiLczHJ0lwPb10uCyBb8GYOF4K4VgEEz8=; b=cverKs2VFUC8JfINeXVaQpIculdj1jx9LVmCnxniTlrIXg8+v5DZC4qUdbVliDSni/di1n JmTLnAMS1hx0diCw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=EdCwKYCg; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=cverKs2V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972061; h=from:from:reply-to: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=K9h1RGVUintiLczHJ0lwPb10uCyBb8GYOF4K4VgEEz8=; b=EdCwKYCgQjR+c33467V+ig3utSpZYmBrd0q/iD96a1C0x/Sj0OT0omZdmIbvcN2MB4RNat U54zTVWn01ExSxrB7Gx4AqpV36jmtFUX9mOqr/wzjfQTtOHiFZOxgakPUQTPXKOi7H0d4u EUC2d+Zng0Oh7cg0ZwzSP+BOSGzmlXc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972061; h=from:from:reply-to: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=K9h1RGVUintiLczHJ0lwPb10uCyBb8GYOF4K4VgEEz8=; b=cverKs2VFUC8JfINeXVaQpIculdj1jx9LVmCnxniTlrIXg8+v5DZC4qUdbVliDSni/di1n JmTLnAMS1hx0diCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Junjie Cao , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 39/43] tests/unit: add pread/pwrite _all tests for io channel file Date: Thu, 23 Apr 2026 16:19:53 -0300 Message-ID: <20260423191958.1440-40-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,intel.com:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: B817A6A8A3 X-Spam-Score: -3.51 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972246199154100 From: Junjie Cao Add unit tests for the new qio_channel_pread{v,}_all{,_eof}() and qio_channel_pwrite{v,}_all() APIs. The basic tests write data to a file channel, then read it back at various offsets using both the single-buffer and iovec variants to make sure the round-trip produces identical content. The _eof tests verify all three return cases -- full read (1), clean EOF (0), and partial-then-EOF (-1 with error set) -- and check that the strict wrappers (preadv_all / pread_all) treat a clean EOF as an error. All tests are guarded by CONFIG_PREADV since the underlying channel methods require preadv(2). Signed-off-by: Junjie Cao Reviewed-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 Acked-by: Daniel P. Berrang=C3=A9 Link: https://lore.kernel.org/qemu-devel/20260413214549.926435-5-junjie.cao= @intel.com Signed-off-by: Fabiano Rosas --- tests/unit/test-io-channel-file.c | 207 ++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) diff --git a/tests/unit/test-io-channel-file.c b/tests/unit/test-io-channel= -file.c index 1977006ce9..b597350dca 100644 --- a/tests/unit/test-io-channel-file.c +++ b/tests/unit/test-io-channel-file.c @@ -102,6 +102,203 @@ static void test_io_channel_fd(void) } =20 =20 +#ifdef CONFIG_PREADV +static void test_io_channel_pread_all(void) +{ + QIOChannel *ioc; + char write_buf[] =3D "Hello World, pread_all"; + char read_buf[sizeof(write_buf)] =3D {0}; + int ret; + + unlink(TEST_FILE); + ioc =3D QIO_CHANNEL(qio_channel_file_new_path( + TEST_FILE, + O_RDWR | O_CREAT | O_TRUNC | O_BINARY, + TEST_MASK, + &error_abort)); + + ret =3D qio_channel_pwrite_all(ioc, write_buf, sizeof(write_buf), + 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Read back at offset 0 */ + ret =3D qio_channel_pread_all(ioc, read_buf, sizeof(read_buf), + 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + g_assert_cmpmem(write_buf, sizeof(write_buf), + read_buf, sizeof(read_buf)); + + /* Read at a non-zero offset */ + memset(read_buf, 0, sizeof(read_buf)); + ret =3D qio_channel_pread_all(ioc, read_buf, sizeof(write_buf) - 7, + 7, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + g_assert_cmpmem(write_buf + 7, sizeof(write_buf) - 7, + read_buf, sizeof(write_buf) - 7); + + unlink(TEST_FILE); + object_unref(OBJECT(ioc)); +} + +static void test_io_channel_preadv_all(void) +{ + QIOChannel *ioc; + char write_buf[256]; + char read_buf[256] =3D {0}; + struct iovec write_iov[2]; + struct iovec read_iov[2]; + int ret; + size_t i; + + for (i =3D 0; i < sizeof(write_buf); i++) { + write_buf[i] =3D i & 0xff; + } + + unlink(TEST_FILE); + ioc =3D QIO_CHANNEL(qio_channel_file_new_path( + TEST_FILE, + O_RDWR | O_CREAT | O_TRUNC | O_BINARY, + TEST_MASK, + &error_abort)); + + /* Write using pwritev_all with 2 iovecs */ + write_iov[0].iov_base =3D write_buf; + write_iov[0].iov_len =3D 128; + write_iov[1].iov_base =3D write_buf + 128; + write_iov[1].iov_len =3D 128; + ret =3D qio_channel_pwritev_all(ioc, write_iov, 2, 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Read back using preadv_all with 2 iovecs */ + read_iov[0].iov_base =3D read_buf; + read_iov[0].iov_len =3D 128; + read_iov[1].iov_base =3D read_buf + 128; + read_iov[1].iov_len =3D 128; + ret =3D qio_channel_preadv_all(ioc, read_iov, 2, 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + + g_assert_cmpmem(write_buf, sizeof(write_buf), + read_buf, sizeof(read_buf)); + + /* Read at non-zero offset with preadv_all */ + memset(read_buf, 0, sizeof(read_buf)); + read_iov[0].iov_base =3D read_buf; + read_iov[0].iov_len =3D 64; + read_iov[1].iov_base =3D read_buf + 64; + read_iov[1].iov_len =3D 64; + ret =3D qio_channel_preadv_all(ioc, read_iov, 2, 128, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + + g_assert_cmpmem(write_buf + 128, 128, + read_buf, 128); + + unlink(TEST_FILE); + object_unref(OBJECT(ioc)); +} + +static void test_io_channel_preadv_all_eof(void) +{ + QIOChannel *ioc; + char write_buf[] =3D "Hello World, preadv_all_eof"; + char read_buf[sizeof(write_buf)] =3D {0}; + struct iovec iov; + int ret; + Error *err =3D NULL; + + unlink(TEST_FILE); + ioc =3D QIO_CHANNEL(qio_channel_file_new_path( + TEST_FILE, + O_RDWR | O_CREAT | O_TRUNC | O_BINARY, + TEST_MASK, + &error_abort)); + + ret =3D qio_channel_pwrite_all(ioc, write_buf, sizeof(write_buf), + 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Full read succeeds: should return 1 */ + iov.iov_base =3D read_buf; + iov.iov_len =3D sizeof(read_buf); + ret =3D qio_channel_preadv_all_eof(ioc, &iov, 1, 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 1); + g_assert_cmpmem(write_buf, sizeof(write_buf), + read_buf, sizeof(read_buf)); + + /* Clean EOF: offset at file end, should return 0 */ + iov.iov_base =3D read_buf; + iov.iov_len =3D 1; + ret =3D qio_channel_preadv_all_eof(ioc, &iov, 1, + sizeof(write_buf), &err); + g_assert_cmpint(ret, =3D=3D, 0); + g_assert_null(err); + + /* Partial EOF: start before end, request extends past */ + iov.iov_base =3D read_buf; + iov.iov_len =3D 8; + ret =3D qio_channel_preadv_all_eof(ioc, &iov, 1, + sizeof(write_buf) - 4, &err); + g_assert_cmpint(ret, =3D=3D, -1); + g_assert_nonnull(err); + error_free(err); + err =3D NULL; + + /* Strict wrapper (preadv_all) treats clean EOF as error */ + iov.iov_base =3D read_buf; + iov.iov_len =3D 1; + ret =3D qio_channel_preadv_all(ioc, &iov, 1, + sizeof(write_buf), &err); + g_assert_cmpint(ret, =3D=3D, -1); + g_assert_nonnull(err); + error_free(err); + + unlink(TEST_FILE); + object_unref(OBJECT(ioc)); +} + +static void test_io_channel_pread_all_eof(void) +{ + QIOChannel *ioc; + char write_buf[] =3D "Hello World, pread_all_eof"; + char read_buf[sizeof(write_buf)] =3D {0}; + int ret; + Error *err =3D NULL; + + unlink(TEST_FILE); + ioc =3D QIO_CHANNEL(qio_channel_file_new_path( + TEST_FILE, + O_RDWR | O_CREAT | O_TRUNC | O_BINARY, + TEST_MASK, + &error_abort)); + + ret =3D qio_channel_pwrite_all(ioc, write_buf, sizeof(write_buf), + 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Full read succeeds: should return 1 */ + ret =3D qio_channel_pread_all_eof(ioc, read_buf, sizeof(read_buf), + 0, &error_abort); + g_assert_cmpint(ret, =3D=3D, 1); + g_assert_cmpmem(write_buf, sizeof(write_buf), + read_buf, sizeof(read_buf)); + + /* Clean EOF: should return 0 */ + ret =3D qio_channel_pread_all_eof(ioc, read_buf, 1, + sizeof(write_buf), &err); + g_assert_cmpint(ret, =3D=3D, 0); + g_assert_null(err); + + /* Partial EOF: should return -1 */ + ret =3D qio_channel_pread_all_eof(ioc, read_buf, 8, + sizeof(write_buf) - 4, &err); + g_assert_cmpint(ret, =3D=3D, -1); + g_assert_nonnull(err); + error_free(err); + + unlink(TEST_FILE); + object_unref(OBJECT(ioc)); +} +#endif /* CONFIG_PREADV */ + #ifndef _WIN32 static void test_io_channel_pipe(bool async) { @@ -147,6 +344,16 @@ int main(int argc, char **argv) g_test_add_func("/io/channel/file", test_io_channel_file); g_test_add_func("/io/channel/file/rdwr", test_io_channel_file_rdwr); g_test_add_func("/io/channel/file/fd", test_io_channel_fd); +#ifdef CONFIG_PREADV + g_test_add_func("/io/channel/file/pread-all", + test_io_channel_pread_all); + g_test_add_func("/io/channel/file/preadv-all", + test_io_channel_preadv_all); + g_test_add_func("/io/channel/file/preadv-all-eof", + test_io_channel_preadv_all_eof); + g_test_add_func("/io/channel/file/pread-all-eof", + test_io_channel_pread_all_eof); +#endif #ifndef _WIN32 g_test_add_func("/io/channel/pipe/sync", test_io_channel_pipe_sync); g_test_add_func("/io/channel/pipe/async", test_io_channel_pipe_async); --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972255; cv=none; d=zohomail.com; s=zohoarc; b=ZbqTodlNkm4TqUCM8pxHFxTFHKiLbmRz4e0c4MkA1ZTLikVsoFvdJVf6Nfac5UfDMOf6gJlJwQ4vvsnHgmob3Mihj4j/DyiAkX906yEVhe/cB3JnEcvgx0C4M4JYf7mHT6vXJ7sAlLOqr0f9pffrsw4xqk+8z5M7v91Tkxuy1YI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972255; 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=d4jlPyOZ8Zi5EadVdmpm+/KWV1+vkRA9+hUwNZBEYHc=; b=OU0eiSoPeqFya9jxRTk7iAIW6ZI9DSGCFCirtbo4beSwEe7nxMDOSzGmVzUCZShzqENIdELJI8nG9M31sMjGMew09k2j/u7ictyVi+tdSeaTEkaNUlXRwXtz3y8fUkLvgtLrr9JhbS14E8ux1dnK/wL1Lkag/uwNwjIkUjb5V/o= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972255773886.9276217373726; Thu, 23 Apr 2026 12:24:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdJ-0006C1-TW; Thu, 23 Apr 2026 15:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcd-0004V3-7m for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:00 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcb-0002Do-GN for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:21:58 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 300B95BD8D; Thu, 23 Apr 2026 19:21:03 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 23ED1593A3; Thu, 23 Apr 2026 19:21:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id QNcyOB1x6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:21:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d4jlPyOZ8Zi5EadVdmpm+/KWV1+vkRA9+hUwNZBEYHc=; b=qeLvomivfcmLUz9c8WihzNcKmI6h1Mmh5PtCeCk9QWUpf22Fa+HcjfYgZ3/WescZtoVEJB NEv4KTeYmUQeBIyHqG5uVOSRfldDALFi+gxLMxOqpqPEFqrBIjN6yvLhGSy+xeGs2O9mQh QmOkn9BVEh2LnFOfOTM625ea5rmxK4Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d4jlPyOZ8Zi5EadVdmpm+/KWV1+vkRA9+hUwNZBEYHc=; b=/4WgRbAIWjDdihoZ0+vld5QjX5rhJLzI2LhBSTfw+n0upisnaWuiCveeFv/dz4QjaaLbTa Kjqnb8X6BlKBMoAg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=qeLvomiv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="/4WgRbAI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d4jlPyOZ8Zi5EadVdmpm+/KWV1+vkRA9+hUwNZBEYHc=; b=qeLvomivfcmLUz9c8WihzNcKmI6h1Mmh5PtCeCk9QWUpf22Fa+HcjfYgZ3/WescZtoVEJB NEv4KTeYmUQeBIyHqG5uVOSRfldDALFi+gxLMxOqpqPEFqrBIjN6yvLhGSy+xeGs2O9mQh QmOkn9BVEh2LnFOfOTM625ea5rmxK4Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d4jlPyOZ8Zi5EadVdmpm+/KWV1+vkRA9+hUwNZBEYHc=; b=/4WgRbAIWjDdihoZ0+vld5QjX5rhJLzI2LhBSTfw+n0upisnaWuiCveeFv/dz4QjaaLbTa Kjqnb8X6BlKBMoAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Trieu Huynh Subject: [PULL 40/43] tests/qtest/migration: fix fd leak in ufd_version_check Date: Thu, 23 Apr 2026 16:19:54 -0300 Message-ID: <20260423191958.1440-41-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:dkim,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 300B95BD8D 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972258170154100 Content-Type: text/plain; charset="utf-8" From: Trieu Huynh ufd_version_check() opens a userfaultfd via uffd_open() but never closes it on any path where the open succeeded: the UFFDIO_API failure path, the missing-ioctls path, and the success path all returned without calling close(ufd). Convert to a goto-out pattern consistent with uffd_open() used in util/userfaultfd.c and migration/postcopy-ram.c, ensuring the fd is always closed before returning. Signed-off-by: Trieu Huynh Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260419110304.8661-1-viking4@gmai= l.com Signed-off-by: Fabiano Rosas --- tests/qtest/migration/migration-util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/qtest/migration/migration-util.c b/tests/qtest/migration= /migration-util.c index 2648ad7f61..db66d8b24f 100644 --- a/tests/qtest/migration/migration-util.c +++ b/tests/qtest/migration/migration-util.c @@ -343,6 +343,7 @@ bool ufd_version_check(bool *uffd_feature_thread_id) { struct uffdio_api api_struct; uint64_t ioctl_mask; + bool ret =3D false; =20 int ufd =3D uffd_open(O_CLOEXEC); =20 @@ -355,7 +356,7 @@ bool ufd_version_check(bool *uffd_feature_thread_id) api_struct.features =3D 0; if (ioctl(ufd, UFFDIO_API, &api_struct)) { g_test_message("Skipping test: UFFDIO_API failed"); - return false; + goto release_ufd; } =20 if (uffd_feature_thread_id) { @@ -366,10 +367,13 @@ bool ufd_version_check(bool *uffd_feature_thread_id) 1ULL << _UFFDIO_UNREGISTER); if ((api_struct.ioctls & ioctl_mask) !=3D ioctl_mask) { g_test_message("Skipping test: Missing userfault feature"); - return false; + goto release_ufd; } =20 - return true; + ret =3D true; +release_ufd: + close(ufd); + return ret; } #else bool ufd_version_check(bool *uffd_feature_thread_id) --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972337; cv=none; d=zohomail.com; s=zohoarc; b=J0lWhxkJkpwo2V/lg4/1syhkudm+y3OOMhoIHfDjMjA0qZxCFekagRqN68/bY4xiVtaLEY6LTNZCiZ9aGv5Jwwxu/O1cqhMElzQ0i2ovcG/HUUNwiE6zXoH6o+rgVAv/5Tysh3YbBtLvOAEC/TUzL93Fl4cAtJDUnwAbVjEqWxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972337; 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=gFYc2iCcctX8eeRxlptNc9/OtgMtLaoHlJzTpnV+VcY=; b=C9sYzoNBh56qJThEyVnCYwIwd1yhV143NJJcq8pLgEHJ56MlFVUE5AOVCE85M1/tBPZN6p5K3QsBDC7cwWz9/lNoK8flgEMtNcOzjkA/G8NDWtpaD82Br/1y8AoxSqzUWgsE2xIGO5xWXQbQauV+GaX9nVXkd9B2k/DB923hA5Y= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972337020219.33900893681744; Thu, 23 Apr 2026 12:25:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdE-0005qA-8C; Thu, 23 Apr 2026 15:22:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzck-0004gu-4f for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:07 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzch-0002JX-55 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:04 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9BDE55BD8A; Thu, 23 Apr 2026 19:21:04 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 909E9593B0; Thu, 23 Apr 2026 19:21:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aGQXFx9x6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:21:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972065; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gFYc2iCcctX8eeRxlptNc9/OtgMtLaoHlJzTpnV+VcY=; b=n4AyYiELDz/FFkSMrQniN+ZTzZEh7D8T9+yzNsPtwnPCogy/FAVZA7x7OPS87kHzsBVKQY zMBrL8Bu+1GKt9iMq25WwtBOLm+ByGpreAwiRUGl98q5PlfHau0YWdQrZ+MleCEQ3/UeQY 1dtrvsh+8RH+Tj+lKDxKquHSojzvuRM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972065; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gFYc2iCcctX8eeRxlptNc9/OtgMtLaoHlJzTpnV+VcY=; b=MOUWPl3/ZruAXhn2++qOKJsbE7lCy0pottxt3D8OqG9eMfw7TN9Ws+CK9j877o73Tsofug Grk1i+UclYhPkxCg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972064; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gFYc2iCcctX8eeRxlptNc9/OtgMtLaoHlJzTpnV+VcY=; b=CnbQcL8ax7SGnm4qeZD15ZiFS8U3b3EKe9ZIJyPFgg1vXQYh7ma1jXhT/Gngk08UcMD1Ru Z/Gt769BFvjMxcXvYeSv39mcULK5WaPKmAn0IoBk9F8kkRkYcBGy9rewxQUFYiZF3Pc6lG cAM9bRgQOiZ2t8buErBPp8C5xvYKzeI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972064; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gFYc2iCcctX8eeRxlptNc9/OtgMtLaoHlJzTpnV+VcY=; b=FK4YCewqlUjnBBmhtsLWV4kfkjPPvqC1SH3li7oY06CN2PI8hB9Y5zSsrt8XEjnF6iQUe5 JD69D8ZY960AYdAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Junjie Cao Subject: [PULL 41/43] migration/qemu-file: switch buffer_at functions to positioned I/O _all helpers Date: Thu, 23 Apr 2026 16:19:55 -0300 Message-ID: <20260423191958.1440-42-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,intel.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1776972338537158500 Content-Type: text/plain; charset="utf-8" From: Junjie Cao qemu_put_buffer_at() and qemu_get_buffer_at() have the same pattern as the bug fixed in multifd_file_recv_data(): the ssize_t return value from the channel layer is stored in a size_t variable, and a short transfer would be mishandled rather than retried. Switch to qio_channel_pwrite_all() / qio_channel_pread_all() which handle short transfers internally and make the code more robust and consistent with the rest of the positioned I/O call sites. Fixes: 7f5b50a401 ("migration/qemu-file: add utility methods for working wi= th seekable channels") Signed-off-by: Junjie Cao Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260420201317.30199-2-junjie.cao@= intel.com Signed-off-by: Fabiano Rosas --- migration/qemu-file.c | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 9cf7dc3bd5..9dfb202203 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -535,28 +535,13 @@ void qemu_put_buffer_at(QEMUFile *f, const uint8_t *b= uf, size_t buflen, off_t pos) { Error *err =3D NULL; - size_t ret; =20 if (f->last_error) { return; } =20 qemu_fflush(f); - ret =3D qio_channel_pwrite(f->ioc, (char *)buf, buflen, pos, &err); - - if (err) { - qemu_file_set_error_obj(f, -EIO, err); - return; - } - - if ((ssize_t)ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { - qemu_file_set_error_obj(f, -EAGAIN, NULL); - return; - } - - if (ret !=3D buflen) { - error_setg(&err, "Partial write of size %zu, expected %zu", ret, - buflen); + if (qio_channel_pwrite_all(f->ioc, buf, buflen, pos, &err) < 0) { qemu_file_set_error_obj(f, -EIO, err); return; } @@ -569,31 +554,17 @@ size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t = *buf, size_t buflen, off_t pos) { Error *err =3D NULL; - size_t ret; =20 if (f->last_error) { return 0; } =20 - ret =3D qio_channel_pread(f->ioc, (char *)buf, buflen, pos, &err); - - if ((ssize_t)ret =3D=3D -1 || err) { - qemu_file_set_error_obj(f, -EIO, err); - return 0; - } - - if ((ssize_t)ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { - qemu_file_set_error_obj(f, -EAGAIN, NULL); - return 0; - } - - if (ret !=3D buflen) { - error_setg(&err, "Partial read of size %zu, expected %zu", ret, bu= flen); + if (qio_channel_pread_all(f->ioc, (char *)buf, buflen, pos, &err) < 0)= { qemu_file_set_error_obj(f, -EIO, err); return 0; } =20 - return ret; + return buflen; } =20 void qemu_set_offset(QEMUFile *f, off_t off, int whence) --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972317; cv=none; d=zohomail.com; s=zohoarc; b=O46XVJrpJyTPPTTTG5euhD8kym4sMWWP5yH8jIkNq/KcAAuEu+t9f0W9Esu3Og4cooiMz6CraqMBgEQJYoqsTMg7pgyhP2MHgZXKBOwp1d3BSKcHohnum1EnvAHWTA2mt5KWze2T0UEMB/tRuUfTcTS1Z8Ggh0zPpUZpNlrPuyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972317; 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=9sthEBYIMVPUpMPGDxjvreljDqO5OkAeAFlrIWjqBnQ=; b=ShbzwIZOCtmUwOFjl25QkCbs8IDq40YYr97RpW3JHX1KbXuOUxQ7239aJMvQgglRjiha3qkb5XIX7x6Q1f+z7+iDePqm0TygiuSc8kdu0o8yisLZ9OnbEgze3fWi1YQzVQMKD2Y26V65xWD06mD8yRypdsnuwsIMMet+mY9zCYo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776972317441962.5502681902788; Thu, 23 Apr 2026 12:25:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdI-00068S-MS; Thu, 23 Apr 2026 15:22:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcp-0004nl-82 for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:11 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzcn-0002Mi-At for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:10 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 137D85BD90; Thu, 23 Apr 2026 19:21:06 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 08317593B1; Thu, 23 Apr 2026 19:21:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KBxnMSBx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:21:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972066; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9sthEBYIMVPUpMPGDxjvreljDqO5OkAeAFlrIWjqBnQ=; b=SC2vMrt0kf10Qy2eJucJwl2j12YzEHTugvSkbtCSq/1CD48Lx1k9b1y1+Jy/ODFuj2vj9o GtX+WULcx23o7k5kl2JBWFQfTN0XblqON47ujg+p3/LQ0TM3x0KCQOd15A0+1nzMidb+9F j261dJRzLdDnlCEBOrfZCv6BCI6l/m0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972066; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9sthEBYIMVPUpMPGDxjvreljDqO5OkAeAFlrIWjqBnQ=; b=K26oJMj+D6MZ1gDPP4tGCoiyEk70Bti/3n7sfpkQCuhcuv3MTWlAltP0LLR9VLj15UgB8M VJtux+LwcGu0AjDw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=SC2vMrt0; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=K26oJMj+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972066; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9sthEBYIMVPUpMPGDxjvreljDqO5OkAeAFlrIWjqBnQ=; b=SC2vMrt0kf10Qy2eJucJwl2j12YzEHTugvSkbtCSq/1CD48Lx1k9b1y1+Jy/ODFuj2vj9o GtX+WULcx23o7k5kl2JBWFQfTN0XblqON47ujg+p3/LQ0TM3x0KCQOd15A0+1nzMidb+9F j261dJRzLdDnlCEBOrfZCv6BCI6l/m0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972066; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9sthEBYIMVPUpMPGDxjvreljDqO5OkAeAFlrIWjqBnQ=; b=K26oJMj+D6MZ1gDPP4tGCoiyEk70Bti/3n7sfpkQCuhcuv3MTWlAltP0LLR9VLj15UgB8M VJtux+LwcGu0AjDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Junjie Cao Subject: [PULL 42/43] migration/file: switch file_write_ramblock_iov to pwritev_all Date: Thu, 23 Apr 2026 16:19:56 -0300 Message-ID: <20260423191958.1440-43-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,intel.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 137D85BD90 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1776972319108154100 Content-Type: text/plain; charset="utf-8" From: Junjie Cao file_write_ramblock_iov() uses single-shot qio_channel_pwritev() and only checks for ret < 0. A short write (0 <=3D ret < requested) would be treated as success. Switch to qio_channel_pwritev_all() which retries until all bytes are written or an error occurs. Fixes: f427d90b98 ("migration/multifd: Support outgoing mapped-ram stream f= ormat") Signed-off-by: Junjie Cao Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260420201317.30199-3-junjie.cao@= intel.com Signed-off-by: Fabiano Rosas --- migration/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/file.c b/migration/file.c index 4e2524e548..8ba1de2006 100644 --- a/migration/file.c +++ b/migration/file.c @@ -202,7 +202,7 @@ void file_connect_incoming(FileMigrationArgs *file_args= , Error **errp) int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, int niov, MultiFDPages_t *pages, Error **errp) { - ssize_t ret =3D 0; + int ret =3D 0; int i, slice_idx, slice_num; uintptr_t base, next, offset; size_t len; @@ -241,8 +241,8 @@ int file_write_ramblock_iov(QIOChannel *ioc, const stru= ct iovec *iov, break; } =20 - ret =3D qio_channel_pwritev(ioc, &iov[slice_idx], slice_num, - block->pages_offset + offset, errp); + ret =3D qio_channel_pwritev_all(ioc, &iov[slice_idx], slice_num, + block->pages_offset + offset, errp); if (ret < 0) { break; } @@ -251,7 +251,7 @@ int file_write_ramblock_iov(QIOChannel *ioc, const stru= ct iovec *iov, slice_num =3D 0; } =20 - return (ret < 0) ? ret : 0; + return ret; } =20 int multifd_file_recv_data(MultiFDRecvParams *p, Error **errp) --=20 2.51.0 From nobody Sat May 30 19:21:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1776972262; cv=none; d=zohomail.com; s=zohoarc; b=ETDSG3jd93IMJKmIsXYec6ZskA6ZfNABMPlyJ42iF3+vf/WhmuDxrF1u65K0T9COFdcvDMnfl+JRzxwLNYNSCi5XjdhNtf9z60uXn5TXxqDCMlsT8JMGc38rSLwPVXs65A5K2R0xprdWCfTiAbFsA3Z6HLNqjPduc+0Iu4QMfVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776972262; 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=M3UDVOPUiWpobauA+2TDTDMQ+HGhvLbgz+74mugUk44=; b=grU3I/J0GLVqgck/M6lwQFOVs0XYaWc++giYJA6+bEcRL8F1J2PfiAhqKEam+13TvqKxKkyL2rE8AKgyVlDr+TS+MXlI+950uAfdwDw4eqDKTkrpQ5MGEVswmdUxuBDHK4P9ePhAmOAui80YR/ZJrXekLIDlo0bUbL/Uy+snd44= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177697226274464.76562366158078; Thu, 23 Apr 2026 12:24:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFzdN-0006kJ-KF; Thu, 23 Apr 2026 15:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wFzcw-0005CZ-Ix for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:20 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wFzct-0002Rz-Ch for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:16 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B10605BD92; Thu, 23 Apr 2026 19:21:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7375C593A3; Thu, 23 Apr 2026 19:21:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aFDxDyJx6mlJCwAAD6G6ig (envelope-from ); Thu, 23 Apr 2026 19:21:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972067; h=from:from:reply-to: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=M3UDVOPUiWpobauA+2TDTDMQ+HGhvLbgz+74mugUk44=; b=XFUu2ywjfRqSIgmNBD8FBYE0YTyZbxhdv+4Y0cm6UJZUSwy/nzhRHj3g0oJIeafW2M/K2V sjugS/zEV9fdrnTHWKY41Oe/TCfxQtJMlqnWNuMvBQV9knwulo3RuI3vKhtvjv/IPRj+Da PZmdHUuGt2UcLyXpCMBbPHq435uE+kg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972067; h=from:from:reply-to: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=M3UDVOPUiWpobauA+2TDTDMQ+HGhvLbgz+74mugUk44=; b=tFJF+hjX4aaxmfYLFjRmwu2CO7wJBQhV7bvLAGBY5g/dzlIhieb+n3MzHrAPXSqcROTB/z r53KmAcsin/ThyBw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776972067; h=from:from:reply-to: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=M3UDVOPUiWpobauA+2TDTDMQ+HGhvLbgz+74mugUk44=; b=XFUu2ywjfRqSIgmNBD8FBYE0YTyZbxhdv+4Y0cm6UJZUSwy/nzhRHj3g0oJIeafW2M/K2V sjugS/zEV9fdrnTHWKY41Oe/TCfxQtJMlqnWNuMvBQV9knwulo3RuI3vKhtvjv/IPRj+Da PZmdHUuGt2UcLyXpCMBbPHq435uE+kg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776972067; h=from:from:reply-to: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=M3UDVOPUiWpobauA+2TDTDMQ+HGhvLbgz+74mugUk44=; b=tFJF+hjX4aaxmfYLFjRmwu2CO7wJBQhV7bvLAGBY5g/dzlIhieb+n3MzHrAPXSqcROTB/z r53KmAcsin/ThyBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Junjie Cao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 43/43] migration/qemu-file: drop incorrect const from qemu_get_buffer_at buf Date: Thu, 23 Apr 2026 16:19:57 -0300 Message-ID: <20260423191958.1440-44-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260423191958.1440-1-farosas@suse.de> References: <20260423191958.1440-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[linaro.org:email, suse.de:mid, suse.de:email, imap1.dmz-prg2.suse.org:helo, intel.com:email] X-Spam-Score: -3.30 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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 @suse.de) X-ZM-MESSAGEID: 1776972264293154100 From: Junjie Cao qemu_get_buffer_at() reads data *into* buf -- it should not be const. Drop the qualifier and remove the now-unnecessary cast. Signed-off-by: Junjie Cao Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu Link: https://lore.kernel.org/qemu-devel/20260420201317.30199-4-junjie.cao@= intel.com Signed-off-by: Fabiano Rosas --- migration/qemu-file.c | 4 ++-- migration/qemu-file.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 9dfb202203..d5a48115bd 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -550,7 +550,7 @@ void qemu_put_buffer_at(QEMUFile *f, const uint8_t *buf= , size_t buflen, } =20 =20 -size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, +size_t qemu_get_buffer_at(QEMUFile *f, uint8_t *buf, size_t buflen, off_t pos) { Error *err =3D NULL; @@ -559,7 +559,7 @@ size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t *b= uf, size_t buflen, return 0; } =20 - if (qio_channel_pread_all(f->ioc, (char *)buf, buflen, pos, &err) < 0)= { + if (qio_channel_pread_all(f->ioc, buf, buflen, pos, &err) < 0) { qemu_file_set_error_obj(f, -EIO, err); return 0; } diff --git a/migration/qemu-file.h b/migration/qemu-file.h index a390554208..8f824c124d 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -76,7 +76,7 @@ void qemu_set_offset(QEMUFile *f, off_t off, int whence); off_t qemu_get_offset(QEMUFile *f); void qemu_put_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, off_t pos); -size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, +size_t qemu_get_buffer_at(QEMUFile *f, uint8_t *buf, size_t buflen, off_t pos); =20 QIOChannel *qemu_file_get_ioc(QEMUFile *file); --=20 2.51.0