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 virStoragePoolObj *virStoragePoolObjPtr;
|
|
|
|
|
|
|
|
typedef struct _virStoragePoolObjList virStoragePoolObjList;
|
|
|
|
typedef virStoragePoolObjList *virStoragePoolObjListPtr;
|
|
|
|
|
|
|
|
typedef struct _virStorageDriverState virStorageDriverState;
|
|
|
|
typedef virStorageDriverState *virStorageDriverStatePtr;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2017-10-07 11:24:24 +00:00
|
|
|
virStoragePoolObjListPtr pools;
|
2017-03-07 20:18:01 +00:00
|
|
|
|
|
|
|
char *configDir;
|
|
|
|
char *autostartDir;
|
|
|
|
char *stateDir;
|
|
|
|
bool privileged;
|
|
|
|
|
|
|
|
/* Immutable pointer, self-locking APIs */
|
|
|
|
virObjectEventStatePtr storageEventState;
|
2019-01-10 12:23:26 +00:00
|
|
|
|
|
|
|
/* Immutable pointer, read only after initialized */
|
|
|
|
virCapsPtr caps;
|
2017-03-07 20:18:01 +00:00
|
|
|
};
|
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
typedef bool
|
|
|
|
(*virStoragePoolObjListFilter)(virConnectPtr conn,
|
|
|
|
virStoragePoolDefPtr def);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-05-08 20:02:36 +00:00
|
|
|
virStoragePoolObjPtr
|
|
|
|
virStoragePoolObjNew(void);
|
|
|
|
|
2017-10-08 13:09:09 +00:00
|
|
|
void
|
|
|
|
virStoragePoolObjEndAPI(virStoragePoolObjPtr *obj);
|
|
|
|
|
2017-05-07 11:56:03 +00:00
|
|
|
virStoragePoolDefPtr
|
|
|
|
virStoragePoolObjGetDef(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjSetDef(virStoragePoolObjPtr obj,
|
|
|
|
virStoragePoolDefPtr def);
|
|
|
|
|
|
|
|
virStoragePoolDefPtr
|
|
|
|
virStoragePoolObjGetNewDef(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj);
|
|
|
|
|
2017-09-19 12:55:43 +00:00
|
|
|
const char *
|
2017-05-07 11:56:03 +00:00
|
|
|
virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj,
|
|
|
|
char *configFile);
|
|
|
|
|
2017-09-19 12:55:43 +00:00
|
|
|
const char *
|
2017-05-07 11:56:03 +00:00
|
|
|
virStoragePoolObjGetAutostartLink(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
bool
|
|
|
|
virStoragePoolObjIsActive(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjSetActive(virStoragePoolObjPtr obj,
|
|
|
|
bool active);
|
|
|
|
|
2019-05-24 14:35:46 +00:00
|
|
|
void
|
|
|
|
virStoragePoolObjSetStarting(virStoragePoolObjPtr obj,
|
|
|
|
bool starting);
|
|
|
|
bool
|
|
|
|
virStoragePoolObjIsStarting(virStoragePoolObjPtr obj);
|
|
|
|
|
2017-05-07 11:56:03 +00:00
|
|
|
bool
|
|
|
|
virStoragePoolObjIsAutostart(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjSetAutostart(virStoragePoolObjPtr obj,
|
2017-08-19 12:16:18 +00:00
|
|
|
bool autostart);
|
2017-05-07 11:56:03 +00:00
|
|
|
|
|
|
|
unsigned int
|
|
|
|
virStoragePoolObjGetAsyncjobs(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjIncrAsyncjobs(virStoragePoolObjPtr obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjDecrAsyncjobs(virStoragePoolObjPtr obj);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
int
|
2017-03-07 21:10:38 +00:00
|
|
|
virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools,
|
|
|
|
const char *configDir,
|
|
|
|
const char *autostartDir);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
int
|
2017-03-07 21:10:38 +00:00
|
|
|
virStoragePoolObjLoadAllState(virStoragePoolObjListPtr pools,
|
|
|
|
const char *stateDir);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-03-07 20:18:01 +00:00
|
|
|
virStoragePoolObjPtr
|
|
|
|
virStoragePoolObjFindByUUID(virStoragePoolObjListPtr pools,
|
|
|
|
const unsigned char *uuid);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-03-07 20:18:01 +00:00
|
|
|
virStoragePoolObjPtr
|
|
|
|
virStoragePoolObjFindByName(virStoragePoolObjListPtr pools,
|
|
|
|
const char *name);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-05-09 12:05:16 +00:00
|
|
|
int
|
|
|
|
virStoragePoolObjAddVol(virStoragePoolObjPtr obj,
|
|
|
|
virStorageVolDefPtr voldef);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjRemoveVol(virStoragePoolObjPtr obj,
|
|
|
|
virStorageVolDefPtr voldef);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
virStoragePoolObjGetVolumesCount(virStoragePoolObjPtr obj);
|
|
|
|
|
2017-05-09 12:18:33 +00:00
|
|
|
typedef int
|
|
|
|
(*virStorageVolObjListIterator)(virStorageVolDefPtr voldef,
|
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
int
|
|
|
|
virStoragePoolObjForEachVolume(virStoragePoolObjPtr obj,
|
|
|
|
virStorageVolObjListIterator iter,
|
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
typedef bool
|
|
|
|
(*virStorageVolObjListSearcher)(virStorageVolDefPtr voldef,
|
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
virStorageVolDefPtr
|
|
|
|
virStoragePoolObjSearchVolume(virStoragePoolObjPtr obj,
|
|
|
|
virStorageVolObjListSearcher iter,
|
|
|
|
const void *opaque);
|
|
|
|
|
2017-03-07 20:18:01 +00:00
|
|
|
virStorageVolDefPtr
|
2017-05-05 19:12:59 +00:00
|
|
|
virStorageVolDefFindByKey(virStoragePoolObjPtr obj,
|
2017-03-07 20:18:01 +00:00
|
|
|
const char *key);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-03-07 20:18:01 +00:00
|
|
|
virStorageVolDefPtr
|
2017-05-05 19:12:59 +00:00
|
|
|
virStorageVolDefFindByPath(virStoragePoolObjPtr obj,
|
2017-03-07 20:18:01 +00:00
|
|
|
const char *path);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-03-07 20:18:01 +00:00
|
|
|
virStorageVolDefPtr
|
2017-05-05 19:12:59 +00:00
|
|
|
virStorageVolDefFindByName(virStoragePoolObjPtr obj,
|
2017-03-07 20:18:01 +00:00
|
|
|
const char *name);
|
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
void
|
2017-05-05 19:12:59 +00:00
|
|
|
virStoragePoolObjClearVols(virStoragePoolObjPtr obj);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-20 14:13:27 +00:00
|
|
|
typedef bool
|
|
|
|
(*virStoragePoolVolumeACLFilter)(virConnectPtr conn,
|
|
|
|
virStoragePoolDefPtr pool,
|
|
|
|
virStorageVolDefPtr def);
|
|
|
|
|
|
|
|
int
|
2017-05-09 11:00:41 +00:00
|
|
|
virStoragePoolObjNumOfVolumes(virStoragePoolObjPtr 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
|
2017-05-09 11:00:41 +00:00
|
|
|
virStoragePoolObjVolumeGetNames(virStoragePoolObjPtr 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,
|
2017-05-09 11:00:41 +00:00
|
|
|
virStoragePoolObjPtr 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;
|
|
|
|
|
2017-03-07 20:18:01 +00:00
|
|
|
virStoragePoolObjPtr
|
2019-05-24 14:35:41 +00:00
|
|
|
virStoragePoolObjListAdd(virStoragePoolObjListPtr pools,
|
|
|
|
virStoragePoolDefPtr 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
|
|
|
|
virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
|
2017-05-05 19:12:59 +00:00
|
|
|
virStoragePoolObjPtr obj,
|
2017-03-07 20:44:41 +00:00
|
|
|
virStoragePoolDefPtr def);
|
|
|
|
|
|
|
|
int
|
2017-05-05 19:12:59 +00:00
|
|
|
virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-03-21 10:30:46 +00:00
|
|
|
typedef bool (*virStoragePoolObjListACLFilter)(virConnectPtr conn,
|
|
|
|
virStoragePoolDefPtr def);
|
|
|
|
|
|
|
|
int
|
|
|
|
virStoragePoolObjNumOfStoragePools(virStoragePoolObjListPtr pools,
|
|
|
|
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
|
|
|
|
virStoragePoolObjGetNames(virStoragePoolObjListPtr pools,
|
|
|
|
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
|
2017-05-05 19:12:59 +00:00
|
|
|
virStoragePoolObjFree(virStoragePoolObjPtr obj);
|
2017-03-07 20:44:41 +00:00
|
|
|
|
2017-10-08 12:14:56 +00:00
|
|
|
typedef void
|
|
|
|
(*virStoragePoolObjListIterator)(virStoragePoolObjPtr obj,
|
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
void
|
|
|
|
virStoragePoolObjListForEach(virStoragePoolObjListPtr pools,
|
|
|
|
virStoragePoolObjListIterator iter,
|
|
|
|
const void *opaque);
|
|
|
|
|
2017-10-08 12:44:31 +00:00
|
|
|
typedef bool
|
|
|
|
(*virStoragePoolObjListSearcher)(virStoragePoolObjPtr obj,
|
|
|
|
const void *opaque);
|
|
|
|
|
|
|
|
virStoragePoolObjPtr
|
|
|
|
virStoragePoolObjListSearch(virStoragePoolObjListPtr pools,
|
|
|
|
virStoragePoolObjListSearcher searcher,
|
|
|
|
const void *opaque);
|
|
|
|
|
2017-10-07 11:24:24 +00:00
|
|
|
virStoragePoolObjListPtr
|
|
|
|
virStoragePoolObjListNew(void);
|
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
void
|
|
|
|
virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
|
2017-05-05 19:12:59 +00:00
|
|
|
virStoragePoolObjPtr obj);
|
2017-03-07 20:18:01 +00:00
|
|
|
|
2017-03-07 20:44:41 +00:00
|
|
|
int
|
|
|
|
virStoragePoolObjListExport(virConnectPtr conn,
|
2017-03-21 14:07:46 +00:00
|
|
|
virStoragePoolObjListPtr poolobjs,
|
2017-03-07 20:44:41 +00:00
|
|
|
virStoragePoolPtr **pools,
|
|
|
|
virStoragePoolObjListFilter filter,
|
|
|
|
unsigned int flags);
|