2017-03-07 20:18:01 +00:00
|
|
|
/*
|
|
|
|
* virstorageobj.h: internal storage pool and volume objects handling
|
|
|
|
* (derived from storage_conf.h)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-07 20:20:20 +00:00
|
|
|
#pragma once
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2019-06-07 20:20:20 +00:00
|
|
|
#include "internal.h"
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2019-06-07 20:20:20 +00:00
|
|
|
#include "storage_conf.h"
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2019-06-07 20:20:20 +00:00
|
|
|
#include "capabilities.h"
|
2019-01-10 12:23:26 +00:00
|
|
|
|
2017-03-07 20:18:01 +00:00
|
|
|
typedef struct _virStoragePoolObj virStoragePoolObj;
|
|
|
|
|
|
|
|
typedef struct _virStoragePoolObjList virStoragePoolObjList;
|
|
|
|
|
|
|
|
typedef struct _virStorageDriverState virStorageDriverState;
|
|
|
|
struct _virStorageDriverState {
|
|
|
|
virMutex lock;
|
|
|
|
|
2019-05-23 10:34:08 +00:00
|
|
|
/* pid file FD, ensures two copies of the driver can't use the same root */
|
|
|
|
int lockFD;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjList *pools;
|
2017-03-07 20:18:01 +00:00
|
|
|
|
|
|
|
char *configDir;
|
|
|
|
char *autostartDir;
|
|
|
|
char *stateDir;
|
|
|
|
bool privileged;
|
|
|
|
|
|
|
|
/* Immutable pointer, self-locking APIs */
|
2021-03-11 07:16:13 +00:00
|
|
|
virObjectEventState *storageEventState;
|
2019-01-10 12:23:26 +00:00
|
|
|
|
|
|
|
/* Immutable pointer, read only after initialized */
|
2021-03-11 07:16:13 +00:00
|
|
|
virCaps *caps;
|
2017-03-07 20:18:01 +00:00
|
|
|
};
|
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
typedef bool
|
|
|
|
(*virStoragePoolObjListFilter)(virConnectPtr conn,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolDef *def);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObj *
|
2017-05-08 20:02:36 +00:00
|
|
|
virStoragePoolObjNew(void);
|
|
|
|
|
2017-10-08 13:09:09 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjEndAPI(virStoragePoolObj **obj);
|
2017-10-08 13:09:09 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolDef *
|
|
|
|
virStoragePoolObjGetDef(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjSetDef(virStoragePoolObj *obj,
|
|
|
|
virStoragePoolDef *def);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolDef *
|
|
|
|
virStoragePoolObjGetNewDef(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjDefUseNewDef(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
2017-09-19 12:55:43 +00:00
|
|
|
const char *
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjGetConfigFile(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjSetConfigFile(virStoragePoolObj *obj,
|
2017-05-07 11:56:03 +00:00
|
|
|
char *configFile);
|
|
|
|
|
2017-09-19 12:55:43 +00:00
|
|
|
const char *
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjGetAutostartLink(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjIsActive(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjSetActive(virStoragePoolObj *obj,
|
2017-05-07 11:56:03 +00:00
|
|
|
bool active);
|
|
|
|
|
2019-05-24 14:35:46 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjSetStarting(virStoragePoolObj *obj,
|
2019-05-24 14:35:46 +00:00
|
|
|
bool starting);
|
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjIsStarting(virStoragePoolObj *obj);
|
2019-05-24 14:35:46 +00:00
|
|
|
|
2017-05-07 11:56:03 +00:00
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjIsAutostart(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjSetAutostart(virStoragePoolObj *obj,
|
2017-08-19 12:16:18 +00:00
|
|
|
bool autostart);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
unsigned int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjGetAsyncjobs(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjIncrAsyncjobs(virStoragePoolObj *obj);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjDecrAsyncjobs(virStoragePoolObj *obj);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjLoadAllConfigs(virStoragePoolObjList *pools,
|
2017-03-07 21:10:38 +00:00
|
|
|
const char *configDir,
|
|
|
|
const char *autostartDir);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjLoadAllState(virStoragePoolObjList *pools,
|
2017-03-07 21:10:38 +00:00
|
|
|
const char *stateDir);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObj *
|
|
|
|
virStoragePoolObjFindByUUID(virStoragePoolObjList *pools,
|
2017-03-07 20:18:01 +00:00
|
|
|
const unsigned char *uuid);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObj *
|
|
|
|
virStoragePoolObjFindByName(virStoragePoolObjList *pools,
|
2017-03-07 20:18:01 +00:00
|
|
|
const char *name);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-05-09 12:05:16 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjAddVol(virStoragePoolObj *obj,
|
|
|
|
virStorageVolDef *voldef);
|
2017-05-09 12:05:16 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjRemoveVol(virStoragePoolObj *obj,
|
|
|
|
virStorageVolDef *voldef);
|
2017-05-09 12:05:16 +00:00
|
|
|
|
|
|
|
size_t
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjGetVolumesCount(virStoragePoolObj *obj);
|
2017-05-09 12:05:16 +00:00
|
|
|
|
2017-05-09 12:18:33 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virStorageVolObjListIterator)(virStorageVolDef *voldef,
|
2017-05-09 12:18:33 +00:00
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjForEachVolume(virStoragePoolObj *obj,
|
2017-05-09 12:18:33 +00:00
|
|
|
virStorageVolObjListIterator iter,
|
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
typedef bool
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virStorageVolObjListSearcher)(virStorageVolDef *voldef,
|
2017-05-09 12:18:33 +00:00
|
|
|
const void *opaque);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageVolDef *
|
|
|
|
virStoragePoolObjSearchVolume(virStoragePoolObj *obj,
|
2017-05-09 12:18:33 +00:00
|
|
|
virStorageVolObjListSearcher iter,
|
|
|
|
const void *opaque);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageVolDef *
|
|
|
|
virStorageVolDefFindByKey(virStoragePoolObj *obj,
|
2017-03-07 20:18:01 +00:00
|
|
|
const char *key);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageVolDef *
|
|
|
|
virStorageVolDefFindByPath(virStoragePoolObj *obj,
|
2017-03-07 20:18:01 +00:00
|
|
|
const char *path);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageVolDef *
|
|
|
|
virStorageVolDefFindByName(virStoragePoolObj *obj,
|
2017-03-07 20:18:01 +00:00
|
|
|
const char *name);
|
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjClearVols(virStoragePoolObj *obj);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-20 14:13:27 +00:00
|
|
|
typedef bool
|
|
|
|
(*virStoragePoolVolumeACLFilter)(virConnectPtr conn,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolDef *pool,
|
|
|
|
virStorageVolDef *def);
|
2017-03-20 14:13:27 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjNumOfVolumes(virStoragePoolObj *obj,
|
2017-03-20 14:13:27 +00:00
|
|
|
virConnectPtr conn,
|
2017-08-16 13:26:59 +00:00
|
|
|
virStoragePoolVolumeACLFilter filter);
|
2017-03-20 14:13:27 +00:00
|
|
|
|
2017-03-20 16:16:26 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjVolumeGetNames(virStoragePoolObj *obj,
|
2017-03-20 16:16:26 +00:00
|
|
|
virConnectPtr conn,
|
2017-08-16 13:26:59 +00:00
|
|
|
virStoragePoolVolumeACLFilter filter,
|
2017-03-20 16:16:26 +00:00
|
|
|
char **const names,
|
|
|
|
int maxnames);
|
|
|
|
|
2017-03-20 17:48:47 +00:00
|
|
|
int
|
|
|
|
virStoragePoolObjVolumeListExport(virConnectPtr conn,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObj *obj,
|
2017-03-20 17:48:47 +00:00
|
|
|
virStorageVolPtr **vols,
|
2017-08-16 13:26:59 +00:00
|
|
|
virStoragePoolVolumeACLFilter filter);
|
2017-03-20 17:48:47 +00:00
|
|
|
|
2019-05-24 14:35:42 +00:00
|
|
|
typedef enum {
|
2019-05-24 14:35:44 +00:00
|
|
|
VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE = (1 << 0),
|
2019-05-24 14:35:42 +00:00
|
|
|
VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),
|
|
|
|
} virStoragePoolObjListFlags;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObj *
|
|
|
|
virStoragePoolObjListAdd(virStoragePoolObjList *pools,
|
|
|
|
virStoragePoolDef *def,
|
2019-05-24 14:35:42 +00:00
|
|
|
unsigned int flags);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjSaveDef(virStorageDriverState *driver,
|
|
|
|
virStoragePoolObj *obj,
|
|
|
|
virStoragePoolDef *def);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjDeleteDef(virStoragePoolObj *obj);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-03-21 10:30:46 +00:00
|
|
|
typedef bool (*virStoragePoolObjListACLFilter)(virConnectPtr conn,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolDef *def);
|
2017-03-21 10:30:46 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjNumOfStoragePools(virStoragePoolObjList *pools,
|
2017-03-21 10:30:46 +00:00
|
|
|
virConnectPtr conn,
|
|
|
|
bool wantActive,
|
2017-08-16 13:26:59 +00:00
|
|
|
virStoragePoolObjListACLFilter filter);
|
2017-03-21 10:30:46 +00:00
|
|
|
|
2017-03-21 13:15:18 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjGetNames(virStoragePoolObjList *pools,
|
2017-03-21 13:15:18 +00:00
|
|
|
virConnectPtr conn,
|
|
|
|
bool wantActive,
|
2017-08-16 13:26:59 +00:00
|
|
|
virStoragePoolObjListACLFilter filter,
|
2017-03-21 13:15:18 +00:00
|
|
|
char **const names,
|
|
|
|
int maxnames);
|
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjFree(virStoragePoolObj *obj);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-10-08 12:14:56 +00:00
|
|
|
typedef void
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virStoragePoolObjListIterator)(virStoragePoolObj *obj,
|
2017-10-08 12:14:56 +00:00
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjListForEach(virStoragePoolObjList *pools,
|
2017-10-08 12:14:56 +00:00
|
|
|
virStoragePoolObjListIterator iter,
|
|
|
|
const void *opaque);
|
|
|
|
|
2017-10-08 12:44:31 +00:00
|
|
|
typedef bool
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virStoragePoolObjListSearcher)(virStoragePoolObj *obj,
|
2017-10-08 12:44:31 +00:00
|
|
|
const void *opaque);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObj *
|
|
|
|
virStoragePoolObjListSearch(virStoragePoolObjList *pools,
|
2017-10-08 12:44:31 +00:00
|
|
|
virStoragePoolObjListSearcher searcher,
|
|
|
|
const void *opaque);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjList *
|
2017-10-07 11:24:24 +00:00
|
|
|
virStoragePoolObjListNew(void);
|
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjRemove(virStoragePoolObjList *pools,
|
|
|
|
virStoragePoolObj *obj);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
int
|
|
|
|
virStoragePoolObjListExport(virConnectPtr conn,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolObjList *poolobjs,
|
2017-03-07 20:44:41 +00:00
|
|
|
virStoragePoolPtr **pools,
|
|
|
|
virStoragePoolObjListFilter filter,
|
|
|
|
unsigned int flags);
|