From patchwork Mon Jun 17 18:15:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NGCQpu00; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ylL6qYcz20Wb for ; Tue, 18 Jun 2024 04:17:02 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGte-0000FJ-5z; Mon, 17 Jun 2024 14:16:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtO-0000Bs-01 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:53 -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 1sJGtL-0006Hw-L8 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648141; 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=wzpRVcMoHJuiYGTTUkqQjk7ezIIqhok8HbPaC8esF3E=; b=NGCQpu00Ea7Y9k9G9tG8OiV7l9vORl3tKUNlmj5fk5HQUQWr4KIxEiGWUgQGnsdYDyCKQU tYCeHjFyjlYKSo0pCFpuUnf7IT0VTy8yRmOWE5zdPHdtnZ+8HHZ2e/A4bhpTIDmgUIRnIM VMIGZE180VNJvBhEISQMPtB4ofnhr0o= 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-196-uvCyQBXeN2aQwzhJ_YhMfw-1; Mon, 17 Jun 2024 14:15:39 -0400 X-MC-Unique: uvCyQBXeN2aQwzhJ_YhMfw-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-440aedca77cso14293911cf.1 for ; Mon, 17 Jun 2024 11:15:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648139; x=1719252939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wzpRVcMoHJuiYGTTUkqQjk7ezIIqhok8HbPaC8esF3E=; b=B3zL8coh+JQDmIbDRLHL7BeV525DcPXu1KScqUozm0IganzvU4hZKmbOH5bwg91F7m eDFF4oRa0t9Owzh+qGD6Wf3owLhlg05Epo+ZA7KTwS2IPaEZ0Dm2BL65p5eUw16jTotH jp5R4iT524Fhh6SXmNA0hM7EUt8MrqB6b3ykuaGDSXVdn98uLqdlo9MGhYDSF3HwhD1V Rxi1vimOo763OlMs8u+N3taIl++efrb1IQrrta+RnszPXMSEb57MY7kump+ZoPuaiRiU ZhHTa1EAROiOvCnW1AXaGSQ2qEPHY4CsEuHHUr5YPu5pVDPaY2qskKYvsApoKSuw1Gry D1cA== X-Gm-Message-State: AOJu0Yy0lgTiv6YG1L67/CwICTqO3Mq9B/h2mhdaBbbEUzF/6Vyu0iUG yvr6T2hjo1jAvGg4DQOE1xiWk+HS798s+fV+pm59BP2YpzRPpvqHLDQnQ4VuytGuVMyBZC7kIF9 IFKWq0up0ONseXZcGSCL6UKy8H6exzbKhm7qUL0W/Xi8hnWA0hYxaABmhYxZSp+6OVRaGRucNjE puvgYpQb5KtuqFqJ94pVWDD0h4JG88owRezg== X-Received: by 2002:a05:620a:4143:b0:79b:a816:94a4 with SMTP id af79cd13be357-79ba81696efmr13774285a.7.1718648138858; Mon, 17 Jun 2024 11:15:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7sBaRIfIps3Np7Rt/g9UGAi6zcND7K/RdpvZpNNRHjHyaIHqOuiaaIJbnGuMweoxcZVHZ+Q== X-Received: by 2002:a05:620a:4143:b0:79b:a816:94a4 with SMTP id af79cd13be357-79ba81696efmr13769785a.7.1718648138169; Mon, 17 Jun 2024 11:15:38 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:37 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 01/10] migration/multifd: Avoid the final FLUSH in complete() Date: Mon, 17 Jun 2024 14:15:25 -0400 Message-ID: <20240617181534.1425179-2-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We always do the flush when finishing one round of scan, and during complete() phase we should scan one more round making sure no dirty page existed. In that case we shouldn't need one explicit FLUSH at the end of complete(), as when reaching there all pages should have been flushed. Reviewed-by: Fabiano Rosas Tested-by: Fabiano Rosas Signed-off-by: Peter Xu --- migration/ram.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ceea586b06..edec1a2d07 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3300,10 +3300,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque) } } - if (migrate_multifd() && !migrate_multifd_flush_after_each_section() && - !migrate_mapped_ram()) { - qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); - } qemu_put_be64(f, RAM_SAVE_FLAG_EOS); return qemu_fflush(f); } From patchwork Mon Jun 17 18:15:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AI8Z4Ena; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ylh3J2Cz20Wb for ; Tue, 18 Jun 2024 04:17:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGte-0000EQ-24; Mon, 17 Jun 2024 14:16:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtV-0000CY-O0 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtN-0006I4-OU for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648143; 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=MuGX7ZrplnQVNu3mzfk0/QaBka3Pq8F7w1QCH59y4VI=; b=AI8Z4EnaHPdRwYeBGI1jYAAQ+dnca4vwwTYmCIJoB8Kp5zTV9KgoyT/iBt2ZJ5+PgNgcDa VSeAJj03tYQJwqaKwmYGO090mCubsXfcjJnH6WHO8Ei8n2fQ9l3AcPrvKziOqV3X67HPxc UW9guJYQC+Cg0afN7YqUxdWqlIy9yhM= 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-345-fwspiEccOWG0hgcxik13Ug-1; Mon, 17 Jun 2024 14:15:41 -0400 X-MC-Unique: fwspiEccOWG0hgcxik13Ug-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6ad803bc570so9577796d6.1 for ; Mon, 17 Jun 2024 11:15:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648141; x=1719252941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MuGX7ZrplnQVNu3mzfk0/QaBka3Pq8F7w1QCH59y4VI=; b=cuvBCk5dBPO70EsSyLCHrf1CVD9/3tfuG4qg6H3z3SAb/TqGqQthd8fuqcb/tKXvfg iLWaOFZzP6l9WwNy4ILL2R2kj9DTS1FPM4QmMVaT8oCqDftnLPI11Y72x/9KVBVnf9FS FpIUE9XCFoK773qKJYbkiV/Cv4/RTAftT2UVITCffX9NVGKXBy3raI46rNRKpsNWV36o yEA/qHI7V8PBJ7NuTlLIXNwcni422YPimZ1Bz52rp0HU39GWrudsyNuwwuQYc/KTfNYF UKfXXsVCKFLGmlThnohTd9hl/WX5yzLXmDfkgwFU4LWm6jbaySYQ0ZVeptoqbLHOZyCZ Djcw== X-Gm-Message-State: AOJu0Yzv0QvMjKw2xj8+1odYBoo2HFbSxRcxcUjtEDx9sUMggnSkg5p+ B/vkzdq+FO5Lak2S/wV/ori4zEhzcqkWOT9wtn841b/eROHSrtOD3E+yv6U30zMWQwSwX8N7cSO 46XXjEXN+/AcX/0knZ7eJAAJ61IrSIzwUnIGrEvGyunOmM0AFaeKQxpvrwvRYcoIhq5FwhGV9bY pghBfCAQKaEieHMXLtHFISa7JgUGR11RVMNw== X-Received: by 2002:a05:620a:319f:b0:79a:26e5:de5f with SMTP id af79cd13be357-79a26e5e0demr955282885a.7.1718648140423; Mon, 17 Jun 2024 11:15:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx5ufs4Nr42yGtP/qOs6txcgNJcFhJXLfuzHSr/3uouBhC7pgvgXsnNo0SIOOwAlqrtbN3sg== X-Received: by 2002:a05:620a:319f:b0:79a:26e5:de5f with SMTP id af79cd13be357-79a26e5e0demr955278785a.7.1718648139532; Mon, 17 Jun 2024 11:15:39 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:39 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 02/10] migration: Rename thread debug names Date: Mon, 17 Jun 2024 14:15:26 -0400 Message-ID: <20240617181534.1425179-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The postcopy thread names on dest QEMU are slightly confusing, partly I'll need to blame myself on 36f62f11e4 ("migration: Postcopy preemption preparation on channel creation"). E.g., "fault-fast" reads like a fast version of "fault-default", but it's actually the fast version of "postcopy/listen". Taking this chance, rename all the migration threads with proper rules. Considering we only have 15 chars usable, prefix all threads with "mig/", meanwhile identify src/dst threads properly this time. So now most thread names will look like "mig/DIR/xxx", where DIR will be "src"/"dst", except the bg-snapshot thread which doesn't have a direction. For multifd threads, making them "mig/{src|dst}/{send|recv}_%d". We used to have "live_migration" thread for a very long time, now it's called "mig/src/main". We may hope to have "mig/dst/main" soon but not yet. Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu --- migration/colo.c | 2 +- migration/migration.c | 6 +++--- migration/multifd.c | 6 +++--- migration/postcopy-ram.c | 4 ++-- migration/savevm.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index f96c2ee069..6449490221 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -935,7 +935,7 @@ void coroutine_fn colo_incoming_co(void) assert(bql_locked()); assert(migration_incoming_colo_enabled()); - qemu_thread_create(&th, "COLO incoming", colo_process_incoming_thread, + qemu_thread_create(&th, "mig/dst/colo", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); mis->colo_incoming_co = qemu_coroutine_self(); diff --git a/migration/migration.c b/migration/migration.c index e1b269624c..d41e00ed4c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2408,7 +2408,7 @@ static int open_return_path_on_source(MigrationState *ms) trace_open_return_path_on_source(); - qemu_thread_create(&ms->rp_state.rp_thread, "return path", + qemu_thread_create(&ms->rp_state.rp_thread, "mig/src/rp-thr", source_return_path_thread, ms, QEMU_THREAD_JOINABLE); ms->rp_state.rp_thread_created = true; @@ -3747,10 +3747,10 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) } if (migrate_background_snapshot()) { - qemu_thread_create(&s->thread, "bg_snapshot", + qemu_thread_create(&s->thread, "mig/snapshot", bg_migration_thread, s, QEMU_THREAD_JOINABLE); } else { - qemu_thread_create(&s->thread, "live_migration", + qemu_thread_create(&s->thread, "mig/src/main", migration_thread, s, QEMU_THREAD_JOINABLE); } s->migration_thread_running = true; diff --git a/migration/multifd.c b/migration/multifd.c index f317bff077..7afc0965f6 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1059,7 +1059,7 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p, args->p = p; p->tls_thread_created = true; - qemu_thread_create(&p->tls_thread, "multifd-tls-handshake-worker", + qemu_thread_create(&p->tls_thread, "mig/src/tls", multifd_tls_handshake_thread, args, QEMU_THREAD_JOINABLE); return true; @@ -1185,7 +1185,7 @@ bool multifd_send_setup(void) } else { p->iov = g_new0(struct iovec, page_count); } - p->name = g_strdup_printf("multifdsend_%d", i); + p->name = g_strdup_printf("mig/src/send_%d", i); p->page_size = qemu_target_page_size(); p->page_count = page_count; p->write_flags = 0; @@ -1601,7 +1601,7 @@ int multifd_recv_setup(Error **errp) + sizeof(uint64_t) * page_count; p->packet = g_malloc0(p->packet_len); } - p->name = g_strdup_printf("multifdrecv_%d", i); + p->name = g_strdup_printf("mig/dst/recv_%d", i); p->iov = g_new0(struct iovec, page_count); p->normal = g_new0(ram_addr_t, page_count); p->zero = g_new0(ram_addr_t, page_count); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 3419779548..97701e6bb2 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1238,7 +1238,7 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *mis) return -1; } - postcopy_thread_create(mis, &mis->fault_thread, "fault-default", + postcopy_thread_create(mis, &mis->fault_thread, "mig/dst/fault", postcopy_ram_fault_thread, QEMU_THREAD_JOINABLE); mis->have_fault_thread = true; @@ -1258,7 +1258,7 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *mis) * This thread needs to be created after the temp pages because * it'll fetch RAM_CHANNEL_POSTCOPY PostcopyTmpPage immediately. */ - postcopy_thread_create(mis, &mis->postcopy_prio_thread, "fault-fast", + postcopy_thread_create(mis, &mis->postcopy_prio_thread, "mig/dst/preempt", postcopy_preempt_thread, QEMU_THREAD_JOINABLE); mis->preempt_thread_status = PREEMPT_THREAD_CREATED; } diff --git a/migration/savevm.c b/migration/savevm.c index c621f2359b..e71410d8c1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2129,7 +2129,7 @@ static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis) } mis->have_listen_thread = true; - postcopy_thread_create(mis, &mis->listen_thread, "postcopy/listen", + postcopy_thread_create(mis, &mis->listen_thread, "mig/dst/listen", postcopy_ram_listen_thread, QEMU_THREAD_DETACHED); trace_loadvm_postcopy_handle_listen("return"); From patchwork Mon Jun 17 18:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948759 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Zc9o2eXn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ymD6MSxz20XJ for ; Tue, 18 Jun 2024 04:17:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGti-0000Lf-Mn; Mon, 17 Jun 2024 14:16:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtZ-0000Dh-Nz for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:00 -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 1sJGtU-0006IL-8B for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648146; 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=0eSeZdzvmXBPLNKlFcOUj7uncDEIhp9AnL4Vfx5wSsI=; b=Zc9o2eXnjNIg1mE1X/waTQwGh/e1LC+rKyuXPRH2V3v+WjlNjdVdSL/lzQiDqdWoNz9Ljb UG7U6ZBAo8tQQp4iUpDbobzkyXe3sehKthzfval3huZZm9gdin6SCD8vf3sKGE/a0bcDFY AF1tuQ+nA/pEfBReqsHIrzWMVk4ylko= 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-151-3mhaTe4HORWp5ZwymuSo3Q-1; Mon, 17 Jun 2024 14:15:43 -0400 X-MC-Unique: 3mhaTe4HORWp5ZwymuSo3Q-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6ad803bc570so9577866d6.1 for ; Mon, 17 Jun 2024 11:15:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648142; x=1719252942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0eSeZdzvmXBPLNKlFcOUj7uncDEIhp9AnL4Vfx5wSsI=; b=OXFFhyBB63N12hR9VTxwAbqp0Oqn0dw87RFNtAMQlkGdhea3s8UASTF3mbJJTyG9pp NwT1GovUn+mVKWmdTAnyLgSyyJYRJKsTZcCrYXVQhZ7zllMyq6cjIGV7ZYyWaw71nbmN rKWdRKM1KcB74o4yaOfVio1yal9qo4+3e/t8fPkiCio3N+gLBkvFWka2A+xg/6j2cUPK ksBCjBQMPsCVJGJD/LZX6RikfYOTO8M2BMrG03qNG5YL7I30vcTfV4JotIeZDtRv7ONZ tNr1htTj0niFNvFlgaEddT8F8IhUevEpbsMSFWITStdPBYGpkSXT4QOa+shgCM+/ObJZ vd8A== X-Gm-Message-State: AOJu0YxygzSAKvpYgeVXap54DEbEp0l7ur140jXTkfutS9JXEvPxpjHJ YF+6s/HxwlVV3qOtdrBG3qLZOPfDSFCTGn27zJr4mzJxOPzoTgWOBEVpxO6OPVn6DR/iCgxGS+D mMRCODvfwuEC5XDUWr6zbLS//TD/lGQPvBGRDRn8qS1pZhdxshcWwR8gvIa//Yt9YVM3WPybjeL /9rxMVoYB+Xgqbs2U4k7ZaZKQ0TycQKFnWCA== X-Received: by 2002:a05:620a:272a:b0:795:493f:9f3f with SMTP id af79cd13be357-798d269f370mr1142477085a.4.1718648141653; Mon, 17 Jun 2024 11:15:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmeSvVhxVlCoYoaL+At8yVRF9RRUHweNYGruOY/1Ah8LXb/0UzMzB4ZhJg/nYD6fz8JpD5AA== X-Received: by 2002:a05:620a:272a:b0:795:493f:9f3f with SMTP id af79cd13be357-798d269f370mr1142472885a.4.1718648140994; Mon, 17 Jun 2024 11:15:40 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:40 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 03/10] migration: Use MigrationStatus instead of int Date: Mon, 17 Jun 2024 14:15:27 -0400 Message-ID: <20240617181534.1425179-4-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org QEMU uses "int" in most cases even if it stores MigrationStatus. I don't know why, so let's try to do that right and see what blows up.. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/migration.h | 9 +++++---- migration/migration.c | 24 +++++++----------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 6af01362d4..38aa1402d5 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -160,7 +160,7 @@ struct MigrationIncomingState { /* PostCopyFD's for external userfaultfds & handlers of shared memory */ GArray *postcopy_remote_fds; - int state; + MigrationStatus state; /* * The incoming migration coroutine, non-NULL during qemu_loadvm_state(). @@ -301,7 +301,7 @@ struct MigrationState { /* params from 'migrate-set-parameters' */ MigrationParameters parameters; - int state; + MigrationStatus state; /* State related to return path */ struct { @@ -459,7 +459,8 @@ struct MigrationState { bool rdma_migration; }; -void migrate_set_state(int *state, int old_state, int new_state); +void migrate_set_state(MigrationStatus *state, MigrationStatus old_state, + MigrationStatus new_state); void migration_fd_process_incoming(QEMUFile *f); void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp); @@ -479,7 +480,7 @@ int migrate_init(MigrationState *s, Error **errp); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); -bool migration_postcopy_is_alive(int state); +bool migration_postcopy_is_alive(MigrationStatus state); MigrationState *migrate_get_current(void); bool migration_has_failed(MigrationState *); bool migrate_mode_is_cpr(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index d41e00ed4c..75c9d80e8e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -390,7 +390,7 @@ void migration_incoming_state_destroy(void) yank_unregister_instance(MIGRATION_YANK_INSTANCE); } -static void migrate_generate_event(int new_state) +static void migrate_generate_event(MigrationStatus new_state) { if (migrate_events()) { qapi_event_send_migration(new_state); @@ -1273,8 +1273,6 @@ static void fill_destination_migration_info(MigrationInfo *info) } switch (mis->state) { - case MIGRATION_STATUS_NONE: - return; case MIGRATION_STATUS_SETUP: case MIGRATION_STATUS_CANCELLING: case MIGRATION_STATUS_CANCELLED: @@ -1290,6 +1288,8 @@ static void fill_destination_migration_info(MigrationInfo *info) info->has_status = true; fill_destination_postcopy_migration_info(info); break; + default: + return; } info->status = mis->state; @@ -1337,7 +1337,8 @@ void qmp_migrate_start_postcopy(Error **errp) /* shared migration helpers */ -void migrate_set_state(int *state, int old_state, int new_state) +void migrate_set_state(MigrationStatus *state, MigrationStatus old_state, + MigrationStatus new_state) { assert(new_state < MIGRATION_STATUS__MAX); if (qatomic_cmpxchg(state, old_state, new_state) == old_state) { @@ -1544,7 +1545,7 @@ bool migration_in_postcopy(void) } } -bool migration_postcopy_is_alive(int state) +bool migration_postcopy_is_alive(MigrationStatus state) { switch (state) { case MIGRATION_STATUS_POSTCOPY_ACTIVE: @@ -1589,20 +1590,9 @@ bool migration_is_idle(void) case MIGRATION_STATUS_COMPLETED: case MIGRATION_STATUS_FAILED: return true; - case MIGRATION_STATUS_SETUP: - case MIGRATION_STATUS_CANCELLING: - case MIGRATION_STATUS_ACTIVE: - case MIGRATION_STATUS_POSTCOPY_ACTIVE: - case MIGRATION_STATUS_COLO: - case MIGRATION_STATUS_PRE_SWITCHOVER: - case MIGRATION_STATUS_DEVICE: - case MIGRATION_STATUS_WAIT_UNPLUG: + default: return false; - case MIGRATION_STATUS__MAX: - g_assert_not_reached(); } - - return false; } bool migration_is_active(void) From patchwork Mon Jun 17 18:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948762 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=D48H8++V; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ymZ6brXz20XJ for ; Tue, 18 Jun 2024 04:18:06 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGtm-0000QM-7a; Mon, 17 Jun 2024 14:16:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtZ-0000Dk-Mt for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:00 -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 1sJGtV-0006IQ-F2 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648149; 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=p42qzqR5kciw8JLdqJ1YJNv4+ai0V2jb43gqFLRGij4=; b=D48H8++VplGVlteZvH3M+ijbJEc7XPgGZcw7EuI/aRfZV571H6MWdppY7Lh7X52GWJwLDm lxXeIL54EZWBlyyKiBAe94Reya3NfVx/wNY7K58be5k8fxivSnDOeVRUgTuYeWIoAloSKV 4kDDllkmJUYz40oNxXML4k5VHsyLrS0= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-arLO_fd-Pm-z-W4mYy-scQ-1; Mon, 17 Jun 2024 14:15:46 -0400 X-MC-Unique: arLO_fd-Pm-z-W4mYy-scQ-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6b29f2d8cf3so11752816d6.3 for ; Mon, 17 Jun 2024 11:15:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648145; x=1719252945; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p42qzqR5kciw8JLdqJ1YJNv4+ai0V2jb43gqFLRGij4=; b=ddOf4ffHs3GOyP3sIzG9sCGmWwWTUfSl7Xfwr3GfsEQrvJzLQndF3mVXSNcjzTL3+3 wVF5JG+IyV3b98nOpxBOWEA4W/YXWvFWRfMQs4bT9KdQMciUBOxeQCvKoDe3ES34yG5U 2o0Wh8ocWxHVKz5XElKc9ZpNzlll/V432DUJlgDBq0Rf4FrhbIrlkgcdRB5qvw81eg/6 y5ICx4SLQWchy+v5OrSbiJmfoIOlj4STaRk4sRwAYbhMYcWZ+k5/Cr+3xx0LOcCfoXse MAD2rFGL+awCdfwSRFCbz/4i3bOPcxfDojO4jd0jmuNo6Y9XE+kN+x4EOGVdYZunyS9c cV/Q== X-Gm-Message-State: AOJu0YwNFq7p2lGTwysKeaF4Eqi+KWnk5KgVwCY+gWaTa7YXVX+oVtMK H2oE84AnT++GwFnltDzb8+bQEM+ffVlOLZwVyHa3QuElcAndbKCLCO/nT8XdFX++soTMry1A2Y/ qfZG7EFUfgTk5EC3DFG2v2lopIycPQVKn6Ff7Ma+2PQjyM3g6v3LF40/VIVY9+hhypKGsr54Fmv l46D6RgldsFxSV4dZefyFKeyuL/i2JDInPCw== X-Received: by 2002:a05:620a:2b85:b0:798:cf0f:b523 with SMTP id af79cd13be357-798d23c4660mr1304576085a.2.1718648144890; Mon, 17 Jun 2024 11:15:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYn2ssArX0+Ktm0J1BKUoHy0VUXD62Zc3f3EcClrd9yoX/KpzHPw+oip+dGMS/s1RDQiPwaA== X-Received: by 2002:a05:620a:2b85:b0:798:cf0f:b523 with SMTP id af79cd13be357-798d23c4660mr1304572285a.2.1718648144270; Mon, 17 Jun 2024 11:15:44 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:41 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 04/10] migration: Cleanup incoming migration setup state change Date: Mon, 17 Jun 2024 14:15:28 -0400 Message-ID: <20240617181534.1425179-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Destination QEMU can setup incoming ports for two purposes: either a fresh new incoming migration, in which QEMU will switch to SETUP for channel establishment, or a paused postcopy migration, in which QEMU will stay in POSTCOPY_PAUSED until kicking off the RECOVER phase. Now the state machine worked on dest node for the latter, only because migrate_set_state() implicitly will become a noop if the current state check failed. It wasn't clear at all. Clean it up by providing a helper migration_incoming_state_setup() doing proper checks over current status. Postcopy-paused will be explicitly checked now, and then we can bail out for unknown states. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/migration.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 75c9d80e8e..59442181a1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -595,6 +595,29 @@ bool migrate_uri_parse(const char *uri, MigrationChannel **channel, return true; } +static bool +migration_incoming_state_setup(MigrationIncomingState *mis, Error **errp) +{ + MigrationStatus current = mis->state; + + if (current == MIGRATION_STATUS_POSTCOPY_PAUSED) { + /* + * Incoming postcopy migration will stay in PAUSED state even if + * reconnection happened. + */ + return true; + } + + if (current != MIGRATION_STATUS_NONE) { + error_setg(errp, "Illegal migration incoming state: %s", + MigrationStatus_str(current)); + return false; + } + + migrate_set_state(&mis->state, current, MIGRATION_STATUS_SETUP); + return true; +} + static void qemu_start_incoming_migration(const char *uri, bool has_channels, MigrationChannelList *channels, Error **errp) @@ -633,8 +656,9 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels, return; } - migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, - MIGRATION_STATUS_SETUP); + if (!migration_incoming_state_setup(mis, errp)) { + return; + } if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) { SocketAddress *saddr = &addr->u.socket; From patchwork Mon Jun 17 18:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948764 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MtmMX2JW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ymv3wk5z20Wb for ; Tue, 18 Jun 2024 04:18:23 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGtm-0000QN-9l; Mon, 17 Jun 2024 14:16:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtZ-0000Dj-Mi for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:00 -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 1sJGtU-0006IV-VQ for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648149; 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=PkUOOpD2kGnivnbVwfazf6T09Z5OI7fBuuuqqPaD6cU=; b=MtmMX2JWubsULut9Jih+8Yi//10XtUNiHT4EGIfZanKpJqZrM1Ymp8nRpIcIVYJZgX+E9q JhPeJ4tQSPAsgZO5AvVxg5Sclzj7juBq2hbEgD9GKJNvbX4xRe7GL8oLOWEQYOXkpyD23M KrbWSVLfaPYhI+vuNVwRPci6ySmKo8I= Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-W0B2RQT4MymRBcArLkk1wA-1; Mon, 17 Jun 2024 14:15:48 -0400 X-MC-Unique: W0B2RQT4MymRBcArLkk1wA-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-254bf518d59so735098fac.1 for ; Mon, 17 Jun 2024 11:15:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648147; x=1719252947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PkUOOpD2kGnivnbVwfazf6T09Z5OI7fBuuuqqPaD6cU=; b=B7/Ob0afew+mCS5MAWu52dIoFtR0FQdzlP4rEeZ0jwRwv4xvd2FfEOiI14UF+oQGLy IP2vC5NZuUkiEZVA5A4PA5NEJUGNtB7zGQIAq2k1jskBj7PEfCUkN5f3RcTVtPiv2cxD /IUCk9pEuXCnX6m86XgZPzBguJZDQH/9sQH3jEzh8KeTDLBCX4fYt9SGqRPmhz56JjK0 oAOZ6GWmI9vCUfiajJfi+5ASXiEKMLtbiRvtPttMSCcCBl1ZSSOv41hHJRcms0Y93ijO 805woqlZ54BEH2pW1H7CFKQlP4AyOofUPJbSBHn6Jw/o5RnlfAPQBrGfqq0Mif6mlA3L mvEw== X-Gm-Message-State: AOJu0YwQbJudU1pcZe7FIYEWVsgx50nOdrPJyWA6yN0PB6BkdJr+aLNT DW+tyb5c81Yx2j/yxLAnJmf6RP3PZbbBWK/zy+AdetAeCS66fcpSEm4Cr0AJqfJJgqLVWkzLR90 /xsLc1UfaS808whKF2Sg5kmoewoJ4xStS2L6wBRhLg6dN0OlBOPtTIk5kLFBB5lgq6AjS022WCG v6joxIGCYbSzFPwP4tYg4wmpnvc5B8LqXnvA== X-Received: by 2002:a05:6808:3090:b0:3d2:2293:996e with SMTP id 5614622812f47-3d24e6e93fdmr11294379b6e.0.1718648146943; Mon, 17 Jun 2024 11:15:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/pcqVavCnrpB7VjFLnfXGN8oMw9LqOFWdTI2LV4Cw7AEYnKV9Zi/SMUTT1M0pHr+bv9JlZw== X-Received: by 2002:a05:6808:3090:b0:3d2:2293:996e with SMTP id 5614622812f47-3d24e6e93fdmr11294336b6e.0.1718648146200; Mon, 17 Jun 2024 11:15:46 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:45 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 05/10] migration/postcopy: Add postcopy-recover-setup phase Date: Mon, 17 Jun 2024 14:15:29 -0400 Message-ID: <20240617181534.1425179-6-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds a migration state on src called "postcopy-recover-setup". The new state will describe the intermediate step starting from when the src QEMU received a postcopy recovery request, until the migration channels are properly established, but before the recovery process take place. The request came from Libvirt where Libvirt currently rely on the migration state events to detect migration state changes. That works for most of the migration process but except postcopy recovery failures at the beginning. Currently postcopy recovery only has two major states: - postcopy-paused: this is the state that both sides of QEMU will be in for a long time as long as the migration channel was interrupted. - postcopy-recover: this is the state where both sides of QEMU handshake with each other, preparing for a continuation of postcopy which used to be interrupted. The issue here is when the recovery port is invalid, the src QEMU will take the URI/channels, noticing the ports are not valid, and it'll silently keep in the postcopy-paused state, with no event sent to Libvirt. In this case, the only thing Libvirt can do is to poll the migration status with a proper interval, however that's less optimal. Considering that this is the only case where Libvirt won't get a notification from QEMU on such events, let's add postcopy-recover-setup state to mimic what we have with the "setup" state of a newly initialized migration, describing the phase of connection establishment. With that, postcopy recovery will have two paths to go now, and either path will guarantee an event generated. Now the events will look like this during a recovery process on src QEMU: - Initially when the recovery is initiated on src, QEMU will go from "postcopy-paused" -> "postcopy-recover-setup". Old QEMUs don't have this event. - Depending on whether the channel re-establishment is succeeded: - In succeeded case, src QEMU will move from "postcopy-recover-setup" to "postcopy-recover". Old QEMUs also have this event. - In failure case, src QEMU will move from "postcopy-recover-setup" to "postcopy-paused" again. Old QEMUs don't have this event. This guarantees that Libvirt will always receive a notification for recovery process properly. One thing to mention is, such new status is only needed on src QEMU not both. On dest QEMU, the state machine doesn't change. Hence the events don't change either. It's done like so because dest QEMU may not have an explicit point of setup start. E.g., it can happen that when dest QEMUs doesn't use migrate-recover command to use a new URI/channel, but the old URI/channels can be reused in recovery, in which case the old ports simply can work again after the network routes are fixed up. Add a new helper postcopy_is_paused() detecting whether postcopy is still paused, taking RECOVER_SETUP into account too. When using it on both src/dst, a slight change is done altogether to always wait for the semaphore before checking the status, because for both sides a sem_post() will be required for a recovery. Cc: Jiri Denemark Cc: Fabiano Rosas Cc: Prasad Pandit Buglink: https://issues.redhat.com/browse/RHEL-38485 Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- qapi/migration.json | 4 ++++ migration/postcopy-ram.h | 3 +++ migration/migration.c | 40 ++++++++++++++++++++++++++++++++++------ migration/postcopy-ram.c | 6 ++++++ migration/savevm.c | 4 ++-- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index a351fd3714..565c40b637 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -142,6 +142,9 @@ # # @postcopy-paused: during postcopy but paused. (since 3.0) # +# @postcopy-recover-setup: setup phase for a postcopy recovery process, +# preparing for a recovery phase to start. (since 9.1) +# # @postcopy-recover: trying to recover from a paused postcopy. (since # 3.0) # @@ -166,6 +169,7 @@ { 'enum': 'MigrationStatus', 'data': [ 'none', 'setup', 'cancelling', 'cancelled', 'active', 'postcopy-active', 'postcopy-paused', + 'postcopy-recover-setup', 'postcopy-recover', 'completed', 'failed', 'colo', 'pre-switchover', 'device', 'wait-unplug' ] } ## diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index ecae941211..a6df1b2811 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -13,6 +13,8 @@ #ifndef QEMU_POSTCOPY_RAM_H #define QEMU_POSTCOPY_RAM_H +#include "qapi/qapi-types-migration.h" + /* Return true if the host supports everything we need to do postcopy-ram */ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis, Error **errp); @@ -193,5 +195,6 @@ enum PostcopyChannels { void postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file); void postcopy_preempt_setup(MigrationState *s); int postcopy_preempt_establish_channel(MigrationState *s); +bool postcopy_is_paused(MigrationStatus status); #endif diff --git a/migration/migration.c b/migration/migration.c index 59442181a1..fc390115bf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1094,6 +1094,7 @@ bool migration_is_setup_or_active(void) case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: + case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: case MIGRATION_STATUS_POSTCOPY_RECOVER: case MIGRATION_STATUS_SETUP: case MIGRATION_STATUS_PRE_SWITCHOVER: @@ -1116,6 +1117,7 @@ bool migration_is_running(void) case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: + case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: case MIGRATION_STATUS_POSTCOPY_RECOVER: case MIGRATION_STATUS_SETUP: case MIGRATION_STATUS_PRE_SWITCHOVER: @@ -1253,6 +1255,7 @@ static void fill_source_migration_info(MigrationInfo *info) case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: case MIGRATION_STATUS_POSTCOPY_PAUSED: + case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: case MIGRATION_STATUS_POSTCOPY_RECOVER: /* TODO add some postcopy stats */ populate_time_info(info, s); @@ -1459,9 +1462,30 @@ static void migrate_error_free(MigrationState *s) static void migrate_fd_error(MigrationState *s, const Error *error) { + MigrationStatus current = s->state; + MigrationStatus next; + assert(s->to_dst_file == NULL); - migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, - MIGRATION_STATUS_FAILED); + + switch (current) { + case MIGRATION_STATUS_SETUP: + next = MIGRATION_STATUS_FAILED; + break; + case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: + /* Never fail a postcopy migration; switch back to PAUSED instead */ + next = MIGRATION_STATUS_POSTCOPY_PAUSED; + break; + default: + /* + * This really shouldn't happen. Just be careful to not crash a VM + * just for this. Instead, dump something. + */ + error_report("%s: Illegal migration status (%s) detected", + __func__, MigrationStatus_str(current)); + return; + } + + migrate_set_state(&s->state, current, next); migrate_set_error(s, error); } @@ -1562,6 +1586,7 @@ bool migration_in_postcopy(void) switch (s->state) { case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: + case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: case MIGRATION_STATUS_POSTCOPY_RECOVER: return true; default: @@ -1949,6 +1974,9 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp) return false; } + migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_PAUSED, + MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP); + /* This is a resume, skip init status */ return true; } @@ -2981,9 +3009,9 @@ static MigThrError postcopy_pause(MigrationState *s) * We wait until things fixed up. Then someone will setup the * status back for us. */ - while (s->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { + do { qemu_sem_wait(&s->postcopy_pause_sem); - } + } while (postcopy_is_paused(s->state)); if (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER) { /* Woken up by a recover procedure. Give it a shot */ @@ -3679,7 +3707,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) { Error *local_err = NULL; uint64_t rate_limit; - bool resume = s->state == MIGRATION_STATUS_POSTCOPY_PAUSED; + bool resume = (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP); int ret; /* @@ -3746,7 +3774,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) if (resume) { /* Wakeup the main migration thread to do the recovery */ - migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_PAUSED, + migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP, MIGRATION_STATUS_POSTCOPY_RECOVER); qemu_sem_post(&s->postcopy_pause_sem); return; diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 97701e6bb2..1c374b7ea1 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1770,3 +1770,9 @@ void *postcopy_preempt_thread(void *opaque) return NULL; } + +bool postcopy_is_paused(MigrationStatus status) +{ + return status == MIGRATION_STATUS_POSTCOPY_PAUSED || + status == MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP; +} diff --git a/migration/savevm.c b/migration/savevm.c index e71410d8c1..deb57833f8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2864,9 +2864,9 @@ static bool postcopy_pause_incoming(MigrationIncomingState *mis) error_report("Detected IO failure for postcopy. " "Migration paused."); - while (mis->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { + do { qemu_sem_wait(&mis->postcopy_pause_sem_dst); - } + } while (postcopy_is_paused(mis->state)); trace_postcopy_pause_incoming_continued(); From patchwork Mon Jun 17 18:15:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bmkuCIRW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ylM2WC0z20XJ for ; Tue, 18 Jun 2024 04:17:03 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGtg-0000Ha-JJ; Mon, 17 Jun 2024 14:16:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGta-0000Dw-RG for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:00 -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 1sJGtX-0006Ir-La for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648154; 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=nEHrtQENt0LFtN0vcvE5nOEIasmLrG79F51JvU/6ieg=; b=bmkuCIRWL2qTVG+zPosi944rk4GWkuW0SuIOp7mQhqDJW127a2qw6C3SIL7Xp3OODW7cRX dfgrWHXd4enEJUnESTdzQ5QAsD1UyK/jxeCCY52/RmavKu3S/apnlL04A4tliDnHntv9uj WYq40jT+QddolKNwGgQwXvdw0ZQ4Faw= 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-320-WKtl73LcNF6pTtNzhaRqaw-1; Mon, 17 Jun 2024 14:15:50 -0400 X-MC-Unique: WKtl73LcNF6pTtNzhaRqaw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6b07a472e83so3991916d6.1 for ; Mon, 17 Jun 2024 11:15:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648149; x=1719252949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nEHrtQENt0LFtN0vcvE5nOEIasmLrG79F51JvU/6ieg=; b=s4GMdVi+wEiEjcyx+IFg5JBkmylryZkN7JAKmrhxROj28ZlksoXstCHukNE6AdzUs5 aZXdXzLGFHRJNwVFZ0Vn7FrgEsFAL445wWAXES+i+/4nKG3Xcnd8dM5IeR8FlP4qkGYV 3I3sUzkKO6vvlTFUPbWEMEUrnyQYQo5KmLjiBwSQjcZgkn6CrFujB6PJfBi0E8FGVsbq xkGlPXD5XPCpM8cn+zsYAu8hoNzAPnPAn6vq5FrPVET0nnoP7uXL6jcxESH53M7c/mTF a44q9PgW/ZAfAjk9SUnWNTkL+ftgTIfMdY1F004ZP+Xc5vNbrzhDE+0jnTenxcfcEURM PZTA== X-Gm-Message-State: AOJu0YzyV6FywRrNa6q576Bw0cyZ9P7bFF4shKeGFqh4duw3Yxi8L+1U E/qOt8JDvrQB1LNZj7Y6UU4/IQFf/8uHzVrm2vINpfGIn74LbZgvSRFJq7oaQlaFgozjeG+R2+i 5TX1UjcKjEb+MIRR5GOVMCRbGciTs7oDII/jHgH2zyw4w70iMfeV3hzUbYeNwuMVC0Cs+AbaNNq +5iz20R6jwNCVNM9DVCMQEwJMHOBhnVvop7A== X-Received: by 2002:a05:620a:4893:b0:797:74ba:8b8 with SMTP id af79cd13be357-798d23e0698mr1366899485a.2.1718648148811; Mon, 17 Jun 2024 11:15:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFasbENddxnm/6ekdse/p/TgRpfH51FOrKDEuAZV6APu5bsFDqKlxS7FDarb4wTo0k8DjXoQ== X-Received: by 2002:a05:620a:4893:b0:797:74ba:8b8 with SMTP id af79cd13be357-798d23e0698mr1366894685a.2.1718648147973; Mon, 17 Jun 2024 11:15:47 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:47 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 06/10] migration/docs: Update postcopy recover session for SETUP phase Date: Mon, 17 Jun 2024 14:15:30 -0400 Message-ID: <20240617181534.1425179-7-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Firstly, the "Paused" state was added in the wrong place before. The state machine section was describing PostcopyState, rather than MigrationStatus. Drop the Paused state descriptions. Then in the postcopy recover session, add more information on the state machine for MigrationStatus in the lines. Add the new RECOVER_SETUP phase. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- docs/devel/migration/postcopy.rst | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/devel/migration/postcopy.rst b/docs/devel/migration/postcopy.rst index 6c51e96d79..a15594e11f 100644 --- a/docs/devel/migration/postcopy.rst +++ b/docs/devel/migration/postcopy.rst @@ -99,17 +99,6 @@ ADVISE->DISCARD->LISTEN->RUNNING->END (although it can't do the cleanup it would do as it finishes a normal migration). - - Paused - - Postcopy can run into a paused state (normally on both sides when - happens), where all threads will be temporarily halted mostly due to - network errors. When reaching paused state, migration will make sure - the qemu binary on both sides maintain the data without corrupting - the VM. To continue the migration, the admin needs to fix the - migration channel using the QMP command 'migrate-recover' on the - destination node, then resume the migration using QMP command 'migrate' - again on source node, with resume=true flag set. - - End The listen thread can now quit, and perform the cleanup of migration @@ -221,7 +210,8 @@ paused postcopy migration. The recovery phase normally contains a few steps: - - When network issue occurs, both QEMU will go into PAUSED state + - When network issue occurs, both QEMU will go into **POSTCOPY_PAUSED** + migration state. - When the network is recovered (or a new network is provided), the admin can setup the new channel for migration using QMP command @@ -229,9 +219,20 @@ The recovery phase normally contains a few steps: - On source host, the admin can continue the interrupted postcopy migration using QMP command 'migrate' with resume=true flag set. - - - After the connection is re-established, QEMU will continue the postcopy - migration on both sides. + Source QEMU will go into **POSTCOPY_RECOVER_SETUP** state trying to + re-establish the channels. + + - When both sides of QEMU successfully reconnects using a new or fixed up + channel, they will go into **POSTCOPY_RECOVER** state, some handshake + procedure will be needed to properly synchronize the VM states between + the two QEMUs to continue the postcopy migration. For example, there + can be pages sent right during the window when the network is + interrupted, then the handshake will guarantee pages lost in-flight + will be resent again. + + - After a proper handshake synchronization, QEMU will continue the + postcopy migration on both sides and go back to **POSTCOPY_ACTIVE** + state. Postcopy migration will continue. During a paused postcopy migration, the VM can logically still continue running, and it will not be impacted from any page access to pages that From patchwork Mon Jun 17 18:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948760 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cKw1qHDT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ymN3D9Rz20Wb for ; Tue, 18 Jun 2024 04:17:56 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGti-0000KU-DU; Mon, 17 Jun 2024 14:16:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGta-0000Du-Bp for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:00 -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 1sJGtX-0006Ic-By for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648153; 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=tz8mAzBKLZeeLf11HYzcmc5ZaFjBtDHCXl7INRqRcO0=; b=cKw1qHDT/HVXqr7pWjlDlsqGIrzB3CswvtjP3KJKH4VMLAyBOjb2lzyJNlx9mHmGX3HDG/ oEc5DEIXXgL0vIC2fGu90mLC0l58sv3pbPzg7JQycgkdzuDo+pbONOila213rbM20Xo67A evO+3MzIPZHLm7ZCe1ivlUXXpk1SYmU= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-139-JdCNRSCiMQi51s2HSTKBng-1; Mon, 17 Jun 2024 14:15:51 -0400 X-MC-Unique: JdCNRSCiMQi51s2HSTKBng-1 Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-375938907fbso6495385ab.2 for ; Mon, 17 Jun 2024 11:15:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648150; x=1719252950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tz8mAzBKLZeeLf11HYzcmc5ZaFjBtDHCXl7INRqRcO0=; b=dAe1A+LKKU+tq036a+Mj/uU1VtCGu4ytTu/XNzyremDx3OYscUU5//XQ/TZGhfBZb7 LJESN4rbTGgO1X78LynFdqDkeZpxeYEj1UENur2Ff3qyB+QMoBUT5OcESSAcSLQZdWDS mvv6DbS9ZEotAjmU+yy+z4Hxkbmg0k7aXRC8l5HPL8k0adyxDWB+HsUT5nAm8eodvtt7 Uwq+JZOlhT6SHdtC5L1I28hBigg9LGfWBWq7IJJTTdVInnwU6+7Hwgy1LW+O/LXTaual X31TVVEyEB/8ipXFHGohdBrQ0JphUPovFszgBVTiN8G++QM9bhnDE/kvkXzZZSmh2/Ce iNSg== X-Gm-Message-State: AOJu0YyRQhXJKE8/QJ0UaqyMcWjPCIqYCgaoUt34j45OAepPPjSV/8LB ABNtHfVG1XV4CdmFs05kSF2v958hYdnzXvdDKl6iE3wEqnEd4gP1Id0iBkBwis90XQZXdeaI17h xhkWIqfwJ0eQJPuUSA+GyKn9u5HRmvHnDv3915saYEwNWIO7rG1EfDFBs4FyExtwTd9lDJln9sr RxmURg+P1FAlB6hebBAtTc6QF1E+ZWw5DMQw== X-Received: by 2002:a92:b707:0:b0:375:ca48:75e9 with SMTP id e9e14a558f8ab-375e0dfb7a1mr104926535ab.1.1718648149903; Mon, 17 Jun 2024 11:15:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsdpZwwufKvv9xaiXPMQn4/OiydT5swjg2BC61HW1ns9+5wQhZNDmup98t4nik66MpxjpovQ== X-Received: by 2002:a92:b707:0:b0:375:ca48:75e9 with SMTP id e9e14a558f8ab-375e0dfb7a1mr104926225ab.1.1718648149313; Mon, 17 Jun 2024 11:15:49 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:48 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 07/10] tests/migration-tests: Drop most WIN32 ifdefs for postcopy failure tests Date: Mon, 17 Jun 2024 14:15:31 -0400 Message-ID: <20240617181534.1425179-8-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Most of them are not needed, we can stick with one ifdef inside postcopy_recover_fail() so as to cover the scm right tricks only. The tests won't run on windows anyway due to has_uffd always false. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/qtest/migration-test.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b7e3406471..13b59d4c10 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1353,9 +1353,9 @@ static void wait_for_postcopy_status(QTestState *one, const char *status) "completed", NULL }); } -#ifndef _WIN32 static void postcopy_recover_fail(QTestState *from, QTestState *to) { +#ifndef _WIN32 int ret, pair1[2], pair2[2]; char c; @@ -1417,8 +1417,8 @@ static void postcopy_recover_fail(QTestState *from, QTestState *to) close(pair1[1]); close(pair2[0]); close(pair2[1]); +#endif } -#endif /* _WIN32 */ static void test_postcopy_recovery_common(MigrateCommon *args) { @@ -1458,7 +1458,6 @@ static void test_postcopy_recovery_common(MigrateCommon *args) wait_for_postcopy_status(to, "postcopy-paused"); wait_for_postcopy_status(from, "postcopy-paused"); -#ifndef _WIN32 if (args->postcopy_recovery_test_fail) { /* * Test when a wrong socket specified for recover, and then the @@ -1467,7 +1466,6 @@ static void test_postcopy_recovery_common(MigrateCommon *args) postcopy_recover_fail(from, to); /* continue with a good recovery */ } -#endif /* _WIN32 */ /* * Create a new socket to emulate a new channel that is different @@ -1496,7 +1494,6 @@ static void test_postcopy_recovery(void) test_postcopy_recovery_common(&args); } -#ifndef _WIN32 static void test_postcopy_recovery_double_fail(void) { MigrateCommon args = { @@ -1505,7 +1502,6 @@ static void test_postcopy_recovery_double_fail(void) test_postcopy_recovery_common(&args); } -#endif /* _WIN32 */ #ifdef CONFIG_GNUTLS static void test_postcopy_recovery_tls_psk(void) @@ -3486,10 +3482,8 @@ int main(int argc, char **argv) test_postcopy_preempt); migration_test_add("/migration/postcopy/preempt/recovery/plain", test_postcopy_preempt_recovery); -#ifndef _WIN32 migration_test_add("/migration/postcopy/recovery/double-failures", test_postcopy_recovery_double_fail); -#endif /* _WIN32 */ if (is_x86) { migration_test_add("/migration/postcopy/suspend", test_postcopy_suspend); From patchwork Mon Jun 17 18:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jJRFBbF/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ymD5fkdz20Wb for ; Tue, 18 Jun 2024 04:17:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGtj-0000NO-Cc; Mon, 17 Jun 2024 14:16:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtb-0000E4-N8 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:00 -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 1sJGtY-0006Iw-Oh for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:15:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648155; 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=eGE+LgWMbS91EIDfvnLwsxRRHX55rP0Vg3VR2s70yow=; b=jJRFBbF/OaDlLjuISOaw0DOqa1h2xd1QlK+xYdQ/OCZjT6ilnQytHfEA9VF1kmcuLH3w29 88lXoIzsNZhw+7+toVXTrE7qJf+6yG2JY3YR788+gYZOCfw9W5QnlAwyrbqSwfzD9EhszF 673JOnGQBTlvwYAEttpL105Q6qUhEA4= 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-541-Crk093aFOryObvx0_g-Ugg-1; Mon, 17 Jun 2024 14:15:53 -0400 X-MC-Unique: Crk093aFOryObvx0_g-Ugg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-794fa90409eso2870285a.3 for ; Mon, 17 Jun 2024 11:15:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648152; x=1719252952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eGE+LgWMbS91EIDfvnLwsxRRHX55rP0Vg3VR2s70yow=; b=wQIJu3nae4eLlS+WDzZOm4bUB1YWDO7c6KVKo4n8q8/cftwfgcNm+9w/ng+n4X7O2c XW/dzxrKNkgOEfujCqlc/GO487X4ovOsJsppW8LwmAFsUMH27an2u8AgsmquZSbyRrq1 pLCEYel9DlqVc5yTUlj+pDlF4Jnb4R8HbzDl98/dUNf+3mFGcQt0t21h8umk0f/8N3N5 73xrRvp4veDd5bkJoixMlwJByeS0L73v0ZqhQ0GZD5OmKpFCxtMPFC0373gq6mWnA7D/ bwL+3xBBgykhKJOJ3/AGzj625KPyV1b9rLbQsoseij3hCqEQ3zeNcWSX72EdJNOnNDoF /hYw== X-Gm-Message-State: AOJu0YyDUC31dnTTPc1sDO8Cao7rx7zBgYHHTsqJlUUO/nPwEunYIp5V /ZuxCKGXcO8hbIStlCwCkFQVZqszVdam/xifXXDbSZo5eBS9Tk4mK7IQ5KojChPU6gzUlJf3iGr AbObou9jtPWLhaCJkdPIfw5V6mz9u/bTJGJacRXLvXE+1jROpUCQOa9gJtyD7zQDvV+BIn1q82p oDG+QMcoK8B/zPh5UK1tpptFGUdyw4hJoI6g== X-Received: by 2002:a05:620a:272a:b0:795:493f:9f3f with SMTP id af79cd13be357-798d269f370mr1142520885a.4.1718648152261; Mon, 17 Jun 2024 11:15:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGO5xIs0uWkac8wmMuslSAq5i21szSRTWc65eVf0Kuqaq+1dlWGdGdzxvWiCqpDXZFGsj3wyg== X-Received: by 2002:a05:620a:272a:b0:795:493f:9f3f with SMTP id af79cd13be357-798d269f370mr1142516585a.4.1718648151541; Mon, 17 Jun 2024 11:15:51 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:50 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 08/10] tests/migration-tests: Always enable migration events Date: Mon, 17 Jun 2024 14:15:32 -0400 Message-ID: <20240617181534.1425179-9-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Libvirt should always enable it, so it'll be nice qtest also cover that for all tests. Though this patch only enables it, no extra tests are done on these events yet. Signed-off-by: Peter Xu Signed-off-by: Peter Xu --- tests/qtest/migration-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 13b59d4c10..9ae8892e26 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -841,6 +841,13 @@ static int test_migrate_start(QTestState **from, QTestState **to, unlink(shmem_path); } + /* + * Always enable migration events. Libvirt always uses it, let's try + * to mimic as closer as that. + */ + migrate_set_capability(*from, "events", true); + migrate_set_capability(*to, "events", true); + return 0; } From patchwork Mon Jun 17 18:15:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YTmSO1AW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2ymZ62Y3z20Wb for ; Tue, 18 Jun 2024 04:18:06 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGtm-0000QO-G1; Mon, 17 Jun 2024 14:16:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtd-0000EH-6Q for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:01 -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 1sJGtb-0006JN-6G for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648158; 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=HAnuiEXSF9coRI1TVtgqNjLkt+KmjbXV8lGXJ3b5PMs=; b=YTmSO1AWCUEFNAw7veBapQDVZladyd2NBHzYrx5NbXqdv7yS0gbyXz+/UNAQN6NJOMhsa7 AQ5i4iYYwvuTLb12UstgQwEWIubkK1kZ5P3FcvxsUoxr91oSw9YtFqiIg8y2JhhmL+8CWO PhzNMK6IDfx7bU7z1aUws/YSTPO0SfE= Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-tLB3RpMQP0mmo4Xn8IrPdA-1; Mon, 17 Jun 2024 14:15:54 -0400 X-MC-Unique: tLB3RpMQP0mmo4Xn8IrPdA-1 Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-254ca2a8e97so1213379fac.0 for ; Mon, 17 Jun 2024 11:15:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648153; x=1719252953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HAnuiEXSF9coRI1TVtgqNjLkt+KmjbXV8lGXJ3b5PMs=; b=eDLpggMVPd91bfw5CscVUdhjNkwH79XpI9uMVJ5aMmnDNbApfNGZ2rDHndv2toR4t/ Z1bJpDllKmP6dRGVHSnxULwOOaTh8G2PoydwfB6BJrKGmWWm9zCSzyTqmNblHTGKiCv1 kVV2602birUOd4TVEa+0TDZ3cXz0q94D+3Es4rlA15Ih0/pSQmvYlt/qDX1wXfYxLiUX 5+75/HkNz4TfHY9KkdfbGq7+aqK/m9A2jB2nCFbmhjZXdZla8COEkd3LLVs/sOq1iC9H q4tutyW20Gz/w7l0mB5eBuRazkrwoWt1nXL9/4S4AwY9S7y0aSdqfYKcBk2slDUHBsx4 hEPg== X-Gm-Message-State: AOJu0Ywnl52muoqYlz182zsVj3yN3EBwuwTyzSEcXjTnOisxLuTnR5SS Y9IbMsnKIstzyh0SLoALT7aZYmmLs0ang80/CX7456Cv+SuPJvEB4nSkUg1vb+UETplfMnzy5jK pS02jAVpGdmhcumDFQYuvTWyzKNIzFKTeSVDkpxEeDy/IKElrpIEN9T9tZ5DoFHMpGIVPSYNwkZ Td+09bBOvCaMKVgWPIggguhtcFb40vVFOlMg== X-Received: by 2002:a05:6808:1a03:b0:3d2:199b:63dc with SMTP id 5614622812f47-3d24eace698mr12638674b6e.5.1718648153464; Mon, 17 Jun 2024 11:15:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcAeO8jXXRBbhyU/4+58cdWQulRUkGrQw0VQClMfhb9z9TDqPrWvRGYogZMT2B/eHHUVHtKw== X-Received: by 2002:a05:6808:1a03:b0:3d2:199b:63dc with SMTP id 5614622812f47-3d24eace698mr12638643b6e.5.1718648152924; Mon, 17 Jun 2024 11:15:52 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:52 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 09/10] tests/migration-tests: Verify postcopy-recover-setup status Date: Mon, 17 Jun 2024 14:15:33 -0400 Message-ID: <20240617181534.1425179-10-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Making sure the postcopy-recover-setup status is present in the postcopy failure unit test. Note that it only applies to src QEMU not dest. This also introduces the tiny but helpful migration_event_wait() helper. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-helpers.c | 20 ++++++++++++++++++++ tests/qtest/migration-test.c | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index 1339835698..356057b4a0 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -55,4 +55,6 @@ char *find_common_machine_version(const char *mtype, const char *var1, char *resolve_machine_version(const char *alias, const char *var1, const char *var2); void migration_test_add(const char *path, void (*fn)(void)); +void migration_event_wait(QTestState *s, const char *target); + #endif /* MIGRATION_HELPERS_H */ diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index ce6d6615b5..c0e2066270 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -473,3 +473,23 @@ void migration_test_add(const char *path, void (*fn)(void)) qtest_add_data_func_full(path, test, migration_test_wrapper, migration_test_destroy); } + +/* + * Wait for a "MIGRATION" event. This is what Libvirt uses to track + * migration status changes. + */ +void migration_event_wait(QTestState *s, const char *target) +{ + QDict *response, *data; + const char *status; + bool found; + + do { + response = qtest_qmp_eventwait_ref(s, "MIGRATION"); + data = qdict_get_qdict(response, "data"); + g_assert(data); + status = qdict_get_str(data, "status"); + found = (strcmp(status, target) == 0); + qobject_unref(response); + } while (!found); +} diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 9ae8892e26..a16b1a4824 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1402,6 +1402,12 @@ static void postcopy_recover_fail(QTestState *from, QTestState *to) migrate_recover(to, "fd:fd-mig"); migrate_qmp(from, to, "fd:fd-mig", NULL, "{'resume': true}"); + /* + * Source QEMU has an extra RECOVER_SETUP phase, dest doesn't have it. + * Make sure it appears along the way. + */ + migration_event_wait(from, "postcopy-recover-setup"); + /* * Make sure both QEMU instances will go into RECOVER stage, then test * kicking them out using migrate-pause. From patchwork Mon Jun 17 18:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1948756 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=S6Al0s5A; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2yld0XRnz20Wb for ; Tue, 18 Jun 2024 04:17:17 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJGtl-0000QE-Mc; Mon, 17 Jun 2024 14:16:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJGtd-0000EI-A2 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:01 -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 1sJGtb-0006JU-FR for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:16:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718648158; 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=HIZg7f7EMSb4DXS9WhlUqeNfOnQttCV1Q7L9oJ5REA8=; b=S6Al0s5AGXqKvyonOKaiTdiN8eRtLCOMUSI7rADMdbk+d9VYPSpKuOuv4fXsWBQSZt6z/H uOLeAu8f+o1I5YBrpNRsu5bddKl0zZUIxEOJq5qvr1QkqnErnWRq4xWpRT74/cPEkzRESq GSG+tR5f/A2M8sg3k4sShZos6a44iOQ= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-XDT_jXlzPBWVfTX4b-Ko5Q-1; Mon, 17 Jun 2024 14:15:57 -0400 X-MC-Unique: XDT_jXlzPBWVfTX4b-Ko5Q-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6b2cbdb07fcso834166d6.3 for ; Mon, 17 Jun 2024 11:15:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718648156; x=1719252956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HIZg7f7EMSb4DXS9WhlUqeNfOnQttCV1Q7L9oJ5REA8=; b=g2B4I05U6GiAHL+DgmpAHmDGHuSz7hklq7V6rZuz96jf8iQnKtnlgid4o6UMm79X2p qiBGMSOzdBCTIDfv1E5uNTjs5mb8ttmV4NvQwVaH+by2Id1IUO0ncuhVooEBTe702Vmh +h96TQMyI2QqTSMuZnaX0tluycjQ+8eElPki9nK0qHAun8JpIhXX2oPxqk+IyKd166/S 4d/7QRATK/ExGthKattLZSbUFVebz6wPtXje0T8MjeR01vhmKW/c7bvQCEOUNqO/k1Aj MzOI7vYEBT/f/POzdPGoONucCgLzscEB0JahuVyDkkzb//eWZVRj51KVi+2reH1ZPTXE +GhQ== X-Gm-Message-State: AOJu0YwYoXI+bnXFPhKv3I3e9qaW738t+YC1DRgatzAu8yt6ChjUTNic MkZzkjkPrWJ806bVeouUneXcZEAATRpX3lxteNBOSz6fOrSTnSTdQnURVCF7fuYxrgika/T3Lin X4lm/IjsGr1Va2sjf0/8qBUmllBR7SasMtAjGpb6cfb4/mkWm6EpXypLmM33G48hLQNcqK524Wx TF0Ximv0IVmBsLU7K6K8KnS026Z+PfJbQVTw== X-Received: by 2002:a05:620a:2b41:b0:798:da55:1269 with SMTP id af79cd13be357-798da5517dcmr1103938685a.1.1718648155629; Mon, 17 Jun 2024 11:15:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEENFI7nLdoDmqZEc7XQVS3SR0APG3J2rMVthD9C+jBu6T6x1HaOUSULK7B7QqJx/NFJTMW0w== X-Received: by 2002:a05:620a:2b41:b0:798:da55:1269 with SMTP id af79cd13be357-798da5517dcmr1103933885a.1.1718648154756; Mon, 17 Jun 2024 11:15:54 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc07501sm449643685a.89.2024.06.17.11.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:15:53 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , Laurent Vivier , Fabiano Rosas , Eric Blake , Prasad Pandit , peterx@redhat.com, Jiri Denemark , Bandan Das Subject: [PATCH v2 10/10] tests/migration-tests: Cover postcopy failure on reconnect Date: Mon, 17 Jun 2024 14:15:34 -0400 Message-ID: <20240617181534.1425179-11-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617181534.1425179-1-peterx@redhat.com> References: <20240617181534.1425179-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Make sure there will be an event for postcopy recovery, irrelevant of whether the reconnect will success, or when the failure happens. The added new case is to fail early in postcopy recovery, in which case it didn't even reach RECOVER stage on src (and in real life it'll be the same to dest, but the test case is just slightly more involved due to the dual socketpair setup). To do that, rename the postcopy_recovery_test_fail to reflect either stage to fail, instead of a boolean. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/qtest/migration-test.c | 89 ++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 15 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index a16b1a4824..3e237a1499 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -70,6 +70,17 @@ static QTestMigrationState dst_state; #define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC" #define QEMU_ENV_DST "QTEST_QEMU_BINARY_DST" +typedef enum PostcopyRecoveryFailStage { + /* + * "no failure" must be 0 as it's the default. OTOH, real failure + * cases must be >0 to make sure they trigger by a "if" test. + */ + POSTCOPY_FAIL_NONE = 0, + POSTCOPY_FAIL_CHANNEL_ESTABLISH, + POSTCOPY_FAIL_RECOVERY, + POSTCOPY_FAIL_MAX +} PostcopyRecoveryFailStage; + #if defined(__linux__) #include #include @@ -680,7 +691,7 @@ typedef struct { /* Postcopy specific fields */ void *postcopy_data; bool postcopy_preempt; - bool postcopy_recovery_test_fail; + PostcopyRecoveryFailStage postcopy_recovery_fail_stage; } MigrateCommon; static int test_migrate_start(QTestState **from, QTestState **to, @@ -1360,12 +1371,16 @@ static void wait_for_postcopy_status(QTestState *one, const char *status) "completed", NULL }); } -static void postcopy_recover_fail(QTestState *from, QTestState *to) +static void postcopy_recover_fail(QTestState *from, QTestState *to, + PostcopyRecoveryFailStage stage) { #ifndef _WIN32 + bool fail_early = (stage == POSTCOPY_FAIL_CHANNEL_ESTABLISH); int ret, pair1[2], pair2[2]; char c; + g_assert(stage > POSTCOPY_FAIL_NONE && stage < POSTCOPY_FAIL_MAX); + /* Create two unrelated socketpairs */ ret = qemu_socketpair(PF_LOCAL, SOCK_STREAM, 0, pair1); g_assert_cmpint(ret, ==, 0); @@ -1399,6 +1414,14 @@ static void postcopy_recover_fail(QTestState *from, QTestState *to) ret = send(pair2[1], &c, 1, 0); g_assert_cmpint(ret, ==, 1); + if (stage == POSTCOPY_FAIL_CHANNEL_ESTABLISH) { + /* + * This will make src QEMU to fail at an early stage when trying to + * resume later, where it shouldn't reach RECOVER stage at all. + */ + close(pair1[1]); + } + migrate_recover(to, "fd:fd-mig"); migrate_qmp(from, to, "fd:fd-mig", NULL, "{'resume': true}"); @@ -1408,28 +1431,53 @@ static void postcopy_recover_fail(QTestState *from, QTestState *to) */ migration_event_wait(from, "postcopy-recover-setup"); + if (fail_early) { + /* + * When fails at reconnection, src QEMU will automatically goes + * back to PAUSED state. Making sure there is an event in this + * case: Libvirt relies on this to detect early reconnection + * errors. + */ + migration_event_wait(from, "postcopy-paused"); + } else { + /* + * We want to test "fail later" at RECOVER stage here. Make sure + * both QEMU instances will go into RECOVER stage first, then test + * kicking them out using migrate-pause. + * + * Explicitly check the RECOVER event on src, that's what Libvirt + * relies on, rather than polling. + */ + migration_event_wait(from, "postcopy-recover"); + wait_for_postcopy_status(from, "postcopy-recover"); + + /* Need an explicit kick on src QEMU in this case */ + migrate_pause(from); + } + /* - * Make sure both QEMU instances will go into RECOVER stage, then test - * kicking them out using migrate-pause. + * For all failure cases, we'll reach such states on both sides now. + * Check them. */ - wait_for_postcopy_status(from, "postcopy-recover"); + wait_for_postcopy_status(from, "postcopy-paused"); wait_for_postcopy_status(to, "postcopy-recover"); /* - * This would be issued by the admin upon noticing the hang, we should - * make sure we're able to kick this out. + * Kick dest QEMU out too. This is normally not needed in reality + * because when the channel is shutdown it should also happens on src. + * However here we used separate socket pairs so we need to do that + * explicitly. */ - migrate_pause(from); - wait_for_postcopy_status(from, "postcopy-paused"); - - /* Do the same test on dest */ migrate_pause(to); wait_for_postcopy_status(to, "postcopy-paused"); close(pair1[0]); - close(pair1[1]); close(pair2[0]); close(pair2[1]); + + if (stage != POSTCOPY_FAIL_CHANNEL_ESTABLISH) { + close(pair1[1]); + } #endif } @@ -1471,12 +1519,12 @@ static void test_postcopy_recovery_common(MigrateCommon *args) wait_for_postcopy_status(to, "postcopy-paused"); wait_for_postcopy_status(from, "postcopy-paused"); - if (args->postcopy_recovery_test_fail) { + if (args->postcopy_recovery_fail_stage) { /* * Test when a wrong socket specified for recover, and then the * ability to kick it out, and continue with a correct socket. */ - postcopy_recover_fail(from, to); + postcopy_recover_fail(from, to, args->postcopy_recovery_fail_stage); /* continue with a good recovery */ } @@ -1510,7 +1558,16 @@ static void test_postcopy_recovery(void) static void test_postcopy_recovery_double_fail(void) { MigrateCommon args = { - .postcopy_recovery_test_fail = true, + .postcopy_recovery_fail_stage = POSTCOPY_FAIL_RECOVERY, + }; + + test_postcopy_recovery_common(&args); +} + +static void test_postcopy_recovery_channel_reconnect(void) +{ + MigrateCommon args = { + .postcopy_recovery_fail_stage = POSTCOPY_FAIL_CHANNEL_ESTABLISH, }; test_postcopy_recovery_common(&args); @@ -3497,6 +3554,8 @@ int main(int argc, char **argv) test_postcopy_preempt_recovery); migration_test_add("/migration/postcopy/recovery/double-failures", test_postcopy_recovery_double_fail); + migration_test_add("/migration/postcopy/recovery/channel-reconnect", + test_postcopy_recovery_channel_reconnect); if (is_x86) { migration_test_add("/migration/postcopy/suspend", test_postcopy_suspend);