]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Rework qemuMigrationSrcConnect
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 24 Aug 2020 20:29:14 +0000 (22:29 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 4 Sep 2020 08:20:49 +0000 (10:20 +0200)
Instead of saving some data from a union up front and changing an overlayed
struct before using said data, let's just set the new values after they are
decided.  This will increase the readability of future commit(s).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration.c

index 60ddfde65d46a16278e06fa1d72a1c84ba24b310..1a3cdb71f42495106c6373b7fa046e9a4ce9e466 100644 (file)
@@ -3368,24 +3368,24 @@ qemuMigrationSrcConnect(virQEMUDriverPtr driver,
                         qemuMigrationSpecPtr spec)
 {
     virNetSocketPtr sock;
-    const char *host;
     g_autofree char *port = NULL;
+    int fd_qemu = -1;
     int ret = -1;
 
-    host = spec->dest.host.name;
-    port = g_strdup_printf("%d", spec->dest.host.port);
-
-    spec->destType = MIGRATION_DEST_FD;
-    spec->dest.fd.qemu = -1;
-
     if (qemuSecuritySetSocketLabel(driver->securityManager, vm->def) < 0)
         goto cleanup;
-    if (virNetSocketNewConnectTCP(host, port,
+    port = g_strdup_printf("%d", spec->dest.host.port);
+    if (virNetSocketNewConnectTCP(spec->dest.host.name,
+                                  port,
                                   AF_UNSPEC,
                                   &sock) == 0) {
-        spec->dest.fd.qemu = virNetSocketDupFD(sock, true);
+        fd_qemu = virNetSocketDupFD(sock, true);
         virObjectUnref(sock);
     }
+
+    spec->destType = MIGRATION_DEST_FD;
+    spec->dest.fd.qemu = fd_qemu;
+
     if (qemuSecurityClearSocketLabel(driver->securityManager, vm->def) < 0 ||
         spec->dest.fd.qemu == -1)
         goto cleanup;