From nobody Sat Sep 26 20:50:46 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=1789594674; cv=none; d=zohomail.com; s=zohoarc; b=fnqppxPmxHz+nDzezTUZoBinei285dpZj+q+/VckHnl4p9Ry7udAW+GmJvKZ19nfPOfoCu5GPmsvMf6X7u1SnXTfGiWwAfoPYQ/elKXeQgN63pac2gMP9DB/Q3CXey8m8qeSaIRe1a8BvhTkO/IvQPeY1eYhjKQoHgoHt6QKD4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789594674; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qaVb+pX+Dprf1Z/whMh/eAqXrLOZN7xKMykck4AAS0Y=; b=aawMW/h5BeaO96PJp1/ZnLVRcxxowxYtX3Z9K6uIbD3oeE7BjTkOhC7gUwa+mrxqaPrvrofyVm3eek/Wi2z6YyO74cm2bd+9U6rjOgabp5PAL9wuzz6TSG6L9Sco3O8iRYcUZzFbaZa5gwShNsKLTzU+2BF0NdR1szA+TTRY0PE= 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 1789594674585830.923130720356; Wed, 16 Sep 2026 14:37:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6xJQ-0000nw-EP; Wed, 16 Sep 2026 17:37:04 -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 1x6xIW-0000hZ-EL for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:09 -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 1x6xIU-0007ZI-1R for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:08 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-jZCSu7vXNyaA4GwSaxD9Zw-1; Wed, 16 Sep 2026 17:36:03 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-530ef845909so1762611cf.1 for ; Wed, 16 Sep 2026 14:36:03 -0700 (PDT) Received: from localhost (bras-vprn-aurron9134w-lp130-03-174-91-117-74.dsl.bell.ca. [174.91.117.74]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-53261fd4cc4sm31478721cf.6.2026.09.16.14.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 14:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789594564; 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=LzZg54NrQHiqlGqq78bpsDu7nItJHX8btdTiHXN/nkdbabE2qhpJlQ8XsPAHLRclQzhamP f/HvWOELkIYGVqwArfc1teec0N47TAhCowfYjTnV1gj9/+KZ76IYurcRWa80HEPxxwAdO1 CNvyVQc4iNXmeS8h5zoCsB/zGqB3d5Q= X-MC-Unique: jZCSu7vXNyaA4GwSaxD9Zw-1 X-Mimecast-MFC-AGG-ID: jZCSu7vXNyaA4GwSaxD9Zw_1789594563 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789594562; x=1790199362; 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=fguZplTF1KPA7++SLPajjZOjTbxhffGcIEuvf6Cei80yoyuhF9VE8XzLd3CiEgbdAP MaqEfmR0d6MVcJk8BogLlOqMs2g/iBT4p+bgUSmPOKIa83gJ3D5jeX5FpqvQEi4aTDFA GVRexVgfYe59hrxo1gTqg//HJrukpoDDlvxy7K/A6g5S/qyrT3UzXLj0gvchQki45S9Q oWu+745Na7DZJw/dO3LUWkvNrLvh2XsKAMycsBPPZq54Skde2FwdAcg4LS5X5dmjiuaN zaFRcHDdumuwJgLNaYIYlducDyfCcqtBuyajvYlny1odZFw1hMxp/c+O51o/LeX8GD1u VXag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789594562; x=1790199362; 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=drU/EpOu0wWiYbFYaoZ/E+5pjBRe9EOtoKZHmTC0+3k11kil0W7Y7Vr8Q/t9Gbrbbb sj/MM+Z89NEu7OQSYHCEXOO/AYGinbXYcfaVrhCeFd2fTkBnqKN48tYxqynpIVp8iUwG J3Ikj4pQMaCHeoXdaO9CwAjz+sGOTvuYV0ouWzODOJuralMMdFVhw+Pt8Y4t5ZvBO7ll SdIS+jQ0LPOel4qFDKJZSa8MdE18wqa8qKr+RHS5jo9xWlgghQHjxQ9csO6ln3QyWLtq +eORmhJv42HBLIviZdMqZtYQ7SGjEUYCoxjQ4rHZ87gkriwUbntuHKAFBXxh1+QZJFtr U2DQ== X-Gm-Message-State: AFuF++nq4rxci2f7mqv+tintH56x9xcCeQZM1XiuWX4yZX4cXacbzEOM Y+2klxbOFzvVEN5a6nUeKuQ7yPInsDBOD28n0hB+Y3OKNRuTy48NDkbQUjx9KL5ISzXyF0NegnO bt6h0yl9t6ZtSW594ejWUrjjozApqCcurfxzmqAK7r7nZZwJsFmfhf7gGawDA8vbRB0Xs5aotsf KDmGBXCoseR4hTIcKNt9EJC6797Ls+SYZ5eGdXsKyF X-Gm-Gg: AYBFou0+DYZU59fKmNWmox+LQubKUwFqBWYS+QdzVQQE0GyIqa7V7+s+XGJoz0m5qZt 9Ne1tpo8gJo5DnHUsPgliSETDV+9zhEczmAtrGRrAHjkeVb+dgqKBIEJFiHXq/ULw99ofuf+AnY 6kHaPgaXv68d/F6ZbGqQuEnXdWwRE5a/FfYsW07Td2g69SFdu+IQeH0U4irD6x9fneE/yuw+ewV Exfr9bFr+1sMKGI4hrD8y76todw+SG37m1+FbZOjSoALer+aPbjPj3dyxzpmU2pFHYiyn8zvdAu 0PGslxFnYvQ1pQcysBDTp+KeGaYfcgJt+inWcQ479BEbshYW5ialXgOXsd4EcH3ZL51Vx2U0Opl neD17cMBvBWm9QgHJs/tkk+qNWZxcJnR59vJq+j7R652rbmropuPb0wB/16g= X-Received: by 2002:a05:622a:2cc:b0:530:e4fb:60fc with SMTP id d75a77b69052e-5327ee1b2bbmr72002001cf.15.1789594562522; Wed, 16 Sep 2026 14:36:02 -0700 (PDT) X-Received: by 2002:a05:622a:2cc:b0:530:e4fb:60fc with SMTP id d75a77b69052e-5327ee1b2bbmr72001641cf.15.1789594561936; Wed, 16 Sep 2026 14:36:01 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH 1/7] tests/migration-test: Add multifd+postcopy test for preempt recovery Date: Wed, 16 Sep 2026 17:35:52 -0400 Message-ID: <20260916213558.587304-2-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916213558.587304-1-peterx@redhat.com> References: <20260916213558.587304-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1789594676232158500 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 --- 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 Sat Sep 26 20:50:46 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=1789594687; cv=none; d=zohomail.com; s=zohoarc; b=MsRNV3AXx1yDUh2obSjz8RIz4Q4LjfMfLiMr9Q8Oubl1YWGNph+UMe3qnpovkOLnaCmgFmkeLpESR4xOkkqoDJOG0yVpFpDJKy+SpjfzW+ek54fpocts+DqyfqOFqp6rERig3RCk+isZIoRGYJe616qh3oE7X31qkaGFqNpqXQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789594687; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G6LO977wvI2xcfln2SzfX18ONYi8bEpf5XH34bvwTKM=; b=GtMvhIi4Mg7B14Fzw9PXmqzcezcHjTHHzkDtwB6NutPOXH0GoDyC8IMLdvxoAoo90ChLSlIc36RoCyXPjM281fFLd8IOHmD18Kjn3Tz4iS6sgcDEJKR/9fXMsVgkWmqbr/fOLhrLWtm+yTfLdSCcW1gDe0fj6YoDjGcHjzqLmJs= 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 1789594687187616.679620084393; Wed, 16 Sep 2026 14:38:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6xJM-0000mP-Fj; Wed, 16 Sep 2026 17:37: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 1x6xIq-0000j4-Je for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:34 -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 1x6xIo-0007bS-Ua for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:28 -0400 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-389-4B2ZYE7sNtKLedbVLMTklg-1; Wed, 16 Sep 2026 17:36:15 -0400 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93a3f673221so41238685a.0 for ; Wed, 16 Sep 2026 14:36:15 -0700 (PDT) Received: from localhost ([174.91.117.74]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93b7821d231sm313373085a.21.2026.09.16.14.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 14:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789594583; 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=G6LO977wvI2xcfln2SzfX18ONYi8bEpf5XH34bvwTKM=; b=ChNW4YPVVtZveytNtNC8e0YxLEPHzK06Gg2YaDUellwt96fXko/yPxfgnUCr02T9Tf1/+N FPmv7MSlXJXdJSx7qhVbOg4YhvyWNbIqj7i7oST4894hYhxOi5QZi70oC0pnNTLD1vnSHN Rup3RFw68sYYkARWKQoYkRvftV9jX6Y= X-MC-Unique: 4B2ZYE7sNtKLedbVLMTklg-1 X-Mimecast-MFC-AGG-ID: 4B2ZYE7sNtKLedbVLMTklg_1789594575 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789594575; x=1790199375; 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=G6LO977wvI2xcfln2SzfX18ONYi8bEpf5XH34bvwTKM=; b=agMT8ABNYPDAqOz0eJW6FXhIBzoGWGsS3n2d97CxAQbk1Pky8LpTenANPVMF+4cUKY waNDcyzcV+rnDKx41UyN3wQt9iMtW20ay/MX+eGyeVNIyExe8fJsldIASwvVzeXllVyz Y8V2uguIlkCAw2umgrkcOzrhts2HNB2jGn/rU9zCj7aTbYkh8zAqdFANa5TTqAH9eR3s ja764szS3zhtzpTQe/DG2SGH862Bpy2nZdZlRL8HFZwkxj9MCEiV6Kl/QuQURUJAm8Hd R+Ty18u/7ECKO6QIOmW9Qsl4+f2frSl+1rfmjLpoqGjCbWnrqI5YK1WPhF+VojBgpszF GTGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789594575; x=1790199375; 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=G6LO977wvI2xcfln2SzfX18ONYi8bEpf5XH34bvwTKM=; b=FTx96WDgxj1AVX36DWAruu17YtknXvuujWj+snYea0A5Dq2Vq7FpcJVSJhCV3Rj/R2 EBCm78J5dd6AiCwVnHKeyd0pkYQT8xC4aK2Hh+Y5aopoEn1mFZoHvRh2VpavRL6K8Evq O0Zg9RpU+9R3sALEN1zEec5gMvFs5VsWCa/loJQLWIPhbwkLa55r/uO6hwVYBBzKQBm7 etURzNedNhkrC+s4sQkSmaWL9Uqip0BM7hhzegfA+CxXO9YMgntFaE/cialxu24QMRln ADBSsBKvYTDxIze91ksXeCdpcxBjb2P03ZzL7iCE5sIdw8DdYzwjBSkWik7SBC1fWCEm INPg== X-Gm-Message-State: AFuF++mvm4p88f+gKpy/BqLvGKU9gyydH/fxjh83DlAKW6lNZ5pXdJlt 5jFM3XAeo8k7iaalLGiHq8zI7yJ4ZczZH3VV8hZpHxN2ItkE3PlNOsUKqIXHXhS26lnzqHOhzQN fkgfkUFUxIQcx872WQ5FKJbqOLzQmi5LQ/L9qWdNkeTEdeLArTwv+r2qTEFIRUnjl5sQKkBoRUc KOzJdJ6tatoEpcTAiCa/qL8i+w2KiEBxcrSA4IwFNC X-Gm-Gg: AYBFou3g/i6iSPNYbuuw37/9jOGoQ2VQ0g6d2YfYNlJDgmReImH2zNE6E5Ck3p+cMs2 qKGYlqe3HtjE86nZxzkPnUAlQm8iNpXDsJoncM+C0p6lJlT5EajjYO6B15xx3vUmr6MuFUXB1ic joaxFMqXce+Xdo14jv4NU1w0FjwwNtd2Aifsktj10cwjOn6G6XctIYK2BWm07017WSpO9Q/fy3C 07wrsF4oAmUYo3uQVi+vE0zZwScKsC4Hr8swqDLEeGTpPoltiZsGb7jLtBrnn172VUzPNJb/XiX TnD3/gu1XEBu1+Eo2sA4aplHoaJYyxHbONS+ldp+MGpGS7pC44UA6r3y/VNPdr64+jKp X-Received: by 2002:a05:620a:43a1:b0:939:a834:98f2 with SMTP id af79cd13be357-93bb770c70amr697956785a.15.1789594574657; Wed, 16 Sep 2026 14:36:14 -0700 (PDT) X-Received: by 2002:a05:620a:43a1:b0:939:a834:98f2 with SMTP id af79cd13be357-93bb770c70amr697947685a.15.1789594573955; Wed, 16 Sep 2026 14:36:13 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH 2/7] migration: Add two more trace points for incoming channel mgmt Date: Wed, 16 Sep 2026 17:35:53 -0400 Message-ID: <20260916213558.587304-3-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916213558.587304-1-peterx@redhat.com> References: <20260916213558.587304-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1789594688060158501 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 --- migration/migration.c | 3 +++ migration/trace-events | 2 ++ 2 files changed, 5 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index d14beb5d22..cfadcc79c2 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 e87d4abd91..e755872496 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 Sat Sep 26 20:50:46 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=1789594687; cv=none; d=zohomail.com; s=zohoarc; b=iOfwWUm35ocGpMJl3PZScx/eP7oNLWk36otVJGy6HNOF9v0jXVeduh94sZywQRhXu7zbtZwo+EPnbQ6mUSfnn+yIj3YOWNJU0CwDuxuK+bkkVKwLfGzfeSJ4t2JtqUn5xe6EhBbQDH6Ux2kanJ1u3OlXQjbZr6C5mUQc22bIQ2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789594687; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9nwNhbSo70/X0tJPmtDCKCPQvZwR26DjNXeNb2q93IA=; b=E38vYvwbTJHYZ0KkmBHZCN7tkv5XhE6uUeFkJKCLZu+LJOswbndu4DtzyIWyMgYSASbPaaSUTHQUXlGM8EUPxodPIctoEiG/g7hQJtR9t7gd8/BNhk07RXe8hy0xJWuChblKGBFRt0a/pfwf8aN3/vzg5FLQniDrHOnv7LofTpk= 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 1789594687828537.1213947890847; Wed, 16 Sep 2026 14:38:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6xJO-0000np-ON; Wed, 16 Sep 2026 17:37:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x6xIi-0000iX-I2 for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:29 -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 1x6xIh-0007ao-17 for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:20 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-AF_Suwq-P1GyQcNZltXmFA-1; Wed, 16 Sep 2026 17:36:17 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-9123be39eeaso2058336d6.2 for ; Wed, 16 Sep 2026 14:36:16 -0700 (PDT) Received: from localhost (bras-vprn-aurron9134w-lp130-03-174-91-117-74.dsl.bell.ca. [174.91.117.74]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9123be9ca82sm34619076d6.32.2026.09.16.14.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 14:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789594578; 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=Ag+bnBwe9t4deeVo8x6+EGFUMKmg623Q05YeWqwNqcBaoMtXFh0awVjUkdFL91EXorAj/q TKXUCRHXwquwlRDry5Sd8ssYpX/++jU5sovTOz7Ufvl8Sv1HqHHD3oxtnpWnp7aI+SIwxO bKsBO7uX7Jr/ag81b0iABQgmWVRxvFg= X-MC-Unique: AF_Suwq-P1GyQcNZltXmFA-1 X-Mimecast-MFC-AGG-ID: AF_Suwq-P1GyQcNZltXmFA_1789594576 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789594576; x=1790199376; 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=MBUDcXfmvrHtji/Lonk+sousi8ih/hyzW3djonEnZ0/4TtIpJD38bRwuV5JSkf6QF7 1Tbcmq5y0cCXJAPsHSKWG6RAKrCunY9Qy7JWtdYmP1V+yxtr8HWB1qXqqUyBPWsYd1jy QHhgipLZ6kTi0CA3lcVnSnFVCJlwSiFDMcOA/isDBMJrC+KYTwk1b7j24If2b+Nss8xI TZ2Ffl2qBjO6zmnf/OskFQUCEJrr5a9cYsXuzZUmWc7zvcVLqDvBscwZL4Niax7mK2fW SSAnHe8nxwRZ3kIrghi9shn+Xo4x3JtesiOUz7E2WpJmIgVrt23JtnFt0twbBMLgl2Dz oNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789594576; x=1790199376; 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=zSQDiwyU5Grye60eI4QPkQ0l7sSWgyHmgkpojxRKQu1ymXJ3lUD5WRSB+O7uRDghWK Yk7jmOSmVPABwFxerc61O+AvYbdRdRbc6McnCvQZ+HXuvt6Arqp7eRuuv2g1KMO9JLTq 8sOz+ULSrHPCWzVyt1mweYH+uzGM/p6PnnsV9de/b7hLSWn3KCJ07cakZSWUd0DvBLYM C3kLihP9PmfaUpzWjPvJgAN1sLjMhNW1jzH3LnYWF2kLDZ5b9j21hj1OVQtS25yY97id n2vB2UI6+rjvwhB8baS2GeTLJZKJPC1+9oA2G0lKAmjPkMziv7HVPSFQz//fFNLynPO7 iVbA== X-Gm-Message-State: AFuF++kL45jln7dHoFhD+ca1dvLuO32L9Q9bGTlGM/ESpCXThA//082K UgOPlAvH6hHXhKHoaoE1naIA5W6CmoKyaqFrPNwqcdwH0eOHjwx1cmEvYyZX8ib6ozcOIV/Xx/B 1smMgrzrAbUGvLMzSfYRmSbb/Msr1sD/W5WkuHcqKBgATDZbfZr5Ncj3fvZ9r9lSWUvAdX+2+/v k9mlj72yuStrxZLp0J7ROV9fyi8rpN7FoolZ9ilo17 X-Gm-Gg: AYBFou1VOTOLO/sH5DKRPOWdeGGZRsjxd/CgRhYcNzwqIDpuuSH9W5MyiY+518tyZdC p8+8Zlgy1tVfywPKsMfvbIHtubiFrbNlNA6M09upBzsgba5Hu4CXKFimRUBdpUXrK7IEnQb8T9I Oo6Rkpo0iLCROTU748NipAVkzbgCG/Yp/S3ziE4YWY/AX+Ud62PJ2UAPTKJN1Utfmn8S3pBHJ+s AxuWQLq5n9EcXtrhNRMgv31NNrAfVywxu8BwVvxG2AG1ocQIU/wrn1YUHubfMYq3wTVZbP7xOrh MlwkxsqX4lo0jc6R6Fgec4Ip+rHGAuhD+k7xhA+k37nNQaja2Db6L56tSFdt2AIXt11i8rC72De 5s/3P7amXPOzrNbU31zzYhjZv+2FnBc+dg2GUOFHuGIhfwUf67ePHotWbsDo= X-Received: by 2002:a05:6214:62d0:20b0:912:407f:6a53 with SMTP id 6a1803df08f44-912407f6b2emr49120746d6.17.1789594576334; Wed, 16 Sep 2026 14:36:16 -0700 (PDT) X-Received: by 2002:a05:6214:62d0:20b0:912:407f:6a53 with SMTP id 6a1803df08f44-912407f6b2emr49120376d6.17.1789594575827; Wed, 16 Sep 2026 14:36:15 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Akash Kulhalli , Juraj Marcin , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 3/7] migration: Fix socket listen backlog Date: Wed, 16 Sep 2026 17:35:54 -0400 Message-ID: <20260916213558.587304-4-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916213558.587304-1-peterx@redhat.com> References: <20260916213558.587304-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.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1789594689870158500 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 --- 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 Sat Sep 26 20:50:46 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=1789594686; cv=none; d=zohomail.com; s=zohoarc; b=fL0UpVd4pdsii/RM3c7sBpBrfUgbgSSjtnHrMtIasasO63cTqJHRJ/Xgua71Fq/Yb2fHF7YjaCpdTptq9FUmgPy0YKD5VoG/rGZOl/rcM5JX22oIKAt4UJj7iMeqm9A0WJ9IgkqP/Oe6vLY7xwdhDF8ZgBlBOPMgg/TQSkaEWEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789594686; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ruJ34mVTBKFRGqovWKs9/aGpon/uDErFImIoiP6PipI=; b=YbMBhG08flFG/1H61jSL1RhMAqfx3xE6iG9hX0MfGvTPq6Ac15p7XoWmP/lLs5wQzsTBPmANbXiAjDSC6COYiI1dA0akP2ghLQBl2sjDiKg0d9xdJdGfN8JAFMEpt9ERaAT/CVdKWbOox/RQLNCn/O65O03porbM93W6dcHkD6M= 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 178959468637047.23610776846408; Wed, 16 Sep 2026 14:38:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6xJH-0000lX-JO; Wed, 16 Sep 2026 17:36:57 -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 1x6xIk-0000id-O2 for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:29 -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 1x6xIi-0007ax-R3 for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:22 -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-630-A4ydqzLoN0WDwpGydPG2pQ-1; Wed, 16 Sep 2026 17:36:18 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-530e89b584cso1364751cf.3 for ; Wed, 16 Sep 2026 14:36:18 -0700 (PDT) Received: from localhost (bras-vprn-aurron9134w-lp130-03-174-91-117-74.dsl.bell.ca. [174.91.117.74]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9123be946f0sm34849616d6.27.2026.09.16.14.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 14:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789594580; 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=ruJ34mVTBKFRGqovWKs9/aGpon/uDErFImIoiP6PipI=; b=Xj8FjZ5PYddpnrUrIgZwE7BfvOhqH0MWcdkzVj3DscVaE2kbAHXmRwFemPpAQ+5IleQbuw L2zNnGEzh+pTs0jgg+SXofI3FW7MI76H2GU0J6ywnQY+IBCpSGxLE2d8W7XSkeofq2mW/y QNPn1dLBBeGDx/LRevT9hsJWysF+gGc= X-MC-Unique: A4ydqzLoN0WDwpGydPG2pQ-1 X-Mimecast-MFC-AGG-ID: A4ydqzLoN0WDwpGydPG2pQ_1789594578 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789594578; x=1790199378; 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=ruJ34mVTBKFRGqovWKs9/aGpon/uDErFImIoiP6PipI=; b=ToZCKMwO1uYYVpRLBEVlRjkGOhPvHaTa1+40kU4Yq2NInGhdZH2ViGzo/HO+YPumz9 QJIRf9to5i/r4RsDtxkYJNqJEfA+WvkGweW1G8zMu4QE0imR47tg4QFC3qtBmPOaCJ9w EncpKc8nD+Rg9G45i3YxJfsHPyej7jV/PIP5RXIOLziD3j9wkNwio3dZmKUGnJMpqY+C 8qRy6EhUig67kOMuRlLxrNFKHk8P7AB6H78eMTgy7qzVgPFAArS7AaQegb6IyolSm3X3 18/sM6nOAab6laQkr/LaYNiBvuhpCzOwCJVFGtgG2zLyQzJjwFFpwnHUZalv3zTBQwXi vKeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789594578; x=1790199378; 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=ruJ34mVTBKFRGqovWKs9/aGpon/uDErFImIoiP6PipI=; b=GXz0cdVP8xm+NcCraBYWmn4ebwaxf/ch2W2KllAkdAg0Aal/dctTGWN/01BZaBZ7Rt ykd7oOW3OxfRhEyH5v+zNa8sTAs20ynvAyQhGguC2h15zmZrt35aRDYz5MpYAnuO1UTL 9lAyzIJxG7/jitXQlYK9t5QUlptP86N7PTEfJJszVrS9nILjl4z/DjEDGjxJ4eUbV1pt maE5tSBC4CBULFusTuU0fQQGJN2NrQV40mza6Ou6Lbc8Of2O8E/l7g6Yr+NcjVQziwYn oNxsvIP8vQTJHEvrsxFOUJ4BkhlCiaDaL6T8a5GwTTDe01ZBLLNvX6XHcuX/x2pauU4D 5pHw== X-Gm-Message-State: AFuF++kKGSYkrg7sUQfAsW6ZfiStZYT3NAiWH54ADgbJh9SBMRlaf7az bO5iueTb/K0CqyevGUOzT30d9wvj389vScLBHjygkzwoaLROddd+GJYZ4SlyhkopQgx17Gwpvpf ZLWy8QXeZiC6feL7xAlW0g8hdRzJ8MALwo7csApSbt+VEEt3WoDFwuKBSjW6XEYsBFZXrciIMED OXI8Gq3vVEMWBpAzE8VnmTb8wYThyPBEwkVcvrRicm X-Gm-Gg: AYBFou3FTpq0sebx9+HKzaQQv3Wp3MWRqL8Idk1Ame0dI1PRjwUudC3BlsGlxd2UCwx +9Z5MEv4C2i8zy3CrmzM7gl3yZ+Btra5gmuhnwCeVOuZN7NhRDvPta+W9NeWyxik+Fhd8xA3vEm 4L4I1DyFprmzeQNcNyNGEAPRWeigD9Vwh0v7D83gbhLt3QgerttdRTOZZBXqDE6A4gQaRiztTf6 ol6W+1Ab8Ji5HhN6c5Jc7xLryA3ayemFG9P0OzrIToQQj9Hs3t4QCyNt8emF6WJ/R1DTAh/lwxi yAh8WwIlQV3GJu8qm1ZOfkoBvi9LSMypdQPTXQuIOOLaMNsF7Qv05nASkqG5onv4izk2JHwBag5 mnzxqjt0IB7sySh1LygVvrm2SxRIFvGHKetKruOtDKxJNT/gnCytqe5rAiq0= X-Received: by 2002:a05:622a:1453:b0:531:175c:4d11 with SMTP id d75a77b69052e-5327f598a2bmr71127091cf.48.1789594578023; Wed, 16 Sep 2026 14:36:18 -0700 (PDT) X-Received: by 2002:a05:622a:1453:b0:531:175c:4d11 with SMTP id d75a77b69052e-5327f598a2bmr71126661cf.48.1789594577501; Wed, 16 Sep 2026 14:36:17 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH 4/7] migration: Split migration_channel_process_incoming() Date: Wed, 16 Sep 2026 17:35:55 -0400 Message-ID: <20260916213558.587304-5-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916213558.587304-1-peterx@redhat.com> References: <20260916213558.587304-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1789594688093158500 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 --- 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 e755872496..c5fa88fe8f 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 Sat Sep 26 20:50:46 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=1789594648; cv=none; d=zohomail.com; s=zohoarc; b=VcPjiBzLq3cymguUvLFn/j8p12n/wTn+u3CFxFjLLrP0tqd8ZRbWovUznRm4oxkO1fPuhsniHq88iLAgguw6yib1dbrkOiRxkf5kpU28jeOvN2NrqDTLcWkkYviv7KaSPFDjaIe0DgrbEy/1c8NKLodsvLSzghXGP0UypiBl214= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789594648; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ttb6FMU9RwrGZr7fYtOzbH5PPqnU2pzD/Mi+DK9ZenI=; b=ZYNposUaj4xjmt0i00cTjOc6fwVmynwdl1qg2kSbgtAql2I6mjk3CJAc4SuLC9ZHfbyTR+ocgNzS0uEhS/v8MHHNoXAUMRZg3AJSCxsvPDGk/VQJDPiT48+U5Xd6CFI8kj3SE+XPwih5jbSTuPEET2UbWtnqwPBCg3UD7bGOzE4= 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 1789594648360733.9848967102727; Wed, 16 Sep 2026 14:37:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6xJF-0000l6-A1; Wed, 16 Sep 2026 17:36:55 -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 1x6xIm-0000ij-6w for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36: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 1x6xIk-0007bC-Md for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:23 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-oGXtUYw0Mda29jV-gj_VVw-1; Wed, 16 Sep 2026 17:36:20 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-912054a1c29so2513706d6.2 for ; Wed, 16 Sep 2026 14:36:20 -0700 (PDT) Received: from localhost (bras-vprn-aurron9134w-lp130-03-174-91-117-74.dsl.bell.ca. [174.91.117.74]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9123be63bdfsm35193276d6.17.2026.09.16.14.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 14:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789594582; 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=Ttb6FMU9RwrGZr7fYtOzbH5PPqnU2pzD/Mi+DK9ZenI=; b=RQcyTfRZn5BwtIJ7IKl6hlumCyA6ySN3g1CsEYzg0JjNh57yiRB/9wtmVuYBEaLVBiUDQJ bAY2Ovk4wYN1rrsAc2nNWSZvyhsRXwDckwMS9swSg9Zt08AW0vt4F2/MIu00Prqc1J0Mlw vxNtb4C+GWWwJVXnaEr0bPQyDt/hG88= X-MC-Unique: oGXtUYw0Mda29jV-gj_VVw-1 X-Mimecast-MFC-AGG-ID: oGXtUYw0Mda29jV-gj_VVw_1789594580 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789594580; x=1790199380; 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=Ttb6FMU9RwrGZr7fYtOzbH5PPqnU2pzD/Mi+DK9ZenI=; b=YCaO6FpQXTbvouAo7bxMtCRlJ+jN6akNRk73g6ZOeQlIjeE4kMUJhoZVwjYWHzflgT ev9NPiEirU6sUOELiHb3Nux77Ba8XlzT4TsNalhV/eP883DeIIL1JPIpWCJrA2YVbyFX 93qhSGPF5sQG9I6xzQUrxL0SSJ0/J2urRJ+ZT/zqliNRnEy8O+AVEyM2YTs56AwAZgs8 4umtgqaXca97X3BPMatlA/KS3kHtFJ55UEjlMoRYEhy3r3q75t1R8EIgnebgybgJCYUp gNmDsV/hlOOTJ4m07UuqlO8gljby+OAS19L/0Xsgtp+Km4RwRo2utAHWbRMVUpi5tIDG iTvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789594580; x=1790199380; 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=Ttb6FMU9RwrGZr7fYtOzbH5PPqnU2pzD/Mi+DK9ZenI=; b=jspfI9UXSLRDKJbSgEWnR2+iRZZC7IVjB765zDY4PPS7G/wsBRGGYPweIV6HEkLoWy abA9s1MQMVsGIuty0Ms2frYTYqf342ahCK7VqmQBNaiKsGGz7uV3s3I2BKgQS0JW3Ix9 ZVz9B9h56Mpm+pOJDND+6LubKv+jmTlhd3mgKqay1bHucTzBr03IC0Pr5o3kNQ7rtJp+ SByi0vptpnV2ksAbB3NC/mYbPqOv+Ep/3udaGWuzke0wv5WVgWyBOBvuYaW/X+ZBOZdq OinWshv80smaoGWbeT16eJkint6gmlwcq5p/aCo5ygi5UQYi8/Y9ROVjDxgK0m1uvEEM b+Kw== X-Gm-Message-State: AFuF++lm3vbcyqnvJMINbJkX0ah8C7RuM9f6OxEJ8A2R64UJ+IVVFaQ8 IjlEMFE2FFbF1kmBDNtkhxem2CLys8511N1kxGF3xz5mCTTZL8h7bpqVja4zXKLKapwKTrdpPOy uX6xzjn4h7ieLuGqOpeGyJX/s9eTqI1qxWgrVwVIOU6TrcT3dVwByDQFrySvtJwEQWbiYpWgZ50 NSI9Kkwdr3JdCGySDO/zL7WZxQmBctgFPUCql0fYrm X-Gm-Gg: AYBFou1lyfvlEtqh8IDosRWxf2DVNwckvffP2zUAefjVe1fnvjpKGF755v8IfBNsshK lYx5bdKm0KzJP8UPzLKRcbqsBw5K0B2WysP8fe+8Q2u3pfEBjtH3rfgA3EFjrTGxKboWp9vgAx9 vwMFHipCt8vccR7bTbmOlVWGUD2tzkGym0qzFXnHlOTcyVWcTv65YcQsEJe9Ca9wGEH8AHGQGsm cuzuDOuQFfvr1JQA1XWRAGyz9e7JA6YrHNpSV+ma+VfZltzJqm50kBpfrXn3y4K7xdvKzfmqBcV L7YQQTIMSqNwXJluw/BPo1mmrgUEY68bOJb2KySDTjrm5HoQGB4fSQaVvlpnDdFLLJPozTK7msW l1hJz1NsHTYFdjaYaHEZ5XLjVvJtF51dM9+UkJFiOgoHRgRkW1Dduo0FzpqU= X-Received: by 2002:a05:6214:2506:b0:912:3b8b:3275 with SMTP id 6a1803df08f44-9123d7916fbmr83636046d6.19.1789594580093; Wed, 16 Sep 2026 14:36:20 -0700 (PDT) X-Received: by 2002:a05:6214:2506:b0:912:3b8b:3275 with SMTP id 6a1803df08f44-9123d7916fbmr83635316d6.19.1789594579432; Wed, 16 Sep 2026 14:36:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH 5/7] migration: Dump type of channel in set_incoming_channel tracepoint Date: Wed, 16 Sep 2026 17:35:56 -0400 Message-ID: <20260916213558.587304-6-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916213558.587304-1-peterx@redhat.com> References: <20260916213558.587304-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1789594650340158500 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 --- 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 c5fa88fe8f..9ef42f54d1 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 Sat Sep 26 20:50:46 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=1789594690; cv=none; d=zohomail.com; s=zohoarc; b=HYkhmZwPzUQf6Vp9ZIG7Wx95tgOlXcvuY7HCdT74BgC4ygXbJgbzBaM5MnuesbBQQQu6yeDb1nhK8YuDkW+DQ8DWeiK1azaykzhblSQlEkuGDfEv2wf5kzh/stzWay8bJY0Djgl2y8LM3R5N98SaynMfvUpQK9ZEiT41MMxdvBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789594690; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EDoKZ9Ceh7nbgRew1bSUQ1mEVz60EKTii7hZS8/SJzI=; b=S5EkHAsSf2NChYe5JlJvi14mQpIj4PhmPG5dYmlxuE3MwoYMTIkaWmCchBc8C8r9aVoxWp/K67XZxOlYgano9LSodEKi1WJ+d0KcoeP6Z9bSLDs30hvh44I5XAD/Nnar10B86sylFsOcKibNad2wv5XZ/Hjp1ERztZ6AH2yIpzw= 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 1789594690082440.4893749114069; Wed, 16 Sep 2026 14:38:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6xJR-0000oH-Fn; Wed, 16 Sep 2026 17:37:05 -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 1x6xIs-0000jJ-Ix for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:36 -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 1x6xIo-0007bn-U0 for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:30 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-AjNZZHldOPKjowTc4Uk-vw-1; Wed, 16 Sep 2026 17:36:24 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-91043af01d9so4018106d6.2 for ; Wed, 16 Sep 2026 14:36:24 -0700 (PDT) Received: from localhost (bras-vprn-aurron9134w-lp130-03-174-91-117-74.dsl.bell.ca. [174.91.117.74]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5326201c60bsm31577041cf.13.2026.09.16.14.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 14:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789594586; 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=EDoKZ9Ceh7nbgRew1bSUQ1mEVz60EKTii7hZS8/SJzI=; b=SKFmd0qutPrzJvAh4epwORPC3Q8jAknsoVBZboE1BYj115zVjmCLVC5o2crWW6xhAnpJHj 8tWKYy3bfLzyQ+GnW20ntr+0XFdU96TAY/6/0R3vClRFkWqA7O3udKy2EhpkfOIzj3Imfp iHlhD8XKJNOEYNCoypEp7cyqiTQkeDM= X-MC-Unique: AjNZZHldOPKjowTc4Uk-vw-1 X-Mimecast-MFC-AGG-ID: AjNZZHldOPKjowTc4Uk-vw_1789594584 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789594584; x=1790199384; 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=EDoKZ9Ceh7nbgRew1bSUQ1mEVz60EKTii7hZS8/SJzI=; b=k0XyNIm0DTNAhEcK57ODkaldMMf6IYwWyYo3l7CiZoWKLMmYrIh7qBSeU8t4YQidkd FwOCS0n6EZ22htYZZyRuUqbJvxvK9vjxhIiyWzlwx4m0557kD0dDWUSLIfcsC7QLmaCx uLUR0TvN4qKCAKt0Q3Ucc5/xGifp7dGB4siJ7wgPVH+5UfIdN0c4s9fSXM7deMBKBuxN F0ethkyzc68ZFaaLUiywPUlSES5ij2wP0W4YgyhY15s7IGluVDSVPL0QS6POWGKQhxcM EwMUX7cZykgJnTwZJsAQoEbQsphksa1vOhlJgNF6PjRE1FNop/l3z4Yg2/rXTUsD/O3y SEVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789594584; x=1790199384; 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=EDoKZ9Ceh7nbgRew1bSUQ1mEVz60EKTii7hZS8/SJzI=; b=m9lt7SWzCVKS8ejDhefDCdjWitcY7HA6SzyMT8eWMYjl4/yGo3Q+Wy8WfC1auZvsc/ MuPDRt9KpiVXVHSjnncJEKAkua4NIRUzqoP0zYqMMdTRa2uw/71wA4VMeEFUzrRUi8JM IZMqxQ20lT7CCA2yScBCbeBlOFwAE1uP+0VQq/vXR0t5sDHouDgEPUu2LpCTIXfN3DPe j9WMdS+yegJ4mcK8eSYtZQmSkJnzzUnirIGuapxXuT6/2koeQsXKBYUK0355DJCP79Is v6IT0W/qBzK1eH8lCh4eESbkPr+4CMaHiFvR85eId8uOksqkvFXMgnuh+pq0kUknhhmq ndsg== X-Gm-Message-State: AFuF++ne+V2NrGwM+GvAXkCbdTPxmD0K7pgG13/4VD7b9VkGm+9+OMwp nOlipIkoSmr/oTdT0f5YRKb9xkInWw+3ZAZpxlBCg3KQCL9Al7ad+W/YFvikY6tMrxYuBZDlPV4 8/FT3664i6aEYaT7LpUr7fP1o+x16qpvFZn2x2i3NbAraNXal+ORrIYPpbzf/XiqioH0SOlpxL2 v+A1XP0IfCE2578p9a/hEW1ZbxpuCzrSNj8FJLojbh X-Gm-Gg: AYBFou2sPPMeoVE/bn09SSrTK1LbxRg6kNLV+jfm0WSCXQ+f70MPVILDtrBoQp110+H 6Dv1UfVeEQzN93GT1sLrLqL5o/Mf7Z0r1MIR9kL2NqUJ0MZXoPKjtT35xE8tsMaotrXLZj/JKl0 YM83ihHra6HqePoT4UGpkFMVJlwdW484N/3X/rr0id25YLoMP0va3QOHjaDe3nXW7RWBe4QuPSZ wKxeJNvhenxCQ15FImCMp0F3dEyNmvymkRcEXKoDWc5LnQ4sm5lHlbJmBHMmr5XRiCU6sBqjMWT 9qOcxsVre8EsvwrHocX/Zb47Y8nzadCrzCGAYxFjQeRWiBB5H9dwb+fKZyopc7vloiC7jPOgx/t QK3ziDMjuylYrWAZvQfSuOGVkDIoOfeqrQVSMYqK/vRE7Iw+s9M2S82lWHQ8= X-Received: by 2002:ac8:5a45:0:b0:530:b2e4:91be with SMTP id d75a77b69052e-5327ef11951mr70130121cf.55.1789594583545; Wed, 16 Sep 2026 14:36:23 -0700 (PDT) X-Received: by 2002:ac8:5a45:0:b0:530:b2e4:91be with SMTP id d75a77b69052e-5327ef11951mr70129261cf.55.1789594582611; Wed, 16 Sep 2026 14:36:22 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH 6/7] migration: Fix incoming channel race with multifd and preempt_pre_7_2 Date: Wed, 16 Sep 2026 17:35:57 -0400 Message-ID: <20260916213558.587304-7-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916213558.587304-1-peterx@redhat.com> References: <20260916213558.587304-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1789594692007158500 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: - 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, 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 --- migration/channel.h | 3 + migration/migration.h | 35 ++++ migration/channel.c | 414 +++++++++++++++++++++++++++++++++++------ migration/migration.c | 23 ++- migration/trace-events | 7 +- 5 files changed, 421 insertions(+), 61 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..acb7ef5206 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,84 @@ 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 { + 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. + */ +static MigChannelType migration_channel_identify(MigrationIncomingState *m= is, + QIOChannel *ioc, Error **= errp) +{ + MigChannelType channel =3D CH_NONE; + + if (migration_has_main_and_multifd_channels()) { assert(migrate_postcopy_preempt()); channel =3D CH_POSTCOPY; + } else 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,31 +239,275 @@ static void migration_incoming_error_propagate(Migra= tionIncomingState *mis, } } =20 +/* Must be with mis->channels_early.mutex held */ +static void +migration_incoming_early_channel_insert(MigrationIncomingState *mis, + QIOChannel *ioc, + GSource *source) +{ + MigEarlyIncomingChannel chan =3D { + .source =3D source, + .ioc =3D ioc, + }; + + 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); + } +} + +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); + /* TODO: make this return the success status instead */ + migration_incoming_setup(ioc, ch, errp); + + return *errp =3D=3D NULL; +} + static bool migration_incoming_channel_install(MigrationIncomingState *mis, QIOChannel *ioc, Error **errp) { - MigChannelType ch =3D migration_channel_identify(mis, ioc, errp); + MigChannelType ch; + bool ret; + + if (qio_channel_is_peekable(ioc)) { + ch =3D migration_channel_peek(mis, ioc, errp); + } else { + ch =3D migration_channel_identify(mis, ioc, errp); + } =20 if (!ch) { - assert(*errp); return false; } =20 - trace_migration_set_incoming_channel(ioc, - object_get_typename(OBJECT(ioc)), - mig_channel_str[ch]); - migration_ioc_register_yank(ioc); + ret =3D migration_incoming_setup_channel(ioc, ch, errp); + if (!ret) { + return false; + } =20 - if (migration_incoming_setup(ioc, ch, errp)) { + /* Installation succeeded, kickoff migration if needed */ + if (migration_has_main_and_multifd_channels()) { migration_start_incoming(); } =20 - if (*errp) { - return false; + return true; +} + +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; } =20 - return true; + /* 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; + + /* + * 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: this will also release the ioc ref that we used to hold, but + * it's fine since we have at least one more refcount in the current + * event handler. + * + * NOTE3: 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; + } + + if (!migration_incoming_channel_install(mis, ioc, &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); } =20 /** @@ -254,13 +523,44 @@ void migration_channel_process_incoming(QIOChannel *i= oc) MigrationIncomingState *mis =3D migration_incoming_get_current(); Error *local_err =3D NULL; =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 { + /* + * Register an IO watch for peekable channels, so that channels + * can be accept()ed with any order. + * + * Non-peekable channels (file, TLS, etc.) cannot register IO + * watch, not only because there's no data to look at to help + * making the decision, but also because after registering we + * will lose the real ordering we get from accept(), which is + * still so far the only source of truth to identify a channel + * in such case. + */ + if (qio_channel_is_peekable(ioc)) { + migration_incoming_channel_watch(mis, ioc); + } else { + migration_incoming_channel_install(mis, ioc, &local_err); + } + } } =20 if (local_err) { @@ -270,7 +570,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 cfadcc79c2..4cc4077a76 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 */ + 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) { diff --git a/migration/trace-events b/migration/trace-events index 9ef42f54d1..c408deeb72 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 Sat Sep 26 20:50:46 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=1789594695; cv=none; d=zohomail.com; s=zohoarc; b=E7jX46liMcVy2PyDLx75MlTjiZ6z8gTjaFSS9+DbjhX5/79jRU/VwryuHnJY6zlfJPvXmyskdDuyG7cKGMvyXGZuy7z6xHtxxsXrGsfstqEDiYMGzlVRAaWmcrzM/L9pgAM3+ewuB2ykkbfp7qriboyawqXWI5E2XZWJwT+LmiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789594695; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QVF/WI5ZN7Ecy+zjQHuQdDRGoeotivOxx+UE2s9/b34=; b=a2gaJIZ/cZbWgcbaSd2KFEutMn3pdsAlw3yzzBgVl7rvatS3bB+LBmOQUhbh0wylDYSvyWD5c73FJGv3YjofsKuZbB+EXPA3p/yeSBI26niXOya17lYqWS1sC+NdeCwPbOu4OTMS5jq/Z+K73h05gBDRgDRVDdJyJF1/OEGYrVQ= 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 1789594695746384.6502538185424; Wed, 16 Sep 2026 14:38:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6xJN-0000mp-2z; Wed, 16 Sep 2026 17:37:01 -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 1x6xIr-0000jG-Rg for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:34 -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 1x6xIp-0007bt-CP for qemu-devel@nongnu.org; Wed, 16 Sep 2026 17:36:29 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-P8lR6wjTMbCVWlKoq9sNFQ-1; Wed, 16 Sep 2026 17:36:25 -0400 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-934963b2bc0so24535085a.3 for ; Wed, 16 Sep 2026 14:36:25 -0700 (PDT) Received: from localhost (bras-vprn-aurron9134w-lp130-03-174-91-117-74.dsl.bell.ca. [174.91.117.74]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-53261fd7e5bsm31559541cf.7.2026.09.16.14.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 14:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789594586; 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=QVF/WI5ZN7Ecy+zjQHuQdDRGoeotivOxx+UE2s9/b34=; b=fw9/hozGgCr3onIUMl7BNuv5yJIB2mDOASLdWNFAzdMZy5chS1UIK9wiOotKmxFbukvSLp qQy+3wk/i8cc+56uj8elGimUScQncBRg1JkFr6Qc+maXzO4f9oENSVRxACMg879fmfWbf9 OF7zLWj7C/blyJs5wgtTYS7zyqOb8m4= X-MC-Unique: P8lR6wjTMbCVWlKoq9sNFQ-1 X-Mimecast-MFC-AGG-ID: P8lR6wjTMbCVWlKoq9sNFQ_1789594585 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789594585; x=1790199385; 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=QVF/WI5ZN7Ecy+zjQHuQdDRGoeotivOxx+UE2s9/b34=; b=NHHlPzIUVrSTtrjmsReSOLRDsimPkzws2XIM46/4hg9D2jdFUsSvcFvzzbZY8jhqOI mvJsyUggvH28CborIwADETSmo0nAtXRFBzJHx7frLKhYC5ZL/jqBQxUHn5jAhSurfJvA 6eH409W6JFs7r73lDYrtewYDX0d2xYwnNa0oc4MEVvGYoaYBaHZBTbz7oLNXoqDUQDtl Vc5/riwrMW/M/tHnk7IpZXMYR0Kvd6QVjrCi8ggcfw1RKbfCwj8hRjnM8Sra21Q/ZByn PBy93l8H/gkZn+IjOl/LPNOe32Htrwkaa4RtvJDH3+NdViyvLxGChPc7FZPeErR1KliG TwJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789594585; x=1790199385; 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=QVF/WI5ZN7Ecy+zjQHuQdDRGoeotivOxx+UE2s9/b34=; b=Qbmph73gajKzM5Ia8/qFrT941x39fgnyLb5pce7qHg/koWs7INy2CYWNYQiE1xx0jw 9hpto0dxIeXRw0mD1dsaA4OHntY2A3RRmnqRTBZ878O8fS05arftPfMxQ5aGmalvOszF 0Z03EqiiWMQ0hQ6q5xIOedVo4KOFcXui91n27uMqxhpLJSYJsMHk7lcsWk7HJnNByiIa y8AzrSbgYuHjCadAArUm7LAAHnwAff6M2lMqbx/jWf4NvsdoHqRsPj69Vj/0PC6ffGQh IpX/J7axxYPM2cY4cx+lbngRHqm+GPilLR1QLwKNLU7Q8q8JiZWbbebjNI6O78Hi29yZ yoFw== X-Gm-Message-State: AFuF++mqTRRHAoe0rsAi9UO1i8ayaAeRupx3RO96ZBb6ZJLKo7KvGR5H lfUoYVJy2m29wiHZWlA1LRqPbM45SYs+qyZFAGkxhuAKVRX5C30yg0twGQ1bb8BHcIGclfGLHdU DibUoswvllwhmQLT6EKOImS713AuMssjeN93bsz0WWwWTbS2F79NIHPcPSHOnsf8RaJ28QCaoTy 8ua13fbHGyaNONP0gwmmzJmhBGzpkKBEWc5wjD7u4a X-Gm-Gg: AYBFou0chFd9gpKUekLl+WRxDyOqQn5WY1jJcMq3vIt25kEWnHJM+f0suZOCWFZDNZK kwc2eEgXlp4iWh9o1NPx3gN6R0JoeeBRAe3YK/G3IncvLgDX2rY5MKrOiPfwZKOK0ragXRxRdTI TNCohtNrSZSpYv+2Hxcyn+/53mV7beX/h5Xs8sCX/avzNN7/7F7MhgRZ4g5HPe2Lczigh4DDqwt X+HKR+Onwc7b3yNSMMovUoV8jiNd9JVjeVMoL4xquaBTX+AepZ8UvQ+Fz/kPlrRGdImMnwnWrTj 5y4a/Dtgu57RRn4igKxsxL/N7bRTE3x+Gox6S9TNMPVoHAIhps7obea0h82GR1GBg5tO4ie1vEH knh1vlTNiEYsQic12DcenCbgQIe1PWfK3pvYv7DWojtbaX3AgQqpraPprYsU= X-Received: by 2002:a05:622a:4d4a:b0:530:178a:9dc5 with SMTP id d75a77b69052e-5327ee3fd52mr101384161cf.19.1789594584903; Wed, 16 Sep 2026 14:36:24 -0700 (PDT) X-Received: by 2002:a05:622a:4d4a:b0:530:178a:9dc5 with SMTP id d75a77b69052e-5327ee3fd52mr101383311cf.19.1789594584332; Wed, 16 Sep 2026 14:36:24 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Akash Kulhalli , Juraj Marcin Subject: [PATCH 7/7] migration: Postpone the outgoing preempt channel for preempt_pre_7_2 Date: Wed, 16 Sep 2026 17:35:58 -0400 Message-ID: <20260916213558.587304-8-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916213558.587304-1-peterx@redhat.com> References: <20260916213558.587304-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1789594695990158500 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. Fixes: e27418861288 ("migration: enable multifd and postcopy together") Signed-off-by: Peter Xu --- migration/migration.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 4cc4077a76..f8d664808f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3733,6 +3733,20 @@ static void *migration_thread(void *opaque) goto out; } =20 + /* + * Only for old 7.1/7.2 machine types running on new binaries (that + * supports multifd+postcopy+preempt). Makes sure to initiate the + * connect() after multifd channels because the old (broken) binaries + * assumes the order of channels, which we cannot fix anymore. + * + * multifd_send_setup() will make sure all multifd channels will be + * connected first, then initiate preempt channel here guarantees the + * ordering to those old 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(); @@ -4013,16 +4027,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