From nobody Sun Feb 8 23:32:18 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=1770072117; cv=none; d=zohomail.com; s=zohoarc; b=MkmQ+HBmT8yBTis6TT/ezQTuztd/Uxh6+Q48W5qCk82yI1XkJX7CdWRWrQ1zqrvmOmH+iXgqr0liUd4JvLWqeYvnAG/ZoxqRqjgWMKmkcXYYvO31wdB6bSIY2GPp4fql3DEJwCR12P8FmccSd3602gjryoXATv1EoWRQVfTga9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072117; 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=EDJqt8uWzuu0pYBRshiU0zbXVLJA6f5OMr93LA+dcPA=; b=WOdIRJyLyhUhV1Rt8UiFlNbXZqDZFNvBv9YDD1YZ3FFmjdZK6tmHMKpjVZvaEOlsuZ5biPaHb0hF5Ma/LtMy5JVTrJUh8Zeaqru+ra2PpHTY7MAxTkoTLaZK5lB3RROffXF2xWovQhIUVxDJRjmdNNmiEPVETZDhMmSK9eFExMU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072117212657.9166585130195; Mon, 2 Feb 2026 14:41:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2be-0007SY-DF; Mon, 02 Feb 2026 17:41:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bd-0007Pn-I4 for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:17 -0500 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 1vn2bc-0000lr-0W for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:17 -0500 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 6D2363E6C6; Mon, 2 Feb 2026 22:41: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 D4FFE3EA62; Mon, 2 Feb 2026 22:41: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 aD0IJQIogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072068; 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=EDJqt8uWzuu0pYBRshiU0zbXVLJA6f5OMr93LA+dcPA=; b=A3OUWwxWj/08o6iGb7b87iUzkLU7XiGt2le85AujZ/Gkkw/qvmVfazysr5nKZt2BE3drKA Ru7FD7KEqeZ//gfj40PC9uwOuEaiFzB04ThYNKPyLqMzbf5fuaYKpAAPz/5XONxU4Pa1hG wY73EIp28YcM9Lu5MYbTP3DY0tWrH0M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072068; 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=EDJqt8uWzuu0pYBRshiU0zbXVLJA6f5OMr93LA+dcPA=; b=DltHleTs1W8symduyu/+7pVBh5CFK4GkgfRpVh3rqlzbGgM7F7HhVzvTkPfyYodQ6svA9y r6IUGTmDlMMb/jBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=A3OUWwxW; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=DltHleTs DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072068; 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=EDJqt8uWzuu0pYBRshiU0zbXVLJA6f5OMr93LA+dcPA=; b=A3OUWwxWj/08o6iGb7b87iUzkLU7XiGt2le85AujZ/Gkkw/qvmVfazysr5nKZt2BE3drKA Ru7FD7KEqeZ//gfj40PC9uwOuEaiFzB04ThYNKPyLqMzbf5fuaYKpAAPz/5XONxU4Pa1hG wY73EIp28YcM9Lu5MYbTP3DY0tWrH0M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072068; 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=EDJqt8uWzuu0pYBRshiU0zbXVLJA6f5OMr93LA+dcPA=; b=DltHleTs1W8symduyu/+7pVBh5CFK4GkgfRpVh3rqlzbGgM7F7HhVzvTkPfyYodQ6svA9y r6IUGTmDlMMb/jBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com Subject: [PATCH v2 1/9] migration/options.c: Don't export migrate_tls_opts_free Date: Mon, 2 Feb 2026 19:40:53 -0300 Message-ID: <20260202224101.20568-2-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-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)[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)[]; TO_DN_NONE(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(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-Spam-Score: -3.01 X-Rspamd-Queue-Id: 6D2363E6C6 X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1770072118269158500 Content-Type: text/plain; charset="utf-8" The migrate_tls_opts_free function was never used outside options.c. Make it static. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/options.c | 2 +- migration/options.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/options.c b/migration/options.c index 1ffe85a2d8..dcd5e07504 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1001,7 +1001,7 @@ AnnounceParameters *migrate_announce_params(void) return ≈ } =20 -void migrate_tls_opts_free(MigrationParameters *params) +static void migrate_tls_opts_free(MigrationParameters *params) { qapi_free_StrOrNull(params->tls_creds); qapi_free_StrOrNull(params->tls_hostname); diff --git a/migration/options.h b/migration/options.h index b502871097..0c3043f1ff 100644 --- a/migration/options.h +++ b/migration/options.h @@ -92,5 +92,4 @@ ZeroPageDetection migrate_zero_page_detection(void); =20 bool migrate_params_check(MigrationParameters *params, Error **errp); void migrate_params_init(MigrationParameters *params); -void migrate_tls_opts_free(MigrationParameters *params); #endif --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072177; cv=none; d=zohomail.com; s=zohoarc; b=JsfbGQMYzZIBFflSDt3x/xo28s84tvfTU2XHMt6/0YXwb8qEoDPMG9v8IrGQETqNkJLK7OvB7TU+rtQXmT4u/aIp39LyGV1HUH4XQntkuc95P3e7Y3Y9UM4xNnm3Yp2hdBjK187gbzOvF0j60+5Xnb3JZ7vnT0HBoYXyLUiupTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072177; 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=DY+2W53egeqkeThQ0vISQVGT1GdVd3dzarPpL4KIM2o=; b=bWmwiSr2fKs+URr7TwFzRnjlwO4ZepHa3c08fdaTUkpJv1Be05TVEp8pmGyw9SdQ92+mS8s2htORH1UaUZ+T8EJClZW3B/anOviOgpLHdz4A2U8P+H8Txi1UF4kRtroKUgNJXpbyu3vySAOqH5EvVnf/EiPVIdyxNSMLzfOzHpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072177559178.81511747405057; Mon, 2 Feb 2026 14:42:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2bl-0007Xp-1Q; Mon, 02 Feb 2026 17:41:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bj-0007XB-16 for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:23 -0500 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 1vn2bh-0000nz-HL for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:22 -0500 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 78A713E6CA; Mon, 2 Feb 2026 22:41: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 DFC013EA62; Mon, 2 Feb 2026 22:41:08 +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 oGGpJwQogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072070; 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=DY+2W53egeqkeThQ0vISQVGT1GdVd3dzarPpL4KIM2o=; b=wEAzdK6CBwL7xMxGl7jD0R8NdTEPe+LiIZ8JzrzCrKO5iuH7+I3XDgDMHNKZbpteCFgmRw DL8m8jvVN5zHZkIevPr8AkitHSqMRnc1bKsuAaWC6vpCc/Qv6b9QaficLaWQXAQWQrIJH/ KbpPUwwFbaNhE4Ix/DEV99nlJteSGv4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072070; 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=DY+2W53egeqkeThQ0vISQVGT1GdVd3dzarPpL4KIM2o=; b=EYjh4qkhd2luIDE04PG2/TqFE8vKnCOgpNZC0/9+kQrSfvKwcqdIQtnt21P+PvjsJ0nfMd 0FfMdOqBHZQaOBDw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=wEAzdK6C; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EYjh4qkh DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072070; 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=DY+2W53egeqkeThQ0vISQVGT1GdVd3dzarPpL4KIM2o=; b=wEAzdK6CBwL7xMxGl7jD0R8NdTEPe+LiIZ8JzrzCrKO5iuH7+I3XDgDMHNKZbpteCFgmRw DL8m8jvVN5zHZkIevPr8AkitHSqMRnc1bKsuAaWC6vpCc/Qv6b9QaficLaWQXAQWQrIJH/ KbpPUwwFbaNhE4Ix/DEV99nlJteSGv4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072070; 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=DY+2W53egeqkeThQ0vISQVGT1GdVd3dzarPpL4KIM2o=; b=EYjh4qkhd2luIDE04PG2/TqFE8vKnCOgpNZC0/9+kQrSfvKwcqdIQtnt21P+PvjsJ0nfMd 0FfMdOqBHZQaOBDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com Subject: [PATCH v2 2/9] migration: Use QAPI_CLONE_MEMBERS in migrate_params_test_apply Date: Mon, 2 Feb 2026 19:40:54 -0300 Message-ID: <20260202224101.20568-3-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 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)[]; TO_DN_NONE(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(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-Action: no action X-Rspamd-Queue-Id: 78A713E6CA X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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: 1770072178511154100 Content-Type: text/plain; charset="utf-8" Use QAPI_CLONE_MEMBERS instead of making an assignment. The QAPI method makes the handling of the TLS strings more intuitive because it clones them as well. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/options.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/migration/options.c b/migration/options.c index dcd5e07504..4161648268 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1264,9 +1264,9 @@ bool migrate_params_check(MigrationParameters *params= , Error **errp) static void migrate_params_test_apply(MigrationParameters *params, MigrationParameters *dest) { - *dest =3D migrate_get_current()->parameters; + MigrationState *s =3D migrate_get_current(); =20 - /* TODO use QAPI_CLONE() instead of duplicating it inline */ + QAPI_CLONE_MEMBERS(MigrationParameters, dest, &s->parameters); =20 if (params->has_throttle_trigger_threshold) { dest->throttle_trigger_threshold =3D params->throttle_trigger_thre= shold; @@ -1285,24 +1285,18 @@ static void migrate_params_test_apply(MigrationPara= meters *params, } =20 if (params->tls_creds) { + qapi_free_StrOrNull(dest->tls_creds); dest->tls_creds =3D QAPI_CLONE(StrOrNull, params->tls_creds); - } else { - /* clear the reference, it's owned by s->parameters */ - dest->tls_creds =3D NULL; } =20 if (params->tls_hostname) { + qapi_free_StrOrNull(dest->tls_hostname); dest->tls_hostname =3D QAPI_CLONE(StrOrNull, params->tls_hostname); - } else { - /* clear the reference, it's owned by s->parameters */ - dest->tls_hostname =3D NULL; } =20 if (params->tls_authz) { + qapi_free_StrOrNull(dest->tls_authz); dest->tls_authz =3D QAPI_CLONE(StrOrNull, params->tls_authz); - } else { - /* clear the reference, it's owned by s->parameters */ - dest->tls_authz =3D NULL; } =20 if (params->has_max_bandwidth) { @@ -1359,8 +1353,9 @@ static void migrate_params_test_apply(MigrationParame= ters *params, } =20 if (params->has_block_bitmap_mapping) { - dest->has_block_bitmap_mapping =3D true; - dest->block_bitmap_mapping =3D params->block_bitmap_mapping; + qapi_free_BitmapMigrationNodeAliasList(dest->block_bitmap_mapping); + dest->block_bitmap_mapping =3D QAPI_CLONE(BitmapMigrationNodeAlias= List, + params->block_bitmap_mappi= ng); } =20 if (params->has_x_vcpu_dirty_limit_period) { @@ -1384,7 +1379,8 @@ static void migrate_params_test_apply(MigrationParame= ters *params, } =20 if (params->has_cpr_exec_command) { - dest->cpr_exec_command =3D params->cpr_exec_command; + qapi_free_strList(dest->cpr_exec_command); + dest->cpr_exec_command =3D QAPI_CLONE(strList, params->cpr_exec_co= mmand); } } =20 @@ -1540,4 +1536,6 @@ void qmp_migrate_set_parameters(MigrationParameters *= params, Error **errp) } =20 migrate_tls_opts_free(&tmp); + qapi_free_BitmapMigrationNodeAliasList(tmp.block_bitmap_mapping); + qapi_free_strList(tmp.cpr_exec_command); } --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072177; cv=none; d=zohomail.com; s=zohoarc; b=lGtc+qwqbkKXCHeB1X5D1cjvBnkQG3SQ3evdiXzD4P3zxQThalyi7TT91bUSEWpdVDtVlq1hibPUL4AsFO5layxBJq7Q1tlRWi6sWKCVtp3R5y79RNArxGlUohGqhwh8VxxCFgg3FipPTJOBJRx54hRt5XlKiRVjwJN7462tzJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072177; 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=zx76ayTs/F4tYmrxu6mBKE3p0D09KMMO/0lWIIEKtTY=; b=cDmdb+CyhtfDdKUsONiBDCGHTQeSXs5A9BpNSnIeQmqAycTkh57fCCqSdU7WWYbkiRADiS8i9iH7LpGQ+eLmmoNW283HY0Me/m9OjBZEQd8HED9CKzFGbTZ2GIdvDEAQzwsVwzpgYbA1a/59MJ5ju3jI1T/FLX041lGVpQv8FN4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177007217754360.45006227625083; Mon, 2 Feb 2026 14:42:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2bp-0007Yy-FW; Mon, 02 Feb 2026 17:41:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bo-0007Yb-5m for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:28 -0500 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 1vn2bm-0000pO-Dj for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:27 -0500 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 C020C3E6C5; Mon, 2 Feb 2026 22:41:12 +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 EAC9B3EA62; Mon, 2 Feb 2026 22:41: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 QJdnKgYogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072072; 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=zx76ayTs/F4tYmrxu6mBKE3p0D09KMMO/0lWIIEKtTY=; b=Ke/z5a/Opqyu5R+l+gSf0jczddgeodoWxvgjPT0LzdNsnnxOyYsNSl3Iq0CbBbMDzqvJ4Y dMatr9GlQmYA0P+Ll0Z5gSk9onavn1cXBc4l2LxdxMPMOPZBZ3GQciicHbj2GqeJM3z4Qx BLKije39y6lJs0gOxfphDmXNcgJhBYY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072072; 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=zx76ayTs/F4tYmrxu6mBKE3p0D09KMMO/0lWIIEKtTY=; b=/+5ro7ts5STkjZfWlKJugdLkmughJBjeGk+dE+loioLu2Wxbc0WZIHSNKrnXfoMxuuyLca liVBdPZz9bGgtoDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="Ke/z5a/O"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="/+5ro7ts" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072072; 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=zx76ayTs/F4tYmrxu6mBKE3p0D09KMMO/0lWIIEKtTY=; b=Ke/z5a/Opqyu5R+l+gSf0jczddgeodoWxvgjPT0LzdNsnnxOyYsNSl3Iq0CbBbMDzqvJ4Y dMatr9GlQmYA0P+Ll0Z5gSk9onavn1cXBc4l2LxdxMPMOPZBZ3GQciicHbj2GqeJM3z4Qx BLKije39y6lJs0gOxfphDmXNcgJhBYY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072072; 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=zx76ayTs/F4tYmrxu6mBKE3p0D09KMMO/0lWIIEKtTY=; b=/+5ro7ts5STkjZfWlKJugdLkmughJBjeGk+dE+loioLu2Wxbc0WZIHSNKrnXfoMxuuyLca liVBdPZz9bGgtoDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com, Prasad Pandit Subject: [PATCH v2 3/9] migration: Use QAPI_CLONE_MEMBERS in migrate_params_apply Date: Mon, 2 Feb 2026 19:40:55 -0300 Message-ID: <20260202224101.20568-4-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-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)[]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: C020C3E6C5 X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1770072178853154100 Content-Type: text/plain; charset="utf-8" Instead of setting parameters one by one, use the temporary object, which already contains the current migration parameters plus the new ones and was just validated by migration_params_check(). Use cloning to overwrite it. This avoids the need to alter this function every time a new parameter is added. Since parameters are not individually checked anymore, the setting of s->has_block_bitmap_mapping moves into migrate_post_update_params(). Reviewed-by: Peter Xu Reviewed-by: Prasad Pandit Signed-off-by: Fabiano Rosas --- migration/options.c | 137 +++++--------------------------------------- 1 file changed, 14 insertions(+), 123 deletions(-) diff --git a/migration/options.c b/migration/options.c index 4161648268..3c80cdfd3a 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1106,6 +1106,10 @@ static void migrate_post_update_params(MigrationPara= meters *new, Error **errp) migration_rate_set(new->max_postcopy_bandwidth); } } + + if (new->has_block_bitmap_mapping) { + s->has_block_bitmap_mapping =3D true; + } } =20 /* @@ -1384,132 +1388,19 @@ static void migrate_params_test_apply(MigrationPar= ameters *params, } } =20 +/* + * Caller must ensure the has_* fields of @params are true so they all + * get copied and the pointer members don't dangle. + */ static void migrate_params_apply(MigrationParameters *params) { MigrationState *s =3D migrate_get_current(); + MigrationParameters *cur =3D &s->parameters; =20 - /* TODO use QAPI_CLONE() instead of duplicating it inline */ - - if (params->has_throttle_trigger_threshold) { - s->parameters.throttle_trigger_threshold =3D params->throttle_trig= ger_threshold; - } - - if (params->has_cpu_throttle_initial) { - s->parameters.cpu_throttle_initial =3D params->cpu_throttle_initia= l; - } - - if (params->has_cpu_throttle_increment) { - s->parameters.cpu_throttle_increment =3D params->cpu_throttle_incr= ement; - } - - if (params->has_cpu_throttle_tailslow) { - s->parameters.cpu_throttle_tailslow =3D params->cpu_throttle_tails= low; - } - - if (params->tls_creds) { - qapi_free_StrOrNull(s->parameters.tls_creds); - s->parameters.tls_creds =3D QAPI_CLONE(StrOrNull, params->tls_cred= s); - } - - if (params->tls_hostname) { - qapi_free_StrOrNull(s->parameters.tls_hostname); - s->parameters.tls_hostname =3D QAPI_CLONE(StrOrNull, - params->tls_hostname); - } - - if (params->tls_authz) { - qapi_free_StrOrNull(s->parameters.tls_authz); - s->parameters.tls_authz =3D QAPI_CLONE(StrOrNull, params->tls_auth= z); - } - - if (params->has_max_bandwidth) { - s->parameters.max_bandwidth =3D params->max_bandwidth; - } - - if (params->has_avail_switchover_bandwidth) { - s->parameters.avail_switchover_bandwidth =3D params->avail_switcho= ver_bandwidth; - } - - if (params->has_downtime_limit) { - s->parameters.downtime_limit =3D params->downtime_limit; - } - - if (params->has_x_checkpoint_delay) { - s->parameters.x_checkpoint_delay =3D params->x_checkpoint_delay; - } - - if (params->has_multifd_channels) { - s->parameters.multifd_channels =3D params->multifd_channels; - } - if (params->has_multifd_compression) { - s->parameters.multifd_compression =3D params->multifd_compression; - } - if (params->has_multifd_qatzip_level) { - s->parameters.multifd_qatzip_level =3D params->multifd_qatzip_leve= l; - } - if (params->has_multifd_zlib_level) { - s->parameters.multifd_zlib_level =3D params->multifd_zlib_level; - } - if (params->has_multifd_zstd_level) { - s->parameters.multifd_zstd_level =3D params->multifd_zstd_level; - } - if (params->has_xbzrle_cache_size) { - s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; - } - if (params->has_max_postcopy_bandwidth) { - s->parameters.max_postcopy_bandwidth =3D params->max_postcopy_band= width; - } - if (params->has_max_cpu_throttle) { - s->parameters.max_cpu_throttle =3D params->max_cpu_throttle; - } - if (params->has_announce_initial) { - s->parameters.announce_initial =3D params->announce_initial; - } - if (params->has_announce_max) { - s->parameters.announce_max =3D params->announce_max; - } - if (params->has_announce_rounds) { - s->parameters.announce_rounds =3D params->announce_rounds; - } - if (params->has_announce_step) { - s->parameters.announce_step =3D params->announce_step; - } - - if (params->has_block_bitmap_mapping) { - qapi_free_BitmapMigrationNodeAliasList( - s->parameters.block_bitmap_mapping); - - s->has_block_bitmap_mapping =3D true; - s->parameters.block_bitmap_mapping =3D - QAPI_CLONE(BitmapMigrationNodeAliasList, - params->block_bitmap_mapping); - } - - if (params->has_x_vcpu_dirty_limit_period) { - s->parameters.x_vcpu_dirty_limit_period =3D - params->x_vcpu_dirty_limit_period; - } - if (params->has_vcpu_dirty_limit) { - s->parameters.vcpu_dirty_limit =3D params->vcpu_dirty_limit; - } - - if (params->has_mode) { - s->parameters.mode =3D params->mode; - } - - if (params->has_zero_page_detection) { - s->parameters.zero_page_detection =3D params->zero_page_detection; - } - - if (params->has_direct_io) { - s->parameters.direct_io =3D params->direct_io; - } - - if (params->has_cpr_exec_command) { - qapi_free_strList(s->parameters.cpr_exec_command); - s->parameters.cpr_exec_command =3D - QAPI_CLONE(strList, params->cpr_exec_command); - } + migrate_tls_opts_free(cur); + qapi_free_BitmapMigrationNodeAliasList(cur->block_bitmap_mapping); + qapi_free_strList(cur->cpr_exec_command); + QAPI_CLONE_MEMBERS(MigrationParameters, cur, params); } =20 void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) @@ -1531,7 +1422,7 @@ void qmp_migrate_set_parameters(MigrationParameters *= params, Error **errp) migrate_params_test_apply(params, &tmp); =20 if (migrate_params_check(&tmp, errp)) { - migrate_params_apply(params); + migrate_params_apply(&tmp); migrate_post_update_params(params, errp); } =20 --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072115; cv=none; d=zohomail.com; s=zohoarc; b=QU7tZjYSP8IleIPTYQIVa5d/kctKH41xHRh2cx4K5zNfuAycpn1Cd4xl2wki02i1tYGvx/7COvI8bSgI6v70WhFVrnonybGgRAkbSwvZ9Ootb5WxqUs1fjP1Q7yWAb0DqszTEwM/Z/Ux08n/hcpAA12LF04okdzweD5H/Y6LKYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072115; 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=eNQTdQp3G977GJsacAmbdN8CKP9bd2OWQw4XQhW6u44=; b=ZUC1l1glkg8T147rxhXKSigDJAzMMEbukP2ceR9NC0600hUhxv8vgp1r/p+mhrIATST5qngenASwHotnKrztbmU9ASzub768exn98awQTUM0Wr6cVVbQqPc8ov5UhCWkkYy+iuWJ0uHCQ6sFezhQZrj2HflnDtTupOC6PMsC6CY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072114867344.51594487473506; Mon, 2 Feb 2026 14:41:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2bg-0007WN-JA; Mon, 02 Feb 2026 17:41:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bf-0007UQ-C6 for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:19 -0500 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 1vn2bd-0000lw-KQ for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:19 -0500 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 120B05BCC3; Mon, 2 Feb 2026 22:41:15 +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 3E6DA3EA62; Mon, 2 Feb 2026 22:41: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 cMBMAAkogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072075; 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=eNQTdQp3G977GJsacAmbdN8CKP9bd2OWQw4XQhW6u44=; b=D2q+yo8cAqr+2JIcoh8bPW+FL0g5uqAWxr0z4CicI1WhyKCIRLW4QeCxmV+fuCegrum9yg uG3Z6EK+qYo+3SSvxyN9inz6qlkfLQYk0z41RJASMw2UNJR/sBpijMfFLUTeQMvtfzHV28 L5w5BV4eZO6wKMvD3vfkMo59fIwEE5Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072075; 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=eNQTdQp3G977GJsacAmbdN8CKP9bd2OWQw4XQhW6u44=; b=WyNtTSQhbsRP5qObUmoHOmRIxlLTdbBsDtLtOQqme5tBIvAf9d4MVBqX+CmHwyWdMCCCFQ 7wzzVzqmc2hWBLDg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=D2q+yo8c; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WyNtTSQh DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072075; 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=eNQTdQp3G977GJsacAmbdN8CKP9bd2OWQw4XQhW6u44=; b=D2q+yo8cAqr+2JIcoh8bPW+FL0g5uqAWxr0z4CicI1WhyKCIRLW4QeCxmV+fuCegrum9yg uG3Z6EK+qYo+3SSvxyN9inz6qlkfLQYk0z41RJASMw2UNJR/sBpijMfFLUTeQMvtfzHV28 L5w5BV4eZO6wKMvD3vfkMo59fIwEE5Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072075; 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=eNQTdQp3G977GJsacAmbdN8CKP9bd2OWQw4XQhW6u44=; b=WyNtTSQhbsRP5qObUmoHOmRIxlLTdbBsDtLtOQqme5tBIvAf9d4MVBqX+CmHwyWdMCCCFQ 7wzzVzqmc2hWBLDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com, Michael Roth Subject: [PATCH v2 4/9] qapi: Implement qapi_dealloc_present_visitor Date: Mon, 2 Feb 2026 19:40:56 -0300 Message-ID: <20260202224101.20568-5-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 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)[]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 120B05BCC3 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1770072117413158500 Content-Type: text/plain; charset="utf-8" Implement a visitor that frees the pointer members of the visited QAPI object in the same way that qapi_dealloc_visitor does, but similarly to qobject_input_visitor, takes an input QObject that will dictate which members get freed and which don't. Members not present in the input QObject will be left unchanged in the visited QAPI object. This is useful to free memory just before perfoming a visit with qobject_input_visitor on a pre-existing, non-null QAPI object. If the same QObject is passed to both visitors, the pointers overwritten by the input visitor match the ones that are freed by the dealloc visitor. Signed-off-by: Fabiano Rosas --- include/qapi/dealloc-visitor.h | 6 ++ qapi/qapi-dealloc-visitor.c | 173 ++++++++++++++++++++++++++++++++- 2 files changed, 178 insertions(+), 1 deletion(-) diff --git a/include/qapi/dealloc-visitor.h b/include/qapi/dealloc-visitor.h index c36715fdf3..96c7bf35c3 100644 --- a/include/qapi/dealloc-visitor.h +++ b/include/qapi/dealloc-visitor.h @@ -25,4 +25,10 @@ typedef struct QapiDeallocVisitor QapiDeallocVisitor; */ Visitor *qapi_dealloc_visitor_new(void); =20 +/* + * Like qapi_dealloc_visitor_new but visits a QObject and only frees + * present members. + */ +Visitor *qapi_dealloc_present_visitor_new(QObject *); + #endif diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index 57a2c904bb..90b017cc93 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -14,14 +14,146 @@ =20 #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" +#include "qemu/queue.h" +#include "qobject/qdict.h" +#include "qobject/qlist.h" #include "qobject/qnull.h" #include "qapi/visitor-impl.h" =20 +typedef struct QStackEntry { + QObject *obj; /* QDict or QList being visited */ + void *qapi; + const QListEntry *entry; /* If @obj is QList: unvisited tail */ + QSLIST_ENTRY(QStackEntry) node; +} QStackEntry; + struct QapiDeallocVisitor { Visitor visitor; + QObject *root; + QSLIST_HEAD(, QStackEntry) stack; }; =20 +static void qapi_dealloc_pop(Visitor *v, void **obj) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + QStackEntry *se =3D QSLIST_FIRST(&qdv->stack); + + assert(se && se->qapi =3D=3D obj); + QSLIST_REMOVE_HEAD(&qdv->stack, node); + g_free(se); +} + +static void qapi_dealloc_push(Visitor *v, QObject *obj, void *qapi) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + QStackEntry *se =3D g_new0(QStackEntry, 1); + + assert(obj); + se->obj =3D obj; + se->qapi =3D qapi; + + if (qobject_type(obj) =3D=3D QTYPE_QLIST) { + se->entry =3D qlist_first(qobject_to(QList, obj)); + } + + QSLIST_INSERT_HEAD(&qdv->stack, se, node); +} + +static QObject *qapi_dealloc_try_get_object(QapiDeallocVisitor *qdv, const= char *name) +{ + QStackEntry *se =3D QSLIST_FIRST(&qdv->stack); + QObject *qobj; + QObject *ret =3D NULL; + + if (!se) { + assert(qdv->root); + return qdv->root; + } + + qobj =3D se->obj; + assert(qobj); + + if (qobject_type(qobj) =3D=3D QTYPE_QDICT) { + assert(name); + ret =3D qdict_get(qobject_to(QDict, qobj), name); + } else { + assert(qobject_type(qobj) =3D=3D QTYPE_QLIST); + assert(!name); + if (se->entry) { + ret =3D qlist_entry_obj(se->entry); + } + } + + return ret; +} + +static bool qapi_dealloc_present_start_struct(Visitor *v, const char *name, + void **obj, size_t size, + Error **errp) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + QObject *qobj =3D qapi_dealloc_try_get_object(qdv, name); + + if (!qobj) { + return false; + } + assert(qobject_type(qobj) =3D=3D QTYPE_QDICT); + qapi_dealloc_push(v, qobj, obj); + return true; +} + +static void qapi_dealloc_present_end_struct(Visitor *v, void **obj) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + QStackEntry *se =3D QSLIST_FIRST(&qdv->stack); + + assert(qobject_type(se->obj) =3D=3D QTYPE_QDICT); + qapi_dealloc_pop(v, obj); + + if (obj) { + g_free(*obj); + } +} + +static bool qapi_dealloc_present_start_list(Visitor *v, const char *name, + GenericList **list, size_t siz= e, + Error **errp) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + QObject *qobj =3D qapi_dealloc_try_get_object(qdv, name); + + if (!qobj) { + return false; + } + assert(qobject_type(qobj) =3D=3D QTYPE_QLIST); + qapi_dealloc_push(v, qobj, list); + return true; +} + +static void qapi_dealloc_present_end_list(Visitor *v, void **obj) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + QStackEntry *se =3D QSLIST_FIRST(&qdv->stack); + + assert(qobject_type(se->obj) =3D=3D QTYPE_QLIST); + qapi_dealloc_pop(v, obj); +} + +static void qapi_dealloc_present_free(Visitor *v) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + + while (!QSLIST_EMPTY(&qdv->stack)) { + QStackEntry *se =3D QSLIST_FIRST(&qdv->stack); + + QSLIST_REMOVE_HEAD(&qdv->stack, node); + g_free(se); + } + qobject_unref(qdv->root); + g_free(qdv); +} + static bool qapi_dealloc_start_struct(Visitor *v, const char *name, void *= *obj, size_t unused, Error **errp) { @@ -35,6 +167,21 @@ static void qapi_dealloc_end_struct(Visitor *v, void **= obj) } } =20 +static bool qapi_dealloc_start_alternate(Visitor *v, const char *name, + GenericAlternate **obj, size_t si= ze, + Error **errp) +{ + QapiDeallocVisitor *qdv =3D container_of(v, QapiDeallocVisitor, visito= r); + QObject *qobj =3D qapi_dealloc_try_get_object(qdv, name); + + if (!qobj) { + return false; + } + assert(*obj); + (*obj)->type =3D qobject_type(qobj); + return true; +} + static void qapi_dealloc_end_alternate(Visitor *v, void **obj) { if (obj) { @@ -117,13 +264,14 @@ static void qapi_dealloc_free(Visitor *v) g_free(container_of(v, QapiDeallocVisitor, visitor)); } =20 -Visitor *qapi_dealloc_visitor_new(void) +static QapiDeallocVisitor *qapi_dealloc_visitor_new_base(void) { QapiDeallocVisitor *v; =20 v =3D g_malloc0(sizeof(*v)); =20 v->visitor.type =3D VISITOR_DEALLOC; + v->visitor.start_struct =3D qapi_dealloc_start_struct; v->visitor.end_struct =3D qapi_dealloc_end_struct; v->visitor.end_alternate =3D qapi_dealloc_end_alternate; @@ -139,5 +287,28 @@ Visitor *qapi_dealloc_visitor_new(void) v->visitor.type_null =3D qapi_dealloc_type_null; v->visitor.free =3D qapi_dealloc_free; =20 + return v; +} + +Visitor *qapi_dealloc_visitor_new(void) +{ + QapiDeallocVisitor *v =3D qapi_dealloc_visitor_new_base(); + + return &v->visitor; +} + +Visitor *qapi_dealloc_present_visitor_new(QObject *obj) +{ + QapiDeallocVisitor *v =3D qapi_dealloc_visitor_new_base(); + + v->visitor.start_alternate =3D qapi_dealloc_start_alternate; + v->visitor.start_list =3D qapi_dealloc_present_start_list; + v->visitor.end_list =3D qapi_dealloc_present_end_list; + v->visitor.start_struct =3D qapi_dealloc_present_start_struct; + v->visitor.end_struct =3D qapi_dealloc_present_end_struct; + v->visitor.free =3D qapi_dealloc_present_free; + + v->root =3D qobject_ref(obj); + return &v->visitor; } --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072157; cv=none; d=zohomail.com; s=zohoarc; b=YIqJ6tZesP2M7Wai7CfxG+inQInRVTVNVJRQvemHR36KoatNA3csKCC7gn4LXQ1NzA5sdSLtnV6ejb/RIkjtb4ohWb0FNb0+UOZuGY1O6rb+8ZMgje0yVVSUaGp3DwS46UXLpOXL37QX/J2I/5e9guO8yxUbSz42mYBPuDV7MmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072157; 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=/NDK5VnnkFXqjnSY/+1rjEdw0JQMtPwLYXBs1hRb32U=; b=JDkn2kctvnLjB94SPh3Xy/CT+n/WEMCIvzhDATalDIjFsZWlyy1NeyTKsReAsH3X2m5LZpoDMcIyfDni2tA46TzgKsdYZ2/XjgW6r+9rC5dI1lfxwQ3Ut4WkLKfTMP5MeixpEtbOHUoQNf93ZWSaGSefnzMfjzAGd7+zL0hXd80= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072157344209.27355756909992; Mon, 2 Feb 2026 14:42:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2bm-0007YD-NJ; Mon, 02 Feb 2026 17:41:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bk-0007Xm-RS for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:24 -0500 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 1vn2bj-0000p6-8F for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:24 -0500 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 5AACE5BCC6; Mon, 2 Feb 2026 22:41: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 859683EA62; Mon, 2 Feb 2026 22:41:15 +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 KI2sEQsogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072077; 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=/NDK5VnnkFXqjnSY/+1rjEdw0JQMtPwLYXBs1hRb32U=; b=PZucfKRIrYDLPHjWZY9gS21dogOOo36TZ9deA6bbfJJ4LhvSJ4bePU8qKaW4TCjf8zvZhn QqKBYW7da6Cfa8koQQ25bdNgEvapAVEU7DmRpC99ytgZk3rhJbSp1zSuB9tCKFbxV937OR moqlobYOG3FPDMRCajedy74+Xoz10gs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072077; 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=/NDK5VnnkFXqjnSY/+1rjEdw0JQMtPwLYXBs1hRb32U=; b=F3zpVaFVR9O9Y70s2EPRVbHk+T9nb2+Mfaq7gsif/K0tyJPY60cJ0iirq0+y9B3571LESY 4IJDHprtD/RGsuBw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=PZucfKRI; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=F3zpVaFV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072077; 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=/NDK5VnnkFXqjnSY/+1rjEdw0JQMtPwLYXBs1hRb32U=; b=PZucfKRIrYDLPHjWZY9gS21dogOOo36TZ9deA6bbfJJ4LhvSJ4bePU8qKaW4TCjf8zvZhn QqKBYW7da6Cfa8koQQ25bdNgEvapAVEU7DmRpC99ytgZk3rhJbSp1zSuB9tCKFbxV937OR moqlobYOG3FPDMRCajedy74+Xoz10gs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072077; 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=/NDK5VnnkFXqjnSY/+1rjEdw0JQMtPwLYXBs1hRb32U=; b=F3zpVaFVR9O9Y70s2EPRVbHk+T9nb2+Mfaq7gsif/K0tyJPY60cJ0iirq0+y9B3571LESY 4IJDHprtD/RGsuBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com, Michael Roth Subject: [PATCH v2 5/9] qapi: Add QAPI_MERGE Date: Mon, 2 Feb 2026 19:40:57 -0300 Message-ID: <20260202224101.20568-6-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-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)[99.99%]; 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)[]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 5AACE5BCC6 X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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: 1770072160418154100 Content-Type: text/plain; charset="utf-8" The migration subsystem currently has code to merge two objects of the same type. It does so by checking which fields are present in a source object and overwriting the corresponding fields on the destination object. This leads to a lot of open-coded lines such as: if (src->has_foobar) { dst->foobar =3D src->foobar; } This pattern could be replaced by a copy using visitors. Implement a macro that extracts elements from a source object using an output visitor and merges it with a destination object using an input visitor. Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/qapi/type-helpers.h | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/qapi/type-helpers.h b/include/qapi/type-helpers.h index fc8352cdec..f22d7b7139 100644 --- a/include/qapi/type-helpers.h +++ b/include/qapi/type-helpers.h @@ -10,6 +10,9 @@ */ =20 #include "qapi/qapi-types-common.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qobject-output-visitor.h" +#include "qapi/dealloc-visitor.h" =20 HumanReadableText *human_readable_text_from_str(GString *str); =20 @@ -20,3 +23,40 @@ HumanReadableText *human_readable_text_from_str(GString = *str); * cleanup. */ char **strv_from_str_list(const strList *list); + +/* + * Merge @src over @dst by copying deep clones of the present members + * from @src to @dst. Non-present on @src are left untouched on + * @dst. Pointer members that are overwritten are also freed. + */ +#define QAPI_MERGE(type, dst_, src_) \ + ({ \ + QObject *out_ =3D NULL; \ + Visitor *v_; \ + /* read in from src */ \ + v_ =3D qobject_output_visitor_new(&out_); \ + visit_type_ ## type(v_, NULL, &src_, &error_abort); \ + visit_complete(v_, &out_); \ + visit_free(v_); \ + /* \ + * Free the memory for which the pointers will be overwritten \ + * in the next step. \ + */ \ + v_ =3D qapi_dealloc_present_visitor_new(out_); \ + visit_start_struct(v_, NULL, NULL, 0, &error_abort); \ + visit_type_ ## type ## _members(v_, dst_, &error_abort); \ + visit_end_struct(v_, NULL); \ + visit_free(v_); \ + /* \ + * Write to dst but leave existing fields intact (except for \ + * has_* which will be updated according to their presence in \ + * src). \ + */ \ + v_ =3D qobject_input_visitor_new(out_); \ + visit_start_struct(v_, NULL, NULL, 0, &error_abort); \ + visit_type_ ## type ## _members(v_, dst_, &error_abort); \ + visit_check_struct(v_, &error_abort); \ + visit_end_struct(v_, NULL); \ + visit_free(v_); \ + qobject_unref(out_); \ + }) --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072126; cv=none; d=zohomail.com; s=zohoarc; b=lpFyDBpMuxrhkBafS8qz8fkB6hrPjsfAjL7GTCgTX3IloYkSf0N08HZIspYlwBDzd6fPc0MX1uCIa63ZodnpEXK25cvzzu502UdLqoPBx4fL8fDfqbLXHACRAhNuGdJ7YkXvTEfbX3VcEp6FelTEmYmqMG14+pWWSL1D91B5JoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072126; 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=86+JJGb7GtWR/nbtnYPa1W6mDxZAg2FCQqGlH06dIEk=; b=IXZEDiI+S9+xAyCTXxkHBjVG3a4ufFPKq94k0VFhwC5aFmRMZ63IQT+7m+f5Zbn77dhkXJV8IhADfox7y10fLWT+b6d1t0Ul6lJJhSRECZ76xmu22JteGEAPuUje66UARY0imLx8bU3qYM+7HKt4tZ1u60WVqeVdATV6u42hShM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072126427231.67273247947696; Mon, 2 Feb 2026 14:42:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2bu-0007bE-Bj; Mon, 02 Feb 2026 17:41:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bt-0007b2-JA for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:33 -0500 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 1vn2br-0000qD-PW for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:33 -0500 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 6512A3E6C6; Mon, 2 Feb 2026 22:41:19 +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 CDF873EA62; Mon, 2 Feb 2026 22:41: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 KC1QIw0ogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072079; 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=86+JJGb7GtWR/nbtnYPa1W6mDxZAg2FCQqGlH06dIEk=; b=uNwU//SCx78KQ1QOH2eycJjfpNLtXypN1z6zwmdGGhb+OF76PVmb3dWVIGJgovaiIUXgXQ TRX8Ux66/uZ8D2rUgGkRfLAfF/PrD/spqBAz5FAmJ+7HgLC7Hoh2WePY5TlM08jMDqj9Ai Ee638DcRYGgrLEhG4jt7Fc+COvgtmUk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072079; 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=86+JJGb7GtWR/nbtnYPa1W6mDxZAg2FCQqGlH06dIEk=; b=9ZayS/tRBeK/VbCgORRn6lWWowHLbK1kAq58U0YMbZGNAQ44LyyUAZ8nBqxR7GNW5FaaV+ mHygg4oIlbMLw/AA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072079; 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=86+JJGb7GtWR/nbtnYPa1W6mDxZAg2FCQqGlH06dIEk=; b=uNwU//SCx78KQ1QOH2eycJjfpNLtXypN1z6zwmdGGhb+OF76PVmb3dWVIGJgovaiIUXgXQ TRX8Ux66/uZ8D2rUgGkRfLAfF/PrD/spqBAz5FAmJ+7HgLC7Hoh2WePY5TlM08jMDqj9Ai Ee638DcRYGgrLEhG4jt7Fc+COvgtmUk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072079; 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=86+JJGb7GtWR/nbtnYPa1W6mDxZAg2FCQqGlH06dIEk=; b=9ZayS/tRBeK/VbCgORRn6lWWowHLbK1kAq58U0YMbZGNAQ44LyyUAZ8nBqxR7GNW5FaaV+ mHygg4oIlbMLw/AA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com Subject: [PATCH v2 6/9] migration/options: Use QAPI_MERGE in migrate_params_test_apply Date: Mon, 2 Feb 2026 19:40:58 -0300 Message-ID: <20260202224101.20568-7-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-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%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; 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)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; 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=lists.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: 1770072128165154100 Content-Type: text/plain; charset="utf-8" Convert the code in migrate_params_test_apply() from an open-coded copy of every migration parameter to a copy using visitors. The current code has conditionals for each parameter's has_* field, which is exactly what the visitors do. This hides the details of QAPI from the migration code and avoids the need to update migrate_params_test_apply() every time a new migration parameter is added. Both were very confusing and while the visitor code can become a bit involved, there is no need for new contributors to ever touch it. Move the QAPI_CLONE_MEMBERS into the caller, so QAPI_CLONE can be used and there's no need to allocate memory in the migration code. Similarly, turn 'tmp' into a pointer so the proper qapi_free_ routine can be used. An extra call to migrate_mark_all_params_present() is now needed because the visitors update the has_ field for non-present fields, but we actually want them all set so QAPI_CLONE_MEMBERS copies all of them. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/options.c | 145 +++----------------------------------------- 1 file changed, 10 insertions(+), 135 deletions(-) diff --git a/migration/options.c b/migration/options.c index 3c80cdfd3a..180ebed51c 100644 --- a/migration/options.c +++ b/migration/options.c @@ -19,6 +19,7 @@ #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qerror.h" +#include "qapi/type-helpers.h" #include "qobject/qnull.h" #include "system/runstate.h" #include "migration/colo.h" @@ -1265,133 +1266,6 @@ bool migrate_params_check(MigrationParameters *para= ms, Error **errp) return true; } =20 -static void migrate_params_test_apply(MigrationParameters *params, - MigrationParameters *dest) -{ - MigrationState *s =3D migrate_get_current(); - - QAPI_CLONE_MEMBERS(MigrationParameters, dest, &s->parameters); - - if (params->has_throttle_trigger_threshold) { - dest->throttle_trigger_threshold =3D params->throttle_trigger_thre= shold; - } - - if (params->has_cpu_throttle_initial) { - dest->cpu_throttle_initial =3D params->cpu_throttle_initial; - } - - if (params->has_cpu_throttle_increment) { - dest->cpu_throttle_increment =3D params->cpu_throttle_increment; - } - - if (params->has_cpu_throttle_tailslow) { - dest->cpu_throttle_tailslow =3D params->cpu_throttle_tailslow; - } - - if (params->tls_creds) { - qapi_free_StrOrNull(dest->tls_creds); - dest->tls_creds =3D QAPI_CLONE(StrOrNull, params->tls_creds); - } - - if (params->tls_hostname) { - qapi_free_StrOrNull(dest->tls_hostname); - dest->tls_hostname =3D QAPI_CLONE(StrOrNull, params->tls_hostname); - } - - if (params->tls_authz) { - qapi_free_StrOrNull(dest->tls_authz); - dest->tls_authz =3D QAPI_CLONE(StrOrNull, params->tls_authz); - } - - if (params->has_max_bandwidth) { - dest->max_bandwidth =3D params->max_bandwidth; - } - - if (params->has_avail_switchover_bandwidth) { - dest->avail_switchover_bandwidth =3D params->avail_switchover_band= width; - } - - if (params->has_downtime_limit) { - dest->downtime_limit =3D params->downtime_limit; - } - - if (params->has_x_checkpoint_delay) { - dest->x_checkpoint_delay =3D params->x_checkpoint_delay; - } - - if (params->has_multifd_channels) { - dest->multifd_channels =3D params->multifd_channels; - } - if (params->has_multifd_compression) { - dest->multifd_compression =3D params->multifd_compression; - } - if (params->has_multifd_qatzip_level) { - dest->multifd_qatzip_level =3D params->multifd_qatzip_level; - } - if (params->has_multifd_zlib_level) { - dest->multifd_zlib_level =3D params->multifd_zlib_level; - } - if (params->has_multifd_zstd_level) { - dest->multifd_zstd_level =3D params->multifd_zstd_level; - } - if (params->has_xbzrle_cache_size) { - dest->xbzrle_cache_size =3D params->xbzrle_cache_size; - } - if (params->has_max_postcopy_bandwidth) { - dest->max_postcopy_bandwidth =3D params->max_postcopy_bandwidth; - } - if (params->has_max_cpu_throttle) { - dest->max_cpu_throttle =3D params->max_cpu_throttle; - } - if (params->has_announce_initial) { - dest->announce_initial =3D params->announce_initial; - } - if (params->has_announce_max) { - dest->announce_max =3D params->announce_max; - } - if (params->has_announce_rounds) { - dest->announce_rounds =3D params->announce_rounds; - } - if (params->has_announce_step) { - dest->announce_step =3D params->announce_step; - } - - if (params->has_block_bitmap_mapping) { - qapi_free_BitmapMigrationNodeAliasList(dest->block_bitmap_mapping); - dest->block_bitmap_mapping =3D QAPI_CLONE(BitmapMigrationNodeAlias= List, - params->block_bitmap_mappi= ng); - } - - if (params->has_x_vcpu_dirty_limit_period) { - dest->x_vcpu_dirty_limit_period =3D - params->x_vcpu_dirty_limit_period; - } - if (params->has_vcpu_dirty_limit) { - dest->vcpu_dirty_limit =3D params->vcpu_dirty_limit; - } - - if (params->has_mode) { - dest->mode =3D params->mode; - } - - if (params->has_zero_page_detection) { - dest->zero_page_detection =3D params->zero_page_detection; - } - - if (params->has_direct_io) { - dest->direct_io =3D params->direct_io; - } - - if (params->has_cpr_exec_command) { - qapi_free_strList(dest->cpr_exec_command); - dest->cpr_exec_command =3D QAPI_CLONE(strList, params->cpr_exec_co= mmand); - } -} - -/* - * Caller must ensure the has_* fields of @params are true so they all - * get copied and the pointer members don't dangle. - */ static void migrate_params_apply(MigrationParameters *params) { MigrationState *s =3D migrate_get_current(); @@ -1400,12 +1274,17 @@ static void migrate_params_apply(MigrationParameter= s *params) migrate_tls_opts_free(cur); qapi_free_BitmapMigrationNodeAliasList(cur->block_bitmap_mapping); qapi_free_strList(cur->cpr_exec_command); + + /* mark all present, so they're all copied */ + migrate_mark_all_params_present(params); QAPI_CLONE_MEMBERS(MigrationParameters, cur, params); } =20 void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) { - MigrationParameters tmp; + MigrationState *s =3D migrate_get_current(); + g_autoptr(MigrationParameters) tmp =3D QAPI_CLONE(MigrationParameters, + &s->parameters); =20 /* * Convert QTYPE_QNULL and NULL to the empty string (""). Even @@ -1419,14 +1298,10 @@ void qmp_migrate_set_parameters(MigrationParameters= *params, Error **errp) tls_opt_to_str(params->tls_hostname); tls_opt_to_str(params->tls_authz); =20 - migrate_params_test_apply(params, &tmp); + QAPI_MERGE(MigrationParameters, tmp, params); =20 - if (migrate_params_check(&tmp, errp)) { - migrate_params_apply(&tmp); + if (migrate_params_check(tmp, errp)) { + migrate_params_apply(tmp); migrate_post_update_params(params, errp); } - - migrate_tls_opts_free(&tmp); - qapi_free_BitmapMigrationNodeAliasList(tmp.block_bitmap_mapping); - qapi_free_strList(tmp.cpr_exec_command); } --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072161; cv=none; d=zohomail.com; s=zohoarc; b=fxgZf8F2S9/hBRiodkoURYdYFXvbFE+IaEgd7NCYnneiLUK6PyRI+7G/nKwvv7VaOuXfJm9kKJCd1ofAZCo+Ahu9QkkS/Hr+OZsKlpftwQgkMiG0BXuxmxpCIpPgxTBqBw7MmBxPT/M5t/KjThyiYsOGmM6D1XiPki+xBXvP5ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072161; 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=vLMEjTWFupYh/uII/IPnXh1gkX9mRWuYujdX2vbuxhg=; b=KDzMPwKxXCgGYD1o5lGKub3FDkkvwmxQPhCw897DOKVZzZC1RTUn0mUhCwVIl1C6MKBVvR/FJ7732c5DpFBx6qe0y8Iba6S953wZMTeAkCqwAXCMMvMoCkgWzWKzCRtf5n7jCY/7Bd1r0pF/KiMSDLya0GHCszQRnt02RJCVxPw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072161790155.7446174216069; Mon, 2 Feb 2026 14:42:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2br-0007Zn-To; Mon, 02 Feb 2026 17:41:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bp-0007ZD-V3 for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:30 -0500 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 1vn2bo-0000ph-EL for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:29 -0500 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 6FD4D5BCC7; Mon, 2 Feb 2026 22:41: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 D8BCC3EA62; Mon, 2 Feb 2026 22:41: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 4IPzJQ8ogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072081; 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=vLMEjTWFupYh/uII/IPnXh1gkX9mRWuYujdX2vbuxhg=; b=H/3MUdVGf/1ihuTbtVe5Wrz6E4bPQN/4aZUXXLywPW+o4K5IkzalJ9VCkMhrfyZZk1mWAX NI12tMjzVKskvP+oSMlPrhGwU9pU8TZ4eNDOlxQBcCEcmnqDNPC/igpppVEYbaC4p2e+nd 9Xw39wiJQ0E+q/WUrrRaVzDdLMsuJ8U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072081; 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=vLMEjTWFupYh/uII/IPnXh1gkX9mRWuYujdX2vbuxhg=; b=1TMTWsfDzNUtM80XlLejGtF7KtUYt1ZQBgnKNAuNtduZgTxSQdNPaWfkFgehd1yXQ0fUYU oXlZmsv1GoDqncBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="H/3MUdVG"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1TMTWsfD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072081; 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=vLMEjTWFupYh/uII/IPnXh1gkX9mRWuYujdX2vbuxhg=; b=H/3MUdVGf/1ihuTbtVe5Wrz6E4bPQN/4aZUXXLywPW+o4K5IkzalJ9VCkMhrfyZZk1mWAX NI12tMjzVKskvP+oSMlPrhGwU9pU8TZ4eNDOlxQBcCEcmnqDNPC/igpppVEYbaC4p2e+nd 9Xw39wiJQ0E+q/WUrrRaVzDdLMsuJ8U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072081; 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=vLMEjTWFupYh/uII/IPnXh1gkX9mRWuYujdX2vbuxhg=; b=1TMTWsfDzNUtM80XlLejGtF7KtUYt1ZQBgnKNAuNtduZgTxSQdNPaWfkFgehd1yXQ0fUYU oXlZmsv1GoDqncBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com Subject: [PATCH v2 7/9] migration/options: Open code migrate_params_apply Date: Mon, 2 Feb 2026 19:40:59 -0300 Message-ID: <20260202224101.20568-8-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 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)[]; TO_DN_NONE(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(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-Action: no action X-Rspamd-Queue-Id: 6FD4D5BCC7 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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: 1770072164566158500 Content-Type: text/plain; charset="utf-8" Remove migrate_params_apply so the logic of setting migration parameters is all in one spot. Suggested-by: Prasad Pandit Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/options.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/migration/options.c b/migration/options.c index 180ebed51c..733aae51a8 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1266,25 +1266,11 @@ bool migrate_params_check(MigrationParameters *para= ms, Error **errp) return true; } =20 -static void migrate_params_apply(MigrationParameters *params) -{ - MigrationState *s =3D migrate_get_current(); - MigrationParameters *cur =3D &s->parameters; - - migrate_tls_opts_free(cur); - qapi_free_BitmapMigrationNodeAliasList(cur->block_bitmap_mapping); - qapi_free_strList(cur->cpr_exec_command); - - /* mark all present, so they're all copied */ - migrate_mark_all_params_present(params); - QAPI_CLONE_MEMBERS(MigrationParameters, cur, params); -} - void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) { MigrationState *s =3D migrate_get_current(); - g_autoptr(MigrationParameters) tmp =3D QAPI_CLONE(MigrationParameters, - &s->parameters); + MigrationParameters *cur =3D &s->parameters; + g_autoptr(MigrationParameters) tmp =3D QAPI_CLONE(MigrationParameters,= cur); =20 /* * Convert QTYPE_QNULL and NULL to the empty string (""). Even @@ -1300,8 +1286,17 @@ void qmp_migrate_set_parameters(MigrationParameters = *params, Error **errp) =20 QAPI_MERGE(MigrationParameters, tmp, params); =20 - if (migrate_params_check(tmp, errp)) { - migrate_params_apply(tmp); - migrate_post_update_params(params, errp); + if (!migrate_params_check(tmp, errp)) { + return; } + + migrate_tls_opts_free(cur); + qapi_free_BitmapMigrationNodeAliasList(cur->block_bitmap_mapping); + qapi_free_strList(cur->cpr_exec_command); + + /* mark all present, so they're all copied */ + migrate_mark_all_params_present(tmp); + QAPI_CLONE_MEMBERS(MigrationParameters, cur, tmp); + + migrate_post_update_params(params, errp); } --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072181; cv=none; d=zohomail.com; s=zohoarc; b=m2m6F7TaUUK+okuRqeQJ5UvrzoWAw2dLhbxgYqQkV1pKnvW1ljmSHZ3hpcWrSmJKJDpJpDsajcAxdxA7rphSpXnQihMIU5qIUL0ONgM01g0/SFOsdfPQ1Zu2nt3USb4d3G2KCpjOm+ykW2gARGdwyTJc1H8K61pJq0vXBPZOZv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072181; 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=F0Aca5JhzPeivpyWT6R9I7tKBlES4Z2z+7/wZ0kxo7E=; b=nOoV+WjrgHhasOtqNXIEmlnU5W5wjNCv+5JjCnslVzyUXpRdCu4iBb0Yk15rGv0fxZ/ORQaSabCcw4dabmpQUYZRNKmT6Z8k8VO9c6nXN86LR/rFAjQzsFyttDW1FOJI2F8kJiqGsZRu7qgRjEo37xUPrpoao8HfSd7inmgU2YA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072181331668.1522250124734; Mon, 2 Feb 2026 14:43:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2bx-0007c4-4j; Mon, 02 Feb 2026 17:41:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bu-0007bM-VH for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:34 -0500 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 1vn2bt-0000r6-I8 for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:34 -0500 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 7A9485BCC3; Mon, 2 Feb 2026 22:41: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 E350B3EA62; Mon, 2 Feb 2026 22:41: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 cC+DKBEogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072083; 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=F0Aca5JhzPeivpyWT6R9I7tKBlES4Z2z+7/wZ0kxo7E=; b=RmLhdx4EAcpED2NSsdP4gz7Btogywu2f3HxbPELQECeRNjDVJIyM6TRXvGhpGscAEWvecH 8jJcJvNwrKx7h64ogYOGaCXy5/zCVahZ6T5QG8+OKFg0YgxRyz06WxplJ+dm0dlvXkVXM1 0TvU7FEMd8X7887nwZMeqUPBhgXKxQQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072083; 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=F0Aca5JhzPeivpyWT6R9I7tKBlES4Z2z+7/wZ0kxo7E=; b=+K+/1mSRmR5OgrColEhPmLoeCWJdYk916yOczPUF1t4VIZYgj2z0aGye+hgGoBrxIucrNn O4wHD07fBz07xCDg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RmLhdx4E; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="+K+/1mSR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072083; 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=F0Aca5JhzPeivpyWT6R9I7tKBlES4Z2z+7/wZ0kxo7E=; b=RmLhdx4EAcpED2NSsdP4gz7Btogywu2f3HxbPELQECeRNjDVJIyM6TRXvGhpGscAEWvecH 8jJcJvNwrKx7h64ogYOGaCXy5/zCVahZ6T5QG8+OKFg0YgxRyz06WxplJ+dm0dlvXkVXM1 0TvU7FEMd8X7887nwZMeqUPBhgXKxQQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072083; 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=F0Aca5JhzPeivpyWT6R9I7tKBlES4Z2z+7/wZ0kxo7E=; b=+K+/1mSRmR5OgrColEhPmLoeCWJdYk916yOczPUF1t4VIZYgj2z0aGye+hgGoBrxIucrNn O4wHD07fBz07xCDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com Subject: [PATCH v2 8/9] migration/options: Stop freeing s->parameters members individually Date: Mon, 2 Feb 2026 19:41:00 -0300 Message-ID: <20260202224101.20568-9-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-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)[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)[]; TO_DN_NONE(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(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-Spam-Score: -3.01 X-Rspamd-Queue-Id: 7A9485BCC3 X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1770072182442154100 Content-Type: text/plain; charset="utf-8" Expecting every pointer member from s->parameters to be freed individually is prone to leave some fields forgotten when the code is eventually updated. Use a dealloc visitor to free them all at once. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/options.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/migration/options.c b/migration/options.c index 733aae51a8..cc5a66750c 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1002,11 +1002,21 @@ AnnounceParameters *migrate_announce_params(void) return ≈ } =20 -static void migrate_tls_opts_free(MigrationParameters *params) +static bool migrate_params_free(MigrationParameters *params, Error **errp) { - qapi_free_StrOrNull(params->tls_creds); - qapi_free_StrOrNull(params->tls_hostname); - qapi_free_StrOrNull(params->tls_authz); + Visitor *v =3D qapi_dealloc_visitor_new(); + bool ret; + + /* + * qapi_free_MigrationParameters can't be used here because + * MigrationParameters is embedded in MigrationState due to qdev + * needing to access the offset of the migration properties inside + * the migration object. + */ + ret =3D visit_type_MigrationParameters_members(v, params, errp); + visit_free(v); + + return ret; } =20 /* normalize QTYPE_QNULL to QTYPE_QSTRING "" */ @@ -1290,9 +1300,9 @@ void qmp_migrate_set_parameters(MigrationParameters *= params, Error **errp) return; } =20 - migrate_tls_opts_free(cur); - qapi_free_BitmapMigrationNodeAliasList(cur->block_bitmap_mapping); - qapi_free_strList(cur->cpr_exec_command); + if (!migrate_params_free(cur, errp)) { + return; + } =20 /* mark all present, so they're all copied */ migrate_mark_all_params_present(tmp); --=20 2.51.0 From nobody Sun Feb 8 23:32:18 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=1770072141; cv=none; d=zohomail.com; s=zohoarc; b=i0nYOKbCehPH5hO9hWh2N/uhzY39fVNblWIb0C0PaIpTblaw7iJSjMv6GUjDhsTJU2goRXP89aVvYZBkbAOEGdoJcZ9YM/YNxRJK67oazS1wtdTNc2N2RT2M9ZdU13B+sW9jmMXvvO/Xy8ya+xeEihhc9RPovGJX0MpqukDStvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770072141; 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=ndFxx01WeyvmjNVnmB0MnBffvWrdktmIdW9Eby8Lyow=; b=gJH4VOQCgaRsnvOY7w3vUgHOp5ZMnoZn1TSPloOJI/j8LHUZrOkYlijU1noyma+FrXzZlUY37Gv/p1K6fmexLwfpFRZsFmawBWmGh+Y9RmsaWBvIFJcLAHZsawxXLBF+7pt18lVZWcQ9yZ+kPER2pngfoNDfLYWUy+kwfjbHw2I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770072141033849.3571010312907; Mon, 2 Feb 2026 14:42:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vn2c0-0007d3-Ql; Mon, 02 Feb 2026 17:41:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vn2bz-0007cW-6L for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:39 -0500 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 1vn2bx-0000s4-Kd for qemu-devel@nongnu.org; Mon, 02 Feb 2026 17:41:38 -0500 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 8C0C13E6CA; Mon, 2 Feb 2026 22:41: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 F12763EA62; Mon, 2 Feb 2026 22:41: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 qGHyKxMogWl8XgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 22:41:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072085; 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=ndFxx01WeyvmjNVnmB0MnBffvWrdktmIdW9Eby8Lyow=; b=XVmmYfAEgP93eMNzwfMMvN9gAOBNrniwnamz0Pi1JW72R/mRWUaMvCOG3I7Du830shSN0U obgnjZX+A30FabbMqn6v2WcvmCs69dvgKeiQuzawT21+Y6C8wtgmt+qqeuvw51baQEMJGd ptzlNmu5eDqA+pNn7mt+sYmemF3WolI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072085; 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=ndFxx01WeyvmjNVnmB0MnBffvWrdktmIdW9Eby8Lyow=; b=Jqsq+yQi8N1PQMATShz9v2I4CtdnBJ+Zfq1LzNmr1p3s9cJgHSQs2m4C81x2uNBwqS2Xmy wqqlrAFzEyMY5IBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=XVmmYfAE; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Jqsq+yQi DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770072085; 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=ndFxx01WeyvmjNVnmB0MnBffvWrdktmIdW9Eby8Lyow=; b=XVmmYfAEgP93eMNzwfMMvN9gAOBNrniwnamz0Pi1JW72R/mRWUaMvCOG3I7Du830shSN0U obgnjZX+A30FabbMqn6v2WcvmCs69dvgKeiQuzawT21+Y6C8wtgmt+qqeuvw51baQEMJGd ptzlNmu5eDqA+pNn7mt+sYmemF3WolI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770072085; 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=ndFxx01WeyvmjNVnmB0MnBffvWrdktmIdW9Eby8Lyow=; b=Jqsq+yQi8N1PQMATShz9v2I4CtdnBJ+Zfq1LzNmr1p3s9cJgHSQs2m4C81x2uNBwqS2Xmy wqqlrAFzEyMY5IBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: peterx@redhat.com, armbru@redhat.com, ppandit@redhat.com Subject: [PATCH v2 9/9] migration: Use migrate_params_free during finalize Date: Mon, 2 Feb 2026 19:41:01 -0300 Message-ID: <20260202224101.20568-10-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202224101.20568-1-farosas@suse.de> References: <20260202224101.20568-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 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)[]; TO_DN_NONE(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(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-Action: no action X-Rspamd-Queue-Id: 8C0C13E6CA X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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: 1770072144679158501 Content-Type: text/plain; charset="utf-8" Use the recently introduced migrate_params_free routine at migration_instance_finalize() so that newly added pointers are already freed by default. Special case: The TLS options are currently the only pointers that also have a qdev property implementation, so they will be freed by qdev using the .release method. Update the method so that a second invocation of qapi_free_StrOrNull doesn't assert. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/migration.c | 3 +-- migration/options.c | 7 ++++--- migration/options.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index b103a82fc0..303626c2a9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3840,8 +3840,7 @@ static void migration_instance_finalize(Object *obj) { MigrationState *ms =3D MIGRATION_OBJ(obj); =20 - qapi_free_BitmapMigrationNodeAliasList(ms->parameters.block_bitmap_map= ping); - qapi_free_strList(ms->parameters.cpr_exec_command); + migrate_params_free(&ms->parameters, NULL); qemu_mutex_destroy(&ms->error_mutex); qemu_mutex_destroy(&ms->qemu_file_lock); qemu_sem_destroy(&ms->wait_unplug_sem); diff --git a/migration/options.c b/migration/options.c index cc5a66750c..2fc86933be 100644 --- a/migration/options.c +++ b/migration/options.c @@ -254,8 +254,9 @@ static void set_StrOrNull(Object *obj, Visitor *v, cons= t char *name, =20 static void release_StrOrNull(Object *obj, const char *name, void *opaque) { - const Property *prop =3D opaque; - qapi_free_StrOrNull(*(StrOrNull **)object_field_prop_ptr(obj, prop)); + StrOrNull **ptr =3D object_field_prop_ptr(obj, opaque); + + g_clear_pointer(ptr, qapi_free_StrOrNull); } =20 static void set_default_value_tls_opt(ObjectProperty *op, const Property *= prop) @@ -1002,7 +1003,7 @@ AnnounceParameters *migrate_announce_params(void) return ≈ } =20 -static bool migrate_params_free(MigrationParameters *params, Error **errp) +bool migrate_params_free(MigrationParameters *params, Error **errp) { Visitor *v =3D qapi_dealloc_visitor_new(); bool ret; diff --git a/migration/options.h b/migration/options.h index 0c3043f1ff..314cdba8d1 100644 --- a/migration/options.h +++ b/migration/options.h @@ -92,4 +92,5 @@ ZeroPageDetection migrate_zero_page_detection(void); =20 bool migrate_params_check(MigrationParameters *params, Error **errp); void migrate_params_init(MigrationParameters *params); +bool migrate_params_free(MigrationParameters *params, Error **errp); #endif --=20 2.51.0