{"id":2223262,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2223262/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260414223718.23965-1-farosas@suse.de/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260414223718.23965-1-farosas@suse.de>","date":"2026-04-14T22:37:18","name":"[v1] migration: Use QAPI_CLONE_MEMBERS in migrate_params_test_apply","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0a93f2669ee985eb81ba2937acb90fd4d0e86bc0","submitter":{"id":85343,"url":"http://patchwork.ozlabs.org/api/1.1/people/85343/?format=json","name":"Fabiano Rosas","email":"farosas@suse.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260414223718.23965-1-farosas@suse.de/mbox/","series":[{"id":499897,"url":"http://patchwork.ozlabs.org/api/1.1/series/499897/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499897","date":"2026-04-14T22:37:18","name":"[v1] migration: Use QAPI_CLONE_MEMBERS in migrate_params_test_apply","version":1,"mbox":"http://patchwork.ozlabs.org/series/499897/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223262/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223262/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=dyk73w7v;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=6hsgq//Z;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=iYT9gdC1;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=s5VhVk8i;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)","smtp-out1.suse.de;\n\tnone"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwK0z4syrz1yHM\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 08:37:55 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wCmO7-0003qR-39; Tue, 14 Apr 2026 18:37:43 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1wCmO4-0003pZ-V1\n for qemu-devel@nongnu.org; Tue, 14 Apr 2026 18:37:40 -0400","from smtp-out1.suse.de ([195.135.223.130])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1wCmO3-0008HE-3B\n for qemu-devel@nongnu.org; Tue, 14 Apr 2026 18:37:40 -0400","from imap1.dmz-prg2.suse.org (unknown [10.150.64.97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id 759576A8E9;\n Tue, 14 Apr 2026 22:37:36 +0000 (UTC)","from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5560D4B6A3;\n Tue, 14 Apr 2026 22:37:35 +0000 (UTC)","from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id QAXPCa/B3mlmVwAAD6G6ig\n (envelope-from <farosas@suse.de>); Tue, 14 Apr 2026 22:37:35 +0000"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1776206257;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding;\n bh=WNOsvQPN/mjRJ8dQDJAMMsNsxvctAmMjLUyub5lQrgc=;\n b=dyk73w7vS7oxSQHHhS9nns1lp1zIaOfvd/e1Z7eUIxTcImgh+z5uMd9KEoIK0M0+LI0wQa\n VHt4CJ030KTjK7QlV5Sd2rVcYsMn8f7zSomOZBibtvNl+v4yYqozVzEj9+yNbPK352aXLq\n f3keQsfEv5j3BTjlPGpPUMaXuaW9bFY=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776206257;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding;\n bh=WNOsvQPN/mjRJ8dQDJAMMsNsxvctAmMjLUyub5lQrgc=;\n b=6hsgq//Z+lTR8uQrKhVHQAhEUonH+q3bkArpiTvAaPzZaZrv6wzFBEtj5W2ish3jYES/Cv\n kQXckk90co5GUuBg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1776206256;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding;\n bh=WNOsvQPN/mjRJ8dQDJAMMsNsxvctAmMjLUyub5lQrgc=;\n b=iYT9gdC1dbt/qCVEo2J6DLw+Vu8+d4ZUmT7ILKD8QXrL9Wfw+tGjPyt7uYfmntNF4mLry6\n JO8GDYe6ePlwW7phXQsDFQ73S4JYBZiVVCAm8u5MuDCQsIC7jlcKzvYgz5SV+zcHOdXNlI\n BDu+XvFqCXcDYgpfv72pewsXlOSdZas=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776206256;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding;\n bh=WNOsvQPN/mjRJ8dQDJAMMsNsxvctAmMjLUyub5lQrgc=;\n b=s5VhVk8iZMtM03UDpYzI+3izWoX2Zo8B0smdkpp36+UJER+/DkzEXNZOK8yewbyS2tcePO\n ssmUIUpScnjJWSAg=="],"From":"Fabiano Rosas <farosas@suse.de>","To":"qemu-devel@nongnu.org","Cc":"Peter Xu <peterx@redhat.com>, Peter Maydell <peter.maydell@linaro.org>,\n \"Maciej S. Szmigiero\" <mail@maciej.szmigiero.name>","Subject":"[PATCH v1] migration: Use QAPI_CLONE_MEMBERS in\n migrate_params_test_apply","Date":"Tue, 14 Apr 2026 19:37:18 -0300","Message-ID":"<20260414223718.23965-1-farosas@suse.de>","X-Mailer":"git-send-email 2.51.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spamd-Result":"default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[];\n R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000];\n MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+];\n TO_DN_SOME(0.00)[];\n DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo];\n RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[];\n RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[]","X-Spam-Score":"-2.80","Received-SPF":"pass client-ip=195.135.223.130; envelope-from=farosas@suse.de;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Use QAPI_CLONE_MEMBERS instead of making an assignment. The QAPI\nmethod makes the handling of the TLS strings more intuitive because it\nclones them as well.\n\nThis also fixes a segfault when a NULL TLS option is accessed as part\nof a validation check for another option (e.g. in the zero-copy +\nmultifd compression case). Details follow:\n\nCurrently, after copying s->parameters to the temporary\nMigrationParameters object before migrate_params_check(), the\nreferences in temporary object to the TLS options are dropped, either\nbecause:\n\na) the user set a new option, in which case that's fine as\n   s->parameters still holds the reference to the old memory or,\n\nb) the user did not set a new option, in which case keeping the\n   references in the temporary object would later cause them to be\n   freed along with it, leading to double-free when s->parameters is\n   also freed later on.\n\nIn this second case, it was overlooked that the TLS options can be\naccessed already during migrate_params_check() as part of validation\nof another option. Those pointers should not have been cleared.\n\nUsing QAPI_CLONE_MEMBERS fixes the issue because the temporary object\nis not stealing a reference from s->parameters anymore.\n\nFixes: aed97f0563 (\"migration: Normalize tls arguments\")\nReported-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>\nLink: https://lore.kernel.org/r/a65a1049-9f19-460a-8e27-a62bb30d2727@maciej.szmigiero.name\nReviewed-by: Peter Xu <peterx@redhat.com>\nSigned-off-by: Fabiano Rosas <farosas@suse.de>\n---\nNOTE#1: For the release we could have a simpler fix just checking for\nNULL, but that would allow two unsupported configurations to be\naccepted: zero-copy with either multifd compression or TLS.\n\nNOTE#2: CI is red due to pre-existing failure in functional tests with\n\"exec:socat\" migration.\n---\n migration/options.c | 26 ++++++++++++--------------\n 1 file changed, 12 insertions(+), 14 deletions(-)","diff":"diff --git a/migration/options.c b/migration/options.c\nindex 7556fbc06b..68441f0276 100644\n--- a/migration/options.c\n+++ b/migration/options.c\n@@ -1279,9 +1279,9 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)\n static void migrate_params_test_apply(MigrationParameters *params,\n                                       MigrationParameters *dest)\n {\n-    *dest = migrate_get_current()->parameters;\n+    MigrationState *s = migrate_get_current();\n \n-    /* TODO use QAPI_CLONE() instead of duplicating it inline */\n+    QAPI_CLONE_MEMBERS(MigrationParameters, dest, &s->parameters);\n \n     if (params->has_throttle_trigger_threshold) {\n         dest->throttle_trigger_threshold = params->throttle_trigger_threshold;\n@@ -1300,24 +1300,18 @@ static void migrate_params_test_apply(MigrationParameters *params,\n     }\n \n     if (params->tls_creds) {\n+        qapi_free_StrOrNull(dest->tls_creds);\n         dest->tls_creds = QAPI_CLONE(StrOrNull, params->tls_creds);\n-    } else {\n-        /* clear the reference, it's owned by s->parameters */\n-        dest->tls_creds = NULL;\n     }\n \n     if (params->tls_hostname) {\n+        qapi_free_StrOrNull(dest->tls_hostname);\n         dest->tls_hostname = QAPI_CLONE(StrOrNull, params->tls_hostname);\n-    } else {\n-        /* clear the reference, it's owned by s->parameters */\n-        dest->tls_hostname = NULL;\n     }\n \n     if (params->tls_authz) {\n+        qapi_free_StrOrNull(dest->tls_authz);\n         dest->tls_authz = QAPI_CLONE(StrOrNull, params->tls_authz);\n-    } else {\n-        /* clear the reference, it's owned by s->parameters */\n-        dest->tls_authz = NULL;\n     }\n \n     if (params->has_max_bandwidth) {\n@@ -1374,8 +1368,9 @@ static void migrate_params_test_apply(MigrationParameters *params,\n     }\n \n     if (params->has_block_bitmap_mapping) {\n-        dest->has_block_bitmap_mapping = true;\n-        dest->block_bitmap_mapping = params->block_bitmap_mapping;\n+        qapi_free_BitmapMigrationNodeAliasList(dest->block_bitmap_mapping);\n+        dest->block_bitmap_mapping = QAPI_CLONE(BitmapMigrationNodeAliasList,\n+                                                params->block_bitmap_mapping);\n     }\n \n     if (params->has_x_vcpu_dirty_limit_period) {\n@@ -1399,7 +1394,8 @@ static void migrate_params_test_apply(MigrationParameters *params,\n     }\n \n     if (params->has_cpr_exec_command) {\n-        dest->cpr_exec_command = params->cpr_exec_command;\n+        qapi_free_strList(dest->cpr_exec_command);\n+        dest->cpr_exec_command = QAPI_CLONE(strList, params->cpr_exec_command);\n     }\n }\n \n@@ -1555,4 +1551,6 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)\n     }\n \n     migrate_tls_opts_free(&tmp);\n+    qapi_free_BitmapMigrationNodeAliasList(tmp.block_bitmap_mapping);\n+    qapi_free_strList(tmp.cpr_exec_command);\n }\n","prefixes":["v1"]}