Skip to contentSkip to conversation

migration: Fix seg with missing port

PATCH Superseded Dr. David Alan Gilbert (git) 4 participants 4 messages Sep 12, 2016 – Sep 15, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 00de1fe..6e82924 100644
@@ -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
#1 lore raw
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
---
 migration/socket.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
migration/socket.c +3 -1
index 00de1fe..6e82924 100644
@@ -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 :|
#2 lore raw
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.c

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);
+    }

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
#3 lore raw
In reply to Dr. David Alan Gilbert (git)
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