virstorageobj.h 7.9 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
/*
 * 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/>.
 */

20
#pragma once
J
John Ferlan 已提交
21

22
#include "internal.h"
J
John Ferlan 已提交
23

24
#include "storage_conf.h"
J
John Ferlan 已提交
25

26
#include "capabilities.h"
27

J
John Ferlan 已提交
28 29 30 31 32 33 34 35 36 37 38 39
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;

40 41 42
    /* pid file FD, ensures two copies of the driver can't use the same root */
    int lockFD;

43
    virStoragePoolObjListPtr pools;
J
John Ferlan 已提交
44 45 46 47 48 49 50 51

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

    /* Immutable pointer, self-locking APIs */
    virObjectEventStatePtr storageEventState;
52 53 54

    /* Immutable pointer, read only after initialized */
    virCapsPtr caps;
J
John Ferlan 已提交
55 56
};

57 58 59
typedef bool
(*virStoragePoolObjListFilter)(virConnectPtr conn,
                               virStoragePoolDefPtr def);
J
John Ferlan 已提交
60

61 62 63
virStoragePoolObjPtr
virStoragePoolObjNew(void);

64 65 66
void
virStoragePoolObjEndAPI(virStoragePoolObjPtr *obj);

67 68 69 70 71 72 73 74 75 76 77 78 79
virStoragePoolDefPtr
virStoragePoolObjGetDef(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetDef(virStoragePoolObjPtr obj,
                        virStoragePoolDefPtr def);

virStoragePoolDefPtr
virStoragePoolObjGetNewDef(virStoragePoolObjPtr obj);

void
virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj);

80
const char *
81 82 83 84 85 86
virStoragePoolObjGetConfigFile(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetConfigFile(virStoragePoolObjPtr obj,
                               char *configFile);

87
const char *
88 89 90 91 92 93 94 95 96 97 98 99 100 101
virStoragePoolObjGetAutostartLink(virStoragePoolObjPtr obj);

bool
virStoragePoolObjIsActive(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetActive(virStoragePoolObjPtr obj,
                           bool active);

bool
virStoragePoolObjIsAutostart(virStoragePoolObjPtr obj);

void
virStoragePoolObjSetAutostart(virStoragePoolObjPtr obj,
102
                              bool autostart);
103 104 105 106 107 108 109 110 111

unsigned int
virStoragePoolObjGetAsyncjobs(virStoragePoolObjPtr obj);

void
virStoragePoolObjIncrAsyncjobs(virStoragePoolObjPtr obj);

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

113
int
114 115 116
virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools,
                                const char *configDir,
                                const char *autostartDir);
J
John Ferlan 已提交
117

118
int
119 120
virStoragePoolObjLoadAllState(virStoragePoolObjListPtr pools,
                              const char *stateDir);
121

J
John Ferlan 已提交
122 123 124
virStoragePoolObjPtr
virStoragePoolObjFindByUUID(virStoragePoolObjListPtr pools,
                            const unsigned char *uuid);
125

J
John Ferlan 已提交
126 127 128
virStoragePoolObjPtr
virStoragePoolObjFindByName(virStoragePoolObjListPtr pools,
                            const char *name);
129

130 131 132 133 134 135 136 137 138 139 140
int
virStoragePoolObjAddVol(virStoragePoolObjPtr obj,
                        virStorageVolDefPtr voldef);

void
virStoragePoolObjRemoveVol(virStoragePoolObjPtr obj,
                           virStorageVolDefPtr voldef);

size_t
virStoragePoolObjGetVolumesCount(virStoragePoolObjPtr obj);

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
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 已提交
159
virStorageVolDefPtr
160
virStorageVolDefFindByKey(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
161
                          const char *key);
162

J
John Ferlan 已提交
163
virStorageVolDefPtr
164
virStorageVolDefFindByPath(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
165
                           const char *path);
166

J
John Ferlan 已提交
167
virStorageVolDefPtr
168
virStorageVolDefFindByName(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
169 170
                           const char *name);

171
void
172
virStoragePoolObjClearVols(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
173

174 175 176 177 178 179
typedef bool
(*virStoragePoolVolumeACLFilter)(virConnectPtr conn,
                                 virStoragePoolDefPtr pool,
                                 virStorageVolDefPtr def);

int
180
virStoragePoolObjNumOfVolumes(virStoragePoolObjPtr obj,
181
                              virConnectPtr conn,
182
                              virStoragePoolVolumeACLFilter filter);
183

184
int
185
virStoragePoolObjVolumeGetNames(virStoragePoolObjPtr obj,
186
                                virConnectPtr conn,
187
                                virStoragePoolVolumeACLFilter filter,
188 189 190
                                char **const names,
                                int maxnames);

191 192
int
virStoragePoolObjVolumeListExport(virConnectPtr conn,
193
                                  virStoragePoolObjPtr obj,
194
                                  virStorageVolPtr **vols,
195
                                  virStoragePoolVolumeACLFilter filter);
196

J
John Ferlan 已提交
197
virStoragePoolObjPtr
198 199 200
virStoragePoolObjListAdd(virStoragePoolObjListPtr pools,
                         virStoragePoolDefPtr def,
                         bool check_active);
J
John Ferlan 已提交
201

202 203
int
virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
204
                         virStoragePoolObjPtr obj,
205 206 207
                         virStoragePoolDefPtr def);

int
208
virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj);
209

210 211 212 213 214 215 216
typedef bool (*virStoragePoolObjListACLFilter)(virConnectPtr conn,
                                               virStoragePoolDefPtr def);

int
virStoragePoolObjNumOfStoragePools(virStoragePoolObjListPtr pools,
                                   virConnectPtr conn,
                                   bool wantActive,
217
                                   virStoragePoolObjListACLFilter filter);
218

219 220 221 222
int
virStoragePoolObjGetNames(virStoragePoolObjListPtr pools,
                          virConnectPtr conn,
                          bool wantActive,
223
                          virStoragePoolObjListACLFilter filter,
224 225 226
                          char **const names,
                          int maxnames);

227
void
228
virStoragePoolObjFree(virStoragePoolObjPtr obj);
229

230 231 232 233 234 235 236 237 238
typedef void
(*virStoragePoolObjListIterator)(virStoragePoolObjPtr obj,
                                 const void *opaque);

void
virStoragePoolObjListForEach(virStoragePoolObjListPtr pools,
                             virStoragePoolObjListIterator iter,
                             const void *opaque);

239 240 241 242 243 244 245 246 247
typedef bool
(*virStoragePoolObjListSearcher)(virStoragePoolObjPtr obj,
                                 const void *opaque);

virStoragePoolObjPtr
virStoragePoolObjListSearch(virStoragePoolObjListPtr pools,
                            virStoragePoolObjListSearcher searcher,
                            const void *opaque);

248 249 250
virStoragePoolObjListPtr
virStoragePoolObjListNew(void);

251 252
void
virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
253
                        virStoragePoolObjPtr obj);
J
John Ferlan 已提交
254

255 256
int
virStoragePoolObjListExport(virConnectPtr conn,
J
John Ferlan 已提交
257
                            virStoragePoolObjListPtr poolobjs,
258 259 260
                            virStoragePoolPtr **pools,
                            virStoragePoolObjListFilter filter,
                            unsigned int flags);