You need to sign in or sign up before continuing.
virstorageobj.h 7.6 KB
Newer Older
J
John Ferlan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/*
 * 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/>.
 */

#ifndef __VIRSTORAGEOBJ_H__
# define __VIRSTORAGEOBJ_H__

# include "internal.h"

# include "storage_conf.h"

typedef struct _virStoragePoolObj virStoragePoolObj;
typedef virStoragePoolObj *virStoragePoolObjPtr;

typedef struct _virStoragePoolObjList virStoragePoolObjList;
typedef virStoragePoolObjList *virStoragePoolObjListPtr;
struct _virStoragePoolObjList {
    size_t count;
    virStoragePoolObjPtr *objs;
};

typedef struct _virStorageDriverState virStorageDriverState;
typedef virStorageDriverState *virStorageDriverStatePtr;

struct _virStorageDriverState {
    virMutex lock;

    virStoragePoolObjList pools;

    char *configDir;
    char *autostartDir;
    char *stateDir;
    bool privileged;

    /* Immutable pointer, self-locking APIs */
    virObjectEventStatePtr storageEventState;
};

54 55 56
typedef bool
(*virStoragePoolObjListFilter)(virConnectPtr conn,
                               virStoragePoolDefPtr def);
J
John Ferlan 已提交
57

58 59 60
virStoragePoolObjPtr
virStoragePoolObjNew(void);

61 62 63 64 65 66 67 68 69 70 71 72 73
virStoragePoolDefPtr
virStoragePoolObjGetDef(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetDef(virStoragePoolObjPtr obj,
                        virStoragePoolDefPtr def);

virStoragePoolDefPtr
virStoragePoolObjGetNewDef(virStoragePoolObjPtr obj);

void
virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj);

74
const char *
75 76 77 78 79 80
virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj,
                               char *configFile);

81
const char *
82 83 84 85 86 87 88 89 90 91 92 93 94 95
virStoragePoolObjGetAutostartLink(virStoragePoolObjPtr obj);

bool
virStoragePoolObjIsActive(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetActive(virStoragePoolObjPtr obj,
                           bool active);

bool
virStoragePoolObjIsAutostart(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetAutostart(virStoragePoolObjPtr obj,
96
                              bool autostart);
97 98 99 100 101 102 103 104 105

unsigned int
virStoragePoolObjGetAsyncjobs(virStoragePoolObjPtr obj);

void
virStoragePoolObjIncrAsyncjobs(virStoragePoolObjPtr obj);

void
virStoragePoolObjDecrAsyncjobs(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
106

107
int
108 109 110
virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools,
                                const char *configDir,
                                const char *autostartDir);
J
John Ferlan 已提交
111

112
int
113 114
virStoragePoolObjLoadAllState(virStoragePoolObjListPtr pools,
                              const char *stateDir);
115

J
John Ferlan 已提交
116 117 118
virStoragePoolObjPtr
virStoragePoolObjFindByUUID(virStoragePoolObjListPtr pools,
                            const unsigned char *uuid);
119

J
John Ferlan 已提交
120 121 122
virStoragePoolObjPtr
virStoragePoolObjFindByName(virStoragePoolObjListPtr pools,
                            const char *name);
123

124 125 126 127 128 129 130 131 132 133 134
int
virStoragePoolObjAddVol(virStoragePoolObjPtr obj,
                        virStorageVolDefPtr voldef);

void
virStoragePoolObjRemoveVol(virStoragePoolObjPtr obj,
                           virStorageVolDefPtr voldef);

size_t
virStoragePoolObjGetVolumesCount(virStoragePoolObjPtr obj);

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
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);

J
John Ferlan 已提交
153
virStorageVolDefPtr
154
virStorageVolDefFindByKey(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
155
                          const char *key);
156

J
John Ferlan 已提交
157
virStorageVolDefPtr
158
virStorageVolDefFindByPath(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
159
                           const char *path);
160

J
John Ferlan 已提交
161
virStorageVolDefPtr
162
virStorageVolDefFindByName(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
163 164
                           const char *name);

165
void
166
virStoragePoolObjClearVols(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
167

168 169 170 171 172 173
typedef bool
(*virStoragePoolVolumeACLFilter)(virConnectPtr conn,
                                 virStoragePoolDefPtr pool,
                                 virStorageVolDefPtr def);

int
174
virStoragePoolObjNumOfVolumes(virStoragePoolObjPtr obj,
175
                              virConnectPtr conn,
176
                              virStoragePoolVolumeACLFilter filter);
177

178
int
179
virStoragePoolObjVolumeGetNames(virStoragePoolObjPtr obj,
180
                                virConnectPtr conn,
181
                                virStoragePoolVolumeACLFilter filter,
182 183 184
                                char **const names,
                                int maxnames);

185 186
int
virStoragePoolObjVolumeListExport(virConnectPtr conn,
187
                                  virStoragePoolObjPtr obj,
188
                                  virStorageVolPtr **vols,
189
                                  virStoragePoolVolumeACLFilter filter);
190

J
John Ferlan 已提交
191 192 193 194
virStoragePoolObjPtr
virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
                           virStoragePoolDefPtr def);

195 196
int
virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
197
                         virStoragePoolObjPtr obj,
198 199 200
                         virStoragePoolDefPtr def);

int
201
virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj);
202

203 204 205 206 207 208 209
typedef bool (*virStoragePoolObjListACLFilter)(virConnectPtr conn,
                                               virStoragePoolDefPtr def);

int
virStoragePoolObjNumOfStoragePools(virStoragePoolObjListPtr pools,
                                   virConnectPtr conn,
                                   bool wantActive,
210
                                   virStoragePoolObjListACLFilter filter);
211

212 213 214 215
int
virStoragePoolObjGetNames(virStoragePoolObjListPtr pools,
                          virConnectPtr conn,
                          bool wantActive,
216
                          virStoragePoolObjListACLFilter filter,
217 218 219
                          char **const names,
                          int maxnames);

220
void
221
virStoragePoolObjFree(virStoragePoolObjPtr obj);
222 223 224 225 226 227

void
virStoragePoolObjListFree(virStoragePoolObjListPtr pools);

void
virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
228
                        virStoragePoolObjPtr obj);
J
John Ferlan 已提交
229

230 231 232 233
int
virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
                             virStoragePoolDefPtr def,
                             unsigned int check_active);
J
John Ferlan 已提交
234

235
int
236 237 238
virStoragePoolObjSourceFindDuplicate(virConnectPtr conn,
                                     virStoragePoolObjListPtr pools,
                                     virStoragePoolDefPtr def);
J
John Ferlan 已提交
239

240 241
void
virStoragePoolObjLock(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
242

243 244
void
virStoragePoolObjUnlock(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
245

246 247
int
virStoragePoolObjListExport(virConnectPtr conn,
J
John Ferlan 已提交
248
                            virStoragePoolObjListPtr poolobjs,
249 250 251
                            virStoragePoolPtr **pools,
                            virStoragePoolObjListFilter filter,
                            unsigned int flags);
J
John Ferlan 已提交
252 253

#endif /* __VIRSTORAGEOBJ_H__ */