mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
storage: driver: Split out code fixing pool state after deactivation
After a pool is made inactive the definition objects need to be updated (if a new definition is prepared) and transient pools need to be completely removed. Split out the code doing these steps into a separate function for later reuse.
This commit is contained in:
parent
894133a3bd
commit
aced6b2356
@ -77,6 +77,31 @@ static void storageDriverUnlock(void)
|
|||||||
virMutexUnlock(&driver->lock);
|
virMutexUnlock(&driver->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virStoragePoolUpdateInactive:
|
||||||
|
* @poolptr: pointer to a variable holding the pool object pointer
|
||||||
|
*
|
||||||
|
* This function is supposed to be called after a pool becomes inactive. The
|
||||||
|
* function switches to the new config object for persistent pools. Inactive
|
||||||
|
* pools are removed.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
virStoragePoolUpdateInactive(virStoragePoolObjPtr *poolptr)
|
||||||
|
{
|
||||||
|
virStoragePoolObjPtr pool = *poolptr;
|
||||||
|
|
||||||
|
if (pool->configFile == NULL) {
|
||||||
|
virStoragePoolObjRemove(&driver->pools, pool);
|
||||||
|
*poolptr = NULL;
|
||||||
|
} else if (pool->newDef) {
|
||||||
|
virStoragePoolDefFree(pool->def);
|
||||||
|
pool->def = pool->newDef;
|
||||||
|
pool->newDef = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
storagePoolUpdateState(virStoragePoolObjPtr pool)
|
storagePoolUpdateState(virStoragePoolObjPtr pool)
|
||||||
{
|
{
|
||||||
@ -1071,14 +1096,7 @@ storagePoolDestroy(virStoragePoolPtr obj)
|
|||||||
|
|
||||||
pool->active = false;
|
pool->active = false;
|
||||||
|
|
||||||
if (pool->configFile == NULL) {
|
virStoragePoolUpdateInactive(&pool);
|
||||||
virStoragePoolObjRemove(&driver->pools, pool);
|
|
||||||
pool = NULL;
|
|
||||||
} else if (pool->newDef) {
|
|
||||||
virStoragePoolDefFree(pool->def);
|
|
||||||
pool->def = pool->newDef;
|
|
||||||
pool->newDef = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -1200,10 +1218,8 @@ storagePoolRefresh(virStoragePoolPtr obj,
|
|||||||
0);
|
0);
|
||||||
pool->active = false;
|
pool->active = false;
|
||||||
|
|
||||||
if (pool->configFile == NULL) {
|
virStoragePoolUpdateInactive(&pool);
|
||||||
virStoragePoolObjRemove(&driver->pools, pool);
|
|
||||||
pool = NULL;
|
|
||||||
}
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user