mirror of https://github.com/xemu-project/xemu.git
migration: avoid using error_is_set and thus relying on errp != NULL
The migration code is using errp to detect "internal" errors, this means that it relies on errp being non-NULL. No impact so far because our only QMP clients (the QMP marshaller and HMP) never pass a NULL Error **. But if we had others, this patch would make sure that migration can work with a NULL Error **. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
1fc05adfa0
commit
be7059cd7f
|
@ -71,14 +71,16 @@ static void tcp_wait_for_connect(int fd, void *opaque)
|
||||||
int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
|
int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
s->get_error = socket_errno;
|
s->get_error = socket_errno;
|
||||||
s->write = socket_write;
|
s->write = socket_write;
|
||||||
s->close = tcp_close;
|
s->close = tcp_close;
|
||||||
|
|
||||||
s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s,
|
s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, &local_err);
|
||||||
errp);
|
if (local_err != NULL) {
|
||||||
if (error_is_set(errp)) {
|
|
||||||
migrate_fd_error(s);
|
migrate_fd_error(s);
|
||||||
|
error_propagate(errp, local_err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
migration.c
13
migration.c
|
@ -483,6 +483,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
|
||||||
bool has_inc, bool inc, bool has_detach, bool detach,
|
bool has_inc, bool inc, bool has_detach, bool detach,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
Error *local_err = NULL;
|
||||||
MigrationState *s = migrate_get_current();
|
MigrationState *s = migrate_get_current();
|
||||||
MigrationParams params;
|
MigrationParams params;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
@ -508,7 +509,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
|
||||||
s = migrate_init(¶ms);
|
s = migrate_init(¶ms);
|
||||||
|
|
||||||
if (strstart(uri, "tcp:", &p)) {
|
if (strstart(uri, "tcp:", &p)) {
|
||||||
ret = tcp_start_outgoing_migration(s, p, errp);
|
ret = tcp_start_outgoing_migration(s, p, &local_err);
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
} else if (strstart(uri, "exec:", &p)) {
|
} else if (strstart(uri, "exec:", &p)) {
|
||||||
ret = exec_start_outgoing_migration(s, p);
|
ret = exec_start_outgoing_migration(s, p);
|
||||||
|
@ -522,11 +523,11 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0 || local_err) {
|
||||||
if (!error_is_set(errp)) {
|
if (!local_err) {
|
||||||
DPRINTF("migration failed: %s\n", strerror(-ret));
|
error_set_errno(errp, -ret, QERR_UNDEFINED_ERROR);
|
||||||
/* FIXME: we should return meaningful errors */
|
} else {
|
||||||
error_set(errp, QERR_UNDEFINED_ERROR);
|
error_propagate(errp, local_err);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue