You need to sign in or sign up before continuing.
virstorageobj.h 5.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 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
/*
 * 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;

struct _virStoragePoolObj {
    virMutex lock;

    char *configFile;
    char *autostartLink;
    bool active;
    int autostart;
    unsigned int asyncjobs;

    virStoragePoolDefPtr def;
    virStoragePoolDefPtr newDef;

    virStorageVolDefList volumes;
};

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;
};

69 70 71
typedef bool
(*virStoragePoolObjListFilter)(virConnectPtr conn,
                               virStoragePoolDefPtr def);
J
John Ferlan 已提交
72 73

static inline int
74
virStoragePoolObjIsActive(virStoragePoolObjPtr obj)
J
John Ferlan 已提交
75
{
76
    return obj->active;
J
John Ferlan 已提交
77 78
}

79
int
80 81 82
virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools,
                                const char *configDir,
                                const char *autostartDir);
J
John Ferlan 已提交
83

84
int
85 86
virStoragePoolObjLoadAllState(virStoragePoolObjListPtr pools,
                              const char *stateDir);
87

J
John Ferlan 已提交
88 89 90
virStoragePoolObjPtr
virStoragePoolObjFindByUUID(virStoragePoolObjListPtr pools,
                            const unsigned char *uuid);
91

J
John Ferlan 已提交
92 93 94
virStoragePoolObjPtr
virStoragePoolObjFindByName(virStoragePoolObjListPtr pools,
                            const char *name);
95

J
John Ferlan 已提交
96
virStorageVolDefPtr
97
virStorageVolDefFindByKey(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
98
                          const char *key);
99

J
John Ferlan 已提交
100
virStorageVolDefPtr
101
virStorageVolDefFindByPath(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
102
                           const char *path);
103

J
John Ferlan 已提交
104
virStorageVolDefPtr
105
virStorageVolDefFindByName(virStoragePoolObjPtr obj,
J
John Ferlan 已提交
106 107
                           const char *name);

108
void
109
virStoragePoolObjClearVols(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
110

111 112 113 114 115 116
typedef bool
(*virStoragePoolVolumeACLFilter)(virConnectPtr conn,
                                 virStoragePoolDefPtr pool,
                                 virStorageVolDefPtr def);

int
117
virStoragePoolObjNumOfVolumes(virStoragePoolObjPtr obj,
118 119 120
                              virConnectPtr conn,
                              virStoragePoolVolumeACLFilter aclfilter);

121
int
122
virStoragePoolObjVolumeGetNames(virStoragePoolObjPtr obj,
123 124 125 126 127
                                virConnectPtr conn,
                                virStoragePoolVolumeACLFilter aclfilter,
                                char **const names,
                                int maxnames);

128 129
int
virStoragePoolObjVolumeListExport(virConnectPtr conn,
130
                                  virStoragePoolObjPtr obj,
131 132 133
                                  virStorageVolPtr **vols,
                                  virStoragePoolVolumeACLFilter aclfilter);

J
John Ferlan 已提交
134 135 136 137
virStoragePoolObjPtr
virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
                           virStoragePoolDefPtr def);

138 139
int
virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
140
                         virStoragePoolObjPtr obj,
141 142 143
                         virStoragePoolDefPtr def);

int
144
virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj);
145

146 147 148 149 150 151 152 153 154
typedef bool (*virStoragePoolObjListACLFilter)(virConnectPtr conn,
                                               virStoragePoolDefPtr def);

int
virStoragePoolObjNumOfStoragePools(virStoragePoolObjListPtr pools,
                                   virConnectPtr conn,
                                   bool wantActive,
                                   virStoragePoolObjListACLFilter aclfilter);

155 156 157 158 159 160 161 162
int
virStoragePoolObjGetNames(virStoragePoolObjListPtr pools,
                          virConnectPtr conn,
                          bool wantActive,
                          virStoragePoolObjListACLFilter aclfilter,
                          char **const names,
                          int maxnames);

163
void
164
virStoragePoolObjFree(virStoragePoolObjPtr obj);
165 166 167 168 169 170

void
virStoragePoolObjListFree(virStoragePoolObjListPtr pools);

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

173 174 175 176
int
virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
                             virStoragePoolDefPtr def,
                             unsigned int check_active);
J
John Ferlan 已提交
177

178
int
179 180 181
virStoragePoolObjSourceFindDuplicate(virConnectPtr conn,
                                     virStoragePoolObjListPtr pools,
                                     virStoragePoolDefPtr def);
J
John Ferlan 已提交
182

183 184
void
virStoragePoolObjLock(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
185

186 187
void
virStoragePoolObjUnlock(virStoragePoolObjPtr obj);
J
John Ferlan 已提交
188

189 190
int
virStoragePoolObjListExport(virConnectPtr conn,
J
John Ferlan 已提交
191
                            virStoragePoolObjListPtr poolobjs,
192 193 194
                            virStoragePoolPtr **pools,
                            virStoragePoolObjListFilter filter,
                            unsigned int flags);
J
John Ferlan 已提交
195 196

#endif /* __VIRSTORAGEOBJ_H__ */