From patchwork Wed Jun 19 22:30:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1D1DC27C53 for ; Wed, 19 Jun 2024 22:32:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pR-0001ob-HF; Wed, 19 Jun 2024 18:30:57 -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 1sK3pP-0001o1-Lu for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:30:55 -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 1sK3pN-0008Ow-TK for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:30:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836253; 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=HvDInXYTLWztisybI8zz5i1YEDj644Qnpu4ECPNRJOCtHjJ9iuN5AzwmBGFix4D/C2YXxH OOfv0UDDU3T1DSQJdmye0rNjXwWpZfM2vPI7OdzE/4alI+vLYWnLN78PNq4J8qVjdCxFK5 vqBxkYu/sNHG6YP/tn88QfgvN7Onv0k= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-7jnWWpaeOF6p8SZ5l4fc2A-1; Wed, 19 Jun 2024 18:30:51 -0400 X-MC-Unique: 7jnWWpaeOF6p8SZ5l4fc2A-1 Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-e02b7b50986so66517276.0 for ; Wed, 19 Jun 2024 15:30:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836250; x=1719441050; 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=XkXFgIFBTQ/WDm1NqWsTAW3w20B5fGyWL4H6aalBCNWyiaRsHt0dk/Yr+lAl8Y/qvB TR1WcQsJ/4js+4+r00tOKAOCF3SVika92Rm0D8xmnCSp3YRmywp0IHWWmnozSCMCK5Vd XNPQDCIDK0QWC/sE0BCQqecRLn2xRxXlE9chn5PkoricNZi0Flfv8RrY+RcmtU0lX23U v8MlTqWBy2u62RVzC6afqHJG8jQdiCtYeBpsaLuofllC0nF0t0GcrBXA2M2yJVU7RirQ Hb9rF2KVnxXtaG5U+XAjUgu821zmv8bX0m64HkqA7NLRyorHFVb4Hq4nHQFTHJ3K16tE Wdxw== X-Gm-Message-State: AOJu0YweuQ2qKSaLQj6qhSx9k0aGtDfbdQytMznbJ8iMKfjyc8eBEZ4T zG8j23Xl6xD1d4sqEDO9Ms6rK4l8qOZdNPdEwT5nMJYTncIro5En5s6l+Wgo6Kl/Xg43x4Bxnb+ u/t9x5bgBDIpD2CnVwtB/aN/8JBt2vGzoJxkcLYPRg9YZ/z+yOKMzb2n/QzOAyp95IYhGK5dsZf IlfeJ2AtIuzWA8nC88jRTF0DBRhScf2glR1Q== X-Received: by 2002:a25:3f43:0:b0:e02:bde3:3166 with SMTP id 3f1490d57ef6-e02be0ff8a9mr3433840276.1.1718836250253; Wed, 19 Jun 2024 15:30:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPmuZ2JgL8GTCtKHRrcd2UupkF1MbvDm18LmonsoRHozY3zHM9LUssJE69o3nQEdKaFC0TeA== X-Received: by 2002:a25:3f43:0:b0:e02:bde3:3166 with SMTP id 3f1490d57ef6-e02be0ff8a9mr3433814276.1.1718836249677; Wed, 19 Jun 2024 15:30: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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:30:49 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 01/11] migration/multifd: Avoid the final FLUSH in complete() Date: Wed, 19 Jun 2024 18:30:36 -0400 Message-ID: <20240619223046.1798968-2-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Wed Jun 19 22:30:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0CDFC27C53 for ; Wed, 19 Jun 2024 22:31:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pV-0001p8-0t; Wed, 19 Jun 2024 18:31:01 -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 1sK3pT-0001ov-8C for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:30:59 -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 1sK3pR-0008PC-GA for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:30:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836256; 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=PVgyQ4Kda41lFezAoCJvwqQ9sH77GJyjC/aLYSrLjWM=; b=PMXbO9LE3j4jxwfemLpKv3ecli0WWLdawiitJDJcS59B+XpykMKnMl6j+WGAIGlmWJdM2j 4U5pHQ8vRL1wT5lGFfUAlmyASTcY0WkJki2uzoQjxeWi/M6N1oyJD1yVl3P0aQ28IvW5bp 3XPEPNlpFheDqT0Gb9DraQnFpYMXHkQ= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-82-s3cBWSBPP9mvV5mgRVT8uA-1; Wed, 19 Jun 2024 18:30:55 -0400 X-MC-Unique: s3cBWSBPP9mvV5mgRVT8uA-1 Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-dfde150e20bso59155276.0 for ; Wed, 19 Jun 2024 15:30:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836253; x=1719441053; 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=PVgyQ4Kda41lFezAoCJvwqQ9sH77GJyjC/aLYSrLjWM=; b=BkqCVGHdCGTqK0gvzKZJ4Rt6Rl2Do0r8PAMKLWlG9mmRH4/TxAGu5wvxBfSsG6wI8C Tw0B5QaQwKKu9Bugnr7+d1BwAtuGtZXR8+yYr1/I2Wn5keKP8bHFS06LdLhvMajwpGay me4pjgnbWBP9KGamRyRuokSDXNL065C4Zi5sZPpWojzipAvJW850DYG7SNKguqkICfKY N8vqli0icmRv51bQwd3ngM/RwmAnYfJM1ziaZxQDc5COLGTYXe09OpCRT8WXN97bPVdm Xh2GrcZWm1SwNt5H9b7DatT2RvfH3EBKxavz8yMHXizF6ElYspwxuJMJjsWfKjUUOt3n 1eLQ== X-Gm-Message-State: AOJu0YyZZF5guDuLr8M2whYBjaTC/OGVsD3o/ULOdJATMWPhy643o4Gl 1qdXEETZQQoY793kw6azdZyd5mMq/q5sIule34KJ4C3H0iXOABvKLh8fwVS1ktltjdmF1TIiOu2 oGJK01GkUsnHAGQGpklaiyvyyHPe4I8yZOcVcpphiCUN+Tnw/fDY8EmVCbKasDLjgYhizwUL9dI HAZJJTRSprCwyEPKMqHAp1Q7Piwfj0Imv+1A== X-Received: by 2002:a25:d041:0:b0:df7:8a41:3009 with SMTP id 3f1490d57ef6-e02be297ccamr3566071276.6.1718836252604; Wed, 19 Jun 2024 15:30:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQonPrnxwwZ4xPsGoly96e3QjDxumRGwVtM02UqPVFi6zrw1prO9yd6f2aL7JNB09+Hy/kQg== X-Received: by 2002:a25:d041:0:b0:df7:8a41:3009 with SMTP id 3f1490d57ef6-e02be297ccamr3566044276.6.1718836251970; Wed, 19 Jun 2024 15:30: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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:30:50 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 02/11] migration: Rename thread debug names Date: Wed, 19 Jun 2024 18:30:37 -0400 Message-ID: <20240619223046.1798968-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Reviewed-by: Zhijian Li (Fujitsu) 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 e03c80b3aa..f9b69af62f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2431,7 +2431,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; @@ -3770,10 +3770,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 d82885fdbb..0b4cbaddfe 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1069,7 +1069,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; @@ -1190,7 +1190,7 @@ bool multifd_send_setup(void) p->packet->magic = cpu_to_be32(MULTIFD_MAGIC); p->packet->version = cpu_to_be32(MULTIFD_VERSION); } - 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; @@ -1604,7 +1604,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->normal = g_new0(ram_addr_t, page_count); p->zero = g_new0(ram_addr_t, page_count); p->page_count = 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 Wed Jun 19 22:30:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704646 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B514C27C53 for ; Wed, 19 Jun 2024 22:32:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pc-0001qj-4D; Wed, 19 Jun 2024 18:31:08 -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 1sK3pZ-0001pr-Q9 for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:05 -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 1sK3pY-0008Pg-5z for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836263; 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=+OLzgDhdQQ/rnqys7jTEDSrmmLFb9m3Dvl5rC/DAIz0=; b=hsWl/3pKx7jxlQgYSNXoOGUG4/pP4MU3VaZ4w90rzmFVjoZBOWIcFNsrd19oeD7ijNcPtd EzIYTiRvwMpQknOap+sca2B1rflgmD4QBYpu9g1ge7fWUZx3brVyz3rDUCLETHPDKT/VFW M9irchDz7pREgEND5ObRsEbCok8cFhM= 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-314-nFyUcqlEN4CmA14RcwRXxA-1; Wed, 19 Jun 2024 18:30:58 -0400 X-MC-Unique: nFyUcqlEN4CmA14RcwRXxA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6b50a68ff6cso780626d6.2 for ; Wed, 19 Jun 2024 15:30:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836258; x=1719441058; 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=+OLzgDhdQQ/rnqys7jTEDSrmmLFb9m3Dvl5rC/DAIz0=; b=J0+pCqlQDfiHYL8SfuSxtnTbbrJiRF8BPnV31lxq4V/fssmHM68akL9LcAGX/Z+rZE 6xQPRtEYN2mfQVZqZ7kYS50bX+Bmfaa4pR97g7AGhjvx9R9AvHBx9KclVF1xarmAc+4w HW7Tn3Gv59QHxSdwlhaSSRCME0RWJBwe4k5oCu4K+3nssFwXX+hwQQz0SWzCsSeHbOIJ HFfijN9Hvr3yhA6e5sIZUUXYLRMYEYTelSShEY1WgW+6VbRk9O/oU5T/20g1J3GW23r8 dttCqT5mIbwq8ZWoQPY7+8q+3lXB0fs2hvFUFPDVz3GUSGxrX0WLFVxcvaNe1lpICjog CDvg== X-Gm-Message-State: AOJu0YwkiLgCMSq+lzvHysVleK0t6bHlDhZAl4Ej57q6G5Bxrkr784Z3 JTxnyXew1sJxweBJlypL2FE59LmObC5doWVDjfwxHm5KgJgc+yPwTuq5Z4GPJwx4PoFIf1z0SIv vgLT7A5S83N7hgjtT9cJX+oBOcZFtaXWDDI5+6P98Fnnj5kskG3tBW/P8B39XLOFEdq+pB2WnBL W0+Of3Yj8vKs9B2+L6M7mBbGpLs6RXn8zMpg== X-Received: by 2002:ad4:5044:0:b0:6b5:6a3:7e4 with SMTP id 6a1803df08f44-6b506a30a02mr28531956d6.6.1718836257501; Wed, 19 Jun 2024 15:30:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaYkYjM4e/RU/DbYTtF3oodGj7vgsAuNjsu5XOBMS/yXhpm8EbwJhliZzxSzA/QvJugo3Bmw== X-Received: by 2002:ad4:5044:0:b0:6b5:6a3:7e4 with SMTP id 6a1803df08f44-6b506a30a02mr28531666d6.6.1718836256796; Wed, 19 Jun 2024 15:30:56 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:30:52 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 03/11] migration: Use MigrationStatus instead of int Date: Wed, 19 Jun 2024 18:30:38 -0400 Message-ID: <20240619223046.1798968-4-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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.. Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu --- 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 f9b69af62f..795b30f0d0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -413,7 +413,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); @@ -1296,8 +1296,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: @@ -1313,6 +1311,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; @@ -1360,7 +1360,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) { @@ -1567,7 +1568,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: @@ -1612,20 +1613,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 Wed Jun 19 22:30:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5417BC2BBCA for ; Wed, 19 Jun 2024 22:32:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pd-0001qv-4J; Wed, 19 Jun 2024 18:31: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 1sK3pa-0001q7-Kk for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:06 -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 1sK3pZ-0008Pk-3O for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836264; 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=27xJFRRKvK54skIyMMmN8RUpsUo90Pcr5piRqr+33Eg=; b=XM1YjGw24IkD8Y23Z00LpZkB2w1vzYfIszkvolQhL+bN/9dCdldjMGVvDpEG0gs+UA8oU/ mDf62xO4hbIW+ccM9Vi78KFc4fmxvcN4lKD/GDRj+JNevyNTcZlhjLkGWcP5aVXp2vt2gR EDPTvwUBXexjqDuynfM1FLplEQ2NJuw= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-lqq_PWoJMLqSi4fHqL4LOw-1; Wed, 19 Jun 2024 18:31:01 -0400 X-MC-Unique: lqq_PWoJMLqSi4fHqL4LOw-1 Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-6faa28bab62so55734a34.3 for ; Wed, 19 Jun 2024 15:31:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836259; x=1719441059; 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=27xJFRRKvK54skIyMMmN8RUpsUo90Pcr5piRqr+33Eg=; b=MEtO2QaRmpVJ4cn7sZyk3dZPWUs9jMheDYCR/vHH2uYh0rtLFMKfBHzrLZCq++1Esv I5VHiVT1VloeVdZGTfIoDdI2GRygLYaIEAW6Q5UxLXpuwx8rIuzYQhmhG5MO4xDk0uIL w8jhNClxANKlKJwuUOnRm9KgKdM5g+D2ltej+mxvOqbEpo8+4hbnTnY5ATqlv1+efl+3 U3jJYshH2/RyANIJLjEUnJLbYoPEm6SiBUYVIktktMACyZPzk9rXQ0XSR30ON3dUJxnH I5k0xJt6edGU5siIMm3w8eKSyDFM1XfjXsVrCe1hJCOGx9f/W+OH+ElsOEENn62LaXsJ eDYQ== X-Gm-Message-State: AOJu0Yy3U1fhK2KwLOweCCjgZWH0+2f8iYiUBTME/XqzgIc6j2hA/Bef TYmOH2Z6OpoQXs/oB/GmfD4STu5CxPIXIfClFzYesXzDI8Y+P1CVIeUew7AFafBQusJZenBMhcL voo/ZOUzwON/vu9i1541DHr5xt7dLG2aHQEHuDQrgrbovCorncYhOGX10l2tqMQAneBgQ35CFpN 0iZHPxWTf3XSCr7YXhRU+4BkRNrksigESkPw== X-Received: by 2002:a05:6830:1c45:b0:6fb:8c91:5969 with SMTP id 46e09a7af769-70075596c20mr3940776a34.2.1718836259415; Wed, 19 Jun 2024 15:30:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHDXuLNbGboiDCcn8RUqKWsKIjQGWZZhpdcsSA28maRIqslrDXnUbrHVSVKs0PEWZZ/Ccd+Q== X-Received: by 2002:a05:6830:1c45:b0:6fb:8c91:5969 with SMTP id 46e09a7af769-70075596c20mr3940737a34.2.1718836258782; Wed, 19 Jun 2024 15:30:58 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:30:57 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 04/11] migration: Cleanup incoming migration setup state change Date: Wed, 19 Jun 2024 18:30:39 -0400 Message-ID: <20240619223046.1798968-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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. Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu --- migration/migration.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 795b30f0d0..41a88fc50a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -618,6 +618,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) @@ -656,8 +679,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 Wed Jun 19 22:30:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9B6DC41513 for ; Wed, 19 Jun 2024 22:32:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pe-0001rO-5f; Wed, 19 Jun 2024 18:31: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 1sK3pc-0001qn-Mj for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:08 -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 1sK3pa-0008Pz-Lp for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836265; 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=9clR7IoupnKkwSljXq0px/U1vTlfLmSISM5L429P7S0=; b=QXa/JBemIz0Sn452030VUTJ3zKfnGNevosYvz9pkmR5h9hy6VqiNkIf8Kq1So1YcCtmuwG 5o5+Kf0cGRZkbFOGSyU5UaFbaQaQLzK43GtKFNZ7XWAJpLSpDHv0PkKCZ9/RbHg6nZ7fLL rqGgCWaxt25jZeFxqdt4iNUbPoNE7Eo= 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-663-CcxlBoe5MaGJLiIO3tLziA-1; Wed, 19 Jun 2024 18:31:03 -0400 X-MC-Unique: CcxlBoe5MaGJLiIO3tLziA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6b50790e82bso853646d6.2 for ; Wed, 19 Jun 2024 15:31:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836262; x=1719441062; 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=9clR7IoupnKkwSljXq0px/U1vTlfLmSISM5L429P7S0=; b=Ca0uxxe9ymySTDKzqLu6mPo8Z1HK9OSyJ7gaLzjFxD/ooAOhuwcOJfkWGcQSQPjpi1 FF43Ims9Y1RTO/hDXljcGmFO8LPW+WVRAzCdP6dshmSrEIdI5N1uH82X4nmFm0OgRziW 5/lKqPgvQIIgFacEQHgFcRbW1oN66vCLjrlNqn1A3x/bDR2oYcP3wUv03YD1Qr6eSMDh 1CB1LvDdd+7xLAYaHPJm+LRpKO4+Izm86RULYtcsFRaZy+y8aDtAQoz553aPGebmEi95 TVPsWqeNKd2SyMhod3k8cjZZ0Oc9udqLbqrMBi3x6AVxEQWyrPo+VnFbj7jnq9hGiWih voSw== X-Gm-Message-State: AOJu0YwkXCcMgE4rlprOEX33jdawxVvb68lFXiko41fm+zCNcEaB61Ml 9RKB4cUI7nZ4x1PGHbcy25Im1OjbhyYik9OU6GR22ARDeesnLsaJUyowuxEj9SQoplskUo+goJf PVdECOo7LyBo4UUY76L10j2aj+iIWb00E3SVf7manlLbxYI0FMnUa+olQGkC6npaIohQuZG3nvB tKJChApdj7vAwY6FlHJtLo5x5TMcZqBNKUWg== X-Received: by 2002:ad4:4b24:0:b0:6b5:6a3:7eb with SMTP id 6a1803df08f44-6b506a30a0dmr27874986d6.5.1718836261869; Wed, 19 Jun 2024 15:31:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvsYjSgjhmTkHOYinwG2e+pfTgpX3KgajRY7ZH8igBWF/DbNBVGr6jrKUsXLCoJCk+bDTPKQ== X-Received: by 2002:ad4:4b24:0:b0:6b5:6a3:7eb with SMTP id 6a1803df08f44-6b506a30a0dmr27874676d6.5.1718836261085; Wed, 19 Jun 2024 15:31:01 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:30:59 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 05/11] migration/postcopy: Add postcopy-recover-setup phase Date: Wed, 19 Jun 2024 18:30:40 -0400 Message-ID: <20240619223046.1798968-6-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: Prasad Pandit Reviewed-by: Fabiano Rosas Buglink: https://issues.redhat.com/browse/RHEL-38485 Signed-off-by: Peter Xu --- 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 de6c8b0444..0f24206bce 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 41a88fc50a..3dea06d577 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1117,6 +1117,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: @@ -1139,6 +1140,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: @@ -1276,6 +1278,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); @@ -1482,9 +1485,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); } @@ -1585,6 +1609,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: @@ -1972,6 +1997,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; } @@ -3004,9 +3032,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 */ @@ -3702,7 +3730,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; /* @@ -3769,7 +3797,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 Wed Jun 19 22:30:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BDF6C2BA1A for ; Wed, 19 Jun 2024 22:32:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pd-0001rJ-V9; Wed, 19 Jun 2024 18:31: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 1sK3pb-0001qb-OA for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:07 -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 1sK3pa-0008Pp-3v for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836265; 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=hjknN8ER+pxUl3oEWYLqDMj6B7YTis7H8m8tqUgYtxU=; b=TuO0FQXzawGccRx8IulZdsY8FUNahDdR8OuNPHvKFbmfqdcQbJcH20x09pbMgpKIPXiIxB rzVbnC4dpdlkGzKhe3L6blALPMc7lmZrHjTCzt9aD0kQPzBy5FwlDQE3pR+oTYTXTD2Rv0 ReMCFQ8YW3bVjKt0Ebij/Se06WM/EKw= Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-217-_H4alwXsNUyecnDTgFhNfQ-1; Wed, 19 Jun 2024 18:31:04 -0400 X-MC-Unique: _H4alwXsNUyecnDTgFhNfQ-1 Received: by mail-yb1-f200.google.com with SMTP id 3f1490d57ef6-dfe5c3dab2cso39927276.2 for ; Wed, 19 Jun 2024 15:31:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836263; x=1719441063; 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=hjknN8ER+pxUl3oEWYLqDMj6B7YTis7H8m8tqUgYtxU=; b=VbXXNOqYLC5coUgDgATehyJe7bXYfskqisbrczHhpOtHt3KHDsnSsoXIDhHd0q31o+ NMle9z0o/4AM67Sj9Y5zlcosaoZZTrq4Vb/HXT/cEbEAEcShYlq6A7N+xFQzh5oNq6FV +OCbU6cBSh/zCdm40HTMtu+7lIHL4qhEyJsXF59X2g7rOaaXFxDA3beEP9+OPCBrVz1T kHrs5crN++Yn9fIWWjm8iECVt6v25yfNYPZmFYZJNoogTVJ5aAIycvVWh9nrMP5Qmuz+ zP9HxloJcz+Gp79ICFspBuFOp0gCVCiJj/2KVBmcLK6DkiZj8kRJsLJPZBKnq0ZY46Cn syZw== X-Gm-Message-State: AOJu0Yyt9fAjqrVJ2C5/vEl7PBs+DRCqzZIM9CqM8y1v05HkH2iZon4i nBbAylG825hP7mMdblOzdKo92ZANC5NrDalFnhCYWqItHy5tGAKykrApcW2DNOFJGn/3iZNqZyV tpgbAQccQYl/q8Fu3ktf0+mCmZkyjL9u/7dkRgGXqSX+so/Jl3hvSDDrVv1157Ig939sIfopONs Rkx9I0Lo2i8d6t+YPCjDQXd5HTrUio3ebS6g== X-Received: by 2002:a25:d041:0:b0:df7:8a41:3009 with SMTP id 3f1490d57ef6-e02be297ccamr3566325276.6.1718836263170; Wed, 19 Jun 2024 15:31:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOXJGwI9BE6J1QQigkV1mtskoejr1cHBXSg57t6LTJaWU8zPT9P2aLVNuM9zT8ACuPKjXRFQ== X-Received: by 2002:a25:d041:0:b0:df7:8a41:3009 with SMTP id 3f1490d57ef6-e02be297ccamr3566298276.6.1718836262429; Wed, 19 Jun 2024 15:31:02 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:31:01 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 06/11] migration/docs: Update postcopy recover session for SETUP phase Date: Wed, 19 Jun 2024 18:30:41 -0400 Message-ID: <20240619223046.1798968-7-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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. Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu --- 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 Wed Jun 19 22:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 05579C2BA1A for ; Wed, 19 Jun 2024 22:32:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pg-0001rp-2D; Wed, 19 Jun 2024 18:31:12 -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 1sK3pd-0001qx-5i for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:09 -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 1sK3pb-0008QA-79 for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836266; 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=L38AJcNNqLJeaRvR67UdJo8JcCpE6ytDh1IVL/CID4c=; b=hdK4TT4PYCMgALSCjzwIJXNn/gDmllFB9ae1khrA1rFC79dZaXDzE/AAh+iMMPsaTtJlMx p+3XI/mBDDfKx6tbckd5wxVbIe9y3ey/JPbGzxO5krBMjB4zyEf61mA16EPyN+OXSJifF9 qgmcw385TVsvtQy1B8+E3CeYCNdxBy4= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-XBOJEqq9NH6ImVnFUeF-_g-1; Wed, 19 Jun 2024 18:31:05 -0400 X-MC-Unique: XBOJEqq9NH6ImVnFUeF-_g-1 Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-5b970b125fcso45188eaf.0 for ; Wed, 19 Jun 2024 15:31:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836264; x=1719441064; 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=L38AJcNNqLJeaRvR67UdJo8JcCpE6ytDh1IVL/CID4c=; b=JEReZpsT7jPNhwZWB8DSQysVhTjOHoXToBq0LJKsxsN+eUZqGCHiT0wb9SLvpZFsY1 n+6XIGr+JXUfsIkM6RUP0LXA/R9nEzkVpO7xXK4X739boDM5w8wE5HmAaGwC9wS7lRx9 7ktRi6yiEOIUmMEhenf9hulFHB8qMopYOSE/UGP7SRfUOYhRAsRYtBKmDwAlNdAfW9y6 L/9yihmtQBKoNidk/caKsFKn33avJx4ubpYYyGUCGzzuVNlfnqWUParMriOfnO3622+X 6nkANa7mHFl5vTO5Fmr9uSweN7o6oCeVGvV8zOZSGvYtszVUl262qQon7CMZv3j5WwTO IeiQ== X-Gm-Message-State: AOJu0Yy2CZbi4SI4/2pHeU67Z4fYGwKe1Jbo+blVz2oajJhAJG+XS+VW qxCvMcVgzwHW8hYJ9ZIayUOtJtwEeSq/2USjCrOxc+52Xr/QZksteEL5ZySVdGkpX/62Q9b40Lh 869wgV1j5cSSc+8PFLmIx/SpoKS0id22qnPMP4C/Uvepfxs8x888NjYQ0wafZVqynJuzyInj1wD XOA3dt6J3tuCogGbjOQFtAC1/sa6VFCY0mAA== X-Received: by 2002:a4a:3559:0:b0:5bb:815d:e2ab with SMTP id 006d021491bc7-5c1adb96992mr3783189eaf.1.1718836264514; Wed, 19 Jun 2024 15:31:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH38j0wnCHFa+BOv3PBcU22V8rrybAa4XrPGaQVggW659b1k1Cxx1i44VX79xVPfbeNHPqeqA== X-Received: by 2002:a4a:3559:0:b0:5bb:815d:e2ab with SMTP id 006d021491bc7-5c1adb96992mr3783160eaf.1.1718836263904; Wed, 19 Jun 2024 15:31:03 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:31:03 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 07/11] tests/migration-tests: Drop most WIN32 ifdefs for postcopy failure tests Date: Wed, 19 Jun 2024 18:30:42 -0400 Message-ID: <20240619223046.1798968-8-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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. Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu --- 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 85a21ff5e9..640713bfd5 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1363,9 +1363,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; @@ -1427,8 +1427,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) { @@ -1468,7 +1468,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 @@ -1477,7 +1476,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 @@ -1506,7 +1504,6 @@ static void test_postcopy_recovery(void) test_postcopy_recovery_common(&args); } -#ifndef _WIN32 static void test_postcopy_recovery_double_fail(void) { MigrateCommon args = { @@ -1515,7 +1512,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) @@ -3693,10 +3689,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 Wed Jun 19 22:30:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E5DAC27C53 for ; Wed, 19 Jun 2024 22:33:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pi-0001sY-LQ; Wed, 19 Jun 2024 18:31:14 -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 1sK3pf-0001rn-Gw for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:11 -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 1sK3pe-0008Qb-4E for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836269; 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=SWa9Q1e98UsIyOBWNw6j1ml8M+NDcRsBv6tl/URKA74=; b=ZClBiMsOoEFbE6PeoLbewVJiFeKWHQkYMwZWBoNIikvSYuCarviyR0sh1uAA+U46bamzDp heBqLZKXBJx6MHna3d43/eKQAhqrHTo2pnysCnRcYZQoM+wBSOkUsoycX7Seeb5DFo9rho l/7wi5gQj5gX8bJ6CK7/MeNBnearPCA= 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-683-EDp9Q_2VMbmBGo0wxYFOTA-1; Wed, 19 Jun 2024 18:31:07 -0400 X-MC-Unique: EDp9Q_2VMbmBGo0wxYFOTA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6b4da351183so910036d6.3 for ; Wed, 19 Jun 2024 15:31:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836266; x=1719441066; 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=SWa9Q1e98UsIyOBWNw6j1ml8M+NDcRsBv6tl/URKA74=; b=aynQGjNKJOdYWU+zbwxtR+ASDoZqAk1X1DyAJVBv3ZRP6ID+9bzNgl9ZYxSrP8ZPGZ M76gtbH8AAt/odcoPiTZIAlu4yRf1/KTJ+1JUkHm4OXURako921PTKtYf2Y3FklulBZ1 v96jOkWm7dl6pkJs8j0gMVzVR5mNWSvU8INozZyeOaOxxyvv7kGn7WWygbCyqIvY3CAJ yJiekgdOSwbB/3BTxWpzVzdPXtadGHuy2g9R/F3ZpB7bN6ntLOPaNNIXfsMqTJ7DgjmH JjZ3oeOtpI9OTs/XqUfgf62/nl9+P9uZtcTgIDnucgIv5+yiGw538sVR1NPN7Ivw6S3W b4Eg== X-Gm-Message-State: AOJu0YyWTPKh0krLaczZSnzBw8JeLsXYT9BRfYCK3si9e8y14j0YpR3I D3FuSMr2qHA5c9uB4JZQ9lv1win7XSc6iJ0LLLoWTNdJr8WxBGGjkERUI/lr4XNd28iS3qOq7Tt UHmSZ2eSW4lAXA1RWzf5sortgzW8mN29i8Pxay8Gwki9MgtLaOXttr/82MnkSMJddPPTTFwrWMi eR1LT55kKdUbTPltpRiUV7fh7NKxrOGv8sJA== X-Received: by 2002:a05:6214:2242:b0:6b2:bf2e:b273 with SMTP id 6a1803df08f44-6b501ec378dmr39903816d6.3.1718836266488; Wed, 19 Jun 2024 15:31:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkaFqAN1Rk+ovLrV0J0Zetg/t5k5YaCUTgLletS4O0OYdRDuBqtOeu4RaDZvhpFkVErl6jiw== X-Received: by 2002:a05:6214:2242:b0:6b2:bf2e:b273 with SMTP id 6a1803df08f44-6b501ec378dmr39903506d6.3.1718836265908; Wed, 19 Jun 2024 15:31:05 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:31:04 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 08/11] tests/migration-tests: Always enable migration events Date: Wed, 19 Jun 2024 18:30:43 -0400 Message-ID: <20240619223046.1798968-9-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Libvirt should always enable it, so it'll be nice qtest also cover that for all tests on both sides. migrate_incoming_qmp() used to enable it only on dst, now we enable them on both, as we'll start to sanity check events even on the src QEMU. We'll need to leave the one in migrate_incoming_qmp(), because virtio-net-failover test uses that one only, and it relies on the events to work. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/qtest/migration-helpers.c | 1 + tests/qtest/migration-test.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index 0ac49ceb54..2ca4425d71 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -258,6 +258,7 @@ void migrate_incoming_qmp(QTestState *to, const char *uri, const char *fmt, ...) g_assert(!qdict_haskey(args, "uri")); qdict_put_str(args, "uri", uri); + /* This function relies on the event to work, make sure it's enabled */ migrate_set_capability(to, "events", true); rsp = qtest_qmp(to, "{ 'execute': 'migrate-incoming', 'arguments': %p}", diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 640713bfd5..c015e801ac 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -851,6 +851,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 Wed Jun 19 22:30:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704644 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 433D2C27C53 for ; Wed, 19 Jun 2024 22:32:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pl-0001tU-1C; Wed, 19 Jun 2024 18:31:17 -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 1sK3pi-0001sw-OB for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:14 -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 1sK3ph-0008Qr-8w for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836272; 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=19AZ/BFvRgTzFKO3dCG34bGOqdNgmbaJrAQjFDpmRek=; b=HLX8+Ye2sGO41sLRQp9BZVG8PEZ+eB6ns3Cq+tpGRsd/OuMBjnoB0G2KOfNSpT/gMhus0x CzKvYNcNJT2ZrW+wDDsucf9KW270wNkGmH3ULY13RO1K8OaweFFdLl8SpbKRZslDrINrta GUPcdlCV12JwMiqxL3Jq8tF9vrrcPVw= 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-1-OHX9OYWkOOS7pGLBFgX2nw-1; Wed, 19 Jun 2024 18:31:09 -0400 X-MC-Unique: OHX9OYWkOOS7pGLBFgX2nw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6b50433ada9so922816d6.3 for ; Wed, 19 Jun 2024 15:31:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836268; x=1719441068; 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=19AZ/BFvRgTzFKO3dCG34bGOqdNgmbaJrAQjFDpmRek=; b=H+Xvaumf+bZ4VVWt+OuED0VUbGpxHHRFc/kNR/zZDIuRl+MeXyVcHLswiuagIyIcaE wVAJ5bKcjY912wZIjwS1MJVWteoZM/NDWNG9VKiKUt240ZFEuKXNt+6ONwNFYYFB0c+/ KlRVc9iEcJTgMWwVO+kROxh7dwYtCVmRObf5BIERKoftGxBgLXhmMpfRI8VhWvyMfHkE oInTXrJSqDuL2YQJ6IzkpiNrt3u/KrEtcSJhdC0qZK3DW6wNsF+cAeFBbTmt6gr3nmHc 4O8/0azaWPSqCXL9ZYJNE0UxP9BTUZRF9FNDY8pNQiCC5Is168tAYKRCyZxyqC5k4h1m WI4g== X-Gm-Message-State: AOJu0YySZN/Yr8xqsqH/al6oO+ipYFNIcvdJfKNYKBQ0gRIw/ev4W2OZ 57YZ3D16Gq4PXT78rdoCV/8uu3eggOxP3O/kEnxKHoGI5lDwkXLb+5BRdiTgvsLzyLCnJUi6GFa xLdqevTkR9v7LRcgw6hox8SS6MMi6u+ohRMgVRhAfPpY6y0geauNlEbcPSWDn4972e8pPPMuaCy forSwDv/pIIpVKSz0mWL56pZC84Li89RAAyw== X-Received: by 2002:ad4:5ecc:0:b0:6aa:3158:e8c9 with SMTP id 6a1803df08f44-6b501d24869mr40330086d6.0.1718836268485; Wed, 19 Jun 2024 15:31:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbT5Xa4fdcxcAxZMlK8ui5n+/xVTbpenhsUJTEu2pPUTECIW0TZrdq59HkL7SgaJ9c7wyyBQ== X-Received: by 2002:ad4:5ecc:0:b0:6aa:3158:e8c9 with SMTP id 6a1803df08f44-6b501d24869mr40329746d6.0.1718836267746; Wed, 19 Jun 2024 15:31:07 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:31:06 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 09/11] tests/migration-tests: migration_event_wait() Date: Wed, 19 Jun 2024 18:30:44 -0400 Message-ID: <20240619223046.1798968-10-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Introduce a small helper to wait for a migration event, generalized from the incoming migration path. Make the helper easier to use by allowing it to keep waiting until the expected event is received. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-helpers.c | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index 50095fca4a..72dba369fb 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -63,4 +63,6 @@ static inline bool probe_o_direct_support(const char *tmpfs) } #endif 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 2ca4425d71..84f49db85e 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -249,7 +249,7 @@ void migrate_set_capability(QTestState *who, const char *capability, void migrate_incoming_qmp(QTestState *to, const char *uri, const char *fmt, ...) { va_list ap; - QDict *args, *rsp, *data; + QDict *args, *rsp; va_start(ap, fmt); args = qdict_from_vjsonf_nofail(fmt, ap); @@ -272,14 +272,7 @@ void migrate_incoming_qmp(QTestState *to, const char *uri, const char *fmt, ...) g_assert(qdict_haskey(rsp, "return")); qobject_unref(rsp); - rsp = qtest_qmp_eventwait_ref(to, "MIGRATION"); - g_assert(qdict_haskey(rsp, "data")); - - data = qdict_get_qdict(rsp, "data"); - g_assert(qdict_haskey(data, "status")); - g_assert_cmpstr(qdict_get_str(data, "status"), ==, "setup"); - - qobject_unref(rsp); + migration_event_wait(to, "setup"); } /* @@ -518,3 +511,23 @@ bool probe_o_direct_support(const char *tmpfs) return true; } #endif + +/* + * 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); +} From patchwork Wed Jun 19 22:30:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0100DC27C53 for ; Wed, 19 Jun 2024 22:32:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pl-0001to-Jc; Wed, 19 Jun 2024 18:31:17 -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 1sK3pk-0001tL-Hj for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:16 -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 1sK3pj-0008R3-4o for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836274; 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=kDX+BRT7uTcZoq/ChEkBCspRZIFbadf0mqmyYyfPnsg=; b=SuuK63vIgM1jkeKkvTuthrVXzccRWyoIEAtEXWlD8AtUTl4+KN1wEnEPfMSaqrS8E4LTLJ Z5Ivrjutkwubl+wpD+r+3q1FcGrRcm5O+xUkscMe4DSrLzpwnT1bqhIpHSimlTCpyQz09z rZAcdS/NDiqRFtrwuDtjy0Jr9MHXCvg= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-SJ90yNxQN46a7FIBho6uWQ-1; Wed, 19 Jun 2024 18:31:13 -0400 X-MC-Unique: SJ90yNxQN46a7FIBho6uWQ-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-5b970b125fcso45216eaf.0 for ; Wed, 19 Jun 2024 15:31:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836272; x=1719441072; 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=kDX+BRT7uTcZoq/ChEkBCspRZIFbadf0mqmyYyfPnsg=; b=olAlHXvVBElNeJnsoSARaV7EsO0gEqFJ4CiJg7NHzWuCGWBi3qlms/rNWy6gE6sb12 FGj6TtfKeIOiwBephgz6SvWQQmt+9xVwuWcr8Z/c5GWepNkW1WO2dbxSK1GTVWisV9Yk 7ZuS8OmnTmb8ef1JdCE4OnZj505GVub17IkaICJueb2B7/F8UiTPiyItckAUdtNX262H A9C07BVq3f4xPHzO3HeBLpOLcanL0mmRNJdnlspbsVsUIIr8xskWxi9sOfg2tQnrZV2+ cBT1SC9o3V9jUiwoB9ERHIPiFURmPTQKM+nDCTHIsslYoqyHDww/KymkUH0PqB959oZj +ZKA== X-Gm-Message-State: AOJu0YzggBgJ/JaptPdFDQIaJlxrG7SEO4WHA5CY2xhciK6KtjM0HP3y 6XbLQBzZ2dJrHKN0pLQ1f9O82/tbZSnmZK0xiybyJiic23GbPRoSNQoUAsoA6+LnZLdD/QvmzJX IINaik3G6EWBdBu+2EFCk+a//icnEIRuz4C1s2Hh7JIMRt8scCLZHvmOLSzTBPqG3oFuDr/x/2A +jryRKw8VDNvQN1wYlFobeUSBGDyhzIjXRJg== X-Received: by 2002:a05:6830:2b26:b0:6fb:97fb:8d09 with SMTP id 46e09a7af769-700733764afmr4202056a34.1.1718836271681; Wed, 19 Jun 2024 15:31:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSyuTT/IdPzWkqHVui5o8WhFEehjxYkdSqtjZmbgbMSSaTXmFptTg59j7yX6MStwaydXENJA== X-Received: by 2002:a05:6830:2b26:b0:6fb:97fb:8d09 with SMTP id 46e09a7af769-700733764afmr4201955a34.1.1718836269041; Wed, 19 Jun 2024 15:31:09 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:31:08 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 10/11] tests/migration-tests: Verify postcopy-recover-setup status Date: Wed, 19 Jun 2024 18:30:45 -0400 Message-ID: <20240619223046.1798968-11-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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-test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index c015e801ac..de81e28088 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1412,6 +1412,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 Wed Jun 19 22:30:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13704648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94012C27C53 for ; Wed, 19 Jun 2024 22:32:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK3pq-0001wP-CK; Wed, 19 Jun 2024 18:31:22 -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 1sK3pp-0001wA-8e for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:21 -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 1sK3pn-0008Sd-9p for qemu-devel@nongnu.org; Wed, 19 Jun 2024 18:31:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718836278; 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=JFT2jGiD3g0jPKvPAJ8TR6jC43QPlRfHqiMRMDNZuHA=; b=JJaKkMPqlxs3dPq48sU4YbGVgsLmYi46Po8hknRmwkJOoY73GseAaMa6/YIyyZ1AwujO6u I5q/s4Slc3EvSbmS/HIXy2phbO+Blf55zZ+g0MN61uM5/V6PER3eRo5TbXqzZEHRrCEGfs fNhYqMx560YKXSKm02fPwK1kmLmdB7o= Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-Sd7XmWodPQylL_SASId15Q-1; Wed, 19 Jun 2024 18:31:14 -0400 X-MC-Unique: Sd7XmWodPQylL_SASId15Q-1 Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-dfdb41f87cbso51076276.0 for ; Wed, 19 Jun 2024 15:31:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718836274; x=1719441074; 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=JFT2jGiD3g0jPKvPAJ8TR6jC43QPlRfHqiMRMDNZuHA=; b=bKQG+UsmwNuS4VJ2E8h0fVtx0IhM8x+Pcd/bDZogkzG4u2XUDRM9ECpqQVe6kb9or3 v6f8nAiIPLwTgbwGYEqrNXSYQtm9z4U8G4cbXVHOHWxvSa9+kXsKFeoxY+axj9bL6in/ XwfUzT8coO/EiuSZmpITMC2d9IO0/fargSQnU9oUQ4u/q524Z1KZPTd+YKEJ0rjyOzfH NYg7msUBMcF8uszRCKvJIPEEUOsutbDUrgn1DHGh2coIHamtiYgIjmBVLEXn/I4jd6Ij yEVu1hYUm+pzN0pkHMUH9FxdxktVCB6w2xUu6QU5Hdra/DnNfQ3U8OxVFwUwlnUhQ1e0 mEFw== X-Gm-Message-State: AOJu0YxuFmy1zrTkgsrK+pVr2ZdvnQNsckG7m/x7p63PN0EaEwHTyRG0 f2601FazRehvonLjvHZHjHk+bUmHUr7547JTZ1zubAeNTquCszoHGy2Zxt7DRlgGucwuJdf2RXB 2E8AqutKn5w9gcxFUvcbUoyMkBCgHuJCptnIELNRVyG5jhcRUZvhW08WUMHj3x1U+D2OB2lAnCs 4jL8iH8ZSUn6dUY36OK/TQv2JFDTnJAr+mVg== X-Received: by 2002:a25:3f47:0:b0:e02:b52a:b79f with SMTP id 3f1490d57ef6-e02be22ce36mr3382300276.3.1718836273649; Wed, 19 Jun 2024 15:31:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAwywbyWdVlOX1db4OT8cRQl3tpMTxvT7rqU0kLnIj7CPSjiPOt0mxDM/U51di1N0eoDB5Sw== X-Received: by 2002:a25:3f47:0:b0:e02:b52a:b79f with SMTP id 3f1490d57ef6-e02be22ce36mr3382283276.3.1718836273122; Wed, 19 Jun 2024 15:31:13 -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 6a1803df08f44-6b2a5c466bfsm80844256d6.68.2024.06.19.15.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 15:31:11 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Markus Armbruster , Bandan Das , Zhijian Li , Fabiano Rosas , Jiri Denemark , Prasad Pandit , Eric Blake , peterx@redhat.com Subject: [PATCH v3 11/11] tests/migration-tests: Cover postcopy failure on reconnect Date: Wed, 19 Jun 2024 18:30:46 -0400 Message-ID: <20240619223046.1798968-12-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240619223046.1798968-1-peterx@redhat.com> References: <20240619223046.1798968-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.144, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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. Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu --- tests/qtest/migration-test.c | 95 +++++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 18 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index de81e28088..fe33b86783 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -72,6 +72,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 @@ -692,7 +703,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, @@ -1370,12 +1381,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); @@ -1409,6 +1424,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}"); @@ -1418,28 +1441,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 happen 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 } @@ -1481,12 +1529,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 */ } @@ -1517,10 +1565,19 @@ static void test_postcopy_recovery(void) test_postcopy_recovery_common(&args); } -static void test_postcopy_recovery_double_fail(void) +static void test_postcopy_recovery_fail_handshake(void) +{ + MigrateCommon args = { + .postcopy_recovery_fail_stage = POSTCOPY_FAIL_RECOVERY, + }; + + test_postcopy_recovery_common(&args); +} + +static void test_postcopy_recovery_fail_reconnect(void) { MigrateCommon args = { - .postcopy_recovery_test_fail = true, + .postcopy_recovery_fail_stage = POSTCOPY_FAIL_CHANNEL_ESTABLISH, }; test_postcopy_recovery_common(&args); @@ -3702,8 +3759,10 @@ int main(int argc, char **argv) test_postcopy_preempt); migration_test_add("/migration/postcopy/preempt/recovery/plain", test_postcopy_preempt_recovery); - migration_test_add("/migration/postcopy/recovery/double-failures", - test_postcopy_recovery_double_fail); + migration_test_add("/migration/postcopy/recovery/double-failures/handshake", + test_postcopy_recovery_fail_handshake); + migration_test_add("/migration/postcopy/recovery/double-failures/reconnect", + test_postcopy_recovery_fail_reconnect); if (is_x86) { migration_test_add("/migration/postcopy/suspend", test_postcopy_suspend);