* wwnn/wwpn, or fabric_wwn (if provided). If no parent is provided, then
* a vport capable scsi_host will be selected.
*
- * Returns 0 on success, -1 on failure
+ * Returns vHBA name on success, NULL on failure with an error message set
*/
-int
+char *
virNodeDeviceCreateVport(virConnectPtr conn,
virStorageAdapterFCHostPtr fchost)
{
- int ret = -1;
unsigned int parent_host;
char *name = NULL;
char *parent_hoststr = NULL;
/* If a parent was provided, let's make sure the 'name' we've
* retrieved has the same parent. If not this will cause failure. */
if (fchost->parent && checkParent(conn, name, fchost->parent))
- ret = 0;
+ VIR_FREE(name);
- goto cleanup;
+ return name;
}
if (fchost->parent) {
VPORT_CREATE) < 0)
goto cleanup;
- ret = 0;
+ /* Let's ensure the device was created */
+ virWaitForDevices();
+ if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
+ ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
+ VPORT_DELETE));
+ goto cleanup;
+ }
cleanup:
- VIR_FREE(name);
VIR_FREE(parent_hoststr);
- return ret;
+ return name;
}
}
}
- if (virNodeDeviceCreateVport(conn, fchost) < 0)
+ if (!(name = virNodeDeviceCreateVport(conn, fchost)))
goto cleanup;
- virWaitForDevices();
-
/* Creating our own VPORT didn't leave enough time to find any LUN's,
* so, let's create a thread whose job it is to call the FindLU's with
* retry logic set to true. If the thread isn't created, then no big
* deal since it's still possible to refresh the pool later.
*/
- if ((name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
- if (VIR_ALLOC(cbdata) == 0) {
- memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN);
- VIR_STEAL_PTR(cbdata->fchost_name, name);
-
- if (virThreadCreate(&thread, false, virStoragePoolFCRefreshThread,
- cbdata) < 0) {
- /* Oh well - at least someone can still refresh afterwards */
- VIR_DEBUG("Failed to create FC Pool Refresh Thread");
- virStoragePoolFCRefreshDataFree(cbdata);
- }
+ if (VIR_ALLOC(cbdata) == 0) {
+ memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN);
+ VIR_STEAL_PTR(cbdata->fchost_name, name);
+
+ if (virThreadCreate(&thread, false, virStoragePoolFCRefreshThread,
+ cbdata) < 0) {
+ /* Oh well - at least someone can still refresh afterwards */
+ VIR_DEBUG("Failed to create FC Pool Refresh Thread");
+ virStoragePoolFCRefreshDataFree(cbdata);
}
}