mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
migration: add reporting of errors for outgoing migration
Currently if an application initiates an outgoing migration, it may or may not, get an error reported back on failure. If the error occurs synchronously to the 'migrate' command execution, the client app will see the error message. This is the case for DNS lookup failures. If the error occurs asynchronously to the monitor command though, the error will be thrown away and the client left guessing about what went wrong. This is the case for failure to connect to the TCP server (eg due to wrong port, or firewall rules, or other similar errors). In the future we'll be adding more scope for errors to happen asynchronously with the TLS protocol handshake. TLS errors are hard to diagnose even when they are well reported, so discarding errors entirely will make it impossible to debug TLS connection problems. Management apps which do migration are already using 'query-migrate' / 'info migrate' to check up on progress of background migration operations and to see their end status. This is a fine place to also include the error message when things go wrong. This patch thus adds an 'error-desc' field to the MigrationInfo struct, which will be populated when the 'status' is set to 'failed': (qemu) migrate -d tcp:localhost:9001 (qemu) info migrate capabilities: xbzrle: off rdma-pin-all: off auto-converge: off zero-blocks: off compress: off events: off x-postcopy-ram: off Migration status: failed (Error connecting to socket: Connection refused) total time: 0 milliseconds In the HMP, when doing non-detached migration, it is also possible to display this error message directly to the app. (qemu) migrate tcp:localhost:9001 Error connecting to socket: Connection refused Or with QMP { "execute": "query-migrate", "arguments": {} } { "return": { "status": "failed", "error-desc": "address resolution failed for myhost:9000: No address associated with hostname" } } Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-Id: <1461751518-12128-11-git-send-email-berrange@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
parent
48f07489ed
commit
d59ce6f344
10 changed files with 42 additions and 18 deletions
|
@ -691,6 +691,10 @@ MigrationInfo *qmp_query_migrate(Error **errp)
|
|||
break;
|
||||
case MIGRATION_STATUS_FAILED:
|
||||
info->has_status = true;
|
||||
if (s->error) {
|
||||
info->has_error_desc = true;
|
||||
info->error_desc = g_strdup(error_get_pretty(s->error));
|
||||
}
|
||||
break;
|
||||
case MIGRATION_STATUS_CANCELLED:
|
||||
info->has_status = true;
|
||||
|
@ -863,12 +867,15 @@ static void migrate_fd_cleanup(void *opaque)
|
|||
notifier_list_notify(&migration_state_notifiers, s);
|
||||
}
|
||||
|
||||
void migrate_fd_error(MigrationState *s)
|
||||
void migrate_fd_error(MigrationState *s, const Error *error)
|
||||
{
|
||||
trace_migrate_fd_error();
|
||||
trace_migrate_fd_error(error ? error_get_pretty(error) : "");
|
||||
assert(s->to_dst_file == NULL);
|
||||
migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
|
||||
MIGRATION_STATUS_FAILED);
|
||||
if (!s->error) {
|
||||
s->error = error_copy(error);
|
||||
}
|
||||
notifier_list_notify(&migration_state_notifiers, s);
|
||||
}
|
||||
|
||||
|
@ -967,6 +974,8 @@ MigrationState *migrate_init(const MigrationParams *params)
|
|||
s->postcopy_after_devices = false;
|
||||
s->migration_thread_running = false;
|
||||
s->last_req_rb = NULL;
|
||||
error_free(s->error);
|
||||
s->error = NULL;
|
||||
|
||||
migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);
|
||||
|
||||
|
@ -1076,7 +1085,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
|
|||
}
|
||||
|
||||
if (local_err) {
|
||||
migrate_fd_error(s);
|
||||
migrate_fd_error(s, local_err);
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3489,16 +3489,14 @@ void rdma_start_outgoing_migration(void *opaque,
|
|||
const char *host_port, Error **errp)
|
||||
{
|
||||
MigrationState *s = opaque;
|
||||
Error *local_err = NULL, **temp = &local_err;
|
||||
RDMAContext *rdma = qemu_rdma_data_init(host_port, &local_err);
|
||||
RDMAContext *rdma = qemu_rdma_data_init(host_port, errp);
|
||||
int ret = 0;
|
||||
|
||||
if (rdma == NULL) {
|
||||
ERROR(temp, "Failed to initialize RDMA data structures! %d", ret);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = qemu_rdma_source_init(rdma, &local_err,
|
||||
ret = qemu_rdma_source_init(rdma, errp,
|
||||
s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL]);
|
||||
|
||||
if (ret) {
|
||||
|
@ -3506,7 +3504,7 @@ void rdma_start_outgoing_migration(void *opaque,
|
|||
}
|
||||
|
||||
trace_rdma_start_outgoing_migration_after_rdma_source_init();
|
||||
ret = qemu_rdma_connect(rdma, &local_err);
|
||||
ret = qemu_rdma_connect(rdma, errp);
|
||||
|
||||
if (ret) {
|
||||
goto err;
|
||||
|
@ -3518,7 +3516,5 @@ void rdma_start_outgoing_migration(void *opaque,
|
|||
migrate_fd_connect(s);
|
||||
return;
|
||||
err:
|
||||
error_propagate(errp, local_err);
|
||||
g_free(rdma);
|
||||
migrate_fd_error(s);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ static void tcp_wait_for_connect(int fd, Error *err, void *opaque)
|
|||
if (fd < 0) {
|
||||
DPRINTF("migrate connect error: %s\n", error_get_pretty(err));
|
||||
s->to_dst_file = NULL;
|
||||
migrate_fd_error(s);
|
||||
migrate_fd_error(s, err);
|
||||
} else {
|
||||
DPRINTF("migrate connect success\n");
|
||||
s->to_dst_file = qemu_fopen_socket(fd, "wb");
|
||||
|
|
|
@ -40,7 +40,7 @@ static void unix_wait_for_connect(int fd, Error *err, void *opaque)
|
|||
if (fd < 0) {
|
||||
DPRINTF("migrate connect error: %s\n", error_get_pretty(err));
|
||||
s->to_dst_file = NULL;
|
||||
migrate_fd_error(s);
|
||||
migrate_fd_error(s, err);
|
||||
} else {
|
||||
DPRINTF("migrate connect success\n");
|
||||
s->to_dst_file = qemu_fopen_socket(fd, "wb");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue