提交 4f426ce4 编写于 作者: M Michal Privoznik

virStoragePoolObjSourceFindDuplicate: Drop @conn argument

The @conn argument is needed only to do some source matching in
case of iSCSI source. Anyway, it's used just for node device
driver and as such can be replaced with virGetConnectNodeDev().

At the same time, the @conn struct member is dropped from
_virStoragePoolObjFindDuplicateData.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 d1300900
...@@ -1169,7 +1169,6 @@ virStorageIsSameHostnum(const char *name, ...@@ -1169,7 +1169,6 @@ virStorageIsSameHostnum(const char *name,
/* /*
* matchFCHostToSCSIHost: * matchFCHostToSCSIHost:
* *
* @conn: Connection pointer
* @fchost: fc_host adapter ptr (either def or pool->def) * @fchost: fc_host adapter ptr (either def or pool->def)
* @scsi_hostnum: Already determined "scsi_pool" hostnum * @scsi_hostnum: Already determined "scsi_pool" hostnum
* *
...@@ -1177,10 +1176,10 @@ virStorageIsSameHostnum(const char *name, ...@@ -1177,10 +1176,10 @@ virStorageIsSameHostnum(const char *name,
* fc_adapter host# and the scsi_host host# * fc_adapter host# and the scsi_host host#
*/ */
static bool static bool
matchFCHostToSCSIHost(virConnectPtr conn, matchFCHostToSCSIHost(virStorageAdapterFCHostPtr fchost,
virStorageAdapterFCHostPtr fchost,
unsigned int scsi_hostnum) unsigned int scsi_hostnum)
{ {
virConnectPtr conn = NULL;
bool ret = false; bool ret = false;
char *name = NULL; char *name = NULL;
char *scsi_host_name = NULL; char *scsi_host_name = NULL;
...@@ -1211,7 +1210,8 @@ matchFCHostToSCSIHost(virConnectPtr conn, ...@@ -1211,7 +1210,8 @@ matchFCHostToSCSIHost(virConnectPtr conn,
* If the parent fc_hostnum is the same as the scsi_hostnum, we * If the parent fc_hostnum is the same as the scsi_hostnum, we
* have a match. * have a match.
*/ */
if (conn && !fchost->parent) { if (!fchost->parent &&
(conn = virGetConnectNodeDev())) {
if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
goto cleanup; goto cleanup;
if ((parent_name = virNodeDeviceGetParentName(conn, if ((parent_name = virNodeDeviceGetParentName(conn,
...@@ -1240,6 +1240,7 @@ matchFCHostToSCSIHost(virConnectPtr conn, ...@@ -1240,6 +1240,7 @@ matchFCHostToSCSIHost(virConnectPtr conn,
VIR_FREE(name); VIR_FREE(name);
VIR_FREE(parent_name); VIR_FREE(parent_name);
VIR_FREE(scsi_host_name); VIR_FREE(scsi_host_name);
virConnectClose(conn);
return ret; return ret;
} }
...@@ -1318,8 +1319,7 @@ virStoragePoolObjSourceMatchTypeDIR(virStoragePoolObjPtr obj, ...@@ -1318,8 +1319,7 @@ virStoragePoolObjSourceMatchTypeDIR(virStoragePoolObjPtr obj,
static virStoragePoolObjPtr static virStoragePoolObjPtr
virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr obj, virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr obj,
virStoragePoolDefPtr def, virStoragePoolDefPtr def)
virConnectPtr conn)
{ {
virStorageAdapterPtr pool_adapter = &obj->def->source.adapter; virStorageAdapterPtr pool_adapter = &obj->def->source.adapter;
virStorageAdapterPtr def_adapter = &def->source.adapter; virStorageAdapterPtr def_adapter = &def->source.adapter;
...@@ -1363,7 +1363,7 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr obj, ...@@ -1363,7 +1363,7 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr obj,
if (getSCSIHostNumber(def_scsi_host, &scsi_hostnum) < 0) if (getSCSIHostNumber(def_scsi_host, &scsi_hostnum) < 0)
return NULL; return NULL;
if (matchFCHostToSCSIHost(conn, pool_fchost, scsi_hostnum)) if (matchFCHostToSCSIHost(pool_fchost, scsi_hostnum))
return obj; return obj;
} else if (pool_adapter->type == VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST && } else if (pool_adapter->type == VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST &&
...@@ -1374,7 +1374,7 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr obj, ...@@ -1374,7 +1374,7 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr obj,
if (getSCSIHostNumber(pool_scsi_host, &scsi_hostnum) < 0) if (getSCSIHostNumber(pool_scsi_host, &scsi_hostnum) < 0)
return NULL; return NULL;
if (matchFCHostToSCSIHost(conn, def_fchost, scsi_hostnum)) if (matchFCHostToSCSIHost(def_fchost, scsi_hostnum))
return obj; return obj;
} }
...@@ -1411,7 +1411,6 @@ virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolObjPtr obj, ...@@ -1411,7 +1411,6 @@ virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolObjPtr obj,
struct _virStoragePoolObjFindDuplicateData { struct _virStoragePoolObjFindDuplicateData {
virConnectPtr conn;
virStoragePoolDefPtr def; virStoragePoolDefPtr def;
}; };
...@@ -1439,7 +1438,7 @@ virStoragePoolObjSourceFindDuplicateCb(const void *payload, ...@@ -1439,7 +1438,7 @@ virStoragePoolObjSourceFindDuplicateCb(const void *payload,
case VIR_STORAGE_POOL_SCSI: case VIR_STORAGE_POOL_SCSI:
if (data->def->type == obj->def->type && if (data->def->type == obj->def->type &&
virStoragePoolObjSourceMatchTypeISCSI(obj, data->def, data->conn)) virStoragePoolObjSourceMatchTypeISCSI(obj, data->def))
return 1; return 1;
break; break;
...@@ -1488,12 +1487,10 @@ virStoragePoolObjSourceFindDuplicateCb(const void *payload, ...@@ -1488,12 +1487,10 @@ virStoragePoolObjSourceFindDuplicateCb(const void *payload,
int int
virStoragePoolObjSourceFindDuplicate(virConnectPtr conn, virStoragePoolObjSourceFindDuplicate(virStoragePoolObjListPtr pools,
virStoragePoolObjListPtr pools,
virStoragePoolDefPtr def) virStoragePoolDefPtr def)
{ {
struct _virStoragePoolObjFindDuplicateData data = { .conn = conn, struct _virStoragePoolObjFindDuplicateData data = {.def = def};
.def = def };
virStoragePoolObjPtr obj = NULL; virStoragePoolObjPtr obj = NULL;
virObjectRWLockRead(pools); virObjectRWLockRead(pools);
......
...@@ -246,8 +246,7 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pools, ...@@ -246,8 +246,7 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
virStoragePoolObjPtr obj); virStoragePoolObjPtr obj);
int int
virStoragePoolObjSourceFindDuplicate(virConnectPtr conn, virStoragePoolObjSourceFindDuplicate(virStoragePoolObjListPtr pools,
virStoragePoolObjListPtr pools,
virStoragePoolDefPtr def); virStoragePoolDefPtr def);
int int
......
...@@ -705,7 +705,7 @@ storagePoolCreateXML(virConnectPtr conn, ...@@ -705,7 +705,7 @@ storagePoolCreateXML(virConnectPtr conn,
if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0) if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0)
goto cleanup; goto cleanup;
if (virStoragePoolObjSourceFindDuplicate(conn, driver->pools, newDef) < 0) if (virStoragePoolObjSourceFindDuplicate(driver->pools, newDef) < 0)
goto cleanup; goto cleanup;
if ((backend = virStorageBackendForType(newDef->type)) == NULL) if ((backend = virStorageBackendForType(newDef->type)) == NULL)
...@@ -796,7 +796,7 @@ storagePoolDefineXML(virConnectPtr conn, ...@@ -796,7 +796,7 @@ storagePoolDefineXML(virConnectPtr conn,
if (virStoragePoolDefineXMLEnsureACL(conn, newDef) < 0) if (virStoragePoolDefineXMLEnsureACL(conn, newDef) < 0)
goto cleanup; goto cleanup;
if (virStoragePoolObjSourceFindDuplicate(conn, driver->pools, newDef) < 0) if (virStoragePoolObjSourceFindDuplicate(driver->pools, newDef) < 0)
goto cleanup; goto cleanup;
if (virStorageBackendForType(newDef->type) == NULL) if (virStorageBackendForType(newDef->type) == NULL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册