migration: Fix seg with missing port
PATCH 1/1 migration: Fix seg with missing port
From: "Dr. David Alan Gilbert" <[email protected]>
The command :
migrate tcp:localhost:
currently segs; fix it so it now says:
error parsing address 'localhost:'
and the same for -incoming.
(We know that errp is non-null; callers use a local_err).
--- migration/socket.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
migration/socket.c +6 -2
@@ -113,7 +113,9 @@ void tcp_start_outgoing_migration(MigrationState *s, Error **errp) {SocketAddress *saddr =tcp_build_address (host_port, errp); -socket_start_outgoing_migration (s, saddr, errp); +if (!*errp) { +socket_start_outgoing_migration (s, saddr, errp); + } } void unix_start_outgoing_migration(MigrationState *s,
@@ -175,7 +177,9 @@ static void socket_start_incoming_migration(SocketAddress *saddr,void tcp_start_incoming_migration (const char *host_port,Error **errp) {SocketAddress *saddr =tcp_build_address (host_port, errp); -socket_start_incoming_migration (saddr, errp); +if (!*errp) { +socket_start_incoming_migration (saddr, errp); + } }void unix_start_incoming_migration (const char *path,Error **errp)
Signature · 1 line
2.7.4
Quoted 5 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The command :
migrate tcp:localhost:
Quoted 7 lines
currently segs; fix it so it now says:
error parsing address 'localhost:'
and the same for -incoming.
(We know that errp is non-null; callers use a
local_err).
I'd still be more comfortable with us using a local Error object here, as it illustrates best practice and protects against future accidents.
Quoted 21 lines
Signed-off-by Dr. David Alan Gilbert <[email protected]>--- migration/socket.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)migration/socket.c +3
-1@@ -113,7 +113,9 @@ void tcp_start_outgoing_migration(MigrationState *s, Error **errp) {SocketAddress *saddr =tcp_build_address (host_port, errp); -socket_start_outgoing_migration (s, saddr, errp); +if (!*errp) { +socket_start_outgoing_migration (s, saddr, errp); + } } void unix_start_outgoing_migration(MigrationState *s,
migration/socket.c static void socket_start_incoming_migration(SocketAddress *saddr, · line 183
Quoted 8 lines
migration/socket.c +3
-1@@ -175,7 +177,9 @@ static void socket_start_incoming_migration(SocketAddress *saddr,void tcp_start_incoming_migration (const char *host_port,Error **errp) {SocketAddress *saddr =tcp_build_address (host_port, errp); -socket_start_incoming_migration (saddr, errp); +if (!*errp) { +socket_start_incoming_migration (saddr, errp); + } }
Yep, makes sense
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 10 lines · Daniel P. Berrange
Quoted 9 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The command :
migrate tcp:localhost:currently segs; fix it so it now says:
error parsing address 'localhost:'
Quoted 7 lines
Quoted 3 lines
and the same for -incoming.
(We know that errp is non-null; callers use a
local_err).I'd still be more comfortable with us using a local Error object here, as it illustrates best practice and protects against future accidents.
Concur. Having an example contrary to best practice makes it far too easy for that example to be copied somewhere where it will later break.
Quoted 9 lines
migration/socket.c void tcp_start_outgoing_migration(MigrationState *s, · line 118
Quoted 9 lines
+++
b/migration/socket.cmigration/socket.c +3
-1@@ -113,7 +113,9 @@ void tcp_start_outgoing_migration(MigrationState *s, Error **errp) {SocketAddress *saddr =tcp_build_address (host_port, errp); -socket_start_outgoing_migration (s, saddr, errp); +if (!*errp) { +socket_start_outgoing_migration (s, saddr, errp); + }
Since we make a decision about code flow based on whether an earlier error occurred, this SHOULD be:
{
Error *err = NULL;
SocketAddress *saddr = tcp_build_address(host_port, &err);
if (!err) {
socket_start_outgoing_migration(s, saddr, &err);
}
error_propagate(errp, err);
}Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 9 lines · Dr. David Alan Gilbert (git)
SocketAddress *saddr = tcp_build_address(host_port, errp);migration/socket.c +3
-1-socket_start_outgoing_migration (s, saddr, errp); +if (!*errp) { +socket_start_outgoing_migration (s, saddr, errp); + } } void unix_start_outgoing_migration(MigrationState *s,
migration/socket.c static void socket_start_incoming_migration(SocketAddress *saddr, · line 182
Quoted 7 lines
migration/socket.c +3
-1@@ -175,7 +177,9 @@ static void socket_start_incoming_migration(SocketAddress *saddr,void tcp_start_incoming_migration (const char *host_port,Error **errp) {SocketAddress *saddr =tcp_build_address (host_port, errp); -socket_start_incoming_migration (saddr, errp); +if (!*errp) { +socket_start_incoming_migration (saddr, errp); + }
FWIW, this less-boilerplate version was almost fine, just replace "!*errp" with "saddr".
Paolo