From nobody Tue Feb 10 17:08:06 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 1522841742935651.4679807418885; Wed, 4 Apr 2018 04:35:42 -0700 (PDT) Received: from localhost ([::1]:50746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3gha-0004vG-3z for importer@patchew.org; Wed, 04 Apr 2018 07:35:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3gZs-0006pS-IB for qemu-devel@nongnu.org; Wed, 04 Apr 2018 07:27:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3gZr-0007jY-0i for qemu-devel@nongnu.org; Wed, 04 Apr 2018 07:27:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34330 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f3gZq-0007jG-RL for qemu-devel@nongnu.org; Wed, 04 Apr 2018 07:27:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FE83406E8B9 for ; Wed, 4 Apr 2018 11:27:42 +0000 (UTC) Received: from secure.mitica (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 627CD8442C; Wed, 4 Apr 2018 11:27:41 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 4 Apr 2018 13:27:27 +0200 Message-Id: <20180404112731.5922-5-quintela@redhat.com> In-Reply-To: <20180404112731.5922-1-quintela@redhat.com> References: <20180404112731.5922-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 04 Apr 2018 11:27:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 04 Apr 2018 11:27:42 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v7 4/8] migration: Create socket-address 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 parameters. We want this only for tcp, so we don't set it for other uris. We need it to know what port is migration running. 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. This used to be a port parameter. I was asked to move to SocketAddress, done. I also merged the setting of the migration tcp port in this one because now I need to free the address, and this makes it easier. This used to be x-socket-address with a single direction, now it is a list of addresses. --- hmp.c | 14 ++++++++++++++ migration/migration.c | 25 +++++++++++++++++++++++++ migration/migration.h | 1 + migration/socket.c | 11 +++++++++++ qapi/migration.json | 13 +++++++++++-- qapi/sockets.json | 13 +++++++++++++ 6 files changed, 75 insertions(+), 2 deletions(-) diff --git a/hmp.c b/hmp.c index a25c7bd9a8..caf94345c9 100644 --- a/hmp.c +++ b/hmp.c @@ -355,6 +355,20 @@ void hmp_info_migrate_parameters(Monitor *mon, const Q= Dict *qdict) monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); + if (params->has_socket_address) { + SocketAddressList *addr; + + monitor_printf(mon, "%s: [\n", + MigrationParameter_str(MIGRATION_PARAMETER_SOCKET_ADDRESS)= ); + + for (addr =3D params->socket_address; addr; addr =3D addr->nex= t) { + char *s =3D SocketAddress_to_str("", addr->value, + false, false); + monitor_printf(mon, "\t%s\n", s); + } + + monitor_printf(mon, "]\n"); + } } =20 qapi_free_MigrationParameters(params); diff --git a/migration/migration.c b/migration/migration.c index 58bd382730..71fa4c8176 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -31,6 +31,8 @@ #include "migration/vmstate.h" #include "block/block.h" #include "qapi/error.h" +#include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-sockets.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-events-migration.h" #include "qapi/qmp/qerror.h" @@ -277,6 +279,21 @@ int migrate_send_rp_req_pages(MigrationIncomingState *= mis, const char *rbname, return migrate_send_rp_message(mis, msg_type, msglen, bufc); } =20 +void migrate_set_address(SocketAddress *address) +{ + MigrationState *s =3D migrate_get_current(); + SocketAddressList *addrs; + + addrs =3D g_new0(SocketAddressList, 1); + addrs->next =3D s->parameters.socket_address; + s->parameters.socket_address =3D addrs; + + if (!s->parameters.has_socket_address) { + s->parameters.has_socket_address =3D true; + } + addrs->value =3D QAPI_CLONE(SocketAddress, address); +} + void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; @@ -564,6 +581,11 @@ MigrationParameters *qmp_query_migrate_parameters(Erro= r **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; + if (s->parameters.socket_address) { + params->has_socket_address =3D true; + params->socket_address =3D + QAPI_CLONE(SocketAddressList, s->parameters.socket_address); + } =20 return params; } @@ -2571,6 +2593,9 @@ static void migration_instance_finalize(Object *obj) qemu_mutex_destroy(&ms->error_mutex); g_free(params->tls_hostname); g_free(params->tls_creds); + if (params->socket_address) { + qapi_free_SocketAddressList(params->socket_address); + } qemu_sem_destroy(&ms->pause_sem); error_free(ms->error); } diff --git a/migration/migration.h b/migration/migration.h index 8d2f320c48..4774ee305f 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -241,5 +241,6 @@ int migrate_send_rp_req_pages(MigrationIncomingState *m= is, const char* rbname, =20 void dirty_bitmap_mig_before_vm_start(void); void init_dirty_bitmap_incoming_migration(void); +void migrate_set_address(SocketAddress *address); =20 #endif diff --git a/migration/socket.c b/migration/socket.c index 122d8ccfbe..5195fd57c5 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" @@ -152,6 +153,7 @@ static void socket_start_incoming_migration(SocketAddre= ss *saddr, Error **errp) { QIONetListener *listener =3D qio_net_listener_new(); + int i; =20 qio_net_listener_set_name(listener, "migration-socket-listener"); =20 @@ -163,6 +165,15 @@ static void socket_start_incoming_migration(SocketAddr= ess *saddr, qio_net_listener_set_client_func(listener, socket_accept_incoming_migration, NULL, NULL); + + for (i =3D 0; i < listener->nsioc; i++) { + SocketAddress *address =3D + qio_channel_socket_get_local_address(listener->sioc[i], errp); + if (address < 0) { + return; + } + migrate_set_address(address); + } } =20 void tcp_start_incoming_migration(const char *host_port, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 9d0bf82cf4..c3aafaf8fe 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -6,6 +6,7 @@ ## =20 { 'include': 'common.json' } +{ 'include': 'sockets.json' } =20 ## # @MigrationStats: @@ -494,6 +495,9 @@ # and a power of 2 # (Since 2.11) # +# @socket-address: Only used for tcp, to know what the real port is +# (Since 2.13) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -502,7 +506,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', 'socket-address' ] } =20 ## # @MigrateSetParameters: @@ -671,6 +675,10 @@ # needs to be a multiple of the target page size # and a power of 2 # (Since 2.11) +# +# @socket-address: Only used for tcp, to know what the real port is +# (Since 2.13) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -687,7 +695,8 @@ '*block-incremental': 'bool' , '*x-multifd-channels': 'uint8', '*x-multifd-page-count': 'uint32', - '*xbzrle-cache-size': 'size' } } + '*xbzrle-cache-size': 'size', + '*socket-address': ['SocketAddress'] } } =20 ## # @query-migrate-parameters: diff --git a/qapi/sockets.json b/qapi/sockets.json index fc81d8d5e8..f1ca09a927 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -152,3 +152,16 @@ 'unix': 'UnixSocketAddress', 'vsock': 'VsockSocketAddress', 'fd': 'String' } } + +## +# @DummyStruct: +# +# Both block-core and migration needs SocketAddressList +# I am open to comments about how to share it +# +# @dummy-list: A dummy list +# +# Since: 2.13 +## +{ 'struct': 'DummyStruct', + 'data': { 'dummy-list': ['SocketAddress'] } } --=20 2.14.3