mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virStoragePoolObjListAdd: Turn boolean arg into flags
There will be more boolean information that we want to pass to this function. Instead of having them in separate arguments per each one, use @flags. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7e08447e8f
commit
8c04707058
@ -1509,17 +1509,20 @@ virStoragePoolObjSourceFindDuplicate(virStoragePoolObjListPtr pools,
|
|||||||
* virStoragePoolObjListAdd:
|
* virStoragePoolObjListAdd:
|
||||||
* @pools: Storage Pool object list pointer
|
* @pools: Storage Pool object list pointer
|
||||||
* @def: Storage pool definition to add or update
|
* @def: Storage pool definition to add or update
|
||||||
* @check_active: If true, ensure that pool is not active
|
* @flags: bitwise-OR of VIR_STORAGE_POOL_OBJ_LIST_* flags
|
||||||
*
|
*
|
||||||
* Lookup the @def to see if it already exists in the @pools in order
|
* Lookup the @def to see if it already exists in the @pools in order
|
||||||
* to either update or add if it does not exist.
|
* to either update or add if it does not exist.
|
||||||
*
|
*
|
||||||
|
* If VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE is set in @flags
|
||||||
|
* then this will fail if the pool exists and is active.
|
||||||
|
*
|
||||||
* Returns locked and reffed object pointer or NULL on error
|
* Returns locked and reffed object pointer or NULL on error
|
||||||
*/
|
*/
|
||||||
virStoragePoolObjPtr
|
virStoragePoolObjPtr
|
||||||
virStoragePoolObjListAdd(virStoragePoolObjListPtr pools,
|
virStoragePoolObjListAdd(virStoragePoolObjListPtr pools,
|
||||||
virStoragePoolDefPtr def,
|
virStoragePoolDefPtr def,
|
||||||
bool check_active)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virStoragePoolObjPtr obj = NULL;
|
virStoragePoolObjPtr obj = NULL;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -1530,7 +1533,9 @@ virStoragePoolObjListAdd(virStoragePoolObjListPtr pools,
|
|||||||
if (virStoragePoolObjSourceFindDuplicate(pools, def) < 0)
|
if (virStoragePoolObjSourceFindDuplicate(pools, def) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
rc = virStoragePoolObjIsDuplicate(pools, def, check_active, &obj);
|
rc = virStoragePoolObjIsDuplicate(pools, def,
|
||||||
|
!!(flags & VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE),
|
||||||
|
&obj);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1590,7 +1595,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(obj = virStoragePoolObjListAdd(pools, def, false)))
|
if (!(obj = virStoragePoolObjListAdd(pools, def, 0)))
|
||||||
return NULL;
|
return NULL;
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
@ -1651,7 +1656,8 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr pools,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create the object */
|
/* create the object */
|
||||||
if (!(obj = virStoragePoolObjListAdd(pools, def, true)))
|
if (!(obj = virStoragePoolObjListAdd(pools, def,
|
||||||
|
VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
|
@ -194,10 +194,14 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn,
|
|||||||
virStorageVolPtr **vols,
|
virStorageVolPtr **vols,
|
||||||
virStoragePoolVolumeACLFilter filter);
|
virStoragePoolVolumeACLFilter filter);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),
|
||||||
|
} virStoragePoolObjListFlags;
|
||||||
|
|
||||||
virStoragePoolObjPtr
|
virStoragePoolObjPtr
|
||||||
virStoragePoolObjListAdd(virStoragePoolObjListPtr pools,
|
virStoragePoolObjListAdd(virStoragePoolObjListPtr pools,
|
||||||
virStoragePoolDefPtr def,
|
virStoragePoolDefPtr def,
|
||||||
bool check_active);
|
unsigned int flags);
|
||||||
|
|
||||||
int
|
int
|
||||||
virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
||||||
|
@ -754,7 +754,8 @@ storagePoolCreateXML(virConnectPtr conn,
|
|||||||
if ((backend = virStorageBackendForType(newDef->type)) == NULL)
|
if ((backend = virStorageBackendForType(newDef->type)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(obj = virStoragePoolObjListAdd(driver->pools, newDef, true)))
|
if (!(obj = virStoragePoolObjListAdd(driver->pools, newDef,
|
||||||
|
VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
newDef = NULL;
|
newDef = NULL;
|
||||||
def = virStoragePoolObjGetDef(obj);
|
def = virStoragePoolObjGetDef(obj);
|
||||||
@ -829,7 +830,7 @@ storagePoolDefineXML(virConnectPtr conn,
|
|||||||
if (virStorageBackendForType(newDef->type) == NULL)
|
if (virStorageBackendForType(newDef->type) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(obj = virStoragePoolObjListAdd(driver->pools, newDef, false)))
|
if (!(obj = virStoragePoolObjListAdd(driver->pools, newDef, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
newDef = virStoragePoolObjGetNewDef(obj);
|
newDef = virStoragePoolObjGetNewDef(obj);
|
||||||
def = virStoragePoolObjGetDef(obj);
|
def = virStoragePoolObjGetDef(obj);
|
||||||
|
@ -1140,7 +1140,7 @@ testParseStorage(testDriverPtr privconn,
|
|||||||
if (!def)
|
if (!def)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(obj = virStoragePoolObjListAdd(privconn->pools, def, false))) {
|
if (!(obj = virStoragePoolObjListAdd(privconn->pools, def, 0))) {
|
||||||
virStoragePoolDefFree(def);
|
virStoragePoolDefFree(def);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -6436,7 +6436,8 @@ testStoragePoolCreateXML(virConnectPtr conn,
|
|||||||
if (!(newDef = virStoragePoolDefParseString(xml)))
|
if (!(newDef = virStoragePoolDefParseString(xml)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(obj = virStoragePoolObjListAdd(privconn->pools, newDef, true)))
|
if (!(obj = virStoragePoolObjListAdd(privconn->pools, newDef,
|
||||||
|
VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
newDef = NULL;
|
newDef = NULL;
|
||||||
def = virStoragePoolObjGetDef(obj);
|
def = virStoragePoolObjGetDef(obj);
|
||||||
@ -6502,7 +6503,7 @@ testStoragePoolDefineXML(virConnectPtr conn,
|
|||||||
newDef->allocation = defaultPoolAlloc;
|
newDef->allocation = defaultPoolAlloc;
|
||||||
newDef->available = defaultPoolCap - defaultPoolAlloc;
|
newDef->available = defaultPoolCap - defaultPoolAlloc;
|
||||||
|
|
||||||
if (!(obj = virStoragePoolObjListAdd(privconn->pools, newDef, false)))
|
if (!(obj = virStoragePoolObjListAdd(privconn->pools, newDef, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
newDef = NULL;
|
newDef = NULL;
|
||||||
def = virStoragePoolObjGetDef(obj);
|
def = virStoragePoolObjGetDef(obj);
|
||||||
|
Loading…
Reference in New Issue
Block a user