From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com,
marcel.apfelbaum@gmail.com, wei.w.wang@intel.com,
yury-kotov@yandex-team.ru, chen.zhang@intel.com
Cc: eblake@redhat.com, armbru@redhat.com
Subject: [Qemu-devel] [PULL 11/22] migration: Create socket-address parameter
Date: Wed, 6 Mar 2019 11:42:16 +0000 [thread overview]
Message-ID: <20190306114227.9125-12-dgilbert@redhat.com> (raw)
In-Reply-To: <20190306114227.9125-1-dgilbert@redhat.com>
From: Juan Quintela <quintela@redhat.com>
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.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
dgilbert: Removed DummyStruct as suggested by Eric & Markus
--
---
hmp.c | 33 +++++++++++++++++++++++++++++++++
migration/migration.c | 24 ++++++++++++++++++++++++
migration/migration.h | 4 ++++
migration/socket.c | 11 +++++++++++
qapi/migration.json | 6 +++++-
5 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/hmp.c b/hmp.c
index 5f13b16e24..c2ad3f8251 100644
--- a/hmp.c
+++ b/hmp.c
@@ -166,6 +166,27 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
qapi_free_MouseInfoList(mice_list);
}
+static char *SocketAddress_to_str(SocketAddress *addr)
+{
+ switch (addr->type) {
+ case SOCKET_ADDRESS_TYPE_INET:
+ return g_strdup_printf("tcp:%s:%s",
+ addr->u.inet.host,
+ addr->u.inet.port);
+ case SOCKET_ADDRESS_TYPE_UNIX:
+ return g_strdup_printf("unix:%s",
+ addr->u.q_unix.path);
+ case SOCKET_ADDRESS_TYPE_FD:
+ return g_strdup_printf("fd:%s", addr->u.fd.str);
+ case SOCKET_ADDRESS_TYPE_VSOCK:
+ return g_strdup_printf("tcp:%s:%s",
+ addr->u.vsock.cid,
+ addr->u.vsock.port);
+ default:
+ return g_strdup("unknown address type");
+ }
+}
+
void hmp_info_migrate(Monitor *mon, const QDict *qdict)
{
MigrationInfo *info;
@@ -306,6 +327,18 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
g_free(str);
visit_free(v);
}
+ if (info->has_socket_address) {
+ SocketAddressList *addr;
+
+ monitor_printf(mon, "socket address: [\n");
+
+ for (addr = info->socket_address; addr; addr = addr->next) {
+ char *s = SocketAddress_to_str(addr->value);
+ monitor_printf(mon, "\t%s\n", s);
+ g_free(s);
+ }
+ monitor_printf(mon, "]\n");
+ }
qapi_free_MigrationInfo(info);
qapi_free_MigrationCapabilityStatusList(caps);
}
diff --git a/migration/migration.c b/migration/migration.c
index e823fd8b91..952d29243e 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"
@@ -213,6 +215,11 @@ void migration_incoming_state_destroy(void)
}
qemu_event_reset(&mis->main_thread_load_event);
+
+ if (mis->socket_address_list) {
+ qapi_free_SocketAddressList(mis->socket_address_list);
+ mis->socket_address_list = NULL;
+ }
}
static void migrate_generate_event(int new_state)
@@ -328,6 +335,17 @@ void migration_incoming_enable_colo(void)
migration_colo_enabled = true;
}
+void migrate_add_address(SocketAddress *address)
+{
+ MigrationIncomingState *mis = migration_incoming_get_current();
+ SocketAddressList *addrs;
+
+ addrs = g_new0(SocketAddressList, 1);
+ addrs->next = mis->socket_address_list;
+ mis->socket_address_list = addrs;
+ addrs->value = QAPI_CLONE(SocketAddress, address);
+}
+
void qemu_start_incoming_migration(const char *uri, Error **errp)
{
const char *p;
@@ -1009,6 +1027,12 @@ static void fill_destination_migration_info(MigrationInfo *info)
{
MigrationIncomingState *mis = migration_incoming_get_current();
+ if (mis->socket_address_list) {
+ info->has_socket_address = true;
+ info->socket_address =
+ QAPI_CLONE(SocketAddressList, mis->socket_address_list);
+ }
+
switch (mis->state) {
case MIGRATION_STATUS_NONE:
return;
diff --git a/migration/migration.h b/migration/migration.h
index 81c261941d..99e99e56bd 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -84,6 +84,9 @@ struct MigrationIncomingState {
bool postcopy_recover_triggered;
QemuSemaphore postcopy_pause_sem_dst;
QemuSemaphore postcopy_pause_sem_fault;
+
+ /* List of listening socket addresses */
+ SocketAddressList *socket_address_list;
};
MigrationIncomingState *migration_incoming_get_current(void);
@@ -305,6 +308,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);
void dirty_bitmap_mig_before_vm_start(void);
void init_dirty_bitmap_incoming_migration(void);
+void migrate_add_address(SocketAddress *address);
int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque);
diff --git a/migration/socket.c b/migration/socket.c
index f4c8174400..239527fb1f 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -15,6 +15,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include "qemu-common.h"
#include "qemu/error-report.h"
@@ -177,6 +178,7 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
Error **errp)
{
QIONetListener *listener = qio_net_listener_new();
+ size_t i;
qio_net_listener_set_name(listener, "migration-socket-listener");
@@ -189,6 +191,15 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
socket_accept_incoming_migration,
NULL, NULL,
g_main_context_get_thread_default());
+
+ for (i = 0; i < listener->nsioc; i++) {
+ SocketAddress *address =
+ qio_channel_socket_get_local_address(listener->sioc[i], errp);
+ if (!address) {
+ return;
+ }
+ migrate_add_address(address);
+ }
}
void tcp_start_incoming_migration(const char *host_port, Error **errp)
diff --git a/qapi/migration.json b/qapi/migration.json
index eab87340b2..6bd7fd3f1a 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -6,6 +6,7 @@
##
{ 'include': 'common.json' }
+{ 'include': 'sockets.json' }
##
# @MigrationStats:
@@ -199,6 +200,8 @@
# @compression: migration compression statistics, only returned if compression
# feature is on and status is 'active' or 'completed' (Since 3.1)
#
+# @socket-address: Only used for tcp, to know what the real port is (Since 4.0)
+#
# Since: 0.14.0
##
{ 'struct': 'MigrationInfo',
@@ -213,7 +216,8 @@
'*error-desc': 'str',
'*postcopy-blocktime' : 'uint32',
'*postcopy-vcpu-blocktime': ['uint32'],
- '*compression': 'CompressionStats'} }
+ '*compression': 'CompressionStats',
+ '*socket-address': ['SocketAddress'] } }
##
# @query-migrate:
--
2.20.1
next prev parent reply other threads:[~2019-03-06 11:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 11:42 [Qemu-devel] [PULL 00/22] migration queue Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 01/22] migration: Fix cancel state Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 02/22] migration/rdma: Fix qemu_rdma_cleanup null check Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 03/22] migration: Cleanup during exit Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 04/22] migration/rdma: clang compilation fix Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 05/22] exec: Change RAMBlockIterFunc definition Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 06/22] migration: Introduce ignore-shared capability Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 07/22] migration: Add an ability to ignore shared RAM blocks Dr. David Alan Gilbert (git)
2019-03-08 17:12 ` Peter Maydell
2019-03-08 18:43 ` Dr. David Alan Gilbert
2019-03-06 11:42 ` [Qemu-devel] [PULL 08/22] tests/migration-test: Add a test for ignore-shared capability Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 09/22] migration: Add capabilities validation Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 10/22] tests: Add migration xbzrle test Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` Dr. David Alan Gilbert (git) [this message]
2019-03-06 11:42 ` [Qemu-devel] [PULL 12/22] tests: Add basic migration precopy tcp test Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 13/22] bitmap: fix bitmap_count_one Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 14/22] bitmap: bitmap_count_one_with_offset Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 15/22] migration: use bitmap_mutex in migration_bitmap_clear_dirty Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 16/22] migration: API to clear bits of guest free pages from the dirty bitmap Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 17/22] migration/ram.c: add a notifier chain for precopy Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 18/22] migration/ram.c: add the free page optimization enable flag Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 19/22] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT Dr. David Alan Gilbert (git)
2019-03-08 17:14 ` Peter Maydell
2019-03-08 18:30 ` Dr. David Alan Gilbert
2019-03-09 11:22 ` Wei Wang
2019-03-06 11:42 ` [Qemu-devel] [PULL 20/22] Migration/colo.c: Fix double close bug when occur COLO failover Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 21/22] Migration/colo.c: Make COLO node running after failover Dr. David Alan Gilbert (git)
2019-03-06 11:42 ` [Qemu-devel] [PULL 22/22] qapi/migration.json: Remove a variable that doesn't exist in example Dr. David Alan Gilbert (git)
2019-03-06 12:06 ` [Qemu-devel] [PULL 00/22] migration queue no-reply
2019-03-06 16:23 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190306114227.9125-12-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=chen.zhang@intel.com \
--cc=eblake@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=wei.w.wang@intel.com \
--cc=yury-kotov@yandex-team.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).