diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index f246a05f3a..7dd7674f88 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -44,7 +44,7 @@ typedef struct _virStoragePoolFCRefreshInfo virStoragePoolFCRefreshInfo; typedef virStoragePoolFCRefreshInfo *virStoragePoolFCRefreshInfoPtr; struct _virStoragePoolFCRefreshInfo { char *fchost_name; - virStoragePoolObjPtr pool; + unsigned char pool_uuid[VIR_UUID_BUFLEN]; }; /* Function to check if the type file in the given sysfs_path is a @@ -594,7 +594,8 @@ virStoragePoolFCRefreshThread(void *opaque) { virStoragePoolFCRefreshInfoPtr cbdata = opaque; const char *fchost_name = cbdata->fchost_name; - virStoragePoolObjPtr pool = cbdata->pool; + const unsigned char *pool_uuid = cbdata->pool_uuid; + virStoragePoolObjPtr pool = NULL; unsigned int host; int found = 0; int tries = 2; @@ -602,12 +603,15 @@ virStoragePoolFCRefreshThread(void *opaque) do { sleep(5); /* Give it time */ - /* Lock the pool, if active, we can get the host number, successfully - * rescan, and find LUN's, then we are happy + /* Let's see if the pool still exists - */ + if (!(pool = virStoragePoolObjFindPoolByUUID(pool_uuid))) + break; + + /* Return with pool lock, if active, we can get the host number, + * successfully, rescan, and find LUN's, then we are happy */ VIR_DEBUG("Attempt FC Refresh for pool='%s' name='%s' tries='%d'", pool->def->name, fchost_name, tries); - virStoragePoolObjLock(pool); if (virStoragePoolObjIsActive(pool) && virGetSCSIHostNumber(fchost_name, &host) == 0 && virStorageBackendSCSITriggerRescan(host) == 0) { @@ -617,7 +621,7 @@ virStoragePoolFCRefreshThread(void *opaque) virStoragePoolObjUnlock(pool); } while (!found && --tries); - if (!found) + if (pool && !found) VIR_DEBUG("FC Refresh Thread failed to find LU's"); virStoragePoolFCRefreshDataFree(cbdata); @@ -798,7 +802,7 @@ createVport(virConnectPtr conn, if ((name = virGetFCHostNameByWWN(NULL, adapter->data.fchost.wwnn, adapter->data.fchost.wwpn))) { if (VIR_ALLOC(cbdata) == 0) { - cbdata->pool = pool; + memcpy(cbdata->pool_uuid, pool->def->uuid, VIR_UUID_BUFLEN); cbdata->fchost_name = name; name = NULL;