From nobody Tue Feb 10 12:57:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501230173057671.3196634370537; Fri, 28 Jul 2017 01:22:53 -0700 (PDT) Received: from localhost ([::1]:46729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1db0Xr-0000DV-LZ for importer@patchew.org; Fri, 28 Jul 2017 04:22:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1db0JO-0001Cw-Lq for qemu-devel@nongnu.org; Fri, 28 Jul 2017 04:07:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1db0JN-0001PK-Io for qemu-devel@nongnu.org; Fri, 28 Jul 2017 04:07:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40036) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1db0JN-0001P1-8i for qemu-devel@nongnu.org; Fri, 28 Jul 2017 04:07:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A5E712394; Fri, 28 Jul 2017 08:07:52 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9000600C2; Fri, 28 Jul 2017 08:07:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3A5E712394 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 28 Jul 2017 16:06:26 +0800 Message-Id: <1501229198-30588-18-git-send-email-peterx@redhat.com> In-Reply-To: <1501229198-30588-1-git-send-email-peterx@redhat.com> References: <1501229198-30588-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 28 Jul 2017 08:07:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 17/29] migration: rebuild channel on source X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Andrea Arcangeli , Juan Quintela , Alexey Perevalov , peterx@redhat.com, "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch detects the "resume" flag of migration command, rebuild the channels only if the flag is set. Signed-off-by: Peter Xu --- migration/migration.c | 52 ++++++++++++++++++++++++++++++++++++++++-------= ---- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 36ff8c3..64de0ee 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1244,6 +1244,15 @@ void qmp_migrate(const char *uri, bool has_blk, bool= blk, MigrationState *s =3D migrate_get_current(); const char *p; =20 + if (has_resume && resume) { + if (s->state !=3D MIGRATION_STATUS_POSTCOPY_PAUSED) { + error_setg(errp, "Cannot resume if there is no " + "paused migration"); + return; + } + goto do_resume; + } + if (migration_is_setup_or_active(s->state) || s->state =3D=3D MIGRATION_STATUS_CANCELLING || s->state =3D=3D MIGRATION_STATUS_COLO) { @@ -1279,6 +1288,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool = blk, =20 s =3D migrate_init(); =20 +do_resume: if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); #ifdef CONFIG_RDMA @@ -1700,7 +1710,8 @@ out: return NULL; } =20 -static int open_return_path_on_source(MigrationState *ms) +static int open_return_path_on_source(MigrationState *ms, + bool create_thread) { =20 ms->rp_state.from_dst_file =3D qemu_file_get_return_path(ms->to_dst_fi= le); @@ -1709,6 +1720,12 @@ static int open_return_path_on_source(MigrationState= *ms) } =20 trace_open_return_path_on_source(); + + if (!create_thread) { + /* We're done */ + return 0; + } + qemu_thread_create(&ms->rp_state.rp_thread, "return path", source_return_path_thread, ms, QEMU_THREAD_JOINABLE= ); =20 @@ -2249,15 +2266,24 @@ static void *migration_thread(void *opaque) =20 void migrate_fd_connect(MigrationState *s) { - s->expected_downtime =3D s->parameters.downtime_limit; - s->cleanup_bh =3D qemu_bh_new(migrate_fd_cleanup, s); + int64_t rate_limit; + bool resume =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_PAUSED; =20 - qemu_file_set_blocking(s->to_dst_file, true); - qemu_file_set_rate_limit(s->to_dst_file, - s->parameters.max_bandwidth / XFER_LIMIT_RATI= O); + if (resume) { + /* This is a resumed migration */ + rate_limit =3D INT64_MAX; + } else { + /* This is a fresh new migration */ + rate_limit =3D s->parameters.max_bandwidth / XFER_LIMIT_RATIO; + s->expected_downtime =3D s->parameters.downtime_limit; + s->cleanup_bh =3D qemu_bh_new(migrate_fd_cleanup, s); =20 - /* Notify before starting migration thread */ - notifier_list_notify(&migration_state_notifiers, s); + /* Notify before starting migration thread */ + notifier_list_notify(&migration_state_notifiers, s); + } + + qemu_file_set_rate_limit(s->to_dst_file, rate_limit); + qemu_file_set_blocking(s->to_dst_file, true); =20 /* * Open the return path. For postcopy, it is used exclusively. For @@ -2265,15 +2291,19 @@ void migrate_fd_connect(MigrationState *s) * QEMU uses the return path. */ if (migrate_postcopy_ram() || migrate_use_return_path()) { - if (open_return_path_on_source(s)) { + if (open_return_path_on_source(s, !resume)) { error_report("Unable to open return-path for postcopy"); - migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, - MIGRATION_STATUS_FAILED); + migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED= ); migrate_fd_cleanup(s); return; } } =20 + if (resume) { + /* TODO: do the resume logic */ + return; + } + qemu_thread_create(&s->thread, "live_migration", migration_thread, s, QEMU_THREAD_JOINABLE); s->migration_thread_running =3D true; --=20 2.7.4