From nobody Sun Apr 28 19:06:42 2024 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.zoho.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 1490715006222227.8186818349094; Tue, 28 Mar 2017 08:30:06 -0700 (PDT) Received: from localhost ([::1]:53932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst4O-0000KL-GN for importer@patchew.org; Tue, 28 Mar 2017 11:30:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst2o-0007Uj-4p for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cst2k-0006zZ-1j for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cst2j-0006zC-QA for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB06E81235 for ; Tue, 28 Mar 2017 15:28:20 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-173.ams2.redhat.com [10.36.117.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08E6281C0A; Tue, 28 Mar 2017 15:28:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DB06E81235 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=pass smtp.mailfrom=dgilbert@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DB06E81235 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, lvivier@redhat.com Date: Tue, 28 Mar 2017 16:27:40 +0100 Message-Id: <20170328152745.28186-2-dgilbert@redhat.com> In-Reply-To: <20170328152745.28186-1-dgilbert@redhat.com> References: <20170328152745.28186-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 28 Mar 2017 15:28:21 +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] [PATCH 1/6] migration/announce: Add parameters for self-announce 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: kashyap@redhat.com, germano@redhat.com, jasowang@redhat.com, armbru@redhat.com, jdenemar@redhat.com 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" From: "Dr. David Alan Gilbert" Add the parameters and wire into the set/get routines. Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ qapi-schema.json | 34 +++++++++++++++++++++++++++++++-- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 54060f7..96c4ad6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -53,6 +53,14 @@ #define MAX_MIGRATE_DOWNTIME_SECONDS 2000 #define MAX_MIGRATE_DOWNTIME (MAX_MIGRATE_DOWNTIME_SECONDS * 1000) =20 +/* Parameters for self_announce_delay giving a stream of RARP/ARP + * packets after migration. + */ +#define DEFAULT_MIGRATE_ANNOUNCE_INITIAL 50 +#define DEFAULT_MIGRATE_ANNOUNCE_MAX 550 +#define DEFAULT_MIGRATE_ANNOUNCE_ROUNDS 5 +#define DEFAULT_MIGRATE_ANNOUNCE_STEP 100 + /* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8 /* Default decompression thread count, usually decompression is at @@ -97,6 +105,10 @@ MigrationState *migrate_get_current(void) .xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE, .mbps =3D -1, .parameters =3D { + .announce_initial =3D DEFAULT_MIGRATE_ANNOUNCE_INITIAL, + .announce_max =3D DEFAULT_MIGRATE_ANNOUNCE_MAX, + .announce_rounds =3D DEFAULT_MIGRATE_ANNOUNCE_ROUNDS, + .announce_step =3D DEFAULT_MIGRATE_ANNOUNCE_STEP, .compress_level =3D DEFAULT_MIGRATE_COMPRESS_LEVEL, .compress_threads =3D DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, .decompress_threads =3D DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUN= T, @@ -580,6 +592,14 @@ MigrationParameters *qmp_query_migrate_parameters(Erro= r **errp) MigrationState *s =3D migrate_get_current(); =20 params =3D g_malloc0(sizeof(*params)); + params->has_announce_initial =3D true; + params->announce_initial =3D s->parameters.announce_initial; + params->has_announce_max =3D true; + params->announce_max =3D s->parameters.announce_max; + params->has_announce_rounds =3D true; + params->announce_rounds =3D s->parameters.announce_rounds; + params->has_announce_step =3D true; + params->announce_step =3D s->parameters.announce_step; params->has_compress_level =3D true; params->compress_level =3D s->parameters.compress_level; params->has_compress_threads =3D true; @@ -809,6 +829,26 @@ void qmp_migrate_set_parameters(MigrationParameters *p= arams, Error **errp) { MigrationState *s =3D migrate_get_current(); =20 + if (params->has_announce_initial && + (params->announce_initial < 1 || params->announce_initial > 100000= )) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "announce_initial", + "is invalid, it should be in the range of 1 to 100000 m= s"); + } + if (params->has_announce_max && + (params->announce_max < 1 || params->announce_max > 100000)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "announce_max", + "is invalid, it should be in the range of 1 to 100000 m= s"); + } + if (params->has_announce_rounds && + (params->announce_rounds < 1 || params->announce_rounds > 1000)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "announce_rounds", + "is invalid, it should be in the range of 1 to 1000"); + } + if (params->has_announce_step && + (params->announce_step < 0 || params->announce_step > 10000)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "announce_step", + "is invalid, it should be in the range of 1 to 10000 ms= "); + } if (params->has_compress_level && (params->compress_level < 0 || params->compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", @@ -865,6 +905,18 @@ void qmp_migrate_set_parameters(MigrationParameters *p= arams, Error **errp) "is invalid, it should be positive"); } =20 + if (params->has_announce_initial) { + s->parameters.announce_initial =3D params->announce_initial; + } + if (params->has_announce_max) { + s->parameters.announce_max =3D params->announce_max; + } + if (params->has_announce_rounds) { + s->parameters.announce_rounds =3D params->announce_rounds; + } + if (params->has_announce_step) { + s->parameters.announce_step =3D params->announce_step; + } if (params->has_compress_level) { s->parameters.compress_level =3D params->compress_level; } diff --git a/qapi-schema.json b/qapi-schema.json index 68a4327..ae66d2e 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -960,6 +960,18 @@ # # Migration parameters enumeration # +# @announce-initial: The inital delay (in ms) before sending the first ann= ounce +# (Since 2.10) +# +# @announce-max: The maximum delay (in ms) between packets in the announcm= ent +# (Since 2.10) +# +# @announce-rounds: The number of self-announce packets sent after migrati= on +# (Since 2.10) +# +# @announce-step: The increase in delay (in ms) between subsequent packets= in +# the announcement (Since 2.10) +# # @compress-level: Set the compression level to be used in live migration, # the compression level is an integer between 0 and 9, where 0 me= ans # no compression, 1 means the best compression speed, and 9 means= best @@ -1009,7 +1021,9 @@ # Since: 2.4 ## { 'enum': 'MigrationParameter', - 'data': ['compress-level', 'compress-threads', 'decompress-threads', + 'data': ['announce-initial', 'announce-max', + 'announce-rounds', 'announce-step', + 'compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay' ] } @@ -1038,6 +1052,18 @@ # ('query-migrate-parameters'), with the exception of tls-creds and # tls-hostname. # +# @announce-initial: The inital delay (in ms) before sending the first ann= ounce +# (Since 2.10) +# +# @announce-max: The maximum delay (in ms) between packets in the announcm= ent +# (Since 2.10) +# +# @announce-rounds: The number of self-announce packets sent after migrati= on +# (Since 2.10) +# +# @announce-step: The increase in delay (in ms) between subsequent packets= in +# the announcement (Since 2.10) +# # @compress-level: compression level # # @compress-threads: compression thread count @@ -1082,7 +1108,11 @@ # Since: 2.4 ## { 'struct': 'MigrationParameters', - 'data': { '*compress-level': 'int', + 'data': { '*announce-initial': 'int', + '*announce-max': 'int', + '*announce-rounds': 'int', + '*announce-step': 'int', + '*compress-level': 'int', '*compress-threads': 'int', '*decompress-threads': 'int', '*cpu-throttle-initial': 'int', --=20 2.9.3 From nobody Sun Apr 28 19:06:42 2024 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.zoho.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 1490715003311477.06771696105795; Tue, 28 Mar 2017 08:30:03 -0700 (PDT) Received: from localhost ([::1]:53931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst4M-0000Ip-03 for importer@patchew.org; Tue, 28 Mar 2017 11:30:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst2o-0007Uu-76 for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cst2n-00070T-91 for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55260) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cst2n-000706-3u for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19EE8C093568 for ; Tue, 28 Mar 2017 15:28:24 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-173.ams2.redhat.com [10.36.117.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25FC681C0A; Tue, 28 Mar 2017 15:28:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 19EE8C093568 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dgilbert@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 19EE8C093568 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, lvivier@redhat.com Date: Tue, 28 Mar 2017 16:27:41 +0100 Message-Id: <20170328152745.28186-3-dgilbert@redhat.com> In-Reply-To: <20170328152745.28186-1-dgilbert@redhat.com> References: <20170328152745.28186-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 28 Mar 2017 15:28:24 +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] [PATCH 2/6] migration/announce: Accessor functions for parameters 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: kashyap@redhat.com, germano@redhat.com, jasowang@redhat.com, armbru@redhat.com, jdenemar@redhat.com 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" From: "Dr. David Alan Gilbert" Standard accessor functions for each of the parameters Signed-off-by: Dr. David Alan Gilbert --- include/migration/migration.h | 5 +++++ migration/migration.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 5720c88..a75800c 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -340,6 +340,11 @@ int migrate_compress_threads(void); int migrate_decompress_threads(void); bool migrate_use_events(void); =20 +int migrate_announce_initial(void); +int migrate_announce_max(void); +int migrate_announce_rounds(void); +int migrate_announce_step(void); + /* Sending on the return path - generic and then for each message type */ void migrate_send_rp_message(MigrationIncomingState *mis, enum mig_rp_message_type message_type, diff --git a/migration/migration.c b/migration/migration.c index 96c4ad6..6ae43a6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1483,6 +1483,26 @@ int64_t migrate_xbzrle_cache_size(void) return s->xbzrle_cache_size; } =20 +int migrate_announce_initial(void) +{ + return migrate_get_current()->parameters.announce_initial; +} + +int migrate_announce_max(void) +{ + return migrate_get_current()->parameters.announce_max; +} + +int migrate_announce_rounds(void) +{ + return migrate_get_current()->parameters.announce_rounds; +} + +int migrate_announce_step(void) +{ + return migrate_get_current()->parameters.announce_step; +} + /* migration thread support */ /* * Something bad happened to the RP stream, mark an error --=20 2.9.3 From nobody Sun Apr 28 19:06:42 2024 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.zoho.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 1490715138290664.6891671133386; Tue, 28 Mar 2017 08:32:18 -0700 (PDT) Received: from localhost ([::1]:53948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst6X-0002DD-7N for importer@patchew.org; Tue, 28 Mar 2017 11:32:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst2s-0007b3-Cd for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cst2r-00071d-9R for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cst2r-00071T-1n for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1328E9F737 for ; Tue, 28 Mar 2017 15:28:28 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-173.ams2.redhat.com [10.36.117.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B36D93417; Tue, 28 Mar 2017 15:28:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1328E9F737 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dgilbert@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1328E9F737 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, lvivier@redhat.com Date: Tue, 28 Mar 2017 16:27:42 +0100 Message-Id: <20170328152745.28186-4-dgilbert@redhat.com> In-Reply-To: <20170328152745.28186-1-dgilbert@redhat.com> References: <20170328152745.28186-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 28 Mar 2017 15:28:28 +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] [PATCH 3/6] migration/announce: Use the new parameters 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: kashyap@redhat.com, germano@redhat.com, jasowang@redhat.com, armbru@redhat.com, jdenemar@redhat.com 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" From: "Dr. David Alan Gilbert" Rework the existing constants to use the new parameters. Signed-off-by: Dr. David Alan Gilbert --- hw/net/virtio-net.c | 3 ++- include/migration/migration.h | 1 + include/migration/vmstate.h | 10 ---------- migration/savevm.c | 32 ++++++++++++++++++++++++++++++-- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index c321680..b56b74a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -19,6 +19,7 @@ #include "net/tap.h" #include "qemu/error-report.h" #include "qemu/timer.h" +#include "migration/migration.h" #include "hw/virtio/virtio-net.h" #include "net/vhost_net.h" #include "hw/virtio/virtio-bus.h" @@ -1611,7 +1612,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) =20 if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { - n->announce_counter =3D SELF_ANNOUNCE_ROUNDS; + n->announce_counter =3D migrate_announce_rounds(); timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)= ); } =20 diff --git a/include/migration/migration.h b/include/migration/migration.h index a75800c..ba25dbf 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -344,6 +344,7 @@ int migrate_announce_initial(void); int migrate_announce_max(void); int migrate_announce_rounds(void); int migrate_announce_step(void); +int64_t self_announce_delay(int round); =20 /* Sending on the return path - generic and then for each message type */ void migrate_send_rp_message(MigrationIncomingState *mis, diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index f2dbf84..c7ef11d 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1003,8 +1003,6 @@ extern const VMStateInfo vmstate_info_qtailq; #define VMSTATE_END_OF_LIST() \ {} =20 -#define SELF_ANNOUNCE_ROUNDS 5 - void loadvm_free_handlers(MigrationIncomingState *mis); =20 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, @@ -1038,14 +1036,6 @@ void vmstate_register_ram(struct MemoryRegion *memor= y, DeviceState *dev); void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev); void vmstate_register_ram_global(struct MemoryRegion *memory); =20 -static inline -int64_t self_announce_delay(int round) -{ - assert(round < SELF_ANNOUNCE_ROUNDS && round > 0); - /* delay 50ms, 150ms, 250ms, ... */ - return 50 + (SELF_ANNOUNCE_ROUNDS - round - 1) * 100; -} - void dump_vmstate_json_to_file(FILE *out_fp); =20 #endif diff --git a/migration/savevm.c b/migration/savevm.c index 361a926..69bb1d2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -118,16 +118,44 @@ static void qemu_announce_self_iter(NICState *nic, vo= id *opaque) qemu_send_packet_raw(qemu_get_queue(nic), buf, len); } =20 +/* Increasing delays between packets in the network announcments, + * both in the RARPs sent by QEMU and the ARPs triggered via virtio-net + * for the guest to send. + * + * Default parameters generate delays of + * 50, 150, 250, 350 + * between 5 packets. + * which corresponds to: + * <> initial <> initial+step <> initial+2*step <> initial+3*step <> + * between 'rounds' packets + * A maximum can be used to override the step after a few packets. + */ +int64_t self_announce_delay(int round) +{ + int64_t ret; + ret =3D migrate_announce_initial() + + (migrate_announce_rounds() - round - 1) * + migrate_announce_step(); + if (ret < 0 || ret > migrate_announce_max()) { + ret =3D migrate_announce_max(); + } + return ret; +} =20 static void qemu_announce_self_once(void *opaque) { - static int count =3D SELF_ANNOUNCE_ROUNDS; + static bool once =3D true; + static int count =3D -1; QEMUTimer *timer =3D *(QEMUTimer **)opaque; =20 + if (once) { + count =3D migrate_announce_rounds(); + once =3D false; + } + qemu_foreach_nic(qemu_announce_self_iter, NULL); =20 if (--count) { - /* delay 50ms, 150ms, 250ms, ... */ timer_mod(timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + self_announce_delay(count)); } else { --=20 2.9.3 From nobody Sun Apr 28 19:06:42 2024 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.zoho.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 1490715106273906.5579389876481; Tue, 28 Mar 2017 08:31:46 -0700 (PDT) Received: from localhost ([::1]:53947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst61-0001qL-3C for importer@patchew.org; Tue, 28 Mar 2017 11:31:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst30-0007hG-J3 for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cst2w-00072d-Fz for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35743) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cst2w-00072U-7Y for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4713E7E9EE for ; Tue, 28 Mar 2017 15:28:33 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-173.ams2.redhat.com [10.36.117.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BCCB99680; Tue, 28 Mar 2017 15:28:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4713E7E9EE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dgilbert@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4713E7E9EE From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, lvivier@redhat.com Date: Tue, 28 Mar 2017 16:27:43 +0100 Message-Id: <20170328152745.28186-5-dgilbert@redhat.com> In-Reply-To: <20170328152745.28186-1-dgilbert@redhat.com> References: <20170328152745.28186-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 28 Mar 2017 15:28:33 +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] [PATCH 4/6] migration/announce: Update hmp migrate parameter info/set 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: kashyap@redhat.com, germano@redhat.com, jasowang@redhat.com, armbru@redhat.com, jdenemar@redhat.com 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" From: "Dr. David Alan Gilbert" Add the new announce parameters to HMPs migrate_parameter commands. Signed-off-by: Dr. David Alan Gilbert --- hmp.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/hmp.c b/hmp.c index edb8970..83a982a 100644 --- a/hmp.c +++ b/hmp.c @@ -285,6 +285,22 @@ void hmp_info_migrate_parameters(Monitor *mon, const Q= Dict *qdict) =20 if (params) { monitor_printf(mon, "parameters:"); + assert(params->has_announce_initial); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_ANNOUNCE_INITIAL= ], + params->announce_initial); + assert(params->has_announce_max); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_ANNOUNCE_MAX], + params->announce_max); + assert(params->has_announce_rounds); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_ANNOUNCE_ROUNDS], + params->announce_rounds); + assert(params->has_announce_step); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_ANNOUNCE_STEP], + params->announce_step); assert(params->has_compress_level); monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL], @@ -1354,6 +1370,22 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) if (strcmp(param, MigrationParameter_lookup[i]) =3D=3D 0) { MigrationParameters p =3D { 0 }; switch (i) { + case MIGRATION_PARAMETER_ANNOUNCE_INITIAL: + p.has_announce_initial =3D true; + use_int_value =3D true; + break; + case MIGRATION_PARAMETER_ANNOUNCE_MAX: + p.has_announce_max =3D true; + use_int_value =3D true; + break; + case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS: + p.has_announce_rounds =3D true; + use_int_value =3D true; + break; + case MIGRATION_PARAMETER_ANNOUNCE_STEP: + p.has_announce_step =3D true; + use_int_value =3D true; + break; case MIGRATION_PARAMETER_COMPRESS_LEVEL: p.has_compress_level =3D true; use_int_value =3D true; @@ -1410,6 +1442,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) } /* Set all integers; only one has_FOO will be set, and * the code ignores the remaining values */ + p.announce_initial =3D valueint; + p.announce_max =3D valueint; + p.announce_rounds =3D valueint; + p.announce_step =3D valueint; p.compress_level =3D valueint; p.compress_threads =3D valueint; p.decompress_threads =3D valueint; --=20 2.9.3 From nobody Sun Apr 28 19:06:42 2024 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.zoho.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 1490715027676218.02757133474324; Tue, 28 Mar 2017 08:30:27 -0700 (PDT) Received: from localhost ([::1]:53938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst4k-0000hX-BP for importer@patchew.org; Tue, 28 Mar 2017 11:30:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst32-0007jN-Jo for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cst31-00074P-Ot for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33124) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cst31-000742-HZ for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DF3CC03BD5A for ; Tue, 28 Mar 2017 15:28:38 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-173.ams2.redhat.com [10.36.117.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8613C81C0A; Tue, 28 Mar 2017 15:28:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DF3CC03BD5A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dgilbert@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9DF3CC03BD5A From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, lvivier@redhat.com Date: Tue, 28 Mar 2017 16:27:44 +0100 Message-Id: <20170328152745.28186-6-dgilbert@redhat.com> In-Reply-To: <20170328152745.28186-1-dgilbert@redhat.com> References: <20170328152745.28186-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 28 Mar 2017 15:28:38 +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] [PATCH 5/6] migration/announce: Document self-announce mechanism 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: kashyap@redhat.com, germano@redhat.com, jasowang@redhat.com, armbru@redhat.com, jdenemar@redhat.com 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" From: "Dr. David Alan Gilbert" Explain the timings and differences between the ARP and RARP streams we send. Signed-off-by: Dr. David Alan Gilbert --- docs/migration.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/docs/migration.txt b/docs/migration.txt index 1b940a8..6f939e1 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -553,3 +553,43 @@ Postcopy now works with hugetlbfs backed memory: hugepages works well, however 1GB hugepages are likely to be problema= tic since it takes ~1 second to transfer a 1GB hugepage across a 10Gbps l= ink, and until the full page is transferred the destination thread is bloc= ked. + +=3D=3D Network self announce =3D=3D + +At the end of a migration QEMU sends a sequence of packets to 'announce' t= he VMs +arrival on the new host in the hope that the L2 network will notice and st= art +sending the packets to it. This, 'self-announce' is split into two parts = that +happens at slightly different times: + + a) RARP - a RARP sequence is sent when the last of the device data has b= een + received but before the guest CPUs are started. Note that when -S is= used + to stop QEMU starting the CPUs automatically, the RARPs are still sent + at the point where the device data is received and the guest CPUs are= ready + to be started. + + b) ARPs - for guests with virtio NICs and drivers new enough to support = the + GUEST_ANNOUNCE feature, the guests are told to emit gratuitous ARPs j= ust + after the guest CPUs are started after an incoming migration. Note the + packets are generated by the guest itself and have the advantage of k= nowing + the guests IP address. + +The two sets may overlap. + +In both cases a stream of packets are sent, the number and timing can be +configured using the announce* migration parameters, which must be set pri= or +to the end of the incoming migration. + +

