diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 20fc0e6e4877964053cf9f5610269c5ce812bf07..35c9cc561f45b3e81fc7fc1edb36f4ef517c8d4d 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -355,6 +355,24 @@ cleanup: return ret; } +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;