From nobody Sun Oct 25 09:31:19 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791362283; cv=none; d=zohomail.com; s=zohoarc; b=mGeW+y/rYGBpwKoYNPiXc7UPQ2DszSIW6ewLsbgnEYSn2YCT7609x+mEBNnOTZjJIRYan7DHnEQGYLiiJQ1RrCfY9JhAc6rUDr/51+TN04VKPG6Bvmw3xgT2s8KjZrdA1BXt4MmdIcjRaA/UdsFlm5y1WFoUVyFaKnAvqub1rPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791362283; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qaVb+pX+Dprf1Z/whMh/eAqXrLOZN7xKMykck4AAS0Y=; b=DxwaeoxJzulr9N+rjnj0usXyRSB8p4sFe1+pheJ5XhEw+I8Y4fhz+i0D1MZ1apYI/T33mIXQo5mKOntIGIy/61YTQ1WGR3MoUsVKSwQX0L92U6fZiVHP/ebIaAZYIAf8QVM7SwdRfdWkOIleQk5qOJANHZ7g4XqkLqgfAjN4s/Q= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791362283881811.4088868616078; Wed, 7 Oct 2026 01:38:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xEMwM-0005On-N2; Wed, 07 Oct 2026 04:23:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEHlN-0006TC-Nz for qemu-devel@nongnu.org; Tue, 06 Oct 2026 22:52:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEHl2-0004rJ-0U for qemu-devel@nongnu.org; Tue, 06 Oct 2026 22:52:01 -0400 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-R2SdGNe2MUKVab-khd489g-1; Tue, 06 Oct 2026 14:20:50 -0400 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-93caf6c528aso489126285a.0 for ; Tue, 06 Oct 2026 11:20:50 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93e98da8aeasm25815485a.0.2026.10.06.11.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 11:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791341436; h=from:from:reply-to:subject:subject: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=qaVb+pX+Dprf1Z/whMh/eAqXrLOZN7xKMykck4AAS0Y=; b=YXNO/cwtkSYOEOjRyod1LXzm3+nBXixYBwPQNmvSiKSe9E20AquRtojgjdbx/VxVIeHCId rzVBNrYEmVZGQ6xt/sTKLQsBOQ00MJ2rjtpNSmpBOIyiYASti3Kl0kp8PWDDW5duDozudm R+fwJURMXYmq5+pTha2aT0+uehofSSw= X-MC-Unique: R2SdGNe2MUKVab-khd489g-1 X-Mimecast-MFC-AGG-ID: R2SdGNe2MUKVab-khd489g_1791310850 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1791310850; x=1791915650; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qaVb+pX+Dprf1Z/whMh/eAqXrLOZN7xKMykck4AAS0Y=; b=paBa48t7Qv0edq8+PfrBLyxsyoAPWoXNbEa67fJ84dH4fOnah52KRy1UCcLI8Hz1hj apeI/DANKaWHjhsxGjz0Xfk8vITjE/en6jGb7S0TRIfFfdd5FHnRedWrYhM2I+d9ayi7 Sbrlr6ebS1ZEG6Q7Bvn2xtITXl8SQfOFHDfGDrE7Fxj8fcwWpIkfkBkM/sROyLsY3SuW XiWoKR6v7IznlQ5toFvhw1C1WEfiw6A2i86e0dRykG4OYIgTGOvY8mwPSsOPtMUBjcf8 I18rX5Rda6KZAHuowaDXaxTt4j7yxmM2op/UjSGUfogScwaXVb1QtWSS+1kTvfBXNn7t EtAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791310850; x=1791915650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qaVb+pX+Dprf1Z/whMh/eAqXrLOZN7xKMykck4AAS0Y=; b=IZuO5DDygnAZBIiAVq2gXB89vjMREOyL594xiQLaf+T5xr0iAfYJb2J6G3AUG2wIjX 3grVE3DgGP3LKIoj75gM2f7KZQOs0tVrdGVj2wlguTbB63Vzy6b/RVtoykM2ijMWri0E OJlubREqj3WXuaJWVI5DMBh5JZYjd62XeEX3HYcgNtEA84+o8oJOdmsec6HG948FQ25c 1kTOGpoWi4Ju1MF0RMYcXNfW5R8+M3gnSwdmU0ao2TWBYj8pKLcY5/BcAfEsrlIGVVoh 2YGUg7jGuYNJ7dzc9XIzIzwZDPuHkLsE6Sgb+5Hgw/a1GJSRrzivqtUJopYCR93n3pz0 X9Dg== X-Gm-Message-State: AFuF++l8w4ybVxcXXH5qhLk69469URYGF+NoqZlPk3a+C+vkndeR6zUJ kdjLd8zYRUSN+dG49XftUBM0DC8FuOUMRkGEiZQg/ya7dUu2kfRz8zfJ9BMjZQRVjT2DDaMLunz nAZA6wRZsH/qe8kOr1MqxNCaIOSDvPnv1FPgJk0VOWkLF4EaZkM3r18RC+/ULrtl1pl4xanu8/5 2ctIDqSI0oFPZVia84Ee0q//BKUG4tN2pUEcAY9A== X-Gm-Gg: AYBFou3Av3llwabINGYMTweakkgtfXgra1T4oaKCiY297+Bjx3MFWp7C2cNLvDm8yEg qsAOUGRgeEsVAY0xjLHR63iTsI3J1WQ0xxJ3tfw8T+YaKXG/ykr/K3QqXW6139DNzmuyjBi6akt Ol+qoojAFTjtLJpFP3Fb9n4raOM/DQez2Q2xMRR5H3HfiH8+zo+SD0VGvdSilAYRcIDTqSdq1zv GWWSfepYGzNocnYHDaxKnr3q3Ll4Esgrt26lCkc5/Zh4GvZOUa38WUut2Jc0XFEkW8r1QIquPXu TIu/7MDscZQnmXdv8eqOTzOLRpO46ggUonKjlu2v98SGDdBhKy8gz01+ngfbpUhKUAUFVgA= X-Received: by 2002:a05:620a:3911:b0:93e:980a:2ff9 with SMTP id af79cd13be357-93e980a3102mr138785985a.77.1791310849851; Tue, 06 Oct 2026 11:20:49 -0700 (PDT) X-Received: by 2002:a05:620a:3911:b0:93e:980a:2ff9 with SMTP id af79cd13be357-93e980a3102mr138777485a.77.1791310849244; Tue, 06 Oct 2026 11:20:49 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH v2 1/7] tests/migration-test: Add multifd+postcopy test for preempt recovery Date: Tue, 6 Oct 2026 14:20:40 -0400 Message-ID: <20261006182046.3767283-2-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261006182046.3767283-1-peterx@redhat.com> References: <20261006182046.3767283-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1791362284978158500 Content-Type: text/plain; charset="utf-8" We have one for TLS, but we don't have the non-TLS version. Add it. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/qtest/migration/postcopy-tests.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/qtest/migration/postcopy-tests.c b/tests/qtest/migration= /postcopy-tests.c index 13a5759655..6c4fd31152 100644 --- a/tests/qtest/migration/postcopy-tests.c +++ b/tests/qtest/migration/postcopy-tests.c @@ -89,6 +89,15 @@ static void test_multifd_postcopy_preempt(char *name, Mi= grateCommon *args) test_postcopy_common(args); } =20 +static void test_multifd_postcopy_preempt_recovery(char *name, + MigrateCommon *args) +{ + args->start.caps[MIGRATION_CAPABILITY_MULTIFD] =3D true; + args->start.caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT] =3D true; + + test_postcopy_recovery_common(args, POSTCOPY_FAIL_NONE); +} + void migration_test_add_postcopy(MigrationTestEnv *env) { migration_test_add_postcopy_smoke(env); @@ -113,6 +122,8 @@ void migration_test_add_postcopy(MigrationTestEnv *env) test_multifd_postcopy); migration_test_add("/migration/multifd+postcopy/preempt/plain", test_multifd_postcopy_preempt); + migration_test_add("/migration/multifd+postcopy/preempt/recovery/p= lain", + test_multifd_postcopy_preempt_recovery); if (env->is_x86) { migration_test_add("/migration/postcopy/suspend", test_postcopy_suspend); --=20 2.55.0 From nobody Sun Oct 25 09:31:19 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791363133; cv=none; d=zohomail.com; s=zohoarc; b=RjlnRiNLIcJotZz1IRw/Z1nw54W0vngRkEHHo6huOTPzUdLiO8I6ye0EZnTyJ8QkjYXEVMSoRfxHK6+6BHhNn7O4US06J/HbjaYC2fwJA+eEZKUPV0c6m6GgGbjs/Z6rWSSj3fv9mM4gm/n9h180x11b986gqKspuiBqiIwK0L4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791363133; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cqpRJxQS+iNTJ0+npVm/fkKuNV78OA2rpfF1fhhaJNk=; b=SXmrsoeIeXa+mrU9/kKET980oAWQc4wNqggzhcnyGz+g8ZC1t/YB/qR7AFR/tlOkNQZNnlc0/M+sbHXRHM+2t85thd6Gm0q7fJbEvdV5Fyk7R/qR/yeF3hSSvqEF7u3PdqaPjyiZbN6cltvoXiR5ZEXSEp7y5vJ+F9IoPxRxzqo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791363133225477.27685714515576; Wed, 7 Oct 2026 01:52:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xENAJ-0003cJ-Gd; Wed, 07 Oct 2026 04:38:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEINT-0003Sd-W4 for qemu-devel@nongnu.org; Tue, 06 Oct 2026 23:31:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEIND-00078J-RP for qemu-devel@nongnu.org; Tue, 06 Oct 2026 23:31:28 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-Z_LSY-NMPv2-Unow2onxNA-1; Tue, 06 Oct 2026 14:20:52 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-534f3fe0236so57007651cf.2 for ; Tue, 06 Oct 2026 11:20:52 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-53571f162e7sm1995671cf.1.2026.10.06.11.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 11:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791343803; h=from:from:reply-to:subject:subject: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=cqpRJxQS+iNTJ0+npVm/fkKuNV78OA2rpfF1fhhaJNk=; b=a/gT/uuaM1NacdagrMwMkjijQEf9pRCNKOgwlxyUsx7oKhKGHDgbdl3wE0KojEnwtgaeCf dX7r0m6urPd6sgmBDkAVtYbvX8OGO5xpct0qe3JeSiTUYDwzUpc6d7hhp7r4dRIbyg7Klo K/z793thXDQHk6A/jrWWZ0dq87El0JQ= X-MC-Unique: Z_LSY-NMPv2-Unow2onxNA-1 X-Mimecast-MFC-AGG-ID: Z_LSY-NMPv2-Unow2onxNA_1791310852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1791310852; x=1791915652; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cqpRJxQS+iNTJ0+npVm/fkKuNV78OA2rpfF1fhhaJNk=; b=bmTnbXAeYJWjO6ZYnzz46H4n6akpr4PiONQm8cH9yPXKIwRAvcdMiM1KVXjof4Cg/v ZzqziFGHwLsEkDhyXYzXkaUIl7NBxt98aO5hkCrFwkjgo5W7vqOoYne/v+hC/u9jFWtM SLSG0J3KLMFBnRMlRjG5ven0NDnnDRKirYwzb89se98jhquHnkUZFiVonE6AD2sJCWrx gp0XQTfoYgsASlAnsO6ljUc5orX4qR3Wuwq5q5HLbG8tgYB4ey3AVkOnlZUi9a4NJCmB ArtcwxNSWVM8VKMHaPGXkeMC6bJJPxXMRct4DQauef78rGkhK8VMeC/C+GUL1D1NH9tY tKyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791310852; x=1791915652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=cqpRJxQS+iNTJ0+npVm/fkKuNV78OA2rpfF1fhhaJNk=; b=fc7ugjfoEwy/gNLeAtgC7y4e3Do03fQQBljOHHx4zuwUvRzMf/I+konlmWqBXgqVut qP/kYhiCdLbm1CoGug9YA8wciVmsn4wZZliI/hfRJxRUBOYHg66TxCcCHIYKnsqQWggv OyTIIJJ/rUJwp6kafFsRiTW4o/jrkhkJCCZ7jZ+4+e5a+6Fs11+em861bRrVep9qJpkI Uwsk5/lk643I9sb/SeNU32NxEZjvYn47ov0mV6C3EWkTHAJABNSzvvBFsgDgp+ZrKgPe +fkk9OmzaxfOxPSBLWW310Y/xSfHYmbaKz3No4qdc/1aB7/k/EnS9nahOjQy+3M/aR7L q/SQ== X-Gm-Message-State: AFuF++ly2QYbRwLLdizZmvk57pRtdz3gpkZDjf3dRzG9gVs+QBmb8ahZ aDAxDaheUSSLa8fgi2gwdTNal/fUZksUtOkW8jTjFiXtTKTrp03emq6CMsj1e8lVsD9ZoeFAH8/ Bl0cZmM9AHLUr/LRIjdBzWXCpUqFCRUU6mXNnk9ooBOmkJ4vPuVzrKEKw6srLfapdX+/lvXCOmb P7pRA5FGR9Tfs3PE8iYzs3dOkSTvw+JCakxKmhlA== X-Gm-Gg: AYBFou2sUCXCVenIMD+fqwQHAcJGM18/VUjtetfiioAUGSueNLPnU1cskTBb9neE1k5 j4Od5lcYNJcAY5hzsDbxk5fWQzKITk0WYcx0q4Y78OwnBEDfus1Q0dCc7LNd7zZbzksy2bv5nFM weJoEJVCxHR8A4f6JLIlPtGfZniM7liIm18C2xpaAnobnFkZertw22zZ4t+VFnCJueA4nHGiPKm 9ip6W5x8CR/OG3HckW/2vNArzju/0pzFLP5VNdm12Y8+cLqXXK+1t8k9p4jyGauB1nS7nqDWt0X MU4mB7P4bWKueBwzHn2JbHbZXH7LDbACfcZwP7kG4B27VJADvnlzjicX77GWzBIpkvAhXEI= X-Received: by 2002:ac8:5f10:0:b0:533:8cc0:2e17 with SMTP id d75a77b69052e-53566d94c2emr35082831cf.50.1791310851556; Tue, 06 Oct 2026 11:20:51 -0700 (PDT) X-Received: by 2002:ac8:5f10:0:b0:533:8cc0:2e17 with SMTP id d75a77b69052e-53566d94c2emr35082071cf.50.1791310850728; Tue, 06 Oct 2026 11:20:50 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH v2 2/7] migration: Add two more trace points for incoming channel mgmt Date: Tue, 6 Oct 2026 14:20:41 -0400 Message-ID: <20261006182046.3767283-3-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261006182046.3767283-1-peterx@redhat.com> References: <20261006182046.3767283-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1791363133633158500 Content-Type: text/plain; charset="utf-8" We have trace points for both multifd channel and preempt channel when a new channel is established on the destination, but no main channel. We can normally deduce this by analyzing the socket channel tracepoints, but add one for debugging purpose so in a trace log we can see when all channels are established. Add one more for start / resume of incoming migration too. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/migration.c | 3 +++ migration/trace-events | 2 ++ 2 files changed, 5 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index fab7949fe1..3ffc0c2c6a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -852,6 +852,7 @@ bool migration_incoming_setup(QIOChannel *ioc, uint8_t = channel, Error **errp) assert(!mis->from_src_file); mis->from_src_file =3D f; qemu_file_set_blocking(f, false, &error_abort); + trace_migration_main_channel_received(); break; =20 case CH_MULTIFD: @@ -918,6 +919,8 @@ static bool postcopy_try_recover(void) =20 void migration_start_incoming(void) { + trace_migration_start_incoming(); + if (postcopy_try_recover()) { return; } diff --git a/migration/trace-events b/migration/trace-events index db911fe6f2..68bcf12dc7 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -200,6 +200,8 @@ postcopy_preempt_enabled(bool value) "%d" migration_precopy_complete(void) "" migration_call_notifiers(int type) "type=3D%d" migration_request_switchover_ack_legacy(const char *requester, unsigned in= t switchover_ack_pending_num_legacy) "Requester %s, switchover_ack_pending_= num_legacy %u" +migration_main_channel_received(void) "" +migration_start_incoming(void) "" =20 # migration-stats migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t= rdma) "qemu_file %" PRIu64 " multifd %" PRIu64 " RDMA %" PRIu64 --=20 2.55.0 From nobody Sun Oct 25 09:31:19 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791363224; cv=none; d=zohomail.com; s=zohoarc; b=FYkfB/f1xFT4AhAwaBYeTj+/sXDoQ6iGh3T4goIui6uk6bRWGNJrLXNhigRkPlZ/oaW08ZMNYM0yobOIle6lqgE1XUdxxcUxJkwLOQAvSWOKZDJ6GvotcrXkAvv18I5p60xZO1bg9iPWA6i6gwJC3bsfkjrz3Tu0kLz3HCma0/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791363224; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9nwNhbSo70/X0tJPmtDCKCPQvZwR26DjNXeNb2q93IA=; b=ibH6SLCogckODlK05qVFSfRuxxDUgARaKU3PgjnWlxLcvaX9/dhxyjq2La7whl6fltMeaygJg2k8V6R9/BXW3Ne1MfK0luG38dd+kM59IH7jBLU8yNNkL/J5VPPwMLudriYmmkbzRH68e+WYjpKzcNKfuQMmBEMSLS+Jn5ub+2I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791363224084964.2028060029932; Wed, 7 Oct 2026 01:53:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xENCu-0001es-Cq; Wed, 07 Oct 2026 04:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEIjY-0006lN-AF for qemu-devel@nongnu.org; Tue, 06 Oct 2026 23:54:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEIjM-0003BI-6D for qemu-devel@nongnu.org; Tue, 06 Oct 2026 23:54:15 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-260-bp19xN5IOCm6Z6Xauof5vg-1; Tue, 06 Oct 2026 14:20:53 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-51c26012cd0so55198341cf.0 for ; Tue, 06 Oct 2026 11:20:53 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-53571f19a98sm1962751cf.3.2026.10.06.11.20.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 11:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791345243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9nwNhbSo70/X0tJPmtDCKCPQvZwR26DjNXeNb2q93IA=; b=WEwuTwhQ4ByrUV3o/R5M765SvhV9yQNXiSGOvEgeWD6w9o3+NQsNR+5OFf4hHVIfmbvyIE hpVaO/6UHY5MJl/9mtj5EajTJAiVAy7TFVbNE2spyzOaB3j9Gk8KxQ0OJJyzw8xyUfumvq crhGLhcJj/WXHF5L34x7cJS++fCK/Ig= X-MC-Unique: bp19xN5IOCm6Z6Xauof5vg-1 X-Mimecast-MFC-AGG-ID: bp19xN5IOCm6Z6Xauof5vg_1791310853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1791310853; x=1791915653; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=9nwNhbSo70/X0tJPmtDCKCPQvZwR26DjNXeNb2q93IA=; b=eb7X5PgthJtPt9H2G5hu5nLqD1uZvEdQWEqi4ZTzRDOAe19vKqkC8P99UysCaSOboM v5cGv+g2gvbLZv65ad2BC0mqFvLQ3HlS5HEi3XNN5Qx3ou1L/WLue7hofmiLeF9aueex zzo5g3KFUKshTugF9e8caSoWzl2EEQ87HIyIf9/TCqG9JMA1M4JhidykMJG6Ob3uSJ71 jm1UGGB7XyZAs7pU9cI8LxbSoX+vCH4RcqZSfhudnCInjChuQ8PHSz4fX8dyzLk5Ixdo DEnms05jm4JPLSmgY1qC7EI65JyTxwLJFHyoPhSETp0vYIeQKhtRuutgoYvtwhJnqnOI SckQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791310853; x=1791915653; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9nwNhbSo70/X0tJPmtDCKCPQvZwR26DjNXeNb2q93IA=; b=Io0wzZHqIfooL6lxtP7f4c9qFV586Mg3nEjZdyat2XIX/B/TWcRdJ1j2KHSUq2Rqve vIHYmcZPF6I6Ej0RjQlmIM+AWZYOZh3IrO2LzaWRDqm05MKaJlKIlZ/5OfgYQE4ztfnh xBzjzEV7taP1Ejew8MzQ0yrzJwK3XPAQaJSL5LwHWe/JF9Y3yKnw1EQxKgahh5yFLyH1 XQx+/Jj1OHik+XcwxQGYhaQZHfKsWPvrqIwgOfWmMG1uI8IijiIB7cAliRuyiAxbM0uu KmbaqyCoYemQG4H1V24LawPxg7R5ANbPHWT1fDnaFqUj1S4stvKNyNihbksk/TQALwUl EGQg== X-Gm-Message-State: AFuF++kY9C4Xv14vidW6zVEfbIbEv5426dMG1IbOI/RVRVyYP/jp/b+c /eToY8XMwQcksSH/9AccPwZE3xbj6peLMVuwOlYrco7Oa4YdqZAZCjdAzb8IAZA033H0dPgr76N vH4qBPDVv0Jau9+K8rBts4BEQ1FFoxN3gd6mvSmgxn7V5PBzjd8DGOoVp0fFDq6cxvNP/8/C0i0 QIxIfkPDYjoacobOV0jxE54MbXEhN9HSKD986LKQ== X-Gm-Gg: AYBFou3NSlz2HeNl1eHEHyhj99oRy1tdhmB++/+GJMys7qT/OGEVMVueQky1aPp9BEj mkLm7N3FMZJ+3BUqrNc7ZzYbprSrBW7dIoAR91wRBX6xgWnMBAYcDJ7+oSWjiScc3S34ZF3ao0o AgApoDhm1MnzLbAqiL7VfLcJZ2LwoOK6+ufG+aqk3VFtQQDLBHU94WII68RXXIvj+jgkYFdnD5d feogTmt6kFP7DBSDyFm5C9j3BxLja2LWyrNWs7i53tQOzaflyWnRhMxiowR6VYfoR90hyPz6am2 SHm0dCwbwxFCgb0WmNZEtiU48fQ/n+2vwsM+H61IEF252B/qB5ccrbFYJhdg66zcJOl8hJ0= X-Received: by 2002:a05:622a:6f12:10b0:535:70c4:9a92 with SMTP id d75a77b69052e-53570c49d02mr9959391cf.72.1791310852815; Tue, 06 Oct 2026 11:20:52 -0700 (PDT) X-Received: by 2002:a05:622a:6f12:10b0:535:70c4:9a92 with SMTP id d75a77b69052e-53570c49d02mr9958911cf.72.1791310852225; Tue, 06 Oct 2026 11:20:52 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Akash Kulhalli , Juraj Marcin , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 3/7] migration: Fix socket listen backlog Date: Tue, 6 Oct 2026 14:20:42 -0400 Message-ID: <20261006182046.3767283-4-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261006182046.3767283-1-peterx@redhat.com> References: <20261006182046.3767283-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1791363226122158500 QEMU incoming side may have set a wrong listen() backlog. After the support of multifd + postcopy now we have four possibilities on setting the backlog, some of them are wrong: Vanilla: 1 (correct) Multifd: N (wrong, should be N+1) Preempt: 2 (correct) Multifd+Preempt: N (wrong, should be N+2) No real report for this, found by code observation only. Logically the backlog (pending accept requests on destination on the listening sockets) needs to be the maximum of possible channels. Otherwise if the accept queue full on destination, source QEMU may hit connection errors. Cc: Daniel P. Berrang=C3=A9 Fixes: 0705e56496 ("multifd: Use number of channels as listen backlog") Fixes: e274188612 ("migration: enable multifd and postcopy together") Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Rosas --- migration/socket.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/migration/socket.c b/migration/socket.c index f57f1a8e7c..31bfa1eeeb 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -139,21 +139,32 @@ socket_incoming_migration_end(void *opaque) object_unref(OBJECT(listener)); } =20 +static int socket_get_max_channels(void) +{ + /* The main channel is always wanted */ + int num =3D 1; + + if (migrate_multifd()) { + num +=3D migrate_multifd_channels(); + } + + if (migrate_postcopy_preempt()) { + /* The preempt channel */ + num +=3D 1; + } + + return num; +} + void socket_connect_incoming(SocketAddress *saddr, Error **errp) { QIONetListener *listener =3D qio_net_listener_new(); MigrationIncomingState *mis =3D migration_incoming_get_current(); size_t i; - int num =3D 1; + int num =3D socket_get_max_channels(); =20 qio_net_listener_set_name(listener, "migration-socket-listener"); =20 - if (migrate_multifd()) { - num =3D migrate_multifd_channels(); - } else if (migrate_postcopy_preempt()) { - num =3D RAM_CHANNEL_MAX; - } - if (qio_net_listener_open_sync(listener, saddr, num, errp) < 0) { object_unref(OBJECT(listener)); return; --=20 2.55.0 From nobody Sun Oct 25 09:31:19 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791363968; cv=none; d=zohomail.com; s=zohoarc; b=g/CIkjHFp0vw+eGH5JYx8Z3sTqTomibWy5zJFVv7Q5zwzJgJ5chX1R3QRp4NLWuMRzenwTYjvAHOyKgQ+s2AGNubACkrxd4vnDGhofWd4rWYJIC+dMFwVmtGvbGIBKSS4g2fHHnE54DOhtS0PW64ci4PR5F0eT51/KXNrhhW0n0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791363968; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qb5aWMXBksVrUWaPolR+H12gXaZIP/HfLkM4YI5bNC0=; b=Y4F5xl0R3nJbgAeMZFDWN3OaZo3JkdJb0V8XuCApozj2hEuD1OG+A8nUGPlCAS6qNFnmqdRA4WcuOWpdTBe3l5gxWrqlN4k+Vxr/wzxjMjXuzkCaHqBhdxSX4ksXySdK8TfSP2imtTdKQf2xLPbyYlSUoYa3hCAbqhyYYmpgUyo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791363968628290.83620903870667; Wed, 7 Oct 2026 02:06:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xENDW-0002nf-E2; Wed, 07 Oct 2026 04:41:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEIet-0005wQ-Mb for qemu-devel@nongnu.org; Tue, 06 Oct 2026 23:49:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEIea-0002Vt-Ce for qemu-devel@nongnu.org; Tue, 06 Oct 2026 23:49:27 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-2P1tNDSYPpGllox8S6zgPQ-1; Tue, 06 Oct 2026 14:20:55 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-5350c2b31c8so60241051cf.2 for ; Tue, 06 Oct 2026 11:20:55 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91996ba7b65sm115056d6.7.2026.10.06.11.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 11:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791344942; h=from:from:reply-to:subject:subject: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=qb5aWMXBksVrUWaPolR+H12gXaZIP/HfLkM4YI5bNC0=; b=FG1nXkYXBQ09XgDnwJV1V4QGhEEckWkJaC2P5Z4DRj6J65LWNEe8qb/MJmJ/D6gRTCcndO 6m1i/31Q5nksc7W7cQQXksRX16Uj3NhFsWeRT80PvOwKOPNoSYwx+EENbL9CQuG7yQdTJ4 DYTrNzu91J00t3BDNgZbsXe0TDB5ikc= X-MC-Unique: 2P1tNDSYPpGllox8S6zgPQ-1 X-Mimecast-MFC-AGG-ID: 2P1tNDSYPpGllox8S6zgPQ_1791310855 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1791310855; x=1791915655; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qb5aWMXBksVrUWaPolR+H12gXaZIP/HfLkM4YI5bNC0=; b=TG3hw1l6R26uqa0PnNBGISkfxMWBsFb7mOES05vorJgJ5ZeccXiHgew/hY/2pp951S +OTGJ/qCX+BzRcar0youU6bv1MciKD7gwBYA84bajQUFacGv7OWSEb66OzTgSLscdVd6 AVguAg0qi+VZe1F4QPHMrVQIf49TlgGIAQeIK6BvjQ8nlydkBRpCBXUD6qJq6WsHwL9k Sl1vZPfy/5mhKJf7hFuMp/wmzpKpcgXwHE3lOY5SFxLPCMEJgJmiImfTIbSWaPLW2iom o9PzPDHtRJckq96XeftuxdLAGkKl2IGnk8nqoN9SC1OYUkVVTg2P/OekjdzlUfr3nOBA qP4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791310855; x=1791915655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qb5aWMXBksVrUWaPolR+H12gXaZIP/HfLkM4YI5bNC0=; b=zjYRShu1oo7EjFeCrgkZU4I3FzUK8VBd+KI7daZRcti6J5IzAq+XF0Av0T5yxAepFC CPD+ICHi51bmVL9y0YBozJDsixgcIc74aqcB7RFYlPPaJx69zkOsx1DDZwKOkSveus6M vxYl7gO0cJmuir97wxZZnKuOOWxfHH22XMQuRoWKOvfAER4LxgI/nKsVXAqd5XqntyDA e6FSzJiQWLdiqr7pE4cM1HQ7nJa6Ex1RutvorOsHZgH/f2Oqvar+HP81xYYVGmjNKC76 cFv+9j9yEQDFAIJ6H+tPiP3e2G3ojUjvfgZ/+C4lBHELzPSO+7TgAx0uSEyIDes2+7GF fGCQ== X-Gm-Message-State: AFuF++nY30YyYRcdJ8HolC2+gCYMhnHZFIqy2NDgnLwt63M5Zdbbkw0i SEph5g8fGblVxWKBeOxTq0sZu8bNhKN4epgGCOQxbBnltIjp+6ZomH/rB48jtiVx38I7RlFN2Fw Z8h0b07vXh1O5w4l/fStCP/d5PMyioF8T74kNnDHWhbUqAbWui/ufUSe4SkovBpNF5o2UH/TRpl N0fNtuserXAEbMLbmz6ucUIjMI8e63iQiS5RCmbA== X-Gm-Gg: AYBFou1iiI6Dv9ZjETz35eKPIlVlqpgNy8CApWHFKHJ1SoRoBEa1ivu6egUWDgKJ5Su jV4ZtZLHHECRj503D09k6CLv/JB1bTkZD5NkFVLJTCKrkh4m7iR8aN8OeD4nHQZJWSVFgLf0W8H c9Py+ZwQaIX9uUXt3Rq3NT80Ro3koqkt/Jt9V1X1pegF5UUpdPhv/1J9Fzt3MWNvDImmiS4I2MG AJ3+b1vNi2hBxewabh6xy/MJEDrhHTCz2fqPnQOybKO8L8L8942517jl6I0GRMV4dU1DVxCUuPz GcdxB6Q+z+B8WS5xDAz3jAl9e+OiAHMiZZ4+xDosHdzP3qWfLPfoYhbP2WlqXrUPhRCyLK0= X-Received: by 2002:a05:622a:1a8d:b0:535:70c4:9a8e with SMTP id d75a77b69052e-53570c49c81mr12559661cf.68.1791310854529; Tue, 06 Oct 2026 11:20:54 -0700 (PDT) X-Received: by 2002:a05:622a:1a8d:b0:535:70c4:9a8e with SMTP id d75a77b69052e-53570c49c81mr12558861cf.68.1791310853804; Tue, 06 Oct 2026 11:20:53 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH v2 4/7] migration: Split migration_channel_process_incoming() Date: Tue, 6 Oct 2026 14:20:43 -0400 Message-ID: <20261006182046.3767283-5-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261006182046.3767283-1-peterx@redhat.com> References: <20261006182046.3767283-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1791363970432158500 Content-Type: text/plain; charset="utf-8" Introduce two smaller functions for it, - migration_incoming_channel_install(): peek at channels whenever possible, and install the channel to one of the slots (main, multifd, preempt) - migration_incoming_error_propagate(): handling an error happened during channel establish phase of an incoming migration. When at it, move the set channel tracepoint into the 1st helper, replacing the existing tracepoint with trace_migration_channel_process_incoming(). So far, they should fire almost the same time if the channel peek worked. This fact will change in follow up refactorings. I also moved migration_ioc_register_yank() to be after identify, hopefully it makes more sense: we'd better be careful on registration of yank, or we should be prepared for explosions. Previously it worked, my guess is when error happens we never unregister yank but hang dest QEMU or quit, depending on exit_on_error value. No real functional change intended. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/channel.c | 57 +++++++++++++++++++++++++++++------------- migration/trace-events | 1 + 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index 266ae8f776..8407ea46cb 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -197,6 +197,42 @@ out: return channel; } =20 +static void migration_incoming_error_propagate(MigrationIncomingState *mis, + Error *error) +{ + error_report_err(error); + migrate_set_state(&mis->state, mis->state, MIGRATION_STATUS_FAILED); + if (mis->exit_on_error) { + exit(EXIT_FAILURE); + } +} + +static bool migration_incoming_channel_install(MigrationIncomingState *mis, + QIOChannel *ioc, + Error **errp) +{ + MigChannelType ch =3D migration_channel_identify(mis, ioc, errp); + + if (!ch) { + assert(*errp); + return false; + } + + trace_migration_set_incoming_channel(ioc, + object_get_typename(OBJECT(ioc))); + migration_ioc_register_yank(ioc); + + if (migration_incoming_setup(ioc, ch, errp)) { + migration_start_incoming(); + } + + if (*errp) { + return false; + } + + return true; +} + /** * @migration_channel_process_incoming - Create new incoming migration cha= nnel * @@ -209,31 +245,18 @@ void migration_channel_process_incoming(QIOChannel *i= oc) { MigrationIncomingState *mis =3D migration_incoming_get_current(); Error *local_err =3D NULL; - MigChannelType ch; =20 - trace_migration_set_incoming_channel( + trace_migration_channel_process_incoming( ioc, object_get_typename(OBJECT(ioc))); =20 if (migrate_channel_requires_tls_upgrade(ioc)) { migration_tls_channel_process_incoming(ioc, &local_err); } else { - migration_ioc_register_yank(ioc); - ch =3D migration_channel_identify(mis, ioc, &local_err); - if (!ch) { - goto out; - } - - if (migration_incoming_setup(ioc, ch, &local_err)) { - migration_start_incoming(); - } + migration_incoming_channel_install(mis, ioc, &local_err); } -out: + if (local_err) { - error_report_err(local_err); - migrate_set_state(&mis->state, mis->state, MIGRATION_STATUS_FAILED= ); - if (mis->exit_on_error) { - exit(EXIT_FAILURE); - } + migration_incoming_error_propagate(mis, local_err); } } =20 diff --git a/migration/trace-events b/migration/trace-events index 68bcf12dc7..c93c9f9e75 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -207,6 +207,7 @@ migration_start_incoming(void) "" migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t= rdma) "qemu_file %" PRIu64 " multifd %" PRIu64 " RDMA %" PRIu64 =20 # channel.c +migration_channel_process_incoming(void *ioc, const char *ioctype) "ioc=3D= %p ioctype=3D%s" migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" migration_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" =20 --=20 2.55.0 From nobody Sun Oct 25 09:31:19 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791349014; cv=none; d=zohomail.com; s=zohoarc; b=WIhI0L8YJSZuDtvqB6CU398w9QbHSvm3CYtTPpqTfavey7cesoIg18OAwyG8e2O5736f6v47y6NcgsgbMSNlc97q5WAVZ8RTb7hkP+9sbP/SxLQiVT1mZxbss2LcN9JpwzhPVjhfi/j/gsYoahIYi1RjBfXx4U/apNfZugUvfhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791349014; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1QccO1ewA7uCctsMw+H9QSnUhVtqxnp43iU3gAZqGys=; b=C818jgTkD/nvjRbeyS2F1rRIbWlz8kg9truXvm8Zx5eP3EuUjA/uTgNmcZoyKeRRULmgauhgmBy+BfVVd3tbp+KTd4fJ2oEJjXHYWQTN0JRkIZHqvDOTtp/8qjR5LByRk9v2DKsy1YEuRsaXrzs1XxcZEQAVwfGnHT3QFl5KNBQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791349014825651.276793349967; Tue, 6 Oct 2026 21:56:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xEJhO-00087f-Ot; Wed, 07 Oct 2026 00:56:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEFp3-00069U-J9 for qemu-devel@nongnu.org; Tue, 06 Oct 2026 20:48:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEFop-0007GL-S2 for qemu-devel@nongnu.org; Tue, 06 Oct 2026 20:47:43 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-7dV8-ErNPUOlY6VVYxQopg-1; Tue, 06 Oct 2026 14:20:57 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-53390e79a19so54325921cf.0 for ; Tue, 06 Oct 2026 11:20:56 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5357219c5f5sm1623791cf.25.2026.10.06.11.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 11:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791333901; h=from:from:reply-to:subject:subject: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=1QccO1ewA7uCctsMw+H9QSnUhVtqxnp43iU3gAZqGys=; b=J0k9rAJXyDAmQ0guPu5KgBkrT/FbPSEvAaTjDCLNi9osmjUULaLrkeUGuVODZOrX0J2867 8ijeJm2utFeXIG5gA2Y3qj+4aSwoKHU3gTCx1Vgx0mimvcRBdsEX6mINFc/yQkteQpXu5v mIV7em1SmJIS0NSTRl5y4ec8+bdMylo= X-MC-Unique: 7dV8-ErNPUOlY6VVYxQopg-1 X-Mimecast-MFC-AGG-ID: 7dV8-ErNPUOlY6VVYxQopg_1791310856 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1791310856; x=1791915656; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1QccO1ewA7uCctsMw+H9QSnUhVtqxnp43iU3gAZqGys=; b=CKRsUFfostpNXsDU0zh7i4XAFQ7Tm885oTxUEBrR+uxskvGMP0qsJvghdlEA+a1gq4 /yHm0gGTzdXezEtQOxj9leGdGpYt8Uje/SXAil5VsG08QwVQD3r77YFTpNXq800hL1M1 vw64qAS1K08vutdCNEJsk1TxTNHLon6cgtrZPZOTvcF6tS/sUOd4O5TbQOukqTQDBDge XJnEHLYrCCsxhWst1mrog/kaj3ryLQ3snVwT49wPPf585qhbjUWpqTfDsk2onmWjYwgp ShljyLwPbicGiJJl/TbqhYR4gLQmp2Bqt6g2h1ME0qgPGDEdqf+ayKT9IOQyT6UgbF6j 5D1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791310856; x=1791915656; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1QccO1ewA7uCctsMw+H9QSnUhVtqxnp43iU3gAZqGys=; b=DwxXHQPt5UEP2s0QUyQH9R/pZ7VPSPWprK87OdBbNby1rWej48FFUPpWBwCLQ+5AHe RYe0lvOD2Jt5lUT/nGaMFauxFUVw9sCcAx2a+6M2acCh0ZeUmaE8WA9jWiov/6f0LjmD jXWbc5GahCbi7Q8na2ucmEHmYrKvhldmf0rpiPYy4SI51ZGjyfHd09Nh5HPxYIe7tgwt 2hE7XwpieOKfAB/NzfmdoP0DWxieczAht1zianmubWxHxAzlJng8lATriBsQLbMA2zqt 3l+H3N1I10a2GZanhNDN/JZ852lITP8l95RR6IDdJr7tSK6pzpbO51nlRWEzBdaVr3/6 CQGA== X-Gm-Message-State: AFuF++nMzafVxxnlPnvIKUej8hA50LEECaRFIofYf967jY1nBmIxphgv IUMfWTUmyGIDQPPU6uEdauGbQLni8uRo2kvJHh9AMPr5SFPOfOtpPx06f4ZAifZusNjATALe4P4 WTrXUVPGoBR6oyKvzHN/o9uJHJXEEUr6RvK5URFTRkTL66plfF3+7rXH+hu15+XOBwQWbGYUXEv NK+ORJ8nrQTYM2kfSrcd1a9K0yUBamHFlFE2gLoQ== X-Gm-Gg: AYBFou3foWRxGYYL+RSLaDUj9WKcCEUfzATwGboTzxWmaYmsR2WSASszMTreshiAbSX LbFXSvN3eU5xu708Kz/zmHaOKr8nE+RQgXdNJnySdfmi7j9t/bQqk0f7co1lJQ/1J70Ji8UvfDs Jxm2tPupMDLpIa7945/sHKZt9qFfT8IX3OGJgb5DXlHDcIM2lWJMHviW4BcKOaxpcxAzixyrVE8 cjnJ4hO0tI/g+cJX3wxROUJLr2MplLkgfUIUsKIsWDIng+3zI36E9Tk0TFKbpNZAOIVSO9v5Nkq o2DUwlNN4y0ViTOWUDMOLZs4LKJdX+kE0RIhjHqOavYLncT1ULU5C/595naU7rUrA5Gm4E4= X-Received: by 2002:ac8:6f09:0:b0:533:3192:7a8e with SMTP id d75a77b69052e-53566d92720mr38236401cf.43.1791310855903; Tue, 06 Oct 2026 11:20:55 -0700 (PDT) X-Received: by 2002:ac8:6f09:0:b0:533:3192:7a8e with SMTP id d75a77b69052e-53566d92720mr38235691cf.43.1791310855242; Tue, 06 Oct 2026 11:20:55 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH v2 5/7] migration: Dump type of channel in set_incoming_channel tracepoint Date: Tue, 6 Oct 2026 14:20:44 -0400 Message-ID: <20261006182046.3767283-6-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261006182046.3767283-1-peterx@redhat.com> References: <20261006182046.3767283-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1791349017915158500 Content-Type: text/plain; charset="utf-8" Add this info to be crystal clear on what channel we're installing. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/channel.h | 3 ++- migration/channel.c | 10 +++++++++- migration/trace-events | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/migration/channel.h b/migration/channel.h index a7d0d29058..678712f291 100644 --- a/migration/channel.h +++ b/migration/channel.h @@ -24,7 +24,8 @@ typedef enum { CH_NONE, CH_MAIN, CH_MULTIFD, - CH_POSTCOPY + CH_POSTCOPY, + CH_NUM, } MigChannelType; =20 void migration_channel_process_incoming(QIOChannel *ioc); diff --git a/migration/channel.c b/migration/channel.c index 8407ea46cb..b9065efd03 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -34,6 +34,13 @@ #include "trace.h" #include "yank_functions.h" =20 +static const char *const mig_channel_str[CH_NUM] =3D { + [CH_NONE] =3D "NONE", + [CH_MAIN] =3D "MAIN", + [CH_MULTIFD] =3D "MULTIFD", + [CH_POSTCOPY] =3D "PREEMPT", +}; + void migration_connect_outgoing(MigrationState *s, MigrationAddress *addr, Error **errp) { @@ -219,7 +226,8 @@ static bool migration_incoming_channel_install(Migratio= nIncomingState *mis, } =20 trace_migration_set_incoming_channel(ioc, - object_get_typename(OBJECT(ioc))); + object_get_typename(OBJECT(ioc)), + mig_channel_str[ch]); migration_ioc_register_yank(ioc); =20 if (migration_incoming_setup(ioc, ch, errp)) { diff --git a/migration/trace-events b/migration/trace-events index c93c9f9e75..8840d82f8d 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -208,7 +208,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_= t multifd, uint64_t rdma) =20 # channel.c migration_channel_process_incoming(void *ioc, const char *ioctype) "ioc=3D= %p ioctype=3D%s" -migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" +migration_set_incoming_channel(void *ioc, const char *ioctype, const char = *type) "ioc=3D%p ioctype=3D%s type=3D%s" migration_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" =20 # global_state.c --=20 2.55.0 From nobody Sun Oct 25 09:31:19 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791362117; cv=none; d=zohomail.com; s=zohoarc; b=NrOXaUBD8jSsCYBWwI8/o6/Eox9kaj4fHc4wnsdNGyDyBvKcCmTEbHrTGivPZRQrUV3WHFPum9FLcZJ7mx/eLnfctpfuIywhEv5IcO/sBcq5t7LEKSuwU0iqePw3bWQAule3epip2h1VVvZP6BZJ+MBIwDDmMOKiLWXNQJTc8Ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791362117; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QHMg9Evu6BsL4KAtm7L3QgUAF+Ch4RbqNyIfur6xzew=; b=e6OzoZpHXP3c/Oz+HIBLHRpAUbBcNR6CK3PugILi8bK8NhMG8trwKvmLHX8uWgbKNiATXQmeUR9JZP6uceocTSrQhymZeE1kOxIMCE29EFa0xFZIzK29/QWH73xbjodU07/dVR73xWZAFRckXdlSwx8Ca7gnr3fpPSP737JCk8k= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791362117936702.2576167679255; Wed, 7 Oct 2026 01:35:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xEN59-0004pn-NU; Wed, 07 Oct 2026 04:32:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEHlY-0006Tb-Ua for qemu-devel@nongnu.org; Tue, 06 Oct 2026 22:52:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEHlJ-0004Qy-Al for qemu-devel@nongnu.org; Tue, 06 Oct 2026 22:52:16 -0400 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-182-lvMMr7MKOcCi93luRlYwbQ-1; Tue, 06 Oct 2026 14:21:00 -0400 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-93ae8e7e546so576819585a.1 for ; Tue, 06 Oct 2026 11:20:59 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93e991eca24sm19396985a.39.2026.10.06.11.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 11:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791341346; h=from:from:reply-to:subject:subject: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=QHMg9Evu6BsL4KAtm7L3QgUAF+Ch4RbqNyIfur6xzew=; b=avUDPZ0lSkDmAG0J3KT5/QNnfxp2SlwrnKYXiHOUG7XPwvKlbAwRhU8rZBIeJG5XYW5tYs AMko7a+lJmQJ7eXsWFUJG61iVfFiRqhBDSqlM92hX82elXiO86hwZdRrGJVozxQjQD/t/w WLuCx7nwWpw31yZRq7uM5gfUy3b2Ps0= X-MC-Unique: lvMMr7MKOcCi93luRlYwbQ-1 X-Mimecast-MFC-AGG-ID: lvMMr7MKOcCi93luRlYwbQ_1791310859 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1791310859; x=1791915659; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QHMg9Evu6BsL4KAtm7L3QgUAF+Ch4RbqNyIfur6xzew=; b=XfYqMFpMZYrJoPJwpsgPpc8gpVxJac57TPG7jS0Mprtemrj7pjSh9V0GjVUJs4ShN0 1NvYo7qIUqGYdBcKQg5FLFNcQr0KosMbn5VXqmfIbkg+AbzNtSWtaX/b08JBREDadfV0 0GLq6mC7tQj/0iD9gsGMtJh6d5A4qXzXNhGJX3/M4UXZiT3EK9ze5USjIMKlXP4AxQAJ GpbUWVrs0HV6J+0c7oPURsybXirzwad+1BFlhtgUkm3wvKMVi+8BeSzqE9pQq2JruFjT KiDkimSpMSOMf/Bj39zlysvx3/E1K2i3LaTywIaBzLVQm3as2QUO+Q3OBD1XRbV/kpN1 n+lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791310859; x=1791915659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=QHMg9Evu6BsL4KAtm7L3QgUAF+Ch4RbqNyIfur6xzew=; b=zWyto2yTaVjA0Dp+sYBF7aQ2mFGI7J2HgaBeUfaM0acAFY9r5K4ubkUMwHtUYirzGg /0x78x9R1duwbR0+xeWVYaXpVrUFi98Jt+88FHwhWTQn8sLewEvfXh3UCrfyCA/LR/SP sqAO5EFVMo/nkYS1pV2xF1Zjaief32/W4RxRPUWi4Qfg/LnFhJ3zJ/qKzLYOE5GeDya8 PB5YLNJ4MOQbGbYdoJSKr4a4v53c7auxx0ZR9I/sucY+GHhR0mTlQBfxl1uZW0eAyz07 icVhulA2l/BL5dbiDQ2SlqEvFtmoX/m6AWuJnDXDnZALZk4TyW2XJme4X+HyKhGbyfgx D+rQ== X-Gm-Message-State: AFuF++kix3MVtZc3PFXkLhGnNEU10Qzyf7+LXKC7yPB+l50W0tF//DdW Bbau8IcStzgrjfFAEwI1PQz0wRyg2fJ8L5AC2Id/Ue9e1LE1Etw3UsEKnl2hc1U8R/8UlqrCDjG 6vQcNNJCgzA6DCjxQWiLf+SLCZWl5iyUJQW3bvW6y4HqsvHa8RcIrkrVD31kr1CwSd1y/funzcY qg0btKvW+vt/gw/UW+O4EC7JBaPs1k/6Caq4rhew== X-Gm-Gg: AYBFou3lKNHNIQug1dIjg4HT+/0rtMt+Y+Zzoy2XShfB8nyGxxEXUcL+AZWqwAsRM+N 4pF/v9tYcWKstSyrhBdudlkbVZcC5dcCQnYxZv3e2TNu+LlD2dyqHdYzpdKxPB5+ePdS83hwPzD vTdaJ7DfRPOm3z9SyB6GS6os6V0Px6dxf8gS6HlB5K3F5zYGgtBt8cRoCnX5+xvFD//Jb6C3KQm MXV5ifntyYgdMcbTgjxIncyTCTVAe1NdAvAopXtsrSU7dE//87fhEvvM3FcETgqI7eqJJV5463E XYV3xz2pw9VIhO6mzAlSvPHc+tu8onFMT5ZcjjJ2nbxwlBA8O5aJ54fD+HVEvFHVieyUwoc= X-Received: by 2002:a05:620a:4494:b0:93e:6ff1:b67c with SMTP id af79cd13be357-93e8f205862mr437537385a.20.1791310858065; Tue, 06 Oct 2026 11:20:58 -0700 (PDT) X-Received: by 2002:a05:620a:4494:b0:93e:6ff1:b67c with SMTP id af79cd13be357-93e8f205862mr437528185a.20.1791310857054; Tue, 06 Oct 2026 11:20:57 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH v2 6/7] migration: Fix incoming channel race with multifd and preempt_pre_7_2 Date: Tue, 6 Oct 2026 14:20:45 -0400 Message-ID: <20261006182046.3767283-7-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261006182046.3767283-1-peterx@redhat.com> References: <20261006182046.3767283-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1791362120246158500 Content-Type: text/plain; charset="utf-8" PROBLEM =3D=3D=3D=3D=3D=3D=3D Migration reliably hangs with old machine types (7.2-) when these migration capabilities are enabled: multifd, postcopy-ram, postcopy-preempt. Simplest reproducer : $ QTEST_QEMU_MACHINE_TYPE=3Dpc-q35-7.2 \ QTEST_QEMU_BINARY=3D./qemu-system-x86_64 \ ./tests/qtest/migration-test --full \ -r /x86_64/migration/multifd+postcopy/preempt/plain Current workaround is to kill destination QEMU, cancel the migration on source (with/without yank), disable one or more of the features, and retry. The hang is caused by receiving preempt channel before most of the multifd channels, the peek buffer operation will stuck forever. Incoming side QEMU hang (with relevant tracepoints enabled): migrate_set_state new state setup migration_socket_incoming_accepted migration_set_incoming_channel ioc=3D0x557d82c1caa0 ioctype=3Dqio-channel= -socket migration_socket_incoming_accepted migration_set_incoming_channel ioc=3D0x557d83023840 ioctype=3Dqio-channel= -socket multifd_recv_new_channel channel 1 migration_socket_incoming_accepted migration_set_incoming_channel ioc=3D0x557d830c08c0 ioctype=3Dqio-channel= -socket multifd_recv_new_channel channel 0 multifd_recv_thread_start 1 migration_socket_incoming_accepted migration_set_incoming_channel ioc=3D0x557d8284a010 ioctype=3Dqio-channel= -socket multifd_recv_thread_start 0 multifd_recv_unfill channel 0 packet_num 0 flags 0x1 next packet size 0 multifd_recv_unfill channel 1 packet_num 1 flags 0x1 next packet size 0 [dest qemu hangs here] Incoming side backtrace: __syscall_cancel_arch __internal_syscall_cancel __syscall_cancel recvmsg qio_channel_socket_readv qio_channel_readv_full migration_channel_read_peek migration_channel_identify migration_channel_process_incoming socket_accept_incoming_migration qio_net_listener_channel_func qio_channel_fd_source_dispatch g_main_context_dispatch_unlocked.lto_priv g_main_context_dispatch glib_pollfds_poll os_host_main_loop_wait main_loop_wait qemu_main_loop qemu_default_main main This patch tries to fix it, from incoming side first. This patch alone should enable single-direction migration to this new QEMU. The next patch will propose a fix for the outgoing path, fixing new->old migrations. BACKGROUND =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D preempt_pre_7_2 used to be a flag marking QEMU releases 7.1/7.2 only because they have a flaw on channel establishment on preempt channel. Now, after we have multifd + postcopy support, new QEMU binaries can migrate old machine types with both features enabled. Juraj reported constant migration hang at the very beginning for those old machine types in our downstream systems with such setup. Juraj found it's because of this flag. QEMU source initiates channels in this order on current master when both features enabled with postcopy-preempt mode (machine type 7.2, implies preempt_pre_7_2=3Don): - First, main channel connect() happens, - Second, postcopy_preempt_setup() invokes connect() for preempt channel, - Last, in migration_thread(), multifd_send_setup() invokes connect()s for all the multifd channels However on an old QEMU, it expect the channels arrive in order of "main"->"multifd"->"preempt". Even on a new QEMU, the destination expects the same order of arrival on the channels when the channels are not peekable. For peekable channels (non-tls sockets), this time we'll likely see preempt channel appearing very soon, peeking at it causing main thread hang, like mentioned in the PROBLEM section above. SOLUTION =3D=3D=3D=3D=3D=3D=3D=3D One major problem of current hang is we try to peek at preempt channel, which offers nothing at the beginning. Since we'll need to accept stream from old binaries (QEMU 10.1 to 11.1), arrival of preempt channel early is unavoidable. What we can do, though, is to allow concurrent monitoring of all channels rather than one. Meanwhile, we shouldn't peek at anything that has no data. migration_channel_read_peek() almost does the wait, but it's too late. This patch proposes to watch all channels from the start without reading at them at all, relying on an IO watch attached. This will make sure (1) for preempt channel, we never read on it (watch can be gracefully disarmed when we know it's preempt channel later) (2) since we have one IO watch for each channel, then we can allow accept() to happen in almost any order, process only when there's some header to read. To maintain these watches, a new GArray @channels_early is introduced, with each element to be a (ioc, GSource) tuple (@MigEarlyIncomingChannel), so that QEMU can manage all the IO watches later with it. Here I used GSource rather than io_tag because the GSource may or may not be attached to the default main thread gcontext: when OOB is used, it may be the iothread context instead. IOW, g_source_remove() on io_tags stops working, which only works for default main context. The trick this patch used is when we have the ability to wait on all channel headers at the same time, we pick one by one from main and multifd channels (since both of the types will contain headers dumped right at the very beginning), leave preempt channel alone. It means, after dest QEMU finds all main and multifd channels, there are three possibilities: - If preempt not enabled, we finished full channel establishment, done. - If preempt enabled, - If we have one registered IO watch with the IOC, it must be the preempt channel, - If we have no further IO watch, wait for the next accept(), which must be the preempt channel. This will make channel establish work on incoming side even with the old QEMU binaries. While working on it, I managed to refactor the peeking logic quite a bit: we used to have a very convoluted migration_channel_identify() function, taking care of two different cases: (1) when the channel is peekable (like normal socket channels), (2) when the channel is not peekable (like TLS or file migrations). This patch refactored that part to make it crystal clear on how we make decisions on which channel is which, and split the peek/identify paths. One example incoming migration from pc-q35-7.2 after this patch applied, and with relevant tracepoints set (8 multifd channels, 1 preempt channel): migrate_set_state new state setup migration_channel_process_incoming ioc=3D0x557dc8af4e20 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc8af4e20 ioctype=3Dqio-chann= el-socket migration_channel_process_incoming ioc=3D0x557dc8abc5d0 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc8abc5d0 ioctype=3Dqio-chann= el-socket migration_channel_process_incoming ioc=3D0x557dc953d680 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc953d680 ioctype=3Dqio-chann= el-socket migration_set_incoming_channel ioc=3D0x557dc8abc5d0 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_channel_process_incoming ioc=3D0x557dc898a820 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc898a820 ioctype=3Dqio-chann= el-socket migration_set_incoming_channel ioc=3D0x557dc953d680 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_channel_process_incoming ioc=3D0x557dc919bd70 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc919bd70 ioctype=3Dqio-chann= el-socket migration_set_incoming_channel ioc=3D0x557dc898a820 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_channel_process_incoming ioc=3D0x557dc8734b20 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc8734b20 ioctype=3Dqio-chann= el-socket migration_set_incoming_channel ioc=3D0x557dc919bd70 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_channel_process_incoming ioc=3D0x557dc898bdf0 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc898bdf0 ioctype=3Dqio-chann= el-socket migration_set_incoming_channel ioc=3D0x557dc8734b20 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_channel_process_incoming ioc=3D0x557dc968cfd0 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc968cfd0 ioctype=3Dqio-chann= el-socket migration_set_incoming_channel ioc=3D0x557dc898bdf0 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_channel_process_incoming ioc=3D0x557dc8c31810 ioctype=3Dqio-cha= nnel-socket migration_incoming_channel_watch ioc=3D0x557dc8c31810 ioctype=3Dqio-chann= el-socket migration_set_incoming_channel ioc=3D0x557dc968cfd0 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_set_incoming_channel ioc=3D0x557dc8c31810 ioctype=3Dqio-channel= -socket type=3DMULTIFD migration_set_incoming_channel ioc=3D0x557dc8af4e20 ioctype=3Dqio-channel= -socket type=3DMAIN migration_start_incoming migrate_set_state new state active migration_channel_process_incoming ioc=3D0x557dc8966160 ioctype=3Dqio-cha= nnel-socket migration_set_incoming_channel ioc=3D0x557dc8966160 ioctype=3Dqio-channel= -socket type=3DPREEMPT While at it, I renamed the four channel incoming/outgoing tracepoints, make all to follow migration_[incoming|outgoing]_channel_*(). Especially for incoming, then we can enable migration_incoming_channel* for incoming channel debuggings. FINAL NOTE ON TLS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Note that this solution isn't a magic bullet fixing everything. TLS is not fixable with this approach because TLS isn't peekable channel, hence the watch won't help. We can have other ways to hack it to make it work, e.g. we can make TLS channels peekable too, but I don't want to pollute the TLS iochannel only for this: let's hope handshake will arrive soon so we can drop these code. For now, when TLS is involved with such old machine type (7.2-), one needs to migrate it out with any combination of features except enabling all four (multifd + TLS + postcopy + preempt) to a patched binary, after that, all combinations will start working. BugLink: https://redhat.atlassian.net/browse/RHEL-254933 Fixes: e27418861288 ("migration: enable multifd and postcopy together") Reported-by: Juraj Marcin Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/channel.h | 3 + migration/migration.h | 35 ++++ migration/channel.c | 413 +++++++++++++++++++++++++++++++++++------ migration/migration.c | 31 +++- migration/trace-events | 7 +- 5 files changed, 418 insertions(+), 71 deletions(-) diff --git a/migration/channel.h b/migration/channel.h index 678712f291..40bd339a3e 100644 --- a/migration/channel.h +++ b/migration/channel.h @@ -49,4 +49,7 @@ bool migration_channel_parse_input(const char *uri, MigrationChannel **main_channelp, MigrationChannel **cpr_channelp, Error **errp); + +void migration_incoming_free_early_channels(MigrationIncomingState *mis); + #endif diff --git a/migration/migration.h b/migration/migration.h index 683bc7bdd5..6f23e1805b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -90,6 +90,28 @@ typedef enum { PREEMPT_THREAD_QUIT, } PreemptThreadStatus; =20 +typedef struct { + /* + * The GSource we have allocated to track G_IO_IN events for the + * channel. Note: it may not be attached to the default main gcontext, + * for example, when in case of io watch created during an OOB + * migrate-recover command. + */ + GSource *source; + /* The channel we will identify later after getting some buffers to re= ad */ + QIOChannel *ioc; +} MigEarlyIncomingChannel; + +typedef struct { + GArray *channels; + /* + * In most cases, channels are only operated with BQl, but since we + * have OOB command support, don't assume it, just use a standalone + * mutex to protect any access to the channels array. + */ + QemuMutex mutex; +} MigEarlyIncomingChannels; + /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; @@ -255,6 +277,19 @@ struct MigrationIncomingState { =20 /* Do exit on incoming migration failure */ bool exit_on_error; + + /* + * Maintains all channels only at early stage. After incoming + * migration started, this should be an empty array and no use anymore. + * + * TODO: we logically only need this to make new QEMU binaries work for + * old machines who have @preempt_pre_7_2 set on the source, but it's + * also good to have this early stage anyway, making sure when peek the + * channel there will be something in the channel. Ideally, we should + * manage all migration channels in the future with proper headers, + * then we can drop this. + */ + MigEarlyIncomingChannels channels_early; }; =20 MigrationIncomingState *migration_incoming_get_current(void); diff --git a/migration/channel.c b/migration/channel.c index b9065efd03..1aeb881485 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -12,6 +12,8 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/main-loop.h" +#include "qemu/error-report.h" #include "channel.h" #include "exec.h" #include "fd.h" @@ -146,61 +148,81 @@ bool migration_has_all_channels(void) return true; } =20 -static MigChannelType migration_channel_identify(MigrationIncomingState *m= is, - QIOChannel *ioc, Error **= errp) +static bool qio_channel_is_peekable(QIOChannel *ioc) +{ + return qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK); +} + +/* + * With multiple channels, it is possible that we receive channels out of + * order on destination side, causing incorrect mapping of source channels + * on destination side. + * + * When the channel is peekable (e.g. non-TLS socket channels), check + * channel MAGIC to decide type of channel. + * + * Please note this is best effort, postcopy preempt channel does not send + * any magic number so avoid it for postcopy live migration. + * + * Returns: >0 if success, =3D=3D0 (CH_NONE) if error. If error happened, + * *errp must be set. + */ +static MigChannelType migration_channel_peek(MigrationIncomingState *mis, + QIOChannel *ioc, + Error **errp) { MigChannelType channel =3D CH_NONE; uint32_t channel_magic =3D 0; int ret =3D 0; =20 - if (!migration_has_main_and_multifd_channels()) { - if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK= )) { - /* - * With multiple channels, it is possible that we receive chan= nels - * out of order on destination side, causing incorrect mapping= of - * source channels on destination side. Check channel MAGIC to - * decide type of channel. Please note this is best effort, - * postcopy preempt channel does not send any magic number so - * avoid it for postcopy live migration. Also tls live migrati= on - * already does tls handshake while initializing main channel = so - * with tls this issue is not possible. - */ - ret =3D migration_channel_read_peek(ioc, (void *)&channel_magi= c, - sizeof(channel_magic), errp); - if (ret !=3D 0) { - goto out; - } + assert(qio_channel_is_peekable(ioc)); =20 - channel_magic =3D be32_to_cpu(channel_magic); - if (channel_magic =3D=3D QEMU_VM_FILE_MAGIC) { - channel =3D CH_MAIN; - } else if (channel_magic =3D=3D MULTIFD_MAGIC) { - assert(migrate_multifd()); - channel =3D CH_MULTIFD; - } else if (!mis->from_src_file && - mis->state =3D=3D MIGRATION_STATUS_POSTCOPY_PAUSED= ) { - /* reconnect main channel for postcopy recovery */ - channel =3D CH_MAIN; - } else { - error_setg(errp, "unknown channel magic: %u", channel_magi= c); - } - } else if (mis->from_src_file && migrate_multifd()) { - /* - * Non-peekable channels like tls/file are processed as - * multifd channels when multifd is enabled. - */ - channel =3D CH_MULTIFD; - } else if (!mis->from_src_file) { - channel =3D CH_MAIN; - } else { - error_setg(errp, "non-peekable channel used without multifd"); - } + ret =3D migration_channel_read_peek(ioc, (void *)&channel_magic, + sizeof(channel_magic), errp); + if (ret !=3D 0) { + /* Failed */ + return channel; + } + + channel_magic =3D be32_to_cpu(channel_magic); + + if (channel_magic =3D=3D QEMU_VM_FILE_MAGIC) { + channel =3D CH_MAIN; + } else if (channel_magic =3D=3D MULTIFD_MAGIC) { + assert(migrate_multifd()); + channel =3D CH_MULTIFD; + } else if (!mis->from_src_file && + mis->state =3D=3D MIGRATION_STATUS_POSTCOPY_PAUSED) { + /* reconnect main channel for postcopy recovery */ + channel =3D CH_MAIN; } else { - assert(migrate_postcopy_preempt()); - channel =3D CH_POSTCOPY; + error_setg(errp, "Unknown channel magic: %u", channel_magic); + } + + return channel; +} + +/* + * Returns: >0 if success, =3D=3D0 (CH_NONE) if error. If error happened, + * *errp must be set. NOTE: preempt channel is done separately. + */ +static MigChannelType migration_channel_identify(MigrationIncomingState *m= is, + QIOChannel *ioc, Error **= errp) +{ + MigChannelType channel =3D CH_NONE; + + if (!mis->from_src_file) { + channel =3D CH_MAIN; + } else if (migrate_multifd()) { + /* + * Non-peekable channels like tls/file are processed as + * multifd channels when multifd is enabled. + */ + channel =3D CH_MULTIFD; + } else { + error_setg(errp, "Unexpected non-peekable channel observed"); } =20 -out: return channel; } =20 @@ -214,33 +236,264 @@ static void migration_incoming_error_propagate(Migra= tionIncomingState *mis, } } =20 -static bool migration_incoming_channel_install(MigrationIncomingState *mis, - QIOChannel *ioc, - Error **errp) +/* Must be with mis->channels_early.mutex held */ +static void +migration_incoming_early_channel_insert(MigrationIncomingState *mis, + QIOChannel *ioc, + GSource *source) { - MigChannelType ch =3D migration_channel_identify(mis, ioc, errp); + MigEarlyIncomingChannel chan =3D { + .source =3D source, + .ioc =3D ioc, + }; =20 - if (!ch) { - assert(*errp); - return false; + object_ref(OBJECT(ioc)); + g_source_ref(source); + + g_array_append_val(mis->channels_early.channels, chan); +} + +static void migration_incoming_early_channel_free(GArray *channels, int i) +{ + MigEarlyIncomingChannel *chan; + + chan =3D &g_array_index(channels, MigEarlyIncomingChannel, i); + + g_source_destroy(chan->source); + g_source_unref(chan->source); + object_unref(OBJECT(chan->ioc)); + + g_array_remove_index_fast(channels, i); +} + +/* + * Remove this channel from the monitoring of @channels_early array. + * Return true if found and successful, false otherwise. + */ +static bool +migration_incoming_early_channel_remove(MigrationIncomingState *mis, + QIOChannel *ioc) +{ + GArray *channels =3D mis->channels_early.channels; + MigEarlyIncomingChannel *chan; + int i; + + QEMU_LOCK_GUARD(&mis->channels_early.mutex); + + for (i =3D 0; i < channels->len; i++) { + chan =3D &g_array_index(channels, MigEarlyIncomingChannel, i); + if (chan->ioc !=3D ioc) { + continue; + } + migration_incoming_early_channel_free(channels, i); + return true; + } + + return false; +} + +void migration_incoming_free_early_channels(MigrationIncomingState *mis) +{ + GArray *channels =3D mis->channels_early.channels; + + QEMU_LOCK_GUARD(&mis->channels_early.mutex); + + while (channels->len) { + migration_incoming_early_channel_free(channels, 0); } +} =20 - trace_migration_set_incoming_channel(ioc, +static bool migration_incoming_setup_channel(QIOChannel *ioc, + MigChannelType ch, + Error **errp) +{ + trace_migration_incoming_channel_set(ioc, object_get_typename(OBJECT(ioc)), mig_channel_str[ch]); migration_ioc_register_yank(ioc); =20 - if (migration_incoming_setup(ioc, ch, errp)) { - migration_start_incoming(); - } + return migration_incoming_setup(ioc, ch, errp); +} =20 - if (*errp) { +static bool migration_incoming_channel_install(MigrationIncomingState *mis, + QIOChannel *ioc, + MigChannelType ch, + Error **errp) +{ + if (!migration_incoming_setup_channel(ioc, ch, errp)) { return false; } =20 + /* Installation succeeded, kickoff migration if needed */ + if (migration_has_main_and_multifd_channels()) { + migration_start_incoming(); + } + return true; } =20 +static void +migration_incoming_channel_preempt_setup(QIOChannel *ioc) +{ + assert(migrate_postcopy_preempt()); + /* Installation of preempt channel should never fail */ + migration_incoming_setup_channel(ioc, CH_POSTCOPY, &error_abort); +} + +static void +migration_incoming_detect_preempt_channel(MigrationIncomingState *mis) +{ + GArray *channels =3D mis->channels_early.channels; + MigEarlyIncomingChannel *chan; + + QEMU_LOCK_GUARD(&mis->channels_early.mutex); + + /* When preempt mode not enabled, nothing to detect.. */ + if (!migrate_postcopy_preempt()) { + /* + * .. but if we found something pending, throw an error only, which + * should not happen. Even if it happens, resources will still be + * released after incoming migration is completedly. + */ + if (channels->len) { + error_report("%s: Found %u unused channels", + __func__, channels->len); + } + return; + } + + /* Preempt channel hasn't yet arrived? Process it later */ + if (!channels->len) { + return; + } + + /* + * More than one channel should never happen.. capture it in case if + * it happens, then there's not much we can do. + */ + if (channels->len > 1) { + error_report("%s: Found %u unused channels, " + "can't identify preempt channel", + __func__, channels->len); + return; + } + + assert(channels->len =3D=3D 1); + /* This is the preempt channel, install it directly */ + chan =3D &g_array_index(channels, MigEarlyIncomingChannel, 0); + migration_incoming_channel_preempt_setup(chan->ioc); + migration_incoming_early_channel_free(channels, 0); +} + +static gboolean migration_incoming_channel_readable(QIOChannel *ioc, + GIOCondition condition, + gpointer opaque) +{ + MigrationIncomingState *mis =3D opaque; + Error *local_err =3D NULL; + MigChannelType ch; + + /* + * No need to monitor this channel anymore as long as anything arrived, + * remove it from tracking. + * + * NOTE: this means if partial data arrived we may still block here, + * but it shouldn't happen in production, only malicious stream. Since + * migration stream is trusted (either due to trusted network, or TLS), + * that's non-issue. + * + * NOTE2: it's theoretically possible that this entry is gone reaching + * here. Example: the main thread is doing incoming cleanup having this + * one removed, while this watch can be registered on the monitor + * iothread's context and fired at the exact same time but in the + * iothread instead. If it happens, skip the rest. I'm not sure if + * this could happen at all, may depend on iothread lifespan management + * in the main thread, but be prepared. + */ + if (!migration_incoming_early_channel_remove(mis, ioc)) { + goto out; + } + + ch =3D migration_channel_peek(mis, ioc, &local_err); + if (!ch) { + goto out; + } + + if (!migration_incoming_channel_install(mis, ioc, ch, &local_err)) { + goto out; + } + + if (migration_has_main_and_multifd_channels()) { + /* + * Possibilities when reaching here: + * + * (1) if preempt not enabled, this should be no-op, all done, + * (2) if preempt enabled, + * (2.a) preempt channel arrived @channels_early, handle it now + * (2.b) preempt channel not arrived, to be handled in + * migration_channel_process_incoming() later + */ + migration_incoming_detect_preempt_channel(mis); + } + +out: + if (local_err) { + migration_incoming_error_propagate(mis, local_err); + } + + /* + * NOTE: we should have already detached the GSource, returning + * G_SOURCE_REMOVE to be logically consistent only. + */ + return G_SOURCE_REMOVE; +} + +static void migration_incoming_channel_watch(MigrationIncomingState *mis, + QIOChannel *ioc) +{ + GMainContext *context =3D g_main_context_get_thread_default(); + GSource *source; + guint io_tag; + + trace_migration_incoming_channel_watch(ioc, + object_get_typename(OBJECT(ioc)= )); + + /* + * Careful: this can be run from either the main thread or the monitor + * iothread when migrate_recover is used with OOB=3Don, so we need to + * take the lock and use the full version to specify the correct + * context. + */ + QEMU_LOCK_GUARD(&mis->channels_early.mutex); + + /* + * We should never watch an @ioc that is not peekable, because there's + * no point. What is worse is we lose the real order of accept()s via + * the asynchronous IO watch operation. + * + * Another note is TLS channel (non-peekable) may or may not work + * properly with IO watch due to its current .io_create_watch() impl, + * which is another story. Just guard both points. + */ + assert(qio_channel_is_peekable(ioc)); + io_tag =3D qio_channel_add_watch_full(ioc, G_IO_IN, + migration_incoming_channel_readabl= e, + mis, NULL, context); + + /* + * Replace this if one day qio_channel_add_watch*() API can directly + * return the GSource*.. for now, stick with it. + */ + source =3D g_main_context_find_source_by_id(context, io_tag); + /* + * Nothing can race with adding the IO watch, aka, concurrent removal + * is not possible when we have the lock. So it must be present. + */ + assert(source); + + migration_incoming_early_channel_insert(mis, ioc, source); +} + /** * @migration_channel_process_incoming - Create new incoming migration cha= nnel * @@ -253,14 +506,52 @@ void migration_channel_process_incoming(QIOChannel *i= oc) { MigrationIncomingState *mis =3D migration_incoming_get_current(); Error *local_err =3D NULL; + MigChannelType ch; =20 - trace_migration_channel_process_incoming( + trace_migration_incoming_channel_process( ioc, object_get_typename(OBJECT(ioc))); =20 if (migrate_channel_requires_tls_upgrade(ioc)) { migration_tls_channel_process_incoming(ioc, &local_err); } else { - migration_incoming_channel_install(mis, ioc, &local_err); + if (migration_has_main_and_multifd_channels()) { + /* + * If all main+multifd channels are present already, this must + * be the preempt channel. + * + * QEMU can't register an IO watch for it if there is only the + * last preempt channel left, because it means the IO watch + * will never fire and nobody will pick it up: we rely on the + * one before the last one to pick both. + * + * See comment in migration_incoming_channel_readable() on + * the migration_incoming_detect_preempt_channel() call. + */ + migration_incoming_channel_preempt_setup(ioc); + } else { + if (qio_channel_is_peekable(ioc)) { + /* + * Register an IO watch for the peekable channel, deciding + * the type of channel later by peeking at it whenever + * possible. migration_incoming_channel_install() will be + * postponed. + */ + migration_incoming_channel_watch(mis, ioc); + } else { + /* + * Non-peekable channels (file, TLS, etc.), cannot register + * IO watch because (1) there's nothing to peek, (2) after + * registering IO watch, QEMU will lose the real ordering + * it gets from accept(), which is still so far the only + * source of truth to identify a channel in this case. + */ + ch =3D migration_channel_identify(mis, ioc, &local_err); + if (ch) { + migration_incoming_channel_install(mis, ioc, ch, + &local_err); + } + } + } } =20 if (local_err) { @@ -270,7 +561,7 @@ void migration_channel_process_incoming(QIOChannel *ioc) =20 void migration_channel_connect_outgoing(MigrationState *s, QIOChannel *ioc) { - trace_migration_set_outgoing_channel(ioc, object_get_typename(OBJECT(i= oc))); + trace_migration_outgoing_channel_set(ioc, object_get_typename(OBJECT(i= oc))); =20 if (migrate_channel_requires_tls_upgrade(ioc)) { Error *local_err =3D NULL; diff --git a/migration/migration.c b/migration/migration.c index 3ffc0c2c6a..b140fb6950 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -334,6 +334,10 @@ void migration_object_init(void) current_incoming->page_requested =3D g_tree_new(page_request_addr_cmp); =20 current_incoming->exit_on_error =3D INMIGRATE_DEFAULT_EXIT_ON_ERROR; + /* zero_terminated=3Dfalse, clear_=3Dtrue (NOTE, "clear_" is not a typ= o) */ + current_incoming->channels_early.channels =3D + g_array_new(FALSE, TRUE, sizeof(MigEarlyIncomingChannel)); + qemu_mutex_init(¤t_incoming->channels_early.mutex); =20 migration_object_check(current_migration, &error_fatal); =20 @@ -447,6 +451,24 @@ void migration_incoming_state_destroy(void) MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyState ps =3D postcopy_state_get(); =20 + /* Cleanup listener to make sure no further accept() for sockets */ + migration_incoming_transport_cleanup(mis); + + /* + * It's safer to free channel watches earlier than most of the rest, in + * case the IO watches could fire in the monitor iothread concurrently + * against this function. + * + * Above migration_incoming_transport_cleanup() should have disarmed + * anything that we could accept() new sockets. + * + * Here return of migration_incoming_free_early_channels() makes sure + * even if something already fired concurrently, it won't really do + * anything but return - see migration_incoming_early_channel_remove() + * and its return code for details. + */ + migration_incoming_free_early_channels(mis); + multifd_recv_cleanup(); =20 if (ps !=3D POSTCOPY_INCOMING_NONE) { @@ -491,7 +513,6 @@ void migration_incoming_state_destroy(void) mis->postcopy_remote_fds =3D NULL; } =20 - migration_incoming_transport_cleanup(mis); qemu_event_reset(&mis->main_thread_load_event); =20 if (mis->page_requested) { @@ -833,10 +854,6 @@ out: migrate_incoming_unref_outgoing_state(); } =20 -/* - * Returns whether all the necessary channels to proceed with the - * incoming migration have been established without error. - */ bool migration_incoming_setup(QIOChannel *ioc, uint8_t channel, Error **er= rp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); @@ -865,13 +882,13 @@ bool migration_incoming_setup(QIOChannel *ioc, uint8_= t channel, Error **errp) assert(!mis->postcopy_qemufile_dst); f =3D qemu_file_new_input(ioc); postcopy_preempt_new_channel(mis, f); - return false; + break; =20 default: g_assert_not_reached(); } =20 - return migration_has_main_and_multifd_channels(); + return true; } =20 void migration_outgoing_setup(QIOChannel *ioc) diff --git a/migration/trace-events b/migration/trace-events index 8840d82f8d..a6e11451f1 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -207,9 +207,10 @@ migration_start_incoming(void) "" migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t= rdma) "qemu_file %" PRIu64 " multifd %" PRIu64 " RDMA %" PRIu64 =20 # channel.c -migration_channel_process_incoming(void *ioc, const char *ioctype) "ioc=3D= %p ioctype=3D%s" -migration_set_incoming_channel(void *ioc, const char *ioctype, const char = *type) "ioc=3D%p ioctype=3D%s type=3D%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" +migration_outgoing_channel_set(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" +migration_incoming_channel_process(void *ioc, const char *ioctype) "ioc=3D= %p ioctype=3D%s" +migration_incoming_channel_set(void *ioc, const char *ioctype, const char = *type) "ioc=3D%p ioctype=3D%s type=3D%s" +migration_incoming_channel_watch(void *ioc, const char *ioctype) "ioc=3D%p= ioctype=3D%s" =20 # global_state.c migrate_state_too_big(void) "" --=20 2.55.0 From nobody Sun Oct 25 09:31:19 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791361318; cv=none; d=zohomail.com; s=zohoarc; b=jUatRV68Y/wET35Pagxf/S1Zz7L+y12ea2SrnZVBspIwKoZBKImQYpE0HhKKAT7ZdJm6wPrFU9LV7JvM8KDVWisPymOJAU55VZsaEB8zuP/8YTWHbXJ9TZQUitEBD1pfn/44q9XbngIwIbvpB8iy+vNbD4/fgcesU12Hx44BC6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791361318; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1sK5GD5O9fskSwF3ozz8UE5sf0fR4JZta0W2sHM0IuM=; b=Mg76TzpHrAF8dmBKLT/rp2I1kP3e5TeTs/j6+hkdsX1uauNGBvZ5hPjcwgtxAez9SCIIWIUxTLVYTLr539W0Gh/tYMK2k7qrKSFZ17KzWk9jQY/uucwnlpXlCr02ru/yuMR54F+DZx0lvJAlqi9vVOW7ykHJqTkVK97EJBX3MCk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791361318276329.7781457746863; Wed, 7 Oct 2026 01:21:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xEMtI-0000eH-7Q; Wed, 07 Oct 2026 04:20:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEHNa-0003dJ-0f for qemu-devel@nongnu.org; Tue, 06 Oct 2026 22:27:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xEHNT-0000UZ-Nt for qemu-devel@nongnu.org; Tue, 06 Oct 2026 22:27:34 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-wRdsIhSYMFGxBFPpuTyQYg-1; Tue, 6 Oct 2026 18:21:00 +0000 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-5338c59f90dso53618431cf.1 for ; Tue, 06 Oct 2026 11:21:00 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5357211719csm1704951cf.16.2026.10.06.11.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 11:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791339961; h=from:from:reply-to:subject:subject: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=1sK5GD5O9fskSwF3ozz8UE5sf0fR4JZta0W2sHM0IuM=; b=XJovKhHvyZN0avrCPMpeX/6JWsZC/EBDcBD/M+fWz5BQF2uUzL1pyJ0riWlEuOkvZXiw+Y Ba3u4VNsySIozQZ8YKtJM0kUXQnVEmGdfyiPVp/DuatCz2LQoFEb0GUguBKL6JSs0quS39 FKTJv3Y4RVaN4rrh2gKf+Wn0ZFrwTAg= X-MC-Unique: wRdsIhSYMFGxBFPpuTyQYg-1 X-Mimecast-MFC-AGG-ID: wRdsIhSYMFGxBFPpuTyQYg_1791310860 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1791310860; x=1791915660; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1sK5GD5O9fskSwF3ozz8UE5sf0fR4JZta0W2sHM0IuM=; b=FV1uYk1R4W92KIFu8Su1bUS0U1jfvTl0LN6BgpDbUc+E3JnbNKFgFO/CezQNQjQfCh 3besqnJUjclrY5DWAFn2U+xtb3MbS60LnykQRjI9nZODKsSYfg2sHPJDzSHF+x8l/syk T0oezZzt60D5M3acHFw6BNPCM8H0X/oc32N33hjGV3fpN7jT/JiApjRdnuUlc8JkA0Xv 1J269k+Mh71L+S7XXI/MsY1uzWBPuEc7bJEE+c3mDq6nA6tnvKoHMe0SGF/NE0dYjP6Y tH5RzXan0OeArTmlhI/afbkhD7xZVat2MWK6vKF51drXDMD40IBziElqtC+fKlPLSATc P6aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791310860; x=1791915660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1sK5GD5O9fskSwF3ozz8UE5sf0fR4JZta0W2sHM0IuM=; b=o9v28w6YH3WRiL6qs8KQYN4Nis1h7edTE/jxA51jxyzG+KI+/IemRaNxr24ElNUslO tV1bUO9U+2LcNfqiL+1Vw0cPJlSSwmkMORFhwSPZk5vJbrzPbOYGnloj4DMnMLcCY75x /in5pnduHJ0cux0dXU/Nr3HT+R8N2U8zpDQeE/bny8qrJuBdzYQ3RUKRzH6Xpgf0WgWV hQdz9AeAM7xUrAdBw2OBm6yZo9MU//KSgsChgQwdwaGJItUE/MxOvdAuMVuoYa95O+T6 0dZGCXuTPrRFynsc6MOdnKe6Rn3Ej4ntebEqRCCCdZge1Ipl+RVAndy0S/ORwzzMbav8 Ebgg== X-Gm-Message-State: AFuF++ktO93UsS6oCsFaIW/sop4U2/4zmhUoB6up1XE+0JcQUO1Egse1 TTMLvUfp6nc+TJTaQ2LrSsFBW7x8bYPDHPWeHWtRMvX6BxlNV8hbKaOtGfokpi2+1K4lFx5f/a0 DKFQBALEvn6aTtfYfo2Wbff+c/FyIiL6fLYyPP5FwpRNGziwoL+P+fxD4IkWLK32O+v7jMugCK0 uRqpTdmeQuazBinqvcUGbSGYPTbszZACiDsr4jDQ== X-Gm-Gg: AYBFou1PYFZJ1z2I0W0BBXuJGo4En1CUXMdsbsb6TMY5cbkBl38DnbnD7oOMhk8x796 0TmlA7HUPRzC+iXPDQxC8k7Qkq7IKFxLuE7/Tp5pLFTYzY9ebPzVWIZygM/0oXY3kk8TuSp3wDL 4EUiZwcsGWRIu+OwnCrh75t5/TRdSgA6PSMIbfXtJ5pw196ivZ5lWT6mW1/mti24dH6HGFsf9bb mFNLGiQ2I6Lay5+s8FCeT1ukwlbL0p+rwK6NNAXJJg7j/BbKuhL0/gBylVwm8Op4fxTiThoPBwb NGqbF4LbAtLA06eGJEwpyh6JziFunTfebgxLdYE4w7Mmh6x1sqBR/HPROn9qCVtuQtXzj14= X-Received: by 2002:ac8:7e93:0:b0:533:37ff:92c1 with SMTP id d75a77b69052e-535668c9ad1mr37281701cf.8.1791310859821; Tue, 06 Oct 2026 11:20:59 -0700 (PDT) X-Received: by 2002:ac8:7e93:0:b0:533:37ff:92c1 with SMTP id d75a77b69052e-535668c9ad1mr37280951cf.8.1791310859059; Tue, 06 Oct 2026 11:20:59 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH v2 7/7] migration: Postpone the outgoing preempt channel for preempt_pre_7_2 Date: Tue, 6 Oct 2026 14:20:46 -0400 Message-ID: <20261006182046.3767283-8-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261006182046.3767283-1-peterx@redhat.com> References: <20261006182046.3767283-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1791361319944158500 Content-Type: text/plain; charset="utf-8" This is the corresponding outgoing fix for the same problem mentioned in the previous patch. The idea is simple: either migration to an old QEMU or when TLS is enabled, we rely on correct ordering of channels to make it work: first main, then multifd, finally preempt. This patch re-orders multifd and postcopy preempt channel on outgoing side, but only for the old machine types where preempt_pre_7_2 set, to make it follow the right orders to create the channels. Keep the resume path alone because the resume path never involve multifd channels, even if multifd is enabled. For that, fun fact: when multifd is enabled with postcopy preempt, network interruption will break all multifd channels, but they're never re-connected, until they got recycled at the end of postcopy migration. OTOH, multifd_recv_all_channels_created() reports true even after postcopy network down, as multifd_recv_state->count is never decremented. NOTE: this will move the preempt channel connection no matter multifd is enabled or not. It should fix multifd's case, but should have zero impact on when multifd is not enabled. Fixes: e27418861288 ("migration: enable multifd and postcopy together") Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/migration.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index b140fb6950..53cb6d3821 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3729,6 +3729,21 @@ static void *migration_thread(void *opaque) goto out; } =20 + /* + * Only for old 7.1/7.2 machine types (preempt mode supported since + * 7.1). Connect the preempt channel only after multifd channels, + * because some QEMU versions (v10.1 to v11.1) will assume the order of + * channels to be: (1) main, then (2) multifd channels, then (3) + * preempt channel. IOW, (3) must be after (2). + * + * multifd_send_setup() makes sure all multifd channels be connected + * first, then initiate preempt channel here guarantees the ordering to + * those QEMU binaries. + */ + if (migrate_postcopy_preempt() && s->preempt_pre_7_2) { + postcopy_preempt_setup(s); + } + bql_lock(); qemu_savevm_state_header(s->to_dst_file); bql_unlock(); @@ -4009,16 +4024,16 @@ void migration_start_outgoing(MigrationState *s) open_return_path_on_source(s); } =20 - /* - * This needs to be done before resuming a postcopy. Note: for newer - * QEMUs we will delay the channel creation until postcopy_start(), to - * avoid disorder of channel creations. - */ - if (migrate_postcopy_preempt() && s->preempt_pre_7_2) { - postcopy_preempt_setup(s); - } - if (resume) { + /* + * This needs to be done before resuming a postcopy. Note: for ne= wer + * QEMUs we will delay the channel creation until postcopy_start()= , to + * avoid disorder of channel creations. + */ + if (migrate_postcopy_preempt() && s->preempt_pre_7_2) { + postcopy_preempt_setup(s); + } + /* Wakeup the main migration thread to do the recovery */ migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER_SET= UP, MIGRATION_STATUS_POSTCOPY_RECOVER); --=20 2.55.0