di

di+ds

di+2*ds

.....

+ + 'announce-rounds' packets are sent. + The gap between the 1st and 2nd packet is 'announce-initial'. + The gap between the 2nd and 3rd packet is increased by 'announce-step' + A maximum can be set such that the gap between subsequent packets stops + increasing. + + The default is: +

50ms

150ms

250ms

350ms

+ +Some complex network systems may take longer than this to reconfigure +and thus it may be useful to increase the count or delays. + --=20 2.9.3 From nobody Sun Apr 28 19:06:42 2024 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.zoho.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 1490715138772860.8585023901564; Tue, 28 Mar 2017 08:32:18 -0700 (PDT) Received: from localhost ([::1]:53949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst6X-0002Dk-GM for importer@patchew.org; Tue, 28 Mar 2017 11:32:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cst35-0007lz-4H for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cst33-00076d-SC for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54348) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cst33-000768-Jv for qemu-devel@nongnu.org; Tue, 28 Mar 2017 11:28:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5E655A5D for ; Tue, 28 Mar 2017 15:28:40 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-173.ams2.redhat.com [10.36.117.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2C1581C0A; Tue, 28 Mar 2017 15:28:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A5E655A5D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dgilbert@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A5E655A5D From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, lvivier@redhat.com Date: Tue, 28 Mar 2017 16:27:45 +0100 Message-Id: <20170328152745.28186-7-dgilbert@redhat.com> In-Reply-To: <20170328152745.28186-1-dgilbert@redhat.com> References: <20170328152745.28186-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 28 Mar 2017 15:28:40 +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] [PATCH 6/6] migration/announce: Add test 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: kashyap@redhat.com, germano@redhat.com, jasowang@redhat.com, armbru@redhat.com, jdenemar@redhat.com 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" From: "Dr. David Alan Gilbert" Add a test for the basic RARP announce. Testing the ARP would need a reasonably complex guest. Signed-off-by: Dr. David Alan Gilbert --- tests/Makefile.include | 2 + tests/announce-test.c | 165 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 167 insertions(+) create mode 100644 tests/announce-test.c diff --git a/tests/Makefile.include b/tests/Makefile.include index f3de81f..460223b 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -258,6 +258,7 @@ endif check-qtest-i386-y +=3D tests/test-netfilter$(EXESUF) check-qtest-i386-y +=3D tests/test-filter-mirror$(EXESUF) check-qtest-i386-y +=3D tests/test-filter-redirector$(EXESUF) +check-qtest-i386-y +=3D tests/announce-test$(EXESUF) check-qtest-i386-y +=3D tests/postcopy-test$(EXESUF) check-qtest-i386-y +=3D tests/test-x86-cpuid-compat$(EXESUF) check-qtest-x86_64-y +=3D $(check-qtest-i386-y) @@ -285,6 +286,7 @@ check-qtest-ppc64-y +=3D tests/boot-order-test$(EXESUF) check-qtest-ppc64-y +=3D tests/prom-env-test$(EXESUF) check-qtest-ppc64-y +=3D tests/pnv-xscom-test$(EXESUF) check-qtest-ppc64-y +=3D tests/drive_del-test$(EXESUF) +check-qtest-ppc64-y +=3D tests/announce-test$(EXESUF) check-qtest-ppc64-y +=3D tests/postcopy-test$(EXESUF) check-qtest-ppc64-y +=3D tests/boot-serial-test$(EXESUF) check-qtest-ppc64-y +=3D tests/rtas-test$(EXESUF) diff --git a/tests/announce-test.c b/tests/announce-test.c new file mode 100644 index 0000000..042d091 --- /dev/null +++ b/tests/announce-test.c @@ -0,0 +1,165 @@ +/* + * QTest testcase for migration announce packets + * + * Copyright (c) 2017 Red Hat, Inc. and/or its affiliates + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" + +#include "libqtest.h" +#include "qemu/option.h" +#include "qemu/range.h" +#include "qemu/sockets.h" +#include "sysemu/char.h" +#include "sysemu/sysemu.h" + +static const char *tmpfs; + +/* + * Events can get in the way of responses we are actually waiting for. + */ +static QDict *return_or_event(QDict *response) +{ + if (!qdict_haskey(response, "event")) { + return response; + } + + /* OK, it was an event */ + QDECREF(response); + return return_or_event(qtest_qmp_receive(global_qtest)); +} + + +static void wait_for_migration_complete(void) +{ + QDict *rsp, *rsp_return; + bool completed; + + do { + const char *status; + + rsp =3D return_or_event(qmp("{ 'execute': 'query-migrate' }")); + rsp_return =3D qdict_get_qdict(rsp, "return"); + status =3D qdict_get_str(rsp_return, "status"); + completed =3D strcmp(status, "completed") =3D=3D 0; + g_assert_cmpstr(status, !=3D, "failed"); + QDECREF(rsp); + usleep(1000 * 100); + } while (!completed); +} + +static void cleanup(const char *filename) +{ + char *path =3D g_strdup_printf("%s/%s", tmpfs, filename); + + unlink(path); + g_free(path); +} + +static void test_migrate(void) +{ + QTestState *global =3D global_qtest, *from, *to; + gchar *cmd, *cmd_dst; + QDict *rsp; + struct stat packet_stat; + char *migpath =3D g_strdup_printf("%s/migstream", tmpfs); + char *packetpath =3D g_strdup_printf("%s/packets", tmpfs); + + from =3D qtest_start("-m 2M -name source,debug-threads=3Don " + "-nographic -nodefaults " + "-netdev user,id=3Dnetuser " + " -device e1000,netdev=3Dnetuser,mac=3D00:11:22:33:= 44:55"); + + global_qtest =3D from; + cmd =3D g_strdup_printf("{ 'execute': 'migrate'," + "'arguments': { 'uri': 'exec:cat > %s' } }", + migpath); + rsp =3D qmp(cmd); + g_free(cmd); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); + + wait_for_migration_complete(); + + cmd_dst =3D g_strdup_printf("-m 2M -name dest,debug-threads=3Don " + "-nographic -nodefaults " + "-netdev user,id=3Dnetuser " + "-object filter-dump,id=3Ddump,netdev=3Dnetuser,file= =3D%s " + "-device e1000,netdev=3Dnetuser,mac=3D00:11:22:33:44= :55 " + " -incoming defer", + packetpath); + + to =3D qtest_start(cmd_dst); + g_free(cmd_dst); + + rsp =3D qmp("{ 'execute': 'migrate-set-parameters'," + "'arguments': { " + " 'announce-rounds': 6, " + " 'announce-initial': 10, " + " 'announce-max': 100, " + " 'announce-step': 40 } }"); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); + + cmd_dst =3D g_strdup_printf("{ 'execute': 'migrate-incoming'," + "'arguments': { 'uri': 'exec:cat %s' } }", + migpath); + rsp =3D return_or_event(qmp(cmd_dst)); + g_free(cmd_dst); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); + + qmp_eventwait("RESUME"); + + /* Sleep for a while to let that announce happens, + * it should be

