[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/18] migration: avoid using error_is_set
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 05/18] migration: avoid using error_is_set |
Date: |
Wed, 3 Oct 2012 16:36:52 +0200 |
Signed-off-by: Paolo Bonzini <address@hidden>
---
migration-tcp.c | 8 +++++---
migration.c | 13 +++++++------
2 file modificati, 12 inserzioni(+), 9 rimozioni(-)
diff --git a/migration-tcp.c b/migration-tcp.c
index a15c2b8..78337a3 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -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,
Error **errp)
{
+ Error *local_err = NULL;
+
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
- s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s,
- errp);
- if (error_is_set(errp)) {
+ s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s,
&local_err);
+ if (local_err != NULL) {
migrate_fd_error(s);
+ error_propagate(errp, local_err);
return -1;
}
diff --git a/migration.c b/migration.c
index 22a05c4..8a04174 100644
--- a/migration.c
+++ b/migration.c
@@ -481,6 +481,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
bool has_inc, bool inc, bool has_detach, bool detach,
Error **errp)
{
+ Error *local_err = NULL;
MigrationState *s = migrate_get_current();
MigrationParams params;
const char *p;
@@ -506,7 +507,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
s = migrate_init(¶ms);
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)
} else if (strstart(uri, "exec:", &p)) {
ret = exec_start_outgoing_migration(s, p);
@@ -520,11 +521,11 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
return;
}
- if (ret < 0) {
- if (!error_is_set(errp)) {
- DPRINTF("migration failed: %s\n", strerror(-ret));
- /* FIXME: we should return meaningful errors */
- error_set(errp, QERR_UNDEFINED_ERROR);
+ if (ret < 0 || local_err) {
+ if (!local_err) {
+ error_set_errno(errp, -ret, QERR_UNDEFINED_ERROR);
+ } else {
+ error_propagate(errp, local_err);
}
return;
}
--
1.7.12.1
- Re: [Qemu-devel] [PATCH 01/18] error: add error_set_errno and error_setg_errno, (continued)
- [Qemu-devel] [PATCH 03/18] qemu-sockets: unix_listen and unix_connect are portable, Paolo Bonzini, 2012/10/03
- [Qemu-devel] [PATCH 05/18] migration: avoid using error_is_set,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 04/18] qemu-sockets: add nonblocking connect for Unix sockets, Paolo Bonzini, 2012/10/03
- [Qemu-devel] [PATCH 06/18] migration: centralize call to migrate_fd_error(), Paolo Bonzini, 2012/10/03
- [Qemu-devel] [PATCH 07/18] migration: use qemu-sockets to establish Unix sockets, Paolo Bonzini, 2012/10/03
- [Qemu-devel] [PATCH 09/18] migration (incoming): add error propagation for fd and exec protocols, Paolo Bonzini, 2012/10/03