[PATCHv2 4/8] Don't create iscsiadm command line in ISCSIPool{Start, Stop}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Create ISCSIConnection{Login,Logout} wrappers for that.
---
 src/storage/storage_backend_iscsi.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 20fc0e6..35c9cc5 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -356,6 +356,24 @@ cleanup:
 }
 
 static int
+virStorageBackendISCSIConnectionLogin(const char *portal,
+                                      const char *initiatoriqn,
+                                      const char *target)
+{
+    const char *extraargv[] = { "--login", NULL };
+    return virStorageBackendISCSIConnection(portal, initiatoriqn, target, extraargv);
+}
+
+static int
+virStorageBackendISCSIConnectionLogout(const char *portal,
+                                       const char *initiatoriqn,
+                                       const char *target)
+{
+    const char *extraargv[] = { "--logout", NULL };
+    return virStorageBackendISCSIConnection(portal, initiatoriqn, target, extraargv);
+}
+
+static int
 virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
                                     uint32_t *host)
 {
@@ -789,7 +807,6 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
     char *portal = NULL;
     char *session = NULL;
     int ret = -1;
-    const char *loginargv[] = { "--login", NULL };
 
     if (pool->def->source.nhost != 1) {
          virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -825,10 +842,9 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
         if (virStorageBackendISCSISetAuth(portal, conn, pool->def) < 0)
             goto cleanup;
 
-        if (virStorageBackendISCSIConnection(portal,
-                                             pool->def->source.initiator.iqn,
-                                             pool->def->source.devices[0].path,
-                                             loginargv) < 0)
+        if (virStorageBackendISCSIConnectionLogin(portal,
+                                                  pool->def->source.initiator.iqn,
+                                                  pool->def->source.devices[0].path) < 0)
             goto cleanup;
     }
     ret = 0;
@@ -867,17 +883,15 @@ static int
 virStorageBackendISCSIStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
                                virStoragePoolObjPtr pool)
 {
-    const char *logoutargv[] = { "--logout", NULL };
     char *portal;
     int ret = -1;
 
     if ((portal = virStorageBackendISCSIPortal(&pool->def->source)) == NULL)
         return -1;
 
-    if (virStorageBackendISCSIConnection(portal,
-                                         pool->def->source.initiator.iqn,
-                                         pool->def->source.devices[0].path,
-                                         logoutargv) < 0)
+    if (virStorageBackendISCSIConnectionLogout(portal,
+                                               pool->def->source.initiator.iqn,
+                                               pool->def->source.devices[0].path) < 0)
         goto cleanup;
     ret = 0;
 
-- 
1.8.3.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]