10ms

50ms

90ms

100ms

100ms

+ * so that's at least 350ms but lets assume we're on a bit of a + * loaded host and give it a bit longer + */ + sleep(2); + qtest_quit(from); + qtest_quit(to); + + g_assert_cmpint(stat(packetpath, &packet_stat), =3D=3D, 0); + /* 480 bytes for 6 packets */ + g_assert_cmpint(packet_stat.st_size, =3D=3D, 480); + + global_qtest =3D global; + + cleanup("packetpath"); + cleanup("migpath"); +} + +int main(int argc, char **argv) +{ + char template[] =3D "/tmp/announce-test-XXXXXX"; + int ret; + + g_test_init(&argc, &argv, NULL); + + tmpfs =3D mkdtemp(template); + if (!tmpfs) { + g_test_message("mkdtemp on path (%s): %s\n", template, strerror(er= rno)); + } + g_assert(tmpfs); + + module_call_init(MODULE_INIT_QOM); + + qtest_add_func("/announce", test_migrate); + + ret =3D g_test_run(); + + g_assert_cmpint(ret, =3D=3D, 0); + + ret =3D rmdir(tmpfs); + if (ret !=3D 0) { + g_test_message("unable to rmdir: path (%s): %s\n", + tmpfs, strerror(errno)); + } + + return ret; +} --=20 2.9.3