From nobody Thu May 2 10:48:12 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.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 1512152577346131.05423058252597; Fri, 1 Dec 2017 10:22:57 -0800 (PST) Received: from localhost ([::1]:59426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKpxZ-0001Ru-3l for importer@patchew.org; Fri, 01 Dec 2017 13:22:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKoGg-0002ca-5p for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:34:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eKoGb-00012o-5e for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:34:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eKoGa-00011r-QU for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:34:21 -0500 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 84485C0586A2 for ; Fri, 1 Dec 2017 12:57:56 +0000 (UTC) Received: from secure.mitica (ovpn-117-171.ams2.redhat.com [10.36.117.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 336C3600D4; Fri, 1 Dec 2017 12:57:55 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 1 Dec 2017 13:57:49 +0100 Message-Id: <20171201125750.1372-2-quintela@redhat.com> In-Reply-To: <20171201125750.1372-1-quintela@redhat.com> References: <20171201125750.1372-1-quintela@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.31]); Fri, 01 Dec 2017 12:57:56 +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 v3 1/2] migration: Create tcp_port parameter 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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" It will be used to store the uri tcp_port parameter. This is the only parameter than can change and we can need to be able to connect to it. Signed-off-by: Juan Quintela -- This used to be uri parameter, but it has so many troubles to reproduce that it don't just make sense. --- hmp.c | 7 +++++++ migration/migration.c | 10 ++++++++++ qapi/migration.json | 19 ++++++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index 1727c9c003..6387d6d517 100644 --- a/hmp.c +++ b/hmp.c @@ -345,6 +345,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); + monitor_printf(mon, "%s: %d\n", + MigrationParameter_str(MIGRATION_PARAMETER_TCP_PORT), + params->tcp_port); } =20 qapi_free_MigrationParameters(params); @@ -1659,6 +1662,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) } p->xbzrle_cache_size =3D cache_size; break; + case MIGRATION_PARAMETER_TCP_PORT: + p->has_tcp_port =3D true; + visit_type_uint16(v, param, &p->tcp_port, &err); + break; default: assert(0); } diff --git a/migration/migration.c b/migration/migration.c index 19917a4b5b..abc02d4efd 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -517,6 +517,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->x_multifd_page_count =3D s->parameters.x_multifd_page_count; params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; + params->has_tcp_port =3D true; + params->tcp_port =3D s->parameters.tcp_port; =20 return params; } @@ -884,6 +886,9 @@ static void migrate_params_test_apply(MigrateSetParamet= ers *params, if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size =3D params->xbzrle_cache_size; } + if (params->has_tcp_port) { + dest->tcp_port =3D params->tcp_port; + } } =20 static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) @@ -956,6 +961,9 @@ static void migrate_params_apply(MigrateSetParameters *= params, Error **errp) s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); } + if (params->has_tcp_port) { + s->parameters.tcp_port =3D params->tcp_port; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) @@ -2422,6 +2430,8 @@ static Property migration_properties[] =3D { DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), + DEFINE_PROP_UINT16("x-tcp-port", MigrationState, + parameters.tcp_port, 0), =20 /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), diff --git a/qapi/migration.json b/qapi/migration.json index 4cd3d13158..e2a1d86216 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -488,6 +488,9 @@ # and a power of 2 # (Since 2.11) # +# @tcp-port: Only used for tcp, to know what is the real port +# (Since 2.12) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -496,7 +499,7 @@ 'tls-creds', 'tls-hostname', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'x-multifd-channels', 'x-multifd-page-count', - 'xbzrle-cache-size' ] } + 'xbzrle-cache-size', 'tcp-port' ] } =20 ## # @MigrateSetParameters: @@ -564,6 +567,10 @@ # needs to be a multiple of the target page size # and a power of 2 # (Since 2.11) +# +# @tcp-port: Only used for tcp, to know what is the real port +# (Since 2.12) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -582,7 +589,8 @@ '*block-incremental': 'bool', '*x-multifd-channels': 'int', '*x-multifd-page-count': 'int', - '*xbzrle-cache-size': 'size' } } + '*xbzrle-cache-size': 'size' , + '*tcp-port': 'uint16'} } =20 ## # @migrate-set-parameters: @@ -665,6 +673,10 @@ # needs to be a multiple of the target page size # and a power of 2 # (Since 2.11) +# +# @tcp-port: Only used for tcp, to know what is the real port +# (Since 2.12) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -681,7 +693,8 @@ '*block-incremental': 'bool' , '*x-multifd-channels': 'uint8', '*x-multifd-page-count': 'uint32', - '*xbzrle-cache-size': 'size' } } + '*xbzrle-cache-size': 'size', + '*tcp-port': 'uint16'} } =20 ## # @query-migrate-parameters: --=20 2.14.3 From nobody Thu May 2 10:48:12 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.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 1512152212799895.9764123572673; Fri, 1 Dec 2017 10:16:52 -0800 (PST) Received: from localhost ([::1]:59381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKpra-0003uK-KQ for importer@patchew.org; Fri, 01 Dec 2017 13:16:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKoGL-0002KH-JJ for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:34:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eKoGG-0000qC-MJ for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:34:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eKoGG-0000pF-EB for qemu-devel@nongnu.org; Fri, 01 Dec 2017 11:34:00 -0500 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 34122820FF for ; Fri, 1 Dec 2017 12:57:58 +0000 (UTC) Received: from secure.mitica (ovpn-117-171.ams2.redhat.com [10.36.117.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id D94DB600D4; Fri, 1 Dec 2017 12:57:56 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 1 Dec 2017 13:57:50 +0100 Message-Id: <20171201125750.1372-3-quintela@redhat.com> In-Reply-To: <20171201125750.1372-1-quintela@redhat.com> References: <20171201125750.1372-1-quintela@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.26]); Fri, 01 Dec 2017 12:57:58 +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 v3 2/2] migration: Set the migration tcp port 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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" We can set the port parameter as zero. This patch lets us know what port the system was choosen for us. Now we can migrate to this place. Signed-off-by: Juan Quintela -- This was migrate_set_uri(), but as we only need the tcp_port, change to that one. --- migration/migration.c | 10 ++++++++++ migration/migration.h | 2 ++ migration/socket.c | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index abc02d4efd..b3e396a382 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -240,6 +240,16 @@ void migrate_send_rp_req_pages(MigrationIncomingState = *mis, const char *rbname, } } =20 +void migrate_set_port(const uint16_t port, Error **errp) +{ + MigrateSetParameters p =3D { + .has_tcp_port =3D true, + .tcp_port =3D port, + }; + + qmp_migrate_set_parameters(&p, errp); +} + void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; diff --git a/migration/migration.h b/migration/migration.h index 663415fe48..53153a9eca 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -210,4 +210,6 @@ void migrate_send_rp_pong(MigrationIncomingState *mis, void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rb= name, ram_addr_t start, size_t len); =20 +void migrate_set_port(const uint16_t port, Error **errp); + #endif diff --git a/migration/socket.c b/migration/socket.c index 3a8232dd2d..248a798543 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -15,6 +15,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" =20 #include "qemu-common.h" #include "qemu/error-report.h" @@ -162,17 +163,24 @@ out: } =20 =20 -static void socket_start_incoming_migration(SocketAddress *saddr, - Error **errp) +static SocketAddress *socket_start_incoming_migration(SocketAddress *saddr, + Error **errp) { QIOChannelSocket *listen_ioc =3D qio_channel_socket_new(); + SocketAddress *address; =20 qio_channel_set_name(QIO_CHANNEL(listen_ioc), "migration-socket-listener"); =20 if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { object_unref(OBJECT(listen_ioc)); - return; + return NULL; + } + + address =3D qio_channel_socket_get_local_address(listen_ioc, errp); + if (address < 0) { + object_unref(OBJECT(listen_ioc)); + return NULL; } =20 qio_channel_add_watch(QIO_CHANNEL(listen_ioc), @@ -180,14 +188,28 @@ static void socket_start_incoming_migration(SocketAdd= ress *saddr, socket_accept_incoming_migration, listen_ioc, (GDestroyNotify)object_unref); + return address; } =20 void tcp_start_incoming_migration(const char *host_port, Error **errp) { Error *err =3D NULL; SocketAddress *saddr =3D tcp_build_address(host_port, &err); + if (!err) { - socket_start_incoming_migration(saddr, &err); + SocketAddress *address =3D socket_start_incoming_migration(saddr, = &err); + + if (address) { + unsigned long long port; + + if (parse_uint_full(address->u.inet.port, &port, 10) < 0) { + error_setg(errp, "error parsing port in '%s'", + address->u.inet.port); + } else { + migrate_set_port(port, errp); + } + qapi_free_SocketAddress(address); + } } qapi_free_SocketAddress(saddr); error_propagate(errp, err); @@ -196,6 +218,9 @@ void tcp_start_incoming_migration(const char *host_port= , Error **errp) void unix_start_incoming_migration(const char *path, Error **errp) { SocketAddress *saddr =3D unix_build_address(path); - socket_start_incoming_migration(saddr, errp); + SocketAddress *address; + + address =3D socket_start_incoming_migration(saddr, errp); + qapi_free_SocketAddress(address); qapi_free_SocketAddress(saddr); } --=20 2.14.3