]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage_iscsi: Reflect the default target port
authorJohn Ferlan <jferlan@redhat.com>
Thu, 18 Jul 2013 16:30:29 +0000 (12:30 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 22 Jul 2013 18:01:04 +0000 (14:01 -0400)
Make sure default iSCSI target is 3260.

src/storage/storage_backend_iscsi.c

index ba4f388bb574a2c0960fe2145a919fcbadfc1be7..54bcd14542b22ad98219842ea530aeb1df502433 100644 (file)
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
+#define ISCSI_DEFAULT_TARGET_PORT 3260
+
 static char *
 virStorageBackendISCSIPortal(virStoragePoolSourcePtr source)
 {
     char *portal = NULL;
-    const char *host;
-    int port = 3260;
 
     if (source->nhost != 1) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -57,14 +57,17 @@ virStorageBackendISCSIPortal(virStoragePoolSourcePtr source)
         return NULL;
     }
 
-    host = source->hosts[0].name;
-    if (source->hosts[0].port != 0)
-        port = source->hosts[0].port;
+    if (source->hosts[0].port == 0)
+        source->hosts[0].port = ISCSI_DEFAULT_TARGET_PORT;
 
-    if (strchr(host, ':')) {
-        ignore_value(virAsprintf(&portal, "[%s]:%d,1", host, port));
+    if (strchr(source->hosts[0].name, ':')) {
+        ignore_value(virAsprintf(&portal, "[%s]:%d,1",
+                                 source->hosts[0].name,
+                                 source->hosts[0].port));
     } else {
-        ignore_value(virAsprintf(&portal, "%s:%d,1", host, port));
+        ignore_value(virAsprintf(&portal, "%s:%d,1",
+                                 source->hosts[0].name,
+                                 source->hosts[0].port));
     }
 
     return portal;