{"id":2225495,"url":"http://patchwork.ozlabs.org/api/patches/2225495/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421052227.8278-1-prtyagi@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260421052227.8278-1-prtyagi@redhat.com>","list_archive_url":null,"date":"2026-04-21T05:22:27","name":"migration: Fix blocking in POSTCOPY_DEVICE during package load","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8f912c7f04e7f7c698f290c90fb1ee59fc1c5701","submitter":{"id":93199,"url":"http://patchwork.ozlabs.org/api/people/93199/?format=json","name":"Pranav Tyagi","email":"prtyagi@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421052227.8278-1-prtyagi@redhat.com/mbox/","series":[{"id":500732,"url":"http://patchwork.ozlabs.org/api/series/500732/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500732","date":"2026-04-21T05:22:27","name":"migration: Fix blocking in POSTCOPY_DEVICE during package load","version":1,"mbox":"http://patchwork.ozlabs.org/series/500732/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225495/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225495/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Gj1o1qO/;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=IXgiEvht;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g09ml4gkSz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 15:25:42 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wF3c0-0004yr-Oq; Tue, 21 Apr 2026 01:25:28 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <prtyagi@redhat.com>)\n id 1wF3bd-0004cY-OU\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 01:25:12 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <prtyagi@redhat.com>)\n id 1wF3bb-0001S6-Hh\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 01:25:05 -0400","from mail-pj1-f70.google.com (mail-pj1-f70.google.com\n [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-627-fcDwTH9uOWS-LuioV2wD1w-1; Tue, 21 Apr 2026 01:23:40 -0400","by mail-pj1-f70.google.com with SMTP id\n 98e67ed59e1d1-35842aa350fso7945979a91.0\n for <qemu-devel@nongnu.org>; Mon, 20 Apr 2026 22:23:39 -0700 (PDT)","from prtyagi-thinkpadt14sgen2i.bengluru.csb ([115.110.236.142])\n by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-36140fc593bsm15460364a91.1.2026.04.20.22.23.35\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 20 Apr 2026 22:23:37 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776749102;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding;\n bh=8KBW0A8lledewlQBJoGaV29wjsscUDIJq9deU9jVCUQ=;\n b=Gj1o1qO/KaPZ0ftx2BZLu1OHZAb4T9JNc4k8im26OoB319gt21swF88ebOFlkmdNLHMDNO\n 0t/2LWs406Z1TM8RXLwzzZdOZZJ1+RVTWZy6pTdf+/GL7sXMgGJfjRx6f45ZHXmNl8Nkoo\n m/CqltFGR2umkr0WYg/QPsx3grBwdbA=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1776749018; x=1777353818; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=8KBW0A8lledewlQBJoGaV29wjsscUDIJq9deU9jVCUQ=;\n b=IXgiEvhtGCJZFGCglH/YgX57OoHjkBlAD8E8161GyRc/WP+vNMi2gxj7ZSfmwW8g9P\n c4N7yCMYu5+mJwyKkXXvfBeBwIvW/+7jcsVCqgga1HdCzyElBho87uQBOUWPvjZCbC2z\n DOJexd8wytqkG0njqO1U6DbjOJRAqYz574FG9HPTgh9HC9aFeRoaGDiAEPKSnfHfrZje\n h4Zf8jRVVbLWIrBf5QVgcl5Zm9P+jdOwt4E/wq0+sN95KgYE4ClQYS4pwNmW+aVD0rDk\n kBWOsyOspS/A0fqh80jk+slpoWrN4do3qWfzO/gzQzsfyr6HfvosGUmYd9s/P3IK1TVE\n 3EdA=="],"X-MC-Unique":"fcDwTH9uOWS-LuioV2wD1w-1","X-Mimecast-MFC-AGG-ID":"fcDwTH9uOWS-LuioV2wD1w_1776749019","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776749018; x=1777353818;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=8KBW0A8lledewlQBJoGaV29wjsscUDIJq9deU9jVCUQ=;\n b=eUqYzwWDBQ2+0etJCR2SLMBgVaHOuhQMxVCUTjIfV9isa/EEjuMuKfR4D8MliqQjwd\n wZ3YGcyuc9IGMbHnILTN2el/MDeqHiMC6I3Iry9HOsJUjfTDqpxylpYVIj6RIbS2TlcP\n PCYE6s7P7armY6kdxOlBXovD9oPCLWlZR6Pf/bTLW7vgxllY07mmJMnIW2LiCDjw7jpt\n a1fHBW/l9oXCN52cnf7AXl3+ezQ3PAr6MrmivK0dWTUDuCblhpHR+Qf0pw1dPKsdVpQS\n pRty+z+TRmqyeyVW6Lb/sOVMAMgkVp/4eM4qmKyd2oIupxf6T5VsBsdr6PYKrsUXmFcJ\n Fqvw==","X-Gm-Message-State":"AOJu0Yw+FjCtzKOV5RKC4LjxFke4iM84kMV2VjmFIueGyaufvkoukbLv\n X1I/bGsHBuNs/LttkV5VGzdIOtmoUlFuO1Q0sVhgVJs1lruO+QPPA79g7bkg1Y5pQiKx2VqsLPa\n Um5cNKBp1Hl0fVfl5hGOOaqkhQoWMvs8E28rvohyLhhgMBcn+WN7sSEPMZ8kosZfps1p4U/Caes\n Ae1nhIR7Sk8jI72SbZGfqgjz4AuJW09Ri1rED4PJ0+Mw==","X-Gm-Gg":"AeBDieuwTpvK4KF7NmNpS0jE9XVCpXU/anSUSXBqeo2Ps6JUYO0+ovoZ9ZZyPJ2LBup\n NZWUS6OC3ihCvo3ZcmP3xLTUn/95ApGPF9LC45QXCdl9ZIvm8U9sqkbMtE7EcX0+6QSIILLbfsx\n gqFERb8iQcPdS3i3J4Jb8vzmoETJHQdrENFigb5ETyEkQONsfxjl43A+73OF0k6mflEF90yYqXq\n JXVtzjAq7okYLg8G0yuUaICi41BBoYKChvBn0BLRPprkHwVSltV/yKKG0wES4eQ+PIu/EqUuv3j\n Egsy2R95Rp23qLuPEBCV8a0S5ReQgk5bRkQZWatzCOvk23rbaf0Xo2sxmpJPdF85j/SqlX0nqn4\n lM8lt0iQdLUIOND29F1I5s9KHzbfm1QK/zfL1HX7KQaeHI3vQuvvX/2RE7tWJI9PgWNtY","X-Received":["by 2002:a17:90b:3504:b0:35f:b6a1:8d27 with SMTP id\n 98e67ed59e1d1-3614046f76amr18163109a91.18.1776749018423;\n Mon, 20 Apr 2026 22:23:38 -0700 (PDT)","by 2002:a17:90b:3504:b0:35f:b6a1:8d27 with SMTP id\n 98e67ed59e1d1-3614046f76amr18163080a91.18.1776749017851;\n Mon, 20 Apr 2026 22:23:37 -0700 (PDT)"],"From":"Pranav Tyagi <prtyagi@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,\n Juraj Marcin <jmarcin@redhat.com>, Prasad Pandit <ppandit@redhat.com>,\n Pranav Tyagi <prtyagi@redhat.com>","Subject":"[PATCH] migration: Fix blocking in POSTCOPY_DEVICE during package\n load","Date":"Tue, 21 Apr 2026 10:52:27 +0530","Message-ID":"<20260421052227.8278-1-prtyagi@redhat.com>","X-Mailer":"git-send-email 2.53.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=prtyagi@redhat.com;\n 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,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"The package_loaded event is not set in case MIG_RP_MSG_PONG does not\narrive on the source from the destination in the return path thread. The\nmigration thread would then be blocked waiting for package_loaded event\nindefinitely in POSTCOPY_DEVICE state. Where as, in such a condition the\nsource VM can safely resume as the destination has not yet started. The\npong message can get lost in case of a network failure or destination\ncrash before sending the pong.\n\nThis patch uses the error detected in case of network failure or\ndestination crash to set the package_loaded event in the out path of the\nreturn path thread. This will kick the migration thread out from\na condition of indefinitely waiting for the package_loaded event. The\nmigration thread then fails early and breaks from the migration loop to\nresume the VM on the source side.\n\nFixes: 7b842fe354c6 (\"migration: Introduce POSTCOPY_DEVICE state\")\nSigned-off-by: Pranav Tyagi <prtyagi@redhat.com>\n---\n migration/migration.c | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)","diff":"diff --git a/migration/migration.c b/migration/migration.c\nindex 5c9aaa6e58..1656c1203c 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -2386,6 +2386,15 @@ out:\n     if (err) {\n         migrate_error_propagate(ms, err);\n         trace_source_return_path_thread_bad_end();\n+        if (ms->state == MIGRATION_STATUS_POSTCOPY_DEVICE) {\n+            /*\n+             * Kick the migration thread if it gets stuck in\n+             * POSTCOPY_DEVICE state waiting for\n+             * postcopy_package_loaded_event. The event will never be\n+             * set as MIG_RP_MSG_PONG from the destination is lost.\n+             */\n+            qemu_event_set(&ms->postcopy_package_loaded_event);\n+        }\n     }\n \n     if (ms->state == MIGRATION_STATUS_POSTCOPY_RECOVER) {\n@@ -3232,6 +3241,17 @@ static MigIterateState migration_iteration_run(MigrationState *s)\n              * package before actually completing.\n              */\n             qemu_event_wait(&s->postcopy_package_loaded_event);\n+            /*\n+             * Check for errors in case the migration thread was stuck in\n+             * POSTCOPY_DEVICE state waiting for the\n+             * postcopy_package_loaded_event which was never set.\n+             * If so, fail now and break out of the iteration.\n+             */\n+            if (migrate_has_error(s)) {\n+                migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_DEVICE,\n+                                  MIGRATION_STATUS_FAILING);\n+                return MIG_ITERATE_BREAK;\n+            }\n             migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_DEVICE,\n                               MIGRATION_STATUS_POSTCOPY_ACTIVE);\n         }\n","prefixes":[]}