mirror of https://gitee.com/openkylin/libvirt.git
storage: Use virStoragePoolObjGetDef accessor for SCSI backend
In preparation for privatizing the object, use the accessor.
This commit is contained in:
parent
4d95a14faf
commit
d823466bc2
|
@ -139,6 +139,7 @@ virStoragePoolFCRefreshThread(void *opaque)
|
||||||
const char *fchost_name = cbdata->fchost_name;
|
const char *fchost_name = cbdata->fchost_name;
|
||||||
const unsigned char *pool_uuid = cbdata->pool_uuid;
|
const unsigned char *pool_uuid = cbdata->pool_uuid;
|
||||||
virStoragePoolObjPtr pool = NULL;
|
virStoragePoolObjPtr pool = NULL;
|
||||||
|
virStoragePoolDefPtr def;
|
||||||
unsigned int host;
|
unsigned int host;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int tries = 2;
|
int tries = 2;
|
||||||
|
@ -149,14 +150,15 @@ virStoragePoolFCRefreshThread(void *opaque)
|
||||||
/* Let's see if the pool still exists - */
|
/* Let's see if the pool still exists - */
|
||||||
if (!(pool = virStoragePoolObjFindPoolByUUID(pool_uuid)))
|
if (!(pool = virStoragePoolObjFindPoolByUUID(pool_uuid)))
|
||||||
break;
|
break;
|
||||||
|
def = virStoragePoolObjGetDef(pool);
|
||||||
|
|
||||||
/* Return with pool lock, if active, we can get the host number,
|
/* Return with pool lock, if active, we can get the host number,
|
||||||
* successfully, rescan, and find LUN's, then we are happy
|
* successfully, rescan, and find LUN's, then we are happy
|
||||||
*/
|
*/
|
||||||
VIR_DEBUG("Attempt FC Refresh for pool='%s' name='%s' tries='%d'",
|
VIR_DEBUG("Attempt FC Refresh for pool='%s' name='%s' tries='%d'",
|
||||||
pool->def->name, fchost_name, tries);
|
def->name, fchost_name, tries);
|
||||||
|
|
||||||
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
|
def->allocation = def->capacity = def->available = 0;
|
||||||
|
|
||||||
if (virStoragePoolObjIsActive(pool) &&
|
if (virStoragePoolObjIsActive(pool) &&
|
||||||
virSCSIHostGetNumber(fchost_name, &host) == 0 &&
|
virSCSIHostGetNumber(fchost_name, &host) == 0 &&
|
||||||
|
@ -371,6 +373,7 @@ static int
|
||||||
virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
|
virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
|
||||||
bool *isActive)
|
bool *isActive)
|
||||||
{
|
{
|
||||||
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
unsigned int host;
|
unsigned int host;
|
||||||
|
@ -378,13 +381,12 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
|
||||||
|
|
||||||
*isActive = false;
|
*isActive = false;
|
||||||
|
|
||||||
if (!(name = getAdapterName(&pool->def->source.adapter))) {
|
if (!(name = getAdapterName(&def->source.adapter))) {
|
||||||
/* It's normal for the pool with "fc_host" type source
|
/* It's normal for the pool with "fc_host" type source
|
||||||
* adapter fails to get the adapter name, since the vHBA
|
* adapter fails to get the adapter name, since the vHBA
|
||||||
* the adapter based on might be not created yet.
|
* the adapter based on might be not created yet.
|
||||||
*/
|
*/
|
||||||
if (pool->def->source.adapter.type ==
|
if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) {
|
||||||
VIR_STORAGE_ADAPTER_TYPE_FC_HOST) {
|
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -412,13 +414,14 @@ static int
|
||||||
virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
|
virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
virStoragePoolObjPtr pool)
|
virStoragePoolObjPtr pool)
|
||||||
{
|
{
|
||||||
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
unsigned int host;
|
unsigned int host;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
|
def->allocation = def->capacity = def->available = 0;
|
||||||
|
|
||||||
if (!(name = getAdapterName(&pool->def->source.adapter)))
|
if (!(name = getAdapterName(&def->source.adapter)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virSCSIHostGetNumber(name, &host) < 0)
|
if (virSCSIHostGetNumber(name, &host) < 0)
|
||||||
|
@ -443,11 +446,12 @@ static int
|
||||||
virStorageBackendSCSIStartPool(virConnectPtr conn,
|
virStorageBackendSCSIStartPool(virConnectPtr conn,
|
||||||
virStoragePoolObjPtr pool)
|
virStoragePoolObjPtr pool)
|
||||||
{
|
{
|
||||||
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
const char *configFile = virStoragePoolObjGetConfigFile(pool);
|
const char *configFile = virStoragePoolObjGetConfigFile(pool);
|
||||||
|
|
||||||
if (pool->def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST)
|
if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST)
|
||||||
return createVport(conn, pool->def, configFile,
|
return createVport(conn, def, configFile,
|
||||||
&pool->def->source.adapter.data.fchost);
|
&def->source.adapter.data.fchost);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -457,9 +461,11 @@ static int
|
||||||
virStorageBackendSCSIStopPool(virConnectPtr conn,
|
virStorageBackendSCSIStopPool(virConnectPtr conn,
|
||||||
virStoragePoolObjPtr pool)
|
virStoragePoolObjPtr pool)
|
||||||
{
|
{
|
||||||
if (pool->def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST)
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
|
|
||||||
|
if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST)
|
||||||
return virNodeDeviceDeleteVport(conn,
|
return virNodeDeviceDeleteVport(conn,
|
||||||
&pool->def->source.adapter.data.fchost);
|
&def->source.adapter.data.fchost);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue