driver.h 9.4 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * driver.h: description of the set of interfaces provided by a 
 *           entry point to the virtualization engine
 */

#ifndef __VIR_DRIVER_H__
#define __VIR_DRIVER_H__

9 10
#include "libvirt/libvirt.h"
#include "libvirt/virterror.h"
11 12 13 14 15

#ifdef __cplusplus
extern "C" {
#endif

16 17 18 19
/*
 * List of registered drivers numbers
 */
typedef enum {
20 21 22
    VIR_DRV_XEN_UNIFIED = 1,
    VIR_DRV_TEST = 2,
    VIR_DRV_QEMU = 3,
23
    VIR_DRV_REMOTE = 4,
24 25 26
} virDrvNo;


27
typedef enum {
28
    /* VIR_DRV_OPEN_QUIET = 1 - removed by RWMJ */
29 30 31
    VIR_DRV_OPEN_RO = 2
} virDrvOpenFlag;

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
/* Status codes returned from driver open call. */
typedef enum {
    /* Opened successfully. */
    VIR_DRV_OPEN_SUCCESS = 0,

    /* 'name' is not for us. */
    VIR_DRV_OPEN_DECLINED = -1,

    /* 'name' is for us, but there was some error.  virConnectOpen will
     * return an error rather than continue probing the other drivers.
     */
    VIR_DRV_OPEN_ERROR = -2,
} virDrvOpenStatus;

typedef virDrvOpenStatus
47 48 49
	(*virDrvOpen)			(virConnectPtr conn,
					 const char *name,
					 int flags);
50 51 52 53 54
typedef int
	(*virDrvClose)			(virConnectPtr conn);
typedef const char *
	(*virDrvGetType)		(virConnectPtr conn);
typedef int
55
	(*virDrvGetVersion)		(virConnectPtr conn,
56
					 unsigned long *hvVer);
57
typedef int
58 59
	(*virDrvGetMaxVcpus)		(virConnectPtr conn,
					 const char *type);
60 61 62
typedef int
	(*virDrvNodeGetInfo)		(virConnectPtr conn,
					 virNodeInfoPtr info);
63 64
typedef char *
	(*virDrvGetCapabilities) (virConnectPtr conn);
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
typedef int
	(*virDrvListDomains)		(virConnectPtr conn,
					 int *ids,
					 int maxids);
typedef int
	(*virDrvNumOfDomains)		(virConnectPtr conn);
typedef virDomainPtr
	(*virDrvDomainCreateLinux)	(virConnectPtr conn,
					 const char *xmlDesc,
					 unsigned int flags);
typedef virDomainPtr
	(*virDrvDomainLookupByID)	(virConnectPtr conn,
					 int id);
typedef virDomainPtr
	(*virDrvDomainLookupByUUID)	(virConnectPtr conn,
					 const unsigned char *uuid);
typedef virDomainPtr
	(*virDrvDomainLookupByName)	(virConnectPtr conn,
					 const char *name);
typedef int
	(*virDrvDomainSuspend)		(virDomainPtr domain);
typedef int
	(*virDrvDomainResume)		(virDomainPtr domain);
typedef int
	(*virDrvDomainShutdown)		(virDomainPtr domain);
90 91 92
typedef int
	(*virDrvDomainReboot)		(virDomainPtr domain,
					 unsigned int flags);
93 94 95 96 97 98 99 100 101
typedef int
	(*virDrvDomainDestroy)		(virDomainPtr domain);
typedef char *
	(*virDrvDomainGetOSType)	(virDomainPtr domain);
typedef unsigned long
	(*virDrvDomainGetMaxMemory)	(virDomainPtr domain);
typedef int
	(*virDrvDomainSetMaxMemory)	(virDomainPtr domain,
					 unsigned long memory);
102 103 104
typedef int
	(*virDrvDomainSetMemory)	(virDomainPtr domain,
					 unsigned long memory);
105 106 107 108 109 110 111 112 113
typedef int
	(*virDrvDomainGetInfo)		(virDomainPtr domain,
					 virDomainInfoPtr info);
typedef int
	(*virDrvDomainSave)		(virDomainPtr domain,
					 const char *to);
typedef int
	(*virDrvDomainRestore)		(virConnectPtr conn,
					 const char *from);
D
Daniel Veillard 已提交
114 115 116 117
typedef int
	(*virDrvDomainCoreDump)		(virDomainPtr domain,
					 const char *to,
					 int flags);
118 119 120
typedef char *
	(*virDrvDomainDumpXML)		(virDomainPtr dom,
					 int flags);
121 122
typedef int
	(*virDrvListDefinedDomains)	(virConnectPtr conn,
123
					 char **const names,
124 125 126 127
					 int maxnames);
typedef int
	(*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
typedef int
128
	(*virDrvDomainCreate)		(virDomainPtr dom);
129
typedef virDomainPtr
130 131
	(*virDrvDomainDefineXML)	(virConnectPtr conn,
					 const char *xml);
132
typedef int
133
	(*virDrvDomainUndefine)		(virDomainPtr dom);
134 135 136 137 138 139 140 141 142 143 144 145 146 147
typedef int
	(*virDrvDomainSetVcpus)		(virDomainPtr domain,
					 unsigned int nvcpus);
typedef int
	(*virDrvDomainPinVcpu)		(virDomainPtr domain,
					 unsigned int vcpu,
					 unsigned char *cpumap,
					 int maplen);
typedef int
	(*virDrvDomainGetVcpus)		(virDomainPtr domain,
					 virVcpuInfoPtr info,
					 int maxinfo,
					 unsigned char *cpumaps,
					 int maplen);
148 149
typedef int
	(*virDrvDomainGetMaxVcpus)	(virDomainPtr domain);
150 151 152 153 154 155
typedef int
	(*virDrvDomainAttachDevice)	(virDomainPtr domain,
					 char *xml);
typedef int
	(*virDrvDomainDetachDevice)	(virDomainPtr domain,
					 char *xml);
156 157 158 159 160 161
typedef int
	(*virDrvDomainGetAutostart)	(virDomainPtr domain,
					 int *autostart);
typedef int
	(*virDrvDomainSetAutostart)	(virDomainPtr domain,
					 int autostart);
162

163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
typedef char *
	(*virDrvDomainGetSchedulerType)	(virDomainPtr domain,
					 int *nparams);

typedef int 
	(*virDrvDomainGetSchedulerParameters)
					(virDomainPtr domain,
					 virSchedParameterPtr params,
					 int *nparams);

typedef int
	(*virDrvDomainSetSchedulerParameters)
					(virDomainPtr domain,
					 virSchedParameterPtr params,
					 int nparams);

179 180 181 182 183 184 185 186
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;

/**
 * _virDriver:
 *
 * Structure associated to a virtualization driver, defining the various
 * entry points for it.
187 188 189 190 191 192
 *
 * All drivers must support the following fields/methods:
 *  - no
 *  - name
 *  - open
 *  - close
193 194
 */
struct _virDriver {
195 196 197
	int	       no;	/* the number virDrvNo */
	const char * name;	/* the name of the driver */
	unsigned long ver;	/* the version of the backend */
198 199 200 201
	virDrvOpen			open;
	virDrvClose			close;
	virDrvGetType			type;
	virDrvGetVersion		version;
202
	virDrvGetMaxVcpus		getMaxVcpus;
203
	virDrvNodeGetInfo		nodeGetInfo;
204
	virDrvGetCapabilities		getCapabilities;
205 206 207 208 209 210 211 212 213
	virDrvListDomains		listDomains;
	virDrvNumOfDomains		numOfDomains;
	virDrvDomainCreateLinux		domainCreateLinux;
	virDrvDomainLookupByID		domainLookupByID;
	virDrvDomainLookupByUUID	domainLookupByUUID;
	virDrvDomainLookupByName	domainLookupByName;
	virDrvDomainSuspend		domainSuspend;
	virDrvDomainResume		domainResume;
	virDrvDomainShutdown		domainShutdown;
214
	virDrvDomainReboot		domainReboot;
215 216 217 218
	virDrvDomainDestroy		domainDestroy;
	virDrvDomainGetOSType		domainGetOSType;
	virDrvDomainGetMaxMemory	domainGetMaxMemory;
	virDrvDomainSetMaxMemory	domainSetMaxMemory;
219
	virDrvDomainSetMemory		domainSetMemory;
220 221 222
	virDrvDomainGetInfo		domainGetInfo;
	virDrvDomainSave		domainSave;
	virDrvDomainRestore		domainRestore;
D
Daniel Veillard 已提交
223
	virDrvDomainCoreDump		domainCoreDump;
224 225 226
	virDrvDomainSetVcpus		domainSetVcpus;
	virDrvDomainPinVcpu		domainPinVcpu;
	virDrvDomainGetVcpus		domainGetVcpus;
227
	virDrvDomainGetMaxVcpus		domainGetMaxVcpus;
228
	virDrvDomainDumpXML		domainDumpXML;
229 230 231 232 233
	virDrvListDefinedDomains	listDefinedDomains;
	virDrvNumOfDefinedDomains	numOfDefinedDomains;
	virDrvDomainCreate		domainCreate;
	virDrvDomainDefineXML           domainDefineXML;
	virDrvDomainUndefine            domainUndefine;
234 235
	virDrvDomainAttachDevice	domainAttachDevice;
	virDrvDomainDetachDevice	domainDetachDevice;
236 237
	virDrvDomainGetAutostart	domainGetAutostart;
	virDrvDomainSetAutostart	domainSetAutostart;
238 239 240
	virDrvDomainGetSchedulerType	domainGetSchedulerType;
	virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
	virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
241 242
};

243 244 245 246
typedef int
	(*virDrvNumOfNetworks)		(virConnectPtr conn);
typedef int
	(*virDrvListNetworks)		(virConnectPtr conn,
247
					 char **const names,
248 249 250 251 252
					 int maxnames);
typedef int
	(*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
typedef int
	(*virDrvListDefinedNetworks)	(virConnectPtr conn,
253
					 char **const names,
254 255 256 257 258 259 260 261 262 263 264
					 int maxnames);
typedef virNetworkPtr
	(*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
					 const unsigned char *uuid);
typedef virNetworkPtr
	(*virDrvNetworkLookupByName)	(virConnectPtr conn,
					 const char *name);
typedef virNetworkPtr
	(*virDrvNetworkCreateXML)	(virConnectPtr conn,
					 const char *xmlDesc);
typedef virNetworkPtr
265 266
	(*virDrvNetworkDefineXML)	(virConnectPtr conn,
					 const char *xml);
267 268 269 270 271 272 273 274 275
typedef int
	(*virDrvNetworkUndefine)	(virNetworkPtr network);
typedef int
	(*virDrvNetworkCreate)		(virNetworkPtr network);
typedef int
	(*virDrvNetworkDestroy)		(virNetworkPtr network);
typedef char *
	(*virDrvNetworkDumpXML)		(virNetworkPtr network,
					 int flags);
276 277
typedef char *
	(*virDrvNetworkGetBridgeName)	(virNetworkPtr network);
278 279 280 281 282 283 284
typedef int
	(*virDrvNetworkGetAutostart)	(virNetworkPtr network,
					 int *autostart);
typedef int
	(*virDrvNetworkSetAutostart)	(virNetworkPtr network,
					 int autostart);

285 286 287 288 289 290 291 292 293

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

/**
 * _virNetworkDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
294 295 296 297
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
 */
struct _virNetworkDriver {
	virDrvOpen			open;
	virDrvClose			close;
	virDrvNumOfNetworks		numOfNetworks;
	virDrvListNetworks		listNetworks;
	virDrvNumOfDefinedNetworks	numOfDefinedNetworks;
	virDrvListDefinedNetworks	listDefinedNetworks;
	virDrvNetworkLookupByUUID	networkLookupByUUID;
	virDrvNetworkLookupByName	networkLookupByName;
	virDrvNetworkCreateXML		networkCreateXML;
	virDrvNetworkDefineXML		networkDefineXML;
	virDrvNetworkUndefine		networkUndefine;
	virDrvNetworkCreate		networkCreate;
	virDrvNetworkDestroy		networkDestroy;
	virDrvNetworkDumpXML		networkDumpXML;
314
	virDrvNetworkGetBridgeName	networkGetBridgeName;
315 316
	virDrvNetworkGetAutostart	networkGetAutostart;
	virDrvNetworkSetAutostart	networkSetAutostart;
317 318
};

319 320 321 322 323 324 325

/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
326
int virRegisterNetworkDriver(virNetworkDriverPtr);
327 328 329 330 331

#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __VIR_DRIVER_H__ */
332 333 334 335 336 337 338 339 340 341 342 343 344 345

/*
 * vim: set tabstop=4:
 * vim: set shiftwidth=4:
 * vim: set expandtab:
 */
/*
 * Local variables:
 *  indent-tabs-mode: nil
 *  c-indent-level: 4
 *  c-basic-offset: 4
 *  tab-width: 4
 * End:
 */