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

#ifndef __VIR_DRIVER_H__
#define __VIR_DRIVER_H__

9 10
#include <libxml/uri.h>

11
#include "internal.h"
12 13 14 15
/*
 * List of registered drivers numbers
 */
typedef enum {
16 17 18
    VIR_DRV_XEN_UNIFIED = 1,
    VIR_DRV_TEST = 2,
    VIR_DRV_QEMU = 3,
19
    VIR_DRV_REMOTE = 4,
20
    VIR_DRV_OPENVZ = 5,
21 22
    VIR_DRV_LXC = 6,
    VIR_DRV_UML = 7,
23 24 25
} virDrvNo;


26 27 28 29 30 31 32 33 34 35 36 37 38 39
/* 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;

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
/* Feature detection.  This is a libvirt-private interface for determining
 * what features are supported by the driver.
 *
 * The remote driver passes features through to the real driver at the
 * remote end unmodified, except if you query a VIR_DRV_FEATURE_REMOTE*
 * feature.
 */
    /* Driver supports V1-style virDomainMigrate, ie. domainMigratePrepare/
     * domainMigratePerform/domainMigrateFinish.
     */
#define VIR_DRV_FEATURE_MIGRATION_V1 1

    /* Driver is not local. */
#define VIR_DRV_FEATURE_REMOTE 2

D
Daniel Veillard 已提交
55 56 57 58 59
    /* Driver supports V2-style virDomainMigrate, ie. domainMigratePrepare2/
     * domainMigratePerform/domainMigrateFinish2.
     */
#define VIR_DRV_FEATURE_MIGRATION_V2 3

60 61 62 63 64 65 66 67 68 69 70 71 72
/* Internal feature-detection macro.  Don't call drv->supports_feature
 * directly, because it may be NULL, use this macro instead.
 *
 * Note that you must check for errors.
 *
 * Returns:
 *   >= 1  Feature is supported.
 *   0     Feature is not supported.
 *   -1    Error.
 */
#define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature)                      \
    ((drv)->supports_feature ? (drv)->supports_feature((conn),(feature)) : 0)

73
typedef virDrvOpenStatus
74
        (*virDrvOpen)			(virConnectPtr conn,
75 76
                             virConnectAuthPtr auth,
                             int flags);
77
typedef int
78
        (*virDrvClose)			(virConnectPtr conn);
79
typedef int
D
Daniel P. Berrange 已提交
80
    (*virDrvDrvSupportsFeature) (virConnectPtr conn, int feature);
81
typedef const char *
82
        (*virDrvGetType)		(virConnectPtr conn);
83
typedef int
84 85
        (*virDrvGetVersion)		(virConnectPtr conn,
                                         unsigned long *hvVer);
86 87 88 89
typedef char *
    (*virDrvGetHostname)    (virConnectPtr conn);
typedef char *
    (*virDrvGetURI)         (virConnectPtr conn);
90
typedef int
91 92
        (*virDrvGetMaxVcpus)		(virConnectPtr conn,
                                         const char *type);
93
typedef int
94 95
        (*virDrvNodeGetInfo)		(virConnectPtr conn,
                                         virNodeInfoPtr info);
96
typedef char *
97
        (*virDrvGetCapabilities) (virConnectPtr conn);
98
typedef int
99 100 101
        (*virDrvListDomains)		(virConnectPtr conn,
                                         int *ids,
                                         int maxids);
102
typedef int
103
        (*virDrvNumOfDomains)		(virConnectPtr conn);
104
typedef virDomainPtr
105
        (*virDrvDomainCreateXML)	(virConnectPtr conn,
106 107
                                         const char *xmlDesc,
                                         unsigned int flags);
108
typedef virDomainPtr
109 110
        (*virDrvDomainLookupByID)	(virConnectPtr conn,
                                         int id);
