[libvirt] [PATCHv2 5/8] Remove storage pool from the arguments of a few functions

Ján Tomko jtomko at redhat.com
Wed Mar 19 15:52:30 UTC 2014


virStorageBackendISCSISession only needs the path of the source
device and virStorageBackendISCSIRescanLUNs doesn't need the pool
at all.

This will allow the functions to be moved to src/util.
---
 src/storage/storage_backend_iscsi.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 35c9cc5..b7a0380 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -96,8 +96,8 @@ virStorageBackendISCSIExtractSession(char **const groups,
 }
 
 static char *
-virStorageBackendISCSISession(virStoragePoolObjPtr pool,
-                              bool probe)
+virStorageBackendISCSIGetSession(const char *devpath,
+                                 bool probe)
 {
     /*
      * # iscsiadm --mode session
@@ -114,7 +114,7 @@ virStorageBackendISCSISession(virStoragePoolObjPtr pool,
     };
     struct virStorageBackendISCSISessionData cbdata = {
         .session = NULL,
-        .devpath = pool->def->source.devices[0].path
+        .devpath = devpath,
     };
 
     virCommandPtr cmd = virCommandNewArgList(ISCSIADM, "--mode", "session", NULL);
@@ -138,6 +138,13 @@ cleanup:
     return cbdata.session;
 }
 
+static char *
+virStorageBackendISCSISession(virStoragePoolObjPtr pool,
+                              bool probe)
+{
+    return virStorageBackendISCSIGetSession(pool->def->source.devices[0].path, probe);
+}
+
 
 #define LINE_SIZE 4096
 
@@ -442,8 +449,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
 }
 
 static int
-virStorageBackendISCSIRescanLUNs(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
-                                 const char *session)
+virStorageBackendISCSIRescanLUNs(const char *session)
 {
     virCommandPtr cmd = virCommandNewArgList(ISCSIADM,
                                              "--mode", "session",
@@ -865,7 +871,7 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     if ((session = virStorageBackendISCSISession(pool, false)) == NULL)
         goto cleanup;
-    if (virStorageBackendISCSIRescanLUNs(pool, session) < 0)
+    if (virStorageBackendISCSIRescanLUNs(session) < 0)
         goto cleanup;
     if (virStorageBackendISCSIFindLUs(pool, session) < 0)
         goto cleanup;
-- 
1.8.3.2




More information about the libvir-list mailing list