111
typedef virDomainPtr
112 113
        (*virDrvDomainLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
114
typedef virDomainPtr
115 116
        (*virDrvDomainLookupByName)	(virConnectPtr conn,
                                         const char *name);
117
typedef int
118
        (*virDrvDomainSuspend)		(virDomainPtr domain);
119
typedef int
120
        (*virDrvDomainResume)		(virDomainPtr domain);
121
typedef int
122
        (*virDrvDomainShutdown)		(virDomainPtr domain);
123
typedef int
124 125
        (*virDrvDomainReboot)		(virDomainPtr domain,
                                         unsigned int flags);
126
typedef int
127
        (*virDrvDomainDestroy)		(virDomainPtr domain);
128
typedef char *
129
        (*virDrvDomainGetOSType)	(virDomainPtr domain);
130
typedef unsigned long
131
        (*virDrvDomainGetMaxMemory)	(virDomainPtr domain);
132
typedef int
133 134
        (*virDrvDomainSetMaxMemory)	(virDomainPtr domain,
                                         unsigned long memory);
135
typedef int
136 137
        (*virDrvDomainSetMemory)	(virDomainPtr domain,
                                         unsigned long memory);
138
typedef int
139 140
        (*virDrvDomainGetInfo)		(virDomainPtr domain,
                                         virDomainInfoPtr info);
141
typedef int
142 143
        (*virDrvDomainSave)		(virDomainPtr domain,
                                         const char *to);
144
typedef int
145 146
        (*virDrvDomainRestore)		(virConnectPtr conn,
                                         const char *from);
D
Daniel Veillard 已提交
147
typedef int
148 149 150
        (*virDrvDomainCoreDump)		(virDomainPtr domain,
                                         const char *to,
                                         int flags);
151
typedef char *
152 153
        (*virDrvDomainDumpXML)		(virDomainPtr dom,
                                         int flags);
154
typedef int
155 156 157
        (*virDrvListDefinedDomains)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
158
typedef int
159
        (*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
160
typedef int
161
        (*virDrvDomainCreate)		(virDomainPtr dom);
162
typedef virDomainPtr
163 164
        (*virDrvDomainDefineXML)	(virConnectPtr conn,
                                         const char *xml);
165
typedef int
166
        (*virDrvDomainUndefine)		(virDomainPtr dom);
167
typedef int
168 169
        (*virDrvDomainSetVcpus)		(virDomainPtr domain,
                                         unsigned int nvcpus);
170
typedef int
171 172 173 174
        (*virDrvDomainPinVcpu)		(virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen);
175
typedef int
176 177 178 179 180
        (*virDrvDomainGetVcpus)		(virDomainPtr domain,
                                         virVcpuInfoPtr info,
                                         int maxinfo,
                                         unsigned char *cpumaps,
                                         int maplen);
181
typedef int
182
        (*virDrvDomainGetMaxVcpus)	(virDomainPtr domain);
183
typedef int
184 185
        (*virDrvDomainAttachDevice)	(virDomainPtr domain,
                                         const char *xml);
186
typedef int
187 188
        (*virDrvDomainDetachDevice)	(virDomainPtr domain,
                                         const char *xml);
189
typedef int
190 191
        (*virDrvDomainGetAutostart)	(virDomainPtr domain,
                                         int *autostart);
192
typedef int
193 194
        (*virDrvDomainSetAutostart)	(virDomainPtr domain,
                                         int autostart);
195

196
typedef char *
197 198
        (*virDrvDomainGetSchedulerType)	(virDomainPtr domain,
                                         int *nparams);
199

200
typedef int
201 202 203 204
        (*virDrvDomainGetSchedulerParameters)
                                        (virDomainPtr domain,
                                         virSchedParameterPtr params,
                                         int *nparams);
205 206

typedef int
207 208 209 210
        (*virDrvDomainSetSchedulerParameters)
                                        (virDomainPtr domain,
                                         virSchedParameterPtr params,
                                         int nparams);
211

212 213 214 215 216 217 218 219 220 221 222
typedef int
    (*virDrvDomainBlockStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainBlockStats *stats);
typedef int
    (*virDrvDomainInterfaceStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainInterfaceStats *stats);

R
Richard W.M. Jones 已提交
223 224 225 226 227
typedef int
    (*virDrvDomainBlockPeek)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long offset, size_t size,
228 229
                     void *buffer,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
230

R
Richard W.M. Jones 已提交
231 232 233 234 235 236 237
typedef int
    (*virDrvDomainMemoryPeek)
                    (virDomainPtr domain,
                     unsigned long long start, size_t size,
                     void *buffer,
                     unsigned int flags);

238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
typedef int
    (*virDrvDomainMigratePrepare)
                    (virConnectPtr dconn,
                     char **cookie,
                     int *cookielen,
                     const char *uri_in,
                     char **uri_out,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

typedef int
    (*virDrvDomainMigratePerform)
                    (virDomainPtr domain,
                     const char *cookie,
                     int cookielen,
                     const char *uri,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

typedef virDomainPtr
    (*virDrvDomainMigrateFinish)
                    (virConnectPtr dconn,
                     const char *dname,
                     const char *cookie,
                     int cookielen,
                     const char *uri,
                     unsigned long flags);

268 269 270
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;

271 272 273 274 275 276 277
typedef int
    (*virDrvNodeGetCellsFreeMemory)
                    (virConnectPtr conn,
                     unsigned long long *freeMems,
                     int startCell,
                     int maxCells);

278 279
typedef unsigned long long
    (*virDrvNodeGetFreeMemory)
280
                    (virConnectPtr conn);
281

282 283 284
typedef int
    (*virDrvDomainEventRegister)
                    (virConnectPtr conn,
285
                     virConnectDomainEventCallback cb,
286 287
                     void *opaque,
                     virFreeCallback freecb);
288 289 290 291

typedef int
    (*virDrvDomainEventDeregister)
                    (virConnectPtr conn,
292
                     virConnectDomainEventCallback cb);
293

D
Daniel Veillard 已提交
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
typedef int
    (*virDrvDomainMigratePrepare2)
                    (virConnectPtr dconn,
                     char **cookie,
                     int *cookielen,
                     const char *uri_in,
                     char **uri_out,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);

typedef virDomainPtr
    (*virDrvDomainMigrateFinish2)
                    (virConnectPtr dconn,
                     const char *dname,
                     const char *cookie,
                     int cookielen,
                     const char *uri,
                     unsigned long flags,
                     int retcode);

316 317 318 319 320
/**
 * _virDriver:
 *
 * Structure associated to a virtualization driver, defining the various
 * entry points for it.
321 322 323 324 325 326
 *
 * All drivers must support the following fields/methods:
 *  - no
 *  - name
 *  - open
 *  - close
327 328
 */
struct _virDriver {
329 330 331 332
    int	       no;	/* the number virDrvNo */
    const char * name;	/* the name of the driver */
    virDrvOpen			open;
    virDrvClose			close;
D
Daniel P. Berrange 已提交
333
    virDrvDrvSupportsFeature   supports_feature;
334 335
    virDrvGetType			type;
    virDrvGetVersion		version;
336 337
    virDrvGetHostname       getHostname;
    virDrvGetURI            getURI;
338 339 340 341 342
    virDrvGetMaxVcpus		getMaxVcpus;
    virDrvNodeGetInfo		nodeGetInfo;
    virDrvGetCapabilities		getCapabilities;
    virDrvListDomains		listDomains;
    virDrvNumOfDomains		numOfDomains;
343
    virDrvDomainCreateXML		domainCreateXML;
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
    virDrvDomainLookupByID		domainLookupByID;
    virDrvDomainLookupByUUID	domainLookupByUUID;
    virDrvDomainLookupByName	domainLookupByName;
    virDrvDomainSuspend		domainSuspend;
    virDrvDomainResume		domainResume;
    virDrvDomainShutdown		domainShutdown;
    virDrvDomainReboot		domainReboot;
    virDrvDomainDestroy		domainDestroy;
    virDrvDomainGetOSType		domainGetOSType;
    virDrvDomainGetMaxMemory	domainGetMaxMemory;
    virDrvDomainSetMaxMemory	domainSetMaxMemory;
    virDrvDomainSetMemory		domainSetMemory;
    virDrvDomainGetInfo		domainGetInfo;
    virDrvDomainSave		domainSave;
    virDrvDomainRestore		domainRestore;
    virDrvDomainCoreDump		domainCoreDump;
    virDrvDomainSetVcpus		domainSetVcpus;
    virDrvDomainPinVcpu		domainPinVcpu;
    virDrvDomainGetVcpus		domainGetVcpus;
    virDrvDomainGetMaxVcpus		domainGetMaxVcpus;
    virDrvDomainDumpXML		domainDumpXML;
    virDrvListDefinedDomains	listDefinedDomains;
    virDrvNumOfDefinedDomains	numOfDefinedDomains;
    virDrvDomainCreate		domainCreate;
    virDrvDomainDefineXML           domainDefineXML;
    virDrvDomainUndefine            domainUndefine;
    virDrvDomainAttachDevice	domainAttachDevice;
    virDrvDomainDetachDevice	domainDetachDevice;
    virDrvDomainGetAutostart	domainGetAutostart;
    virDrvDomainSetAutostart	domainSetAutostart;
    virDrvDomainGetSchedulerType	domainGetSchedulerType;
    virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
    virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
377 378 379
    virDrvDomainMigratePrepare	domainMigratePrepare;
    virDrvDomainMigratePerform	domainMigratePerform;
    virDrvDomainMigrateFinish	domainMigrateFinish;
380 381
    virDrvDomainBlockStats      domainBlockStats;
    virDrvDomainInterfaceStats  domainInterfaceStats;
R
Richard W.M. Jones 已提交
382
    virDrvDomainBlockPeek	domainBlockPeek;
R
Richard W.M. Jones 已提交
383
    virDrvDomainMemoryPeek      domainMemoryPeek;
384 385
    virDrvNodeGetCellsFreeMemory	nodeGetCellsFreeMemory;
    virDrvNodeGetFreeMemory		getFreeMemory;
386 387
    virDrvDomainEventRegister         domainEventRegister;
    virDrvDomainEventDeregister       domainEventDeregister;
D
Daniel Veillard 已提交
388 389
    virDrvDomainMigratePrepare2	domainMigratePrepare2;
    virDrvDomainMigrateFinish2	domainMigrateFinish2;
390 391
};

392
typedef int
393
        (*virDrvNumOfNetworks)		(virConnectPtr conn);
394
typedef int
395 396 397
        (*virDrvListNetworks)		(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
398
typedef int
399
        (*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
400
typedef int
401 402 403
        (*virDrvListDefinedNetworks)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
404
typedef virNetworkPtr
405 406
        (*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
407
typedef virNetworkPtr
408 409
        (*virDrvNetworkLookupByName)	(virConnectPtr conn,
                                         const char *name);
410
typedef virNetworkPtr
411 412
        (*virDrvNetworkCreateXML)	(virConnectPtr conn,
                                         const char *xmlDesc);
413
typedef virNetworkPtr
414 415
        (*virDrvNetworkDefineXML)	(virConnectPtr conn,
                                         const char *xml);
416
typedef int
417
        (*virDrvNetworkUndefine)	(virNetworkPtr network);
418
typedef int
419
        (*virDrvNetworkCreate)		(virNetworkPtr network);
420
typedef int
421
        (*virDrvNetworkDestroy)		(virNetworkPtr network);
422
typedef char *
423 424
        (*virDrvNetworkDumpXML)		(virNetworkPtr network,
                                         int flags);
425
typedef char *
426
        (*virDrvNetworkGetBridgeName)	(virNetworkPtr network);
427
typedef int
428 429
        (*virDrvNetworkGetAutostart)	(virNetworkPtr network,
                                         int *autostart);
430
typedef int
431 432
        (*virDrvNetworkSetAutostart)	(virNetworkPtr network,
                                         int autostart);
433

434 435 436 437 438 439 440 441 442

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

/**
 * _virNetworkDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
443 444 445 446
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
447 448
 */
struct _virNetworkDriver {
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
        const char * name;	/* the name of the driver */
        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;
        virDrvNetworkGetBridgeName	networkGetBridgeName;
        virDrvNetworkGetAutostart	networkGetAutostart;
        virDrvNetworkSetAutostart	networkSetAutostart;
467 468
};

469 470 471 472 473 474 475 476 477 478 479 480 481

typedef int
    (*virDrvConnectNumOfStoragePools)        (virConnectPtr conn);
typedef int
    (*virDrvConnectListStoragePools)         (virConnectPtr conn,
                                              char **const names,
                                              int maxnames);
typedef int
    (*virDrvConnectNumOfDefinedStoragePools) (virConnectPtr conn);
typedef int
    (*virDrvConnectListDefinedStoragePools)  (virConnectPtr conn,
                                              char **const names,
                                              int maxnames);
482 483 484 485 486
typedef char *
    (*virDrvConnectFindStoragePoolSources)   (virConnectPtr conn,
                                              const char *type,
                                              const char *srcSpec,
                                              unsigned int flags);
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
typedef virStoragePoolPtr
    (*virDrvStoragePoolLookupByName)         (virConnectPtr conn,
                                              const char *name);
typedef virStoragePoolPtr
    (*virDrvStoragePoolLookupByUUID)         (virConnectPtr conn,
                                              const unsigned char *uuid);
typedef virStoragePoolPtr
    (*virDrvStoragePoolLookupByVolume)       (virStorageVolPtr vol);
typedef virStoragePoolPtr
    (*virDrvStoragePoolCreateXML)            (virConnectPtr conn,
                                              const char *xmlDesc,
                                              unsigned int flags);
typedef virStoragePoolPtr
    (*virDrvStoragePoolDefineXML)            (virConnectPtr conn,
                                              const char *xmlDesc,
                                              unsigned int flags);
typedef int
    (*virDrvStoragePoolUndefine)             (virStoragePoolPtr pool);
typedef int
    (*virDrvStoragePoolBuild)                (virStoragePoolPtr pool,
                                              unsigned int flags);
typedef int
    (*virDrvStoragePoolCreate)               (virStoragePoolPtr pool,
                                              unsigned int flags);
typedef int
    (*virDrvStoragePoolDestroy)              (virStoragePoolPtr pool);
typedef int
    (*virDrvStoragePoolDelete)               (virStoragePoolPtr pool,
                                              unsigned int flags);
typedef int
    (*virDrvStoragePoolRefresh)              (virStoragePoolPtr pool,
                                              unsigned int flags);
typedef int
    (*virDrvStoragePoolGetInfo)              (virStoragePoolPtr vol,
                                              virStoragePoolInfoPtr info);
typedef char *
    (*virDrvStoragePoolGetXMLDesc)           (virStoragePoolPtr pool,
                                              unsigned int flags);
typedef int
    (*virDrvStoragePoolGetAutostart)         (virStoragePoolPtr pool,
                                              int *autostart);
typedef int
    (*virDrvStoragePoolSetAutostart)         (virStoragePoolPtr pool,
                                              int autostart);
typedef int
    (*virDrvStoragePoolNumOfVolumes)         (virStoragePoolPtr pool);
typedef int
    (*virDrvStoragePoolListVolumes)          (virStoragePoolPtr pool,
                                              char **const names,
                                              int maxnames);


typedef virStorageVolPtr
    (*virDrvStorageVolLookupByName)          (virStoragePoolPtr pool,
                                              const char *name);
typedef virStorageVolPtr
    (*virDrvStorageVolLookupByKey)           (virConnectPtr pool,
                                              const char *key);
typedef virStorageVolPtr
    (*virDrvStorageVolLookupByPath)          (virConnectPtr pool,
                                              const char *path);


typedef virStorageVolPtr
    (*virDrvStorageVolCreateXML)             (virStoragePoolPtr pool,
                                              const char *xmldesc,
                                              unsigned int flags);
typedef int
    (*virDrvStorageVolDelete)               (virStorageVolPtr vol,
                                             unsigned int flags);

typedef int
    (*virDrvStorageVolGetInfo)               (virStorageVolPtr vol,
                                              virStorageVolInfoPtr info);
typedef char *
    (*virDrvStorageVolGetXMLDesc)            (virStorageVolPtr pool,
                                              unsigned int flags);
typedef char *
    (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);



typedef struct _virStorageDriver virStorageDriver;
typedef virStorageDriver *virStorageDriverPtr;

/**
 * _virStorageDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
 */
struct _virStorageDriver {
    const char * name;    /* the name of the driver */
    virDrvOpen            open;
    virDrvClose           close;

    virDrvConnectNumOfStoragePools numOfPools;
    virDrvConnectListStoragePools listPools;
    virDrvConnectNumOfDefinedStoragePools numOfDefinedPools;
    virDrvConnectListDefinedStoragePools listDefinedPools;
591
    virDrvConnectFindStoragePoolSources findPoolSources;
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
    virDrvStoragePoolLookupByName poolLookupByName;
    virDrvStoragePoolLookupByUUID poolLookupByUUID;
    virDrvStoragePoolLookupByVolume poolLookupByVolume;
    virDrvStoragePoolCreateXML poolCreateXML;
    virDrvStoragePoolDefineXML poolDefineXML;
    virDrvStoragePoolBuild poolBuild;
    virDrvStoragePoolUndefine poolUndefine;
    virDrvStoragePoolCreate poolCreate;
    virDrvStoragePoolDestroy poolDestroy;
    virDrvStoragePoolDelete poolDelete;
    virDrvStoragePoolRefresh poolRefresh;
    virDrvStoragePoolGetInfo poolGetInfo;
    virDrvStoragePoolGetXMLDesc poolGetXMLDesc;
    virDrvStoragePoolGetAutostart poolGetAutostart;
    virDrvStoragePoolSetAutostart poolSetAutostart;
    virDrvStoragePoolNumOfVolumes poolNumOfVolumes;
    virDrvStoragePoolListVolumes poolListVolumes;

    virDrvStorageVolLookupByName volLookupByName;
    virDrvStorageVolLookupByKey volLookupByKey;
    virDrvStorageVolLookupByPath volLookupByPath;
    virDrvStorageVolCreateXML volCreateXML;
    virDrvStorageVolDelete volDelete;
    virDrvStorageVolGetInfo volGetInfo;
    virDrvStorageVolGetXMLDesc volGetXMLDesc;
    virDrvStorageVolGetPath volGetPath;
};

620
#ifdef WITH_LIBVIRTD
621 622 623 624 625 626 627 628 629 630 631 632 633 634
typedef int (*virDrvStateInitialize) (void);
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);

typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;

struct _virStateDriver {
    virDrvStateInitialize  initialize;
    virDrvStateCleanup     cleanup;
    virDrvStateReload      reload;
    virDrvStateActive      active;
};
A
Atsushi SAKAI 已提交
635
#endif
636

637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684

typedef struct _virDeviceMonitor virDeviceMonitor;
typedef virDeviceMonitor *virDeviceMonitorPtr;

typedef int (*virDevMonNumOfDevices)(virConnectPtr conn,
                                     const char *cap,
                                     unsigned int flags);

typedef int (*virDevMonListDevices)(virConnectPtr conn,
                                    const char *cap,
                                    char **const names,
                                    int maxnames,
                                    unsigned int flags);

typedef virNodeDevicePtr (*virDevMonDeviceLookupByName)(virConnectPtr conn,
                                                        const char *name);

typedef char * (*virDevMonDeviceDumpXML)(virNodeDevicePtr dev,
                                         unsigned int flags);

typedef char * (*virDevMonDeviceGetParent)(virNodeDevicePtr dev);

typedef int (*virDevMonDeviceNumOfCaps)(virNodeDevicePtr dev);

typedef int (*virDevMonDeviceListCaps)(virNodeDevicePtr dev,
                                       char **const names,
                                       int maxnames);

/**
 * _virDeviceMonitor:
 *
 * Structure associated with monitoring the devices
 * on a virtualized node.
 *
 */
struct _virDeviceMonitor {
    const char * name;    /* the name of the driver */
    virDrvOpen open;
    virDrvClose close;
    virDevMonNumOfDevices numOfDevices;
    virDevMonListDevices listDevices;
    virDevMonDeviceLookupByName deviceLookupByName;
    virDevMonDeviceDumpXML deviceDumpXML;
    virDevMonDeviceGetParent deviceGetParent;
    virDevMonDeviceNumOfCaps deviceNumOfCaps;
    virDevMonDeviceListCaps deviceListCaps;
};

685 686 687 688 689 690
/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
691
int virRegisterNetworkDriver(virNetworkDriverPtr);
692
int virRegisterStorageDriver(virStorageDriverPtr);
693
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
A
Atsushi SAKAI 已提交
694
#ifdef WITH_LIBVIRTD
695
int virRegisterStateDriver(virStateDriverPtr);
A
Atsushi SAKAI 已提交
696
#endif
697
void *virDriverLoadModule(const char *name);
698 699

#endif /* __VIR_DRIVER_H__ */