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

#ifndef __VIR_DRIVER_H__
7
# define __VIR_DRIVER_H__
8

9
# include "config.h"
10

11
# include <libxml/uri.h>
12

13
# include "internal.h"
14 15 16 17
/*
 * List of registered drivers numbers
 */
typedef enum {
18 19 20
    VIR_DRV_XEN_UNIFIED = 1,
    VIR_DRV_TEST = 2,
    VIR_DRV_QEMU = 3,
21
    VIR_DRV_REMOTE = 4,
22
    VIR_DRV_OPENVZ = 5,
23 24
    VIR_DRV_LXC = 6,
    VIR_DRV_UML = 7,
25
    VIR_DRV_VBOX = 8,
D
Daniel Veillard 已提交
26
    VIR_DRV_ONE = 9,
27
    VIR_DRV_ESX = 10,
28
    VIR_DRV_PHYP = 11,
29
    VIR_DRV_XENAPI = 12,
J
Jim Fehlig 已提交
30 31
    VIR_DRV_VMWARE = 13,
    VIR_DRV_LIBXL = 14,
M
Matthias Bolte 已提交
32
    VIR_DRV_HYPERV = 15,
33 34 35
} virDrvNo;


36 37 38 39 40 41 42 43 44 45 46 47 48 49
/* 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;

D
Daniel Veillard 已提交
50

51
/* Internal feature-detection macro.  Don't call drv->supports_feature
52 53
 * directly if you don't have to, because it may be NULL, use this macro
 * instead.
54
 *
55 56 57
 * Note that this treats a possible error returned by drv->supports_feature
 * the same as not supported. If you care about the error, call
 * drv->supports_feature directly.
58 59
 *
 * Returns:
60
 *   != 0  Feature is supported.
61 62
 *   0     Feature is not supported.
 */
63 64 65
# define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature)                         \
    ((drv)->supports_feature ?                                              \
        (drv)->supports_feature((conn), (feature)) > 0 : 0)
66

67
typedef virDrvOpenStatus
68
        (*virDrvOpen)			(virConnectPtr conn,
69
                             virConnectAuthPtr auth,
70
                             unsigned int flags);
71
typedef int
72
        (*virDrvClose)			(virConnectPtr conn);
73
typedef int
D
Daniel P. Berrange 已提交
74
    (*virDrvDrvSupportsFeature) (virConnectPtr conn, int feature);
75
typedef const char *
76
        (*virDrvGetType)		(virConnectPtr conn);
77
typedef int
78 79
        (*virDrvGetVersion)		(virConnectPtr conn,
                                         unsigned long *hvVer);
80 81 82
typedef int
        (*virDrvGetLibVersion)      (virConnectPtr conn,
                                     unsigned long *libVer);
83 84 85 86
typedef char *
    (*virDrvGetHostname)    (virConnectPtr conn);
typedef char *
    (*virDrvGetURI)         (virConnectPtr conn);
E
Eric Blake 已提交
87 88 89
typedef char *
    (*virDrvGetSysinfo)     (virConnectPtr conn,
                             unsigned int flags);
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 129 130
typedef int
        (*virDrvDomainDestroyFlags) (virDomainPtr domain,
                                         unsigned int flags);
131
typedef char *
132
        (*virDrvDomainGetOSType)	(virDomainPtr domain);
133
typedef unsigned long
134
        (*virDrvDomainGetMaxMemory)	(virDomainPtr domain);
135
typedef int
136 137
        (*virDrvDomainSetMaxMemory)	(virDomainPtr domain,
                                         unsigned long memory);
138
typedef int
139 140
        (*virDrvDomainSetMemory)	(virDomainPtr domain,
                                         unsigned long memory);
141 142 143 144
typedef int
        (*virDrvDomainSetMemoryFlags)	(virDomainPtr domain,
                                         unsigned long memory,
                                         unsigned int flags);
145 146 147
typedef int
        (*virDrvDomainSetMemoryParameters)
                                        (virDomainPtr domain,
148
                                         virTypedParameterPtr params,
149 150 151 152 153
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetMemoryParameters)
                                        (virDomainPtr domain,
154
                                         virTypedParameterPtr params,
155 156
                                         int *nparams,
                                         unsigned int flags);
157 158 159
typedef int
        (*virDrvDomainSetBlkioParameters)
                                        (virDomainPtr domain,
160
                                         virTypedParameterPtr params,
161 162 163 164 165
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetBlkioParameters)
                                        (virDomainPtr domain,
166
                                         virTypedParameterPtr params,
167 168
                                         int *nparams,
                                         unsigned int flags);
169
typedef int
170 171
        (*virDrvDomainGetInfo)		(virDomainPtr domain,
                                         virDomainInfoPtr info);
172 173 174 175 176
typedef int
        (*virDrvDomainGetState)         (virDomainPtr domain,
                                         int *state,
                                         int *reason,
                                         unsigned int flags);
177 178 179 180
typedef int
        (*virDrvDomainGetControlInfo)   (virDomainPtr domain,
                                         virDomainControlInfoPtr info,
                                         unsigned int flags);
181
typedef int
182 183
        (*virDrvDomainSave)		(virDomainPtr domain,
                                         const char *to);
184 185 186 187 188
typedef int
        (*virDrvDomainSaveFlags)	(virDomainPtr domain,
                                         const char *to,
                                         const char *dxml,
                                         unsigned int flags);
189
typedef int
190 191
        (*virDrvDomainRestore)		(virConnectPtr conn,
                                         const char *from);
192 193 194 195 196
typedef int
        (*virDrvDomainRestoreFlags)	(virConnectPtr conn,
                                         const char *from,
                                         const char *dxml,
                                         unsigned int flags);
197 198 199 200 201 202 203 204 205
typedef char *
        (*virDrvDomainSaveImageGetXMLDesc)      (virConnectPtr conn,
                                                 const char *file,
                                                 unsigned int flags);
typedef int
        (*virDrvDomainSaveImageDefineXML)       (virConnectPtr conn,
                                                 const char *file,
                                                 const char *dxml,
                                                 unsigned int flags);
D
Daniel Veillard 已提交
206
typedef int
207 208
        (*virDrvDomainCoreDump)		(virDomainPtr domain,
                                         const char *to,
209
                                         unsigned int flags);
210 211 212 213 214
typedef char *
        (*virDrvDomainScreenshot)   (virDomainPtr domain,
                                         virStreamPtr stream,
                                         unsigned int screen,
                                         unsigned int flags);
215
typedef char *
216
        (*virDrvDomainGetXMLDesc)		(virDomainPtr dom,
217
                                                 unsigned int flags);
218 219 220 221 222 223 224 225 226 227
typedef char *
        (*virDrvConnectDomainXMLFromNative) (virConnectPtr conn,
                                             const char *nativeFormat,
                                             const char *nativeConfig,
                                             unsigned int flags);
typedef char *
        (*virDrvConnectDomainXMLToNative) (virConnectPtr conn,
                                           const char *nativeFormat,
                                           const char *domainXml,
                                           unsigned int flags);
228
typedef int
229 230 231
        (*virDrvListDefinedDomains)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
232
typedef int
233
        (*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
234
typedef int
235
        (*virDrvDomainCreate)		(virDomainPtr dom);
236 237 238
typedef int
        (*virDrvDomainCreateWithFlags)	(virDomainPtr dom,
                                         unsigned int flags);
239
typedef virDomainPtr
240 241
        (*virDrvDomainDefineXML)	(virConnectPtr conn,
                                         const char *xml);
242
typedef int
243
        (*virDrvDomainUndefine)		(virDomainPtr dom);
O
Osier Yang 已提交
244 245 246
typedef int
        (*virDrvDomainUndefineFlags)	(virDomainPtr dom,
                                         unsigned int flags);
247
typedef int
248 249
        (*virDrvDomainSetVcpus)		(virDomainPtr domain,
                                         unsigned int nvcpus);
E
Eric Blake 已提交
250 251 252 253 254 255 256
typedef int
        (*virDrvDomainSetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int nvcpus,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int flags);
257
typedef int
258 259 260 261
        (*virDrvDomainPinVcpu)		(virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen);
262 263 264 265 266 267
typedef int
        (*virDrvDomainPinVcpuFlags)     (virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen,
                                         unsigned int flags);
268
typedef int
E
Eric Blake 已提交
269
        (*virDrvDomainGetVcpuPinInfo)   (virDomainPtr domain,
270 271 272 273 274
                                         int ncpumaps,
                                         unsigned char *cpumaps,
                                         int maplen,
                                         unsigned int flags);

275
typedef int
276 277 278 279 280
        (*virDrvDomainGetVcpus)		(virDomainPtr domain,
                                         virVcpuInfoPtr info,
                                         int maxinfo,
                                         unsigned char *cpumaps,
                                         int maplen);
281
typedef int
282
        (*virDrvDomainGetMaxVcpus)	(virDomainPtr domain);
283 284 285 286 287 288 289

typedef int
        (*virDrvDomainGetSecurityLabel)	(virDomainPtr domain,
                                         virSecurityLabelPtr seclabel);
typedef int
        (*virDrvNodeGetSecurityModel)	(virConnectPtr conn,
                                         virSecurityModelPtr secmodel);
290
typedef int
291 292
        (*virDrvDomainAttachDevice)	(virDomainPtr domain,
                                         const char *xml);
J
Jim Fehlig 已提交
293 294 295 296
typedef int
        (*virDrvDomainAttachDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
297
typedef int
298 299
        (*virDrvDomainDetachDevice)	(virDomainPtr domain,
                                         const char *xml);
J
Jim Fehlig 已提交
300 301 302 303
typedef int
        (*virDrvDomainDetachDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
304 305 306 307
typedef int
        (*virDrvDomainUpdateDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
308
typedef int
309 310
        (*virDrvDomainGetAutostart)	(virDomainPtr domain,
                                         int *autostart);
311
typedef int
312 313
        (*virDrvDomainSetAutostart)	(virDomainPtr domain,
                                         int autostart);
314

315
typedef char *
316 317
        (*virDrvDomainGetSchedulerType)	(virDomainPtr domain,
                                         int *nparams);
318

319
typedef int
320 321
        (*virDrvDomainGetSchedulerParameters)
                                        (virDomainPtr domain,
322
                                         virTypedParameterPtr params,
323
                                         int *nparams);
324

325 326 327 328 329 330 331
typedef int
        (*virDrvDomainGetSchedulerParametersFlags)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         unsigned int flags);

332
typedef int
333 334
        (*virDrvDomainSetSchedulerParameters)
                                        (virDomainPtr domain,
335
                                         virTypedParameterPtr params,
336
                                         int nparams);
337

338 339 340
typedef int
        (*virDrvDomainSetSchedulerParametersFlags)
                                        (virDomainPtr domain,
341
                                         virTypedParameterPtr params,
342 343 344
                                         int nparams,
                                         unsigned int flags);

345 346 347 348 349 350 351 352 353 354 355
typedef int
    (*virDrvDomainBlockStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainBlockStats *stats);
typedef int
    (*virDrvDomainInterfaceStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainInterfaceStats *stats);

356 357 358 359
typedef int
    (*virDrvDomainMemoryStats)
                    (virDomainPtr domain,
                     struct _virDomainMemoryStat *stats,
360 361
                     unsigned int nr_stats,
                     unsigned int flags);
362

R
Richard W.M. Jones 已提交
363 364 365 366 367
typedef int
    (*virDrvDomainBlockPeek)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long offset, size_t size,
368 369
                     void *buffer,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
370

R
Richard W.M. Jones 已提交
371 372 373 374 375 376
typedef int
    (*virDrvDomainMemoryPeek)
                    (virDomainPtr domain,
                     unsigned long long start, size_t size,
                     void *buffer,
                     unsigned int flags);
377 378 379 380 381 382
typedef int
    (*virDrvDomainGetBlockInfo)
                    (virDomainPtr domain,
                     const char *path,
                     virDomainBlockInfoPtr info,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
383

384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
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);

414 415 416
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;

417 418 419 420
typedef int
    (*virDrvNodeGetCPUStats)
                    (virConnectPtr conn,
                     int cpuNum,
421
                     virNodeCPUStatsPtr params,
422 423 424
                     int *nparams,
                     unsigned int flags);

425 426 427 428
typedef int
    (*virDrvNodeGetMemoryStats)
                    (virConnectPtr conn,
                     int cellNum,
429
                     virNodeMemoryStatsPtr params,
430 431 432
                     int *nparams,
                     unsigned int flags);

433 434 435 436 437 438 439
typedef int
    (*virDrvNodeGetCellsFreeMemory)
                    (virConnectPtr conn,
                     unsigned long long *freeMems,
                     int startCell,
                     int maxCells);

440 441
typedef unsigned long long
    (*virDrvNodeGetFreeMemory)
442
                    (virConnectPtr conn);
443

444 445 446
typedef int
    (*virDrvDomainEventRegister)
                    (virConnectPtr conn,
447
                     virConnectDomainEventCallback cb,
448 449
                     void *opaque,
                     virFreeCallback freecb);
450 451 452 453

typedef int
    (*virDrvDomainEventDeregister)
                    (virConnectPtr conn,
454
                     virConnectDomainEventCallback cb);
455

D
Daniel Veillard 已提交
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
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);

478 479 480 481 482 483 484 485 486 487
typedef int
    (*virDrvNodeDeviceDettach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReAttach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReset)
                    (virNodeDevicePtr dev);

C
Chris Lalancette 已提交
488 489
typedef int
    (*virDrvDomainMigratePrepareTunnel)
490
                    (virConnectPtr dconn,
C
Chris Lalancette 已提交
491 492 493 494 495 496
                     virStreamPtr st,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);

497 498 499 500 501 502 503 504
typedef int
    (*virDrvConnectIsEncrypted)(virConnectPtr conn);
typedef int
    (*virDrvConnectIsSecure)(virConnectPtr conn);
typedef int
    (*virDrvDomainIsActive)(virDomainPtr dom);
typedef int
    (*virDrvDomainIsPersistent)(virDomainPtr dom);
O
Osier Yang 已提交
505 506
typedef int
    (*virDrvDomainIsUpdated)(virDomainPtr dom);
507

J
Jiri Denemark 已提交
508
typedef int
509
    (*virDrvCompareCPU)(virConnectPtr conn,
J
Jiri Denemark 已提交
510 511
                        const char *cpu,
                        unsigned int flags);
512
typedef char *
513
    (*virDrvBaselineCPU)(virConnectPtr conn,
514 515 516
                         const char **xmlCPUs,
                         unsigned int ncpus,
                         unsigned int flags);
J
Jiri Denemark 已提交
517

518 519 520 521
typedef int
    (*virDrvDomainGetJobInfo)(virDomainPtr domain,
                              virDomainJobInfoPtr info);

522 523 524
typedef int
    (*virDrvDomainAbortJob)(virDomainPtr domain);

525 526 527 528
typedef int
    (*virDrvDomainMigrateSetMaxDowntime)(virDomainPtr domain,
                                         unsigned long long downtime,
                                         unsigned int flags);
529 530 531 532
typedef int
    (*virDrvDomainMigrateSetMaxSpeed)(virDomainPtr domain,
                                      unsigned long bandwidth,
                                      unsigned int flags);
533

534 535 536 537 538
typedef int
    (*virDrvDomainMigrateGetMaxSpeed)(virDomainPtr domain,
                                      unsigned long *bandwidth,
                                      unsigned int flags);

539 540 541 542 543 544 545 546 547 548 549 550
typedef int
    (*virDrvDomainEventRegisterAny)(virConnectPtr conn,
                                    virDomainPtr dom,
                                    int eventID,
                                    virConnectDomainEventGenericCallback cb,
                                    void *opaque,
                                    virFreeCallback freecb);

typedef int
    (*virDrvDomainEventDeregisterAny)(virConnectPtr conn,
                                      int callbackID);

551 552 553 554 555 556 557 558 559
typedef int
    (*virDrvDomainManagedSave)(virDomainPtr domain, unsigned int flags);

typedef int
    (*virDrvDomainHasManagedSaveImage)(virDomainPtr domain, unsigned int flags);

typedef int
    (*virDrvDomainManagedSaveRemove)(virDomainPtr domain, unsigned int flags);

C
Chris Lalancette 已提交
560 561 562 563 564 565
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain,
                                     const char *xmlDesc,
                                     unsigned int flags);

typedef char *
566 567
    (*virDrvDomainSnapshotGetXMLDesc)(virDomainSnapshotPtr snapshot,
                                      unsigned int flags);
C
Chris Lalancette 已提交
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596

typedef int
    (*virDrvDomainSnapshotNum)(virDomainPtr domain, unsigned int flags);

typedef int
    (*virDrvDomainSnapshotListNames)(virDomainPtr domain, char **names,
                                     int nameslen,
                                     unsigned int flags);

typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotLookupByName)(virDomainPtr domain,
                                        const char *name,
                                        unsigned int flags);

typedef int
    (*virDrvDomainHasCurrentSnapshot)(virDomainPtr domain, unsigned int flags);

typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotCurrent)(virDomainPtr domain,
                                   unsigned int flags);

typedef int
    (*virDrvDomainRevertToSnapshot)(virDomainSnapshotPtr snapshot,
                                    unsigned int flags);

typedef int
    (*virDrvDomainSnapshotDelete)(virDomainSnapshotPtr snapshot,
                                  unsigned int flags);

C
Chris Lalancette 已提交
597
typedef int
598
    (*virDrvDomainQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
C
Chris Lalancette 已提交
599 600
                                      char **result, unsigned int flags);

601 602 603 604 605
typedef virDomainPtr
    (*virDrvDomainQemuAttach)(virConnectPtr conn,
                              unsigned int pid,
                              unsigned int flags);

606 607 608 609 610
typedef int
    (*virDrvDomainOpenConsole)(virDomainPtr dom,
                               const char *devname,
                               virStreamPtr st,
                               unsigned int flags);
C
Chris Lalancette 已提交
611

612 613 614
typedef int
    (*virDrvDomainInjectNMI)(virDomainPtr dom, unsigned int flags);

615 616 617 618
typedef int
    (*virDrvDomainSendKey)(virDomainPtr dom, unsigned int codeset,
                           unsigned int holdtime,
                           unsigned int *keycodes,
619
                           int nkeycodes,
620 621
                           unsigned int flags);

622 623 624
typedef char *
    (*virDrvDomainMigrateBegin3)
                    (virDomainPtr domain,
625
                     const char *xmlin,
626 627 628 629 630 631 632 633 634 635 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
                     char **cookieout,
                     int *cookieoutlen,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

typedef int
    (*virDrvDomainMigratePrepare3)
                    (virConnectPtr dconn,
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
                     const char *uri_in,
                     char **uri_out,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);

typedef int
    (*virDrvDomainMigratePrepareTunnel3)
                    (virConnectPtr dconn,
                     virStreamPtr st,
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);


typedef int
    (*virDrvDomainMigratePerform3)
                    (virDomainPtr dom,
663
                     const char *xmlin,
664 665 666 667
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
668
                     const char *dconnuri,
669 670 671 672 673
                     const char *uri,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

674
typedef virDomainPtr
675 676 677 678 679 680 681
    (*virDrvDomainMigrateFinish3)
                    (virConnectPtr dconn,
                     const char *dname,
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
682
                     const char *dconnuri,
683 684
                     const char *uri,
                     unsigned long flags,
685
                     int cancelled);
686 687 688 689 690 691 692 693

typedef int
    (*virDrvDomainMigrateConfirm3)
                    (virDomainPtr domain,
                     const char *cookiein,
                     int cookieinlen,
                     unsigned long flags,
                     int cancelled);
C
Chris Lalancette 已提交
694

695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714

typedef int
    (*virDrvDomainBlockJobAbort)(virDomainPtr dom, const char *path,
                                 unsigned int flags);

typedef int
    (*virDrvDomainGetBlockJobInfo)(virDomainPtr dom, const char *path,
                                   virDomainBlockJobInfoPtr info,
                                   unsigned int flags);

typedef int
    (*virDrvDomainBlockJobSetSpeed)(virDomainPtr dom,
                                    const char *path, unsigned long bandwidth,
                                    unsigned int flags);

typedef int
    (*virDrvDomainBlockPull)(virDomainPtr dom, const char *path,
                             unsigned long bandwidth, unsigned int flags);


715 716 717 718 719
/**
 * _virDriver:
 *
 * Structure associated to a virtualization driver, defining the various
 * entry points for it.
720 721 722 723 724 725
 *
 * All drivers must support the following fields/methods:
 *  - no
 *  - name
 *  - open
 *  - close
726 727
 */
struct _virDriver {
728
    int        no;	/* the number virDrvNo */
729 730 731
    const char * name;	/* the name of the driver */
    virDrvOpen			open;
    virDrvClose			close;
D
Daniel P. Berrange 已提交
732
    virDrvDrvSupportsFeature   supports_feature;
733 734
    virDrvGetType			type;
    virDrvGetVersion		version;
735
    virDrvGetLibVersion		libvirtVersion;
736
    virDrvGetHostname       getHostname;
E
Eric Blake 已提交
737
    virDrvGetSysinfo            getSysinfo;
738 739 740 741 742
    virDrvGetMaxVcpus		getMaxVcpus;
    virDrvNodeGetInfo		nodeGetInfo;
    virDrvGetCapabilities		getCapabilities;
    virDrvListDomains		listDomains;
    virDrvNumOfDomains		numOfDomains;
743
    virDrvDomainCreateXML		domainCreateXML;
744 745 746 747 748 749 750 751
    virDrvDomainLookupByID		domainLookupByID;
    virDrvDomainLookupByUUID	domainLookupByUUID;
    virDrvDomainLookupByName	domainLookupByName;
    virDrvDomainSuspend		domainSuspend;
    virDrvDomainResume		domainResume;
    virDrvDomainShutdown		domainShutdown;
    virDrvDomainReboot		domainReboot;
    virDrvDomainDestroy		domainDestroy;
752
    virDrvDomainDestroyFlags    domainDestroyFlags;
753 754 755 756
    virDrvDomainGetOSType		domainGetOSType;
    virDrvDomainGetMaxMemory	domainGetMaxMemory;
    virDrvDomainSetMaxMemory	domainSetMaxMemory;
    virDrvDomainSetMemory		domainSetMemory;
757
    virDrvDomainSetMemoryFlags  domainSetMemoryFlags;
758 759 760 761
    virDrvDomainSetMemoryParameters domainSetMemoryParameters;
    virDrvDomainGetMemoryParameters domainGetMemoryParameters;
    virDrvDomainSetBlkioParameters domainSetBlkioParameters;
    virDrvDomainGetBlkioParameters domainGetBlkioParameters;
762
    virDrvDomainGetInfo		domainGetInfo;
763
    virDrvDomainGetState	domainGetState;
764
    virDrvDomainGetControlInfo  domainGetControlInfo;
765
    virDrvDomainSave		domainSave;
766
    virDrvDomainSaveFlags	domainSaveFlags;
767
    virDrvDomainRestore		domainRestore;
768
    virDrvDomainRestoreFlags	domainRestoreFlags;
769 770
    virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
    virDrvDomainSaveImageDefineXML domainSaveImageDefineXML;
771 772
    virDrvDomainCoreDump        domainCoreDump;
    virDrvDomainScreenshot      domainScreenshot;
773
    virDrvDomainSetVcpus		domainSetVcpus;
E
Eric Blake 已提交
774 775
    virDrvDomainSetVcpusFlags		domainSetVcpusFlags;
    virDrvDomainGetVcpusFlags		domainGetVcpusFlags;
776
    virDrvDomainPinVcpu		domainPinVcpu;
777
    virDrvDomainPinVcpuFlags    domainPinVcpuFlags;
E
Eric Blake 已提交
778
    virDrvDomainGetVcpuPinInfo  domainGetVcpuPinInfo;
779 780
    virDrvDomainGetVcpus		domainGetVcpus;
    virDrvDomainGetMaxVcpus		domainGetMaxVcpus;
781 782
    virDrvDomainGetSecurityLabel     domainGetSecurityLabel;
    virDrvNodeGetSecurityModel  nodeGetSecurityModel;
783
    virDrvDomainGetXMLDesc		domainGetXMLDesc;
784 785
    virDrvConnectDomainXMLFromNative domainXMLFromNative;
    virDrvConnectDomainXMLToNative domainXMLToNative;
786 787 788
    virDrvListDefinedDomains	listDefinedDomains;
    virDrvNumOfDefinedDomains	numOfDefinedDomains;
    virDrvDomainCreate		domainCreate;
789
    virDrvDomainCreateWithFlags	domainCreateWithFlags;
790 791
    virDrvDomainDefineXML           domainDefineXML;
    virDrvDomainUndefine            domainUndefine;
O
Osier Yang 已提交
792
    virDrvDomainUndefineFlags       domainUndefineFlags;
793
    virDrvDomainAttachDevice	domainAttachDevice;
J
Jim Fehlig 已提交
794
    virDrvDomainAttachDeviceFlags	domainAttachDeviceFlags;
795
    virDrvDomainDetachDevice	domainDetachDevice;
J
Jim Fehlig 已提交
796
    virDrvDomainDetachDeviceFlags	domainDetachDeviceFlags;
797
    virDrvDomainUpdateDeviceFlags	domainUpdateDeviceFlags;
798 799 800 801
    virDrvDomainGetAutostart	domainGetAutostart;
    virDrvDomainSetAutostart	domainSetAutostart;
    virDrvDomainGetSchedulerType	domainGetSchedulerType;
    virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
802
    virDrvDomainGetSchedulerParametersFlags domainGetSchedulerParametersFlags;
803
    virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
804
    virDrvDomainSetSchedulerParametersFlags domainSetSchedulerParametersFlags;
805 806 807
    virDrvDomainMigratePrepare	domainMigratePrepare;
    virDrvDomainMigratePerform	domainMigratePerform;
    virDrvDomainMigrateFinish	domainMigrateFinish;
808 809
    virDrvDomainBlockStats      domainBlockStats;
    virDrvDomainInterfaceStats  domainInterfaceStats;
810
    virDrvDomainMemoryStats     domainMemoryStats;
R
Richard W.M. Jones 已提交
811
    virDrvDomainBlockPeek	domainBlockPeek;
R
Richard W.M. Jones 已提交
812
    virDrvDomainMemoryPeek      domainMemoryPeek;
813
    virDrvDomainGetBlockInfo    domainGetBlockInfo;
814
    virDrvNodeGetCPUStats       nodeGetCPUStats;
815
    virDrvNodeGetMemoryStats	nodeGetMemoryStats;
816
    virDrvNodeGetCellsFreeMemory	nodeGetCellsFreeMemory;
817
    virDrvNodeGetFreeMemory		nodeGetFreeMemory;
818 819
    virDrvDomainEventRegister         domainEventRegister;
    virDrvDomainEventDeregister       domainEventDeregister;
D
Daniel Veillard 已提交
820 821
    virDrvDomainMigratePrepare2	domainMigratePrepare2;
    virDrvDomainMigrateFinish2	domainMigrateFinish2;
822 823 824
    virDrvNodeDeviceDettach     nodeDeviceDettach;
    virDrvNodeDeviceReAttach    nodeDeviceReAttach;
    virDrvNodeDeviceReset       nodeDeviceReset;
C
Chris Lalancette 已提交
825
    virDrvDomainMigratePrepareTunnel domainMigratePrepareTunnel;
826 827 828 829
    virDrvConnectIsEncrypted   isEncrypted;
    virDrvConnectIsSecure      isSecure;
    virDrvDomainIsActive       domainIsActive;
    virDrvDomainIsPersistent   domainIsPersistent;
O
Osier Yang 已提交
830
    virDrvDomainIsUpdated      domainIsUpdated;
831 832
    virDrvCompareCPU            cpuCompare;
    virDrvBaselineCPU           cpuBaseline;
833
    virDrvDomainGetJobInfo     domainGetJobInfo;
834
    virDrvDomainAbortJob     domainAbortJob;
835
    virDrvDomainMigrateSetMaxDowntime  domainMigrateSetMaxDowntime;
836
    virDrvDomainMigrateGetMaxSpeed  domainMigrateGetMaxSpeed;
837
    virDrvDomainMigrateSetMaxSpeed  domainMigrateSetMaxSpeed;
838 839
    virDrvDomainEventRegisterAny domainEventRegisterAny;
    virDrvDomainEventDeregisterAny domainEventDeregisterAny;
840 841 842
    virDrvDomainManagedSave domainManagedSave;
    virDrvDomainHasManagedSaveImage domainHasManagedSaveImage;
    virDrvDomainManagedSaveRemove domainManagedSaveRemove;
C
Chris Lalancette 已提交
843
    virDrvDomainSnapshotCreateXML domainSnapshotCreateXML;
844
    virDrvDomainSnapshotGetXMLDesc domainSnapshotGetXMLDesc;
C
Chris Lalancette 已提交
845 846 847 848 849 850 851
    virDrvDomainSnapshotNum domainSnapshotNum;
    virDrvDomainSnapshotListNames domainSnapshotListNames;
    virDrvDomainSnapshotLookupByName domainSnapshotLookupByName;
    virDrvDomainHasCurrentSnapshot domainHasCurrentSnapshot;
    virDrvDomainSnapshotCurrent domainSnapshotCurrent;
    virDrvDomainRevertToSnapshot domainRevertToSnapshot;
    virDrvDomainSnapshotDelete domainSnapshotDelete;
852
    virDrvDomainQemuMonitorCommand qemuDomainMonitorCommand;
853
    virDrvDomainQemuAttach qemuDomainAttach;
854
    virDrvDomainOpenConsole domainOpenConsole;
855
    virDrvDomainInjectNMI domainInjectNMI;
856 857 858 859 860 861
    virDrvDomainMigrateBegin3	domainMigrateBegin3;
    virDrvDomainMigratePrepare3	domainMigratePrepare3;
    virDrvDomainMigratePrepareTunnel3	domainMigratePrepareTunnel3;
    virDrvDomainMigratePerform3	domainMigratePerform3;
    virDrvDomainMigrateFinish3	domainMigrateFinish3;
    virDrvDomainMigrateConfirm3	domainMigrateConfirm3;
862
    virDrvDomainSendKey domainSendKey;
863 864 865 866
    virDrvDomainBlockJobAbort domainBlockJobAbort;
    virDrvDomainGetBlockJobInfo domainGetBlockJobInfo;
    virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
    virDrvDomainBlockPull domainBlockPull;
867 868
};

869
typedef int
870
        (*virDrvNumOfNetworks)		(virConnectPtr conn);
871
typedef int
872 873 874
        (*virDrvListNetworks)		(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
875
typedef int
876
        (*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
877
typedef int
878 879 880
        (*virDrvListDefinedNetworks)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
881
typedef virNetworkPtr
882 883
        (*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
884
typedef virNetworkPtr
885 886
        (*virDrvNetworkLookupByName)	(virConnectPtr conn,
                                         const char *name);
887
typedef virNetworkPtr
888 889
        (*virDrvNetworkCreateXML)	(virConnectPtr conn,
                                         const char *xmlDesc);
890
typedef virNetworkPtr
891 892
        (*virDrvNetworkDefineXML)	(virConnectPtr conn,
                                         const char *xml);
893
typedef int
894
        (*virDrvNetworkUndefine)	(virNetworkPtr network);
895
typedef int
896
        (*virDrvNetworkCreate)		(virNetworkPtr network);
897
typedef int
898
        (*virDrvNetworkDestroy)		(virNetworkPtr network);
899
typedef char *
900
        (*virDrvNetworkGetXMLDesc)		(virNetworkPtr network,
901
                                         unsigned int flags);
902
typedef char *
903
        (*virDrvNetworkGetBridgeName)	(virNetworkPtr network);
904
typedef int
905 906
        (*virDrvNetworkGetAutostart)	(virNetworkPtr network,
                                         int *autostart);
907
typedef int
908 909
        (*virDrvNetworkSetAutostart)	(virNetworkPtr network,
                                         int autostart);
910

911 912 913 914 915 916
typedef int
        (*virDrvNetworkIsActive)(virNetworkPtr net);
typedef int
        (*virDrvNetworkIsPersistent)(virNetworkPtr net);


917 918 919 920 921 922 923 924 925

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

/**
 * _virNetworkDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
926 927 928 929
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
930 931
 */
struct _virNetworkDriver {
932 933 934 935 936 937 938 939 940 941 942 943 944 945
        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;
946
        virDrvNetworkGetXMLDesc		networkGetXMLDesc;
947 948 949
        virDrvNetworkGetBridgeName	networkGetBridgeName;
        virDrvNetworkGetAutostart	networkGetAutostart;
        virDrvNetworkSetAutostart	networkSetAutostart;
950 951
        virDrvNetworkIsActive           networkIsActive;
        virDrvNetworkIsPersistent       networkIsPersistent;
952 953
};

D
Daniel Veillard 已提交
954 955 956 957 958 959 960
/*-------*/
typedef int
        (*virDrvNumOfInterfaces)        (virConnectPtr conn);
typedef int
        (*virDrvListInterfaces)         (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
961 962 963 964 965 966
typedef int
        (*virDrvNumOfDefinedInterfaces) (virConnectPtr conn);
typedef int
        (*virDrvListDefinedInterfaces)  (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
D
Daniel Veillard 已提交
967 968 969 970 971 972 973 974
typedef virInterfacePtr
        (*virDrvInterfaceLookupByName)  (virConnectPtr conn,
                                         const char *name);
typedef virInterfacePtr
        (*virDrvInterfaceLookupByMACString)   (virConnectPtr conn,
                                               const char *mac);

typedef char *
975
        (*virDrvInterfaceGetXMLDesc)    (virInterfacePtr iface,
D
Daniel Veillard 已提交
976 977 978 979 980 981 982
                                         unsigned int flags);

typedef virInterfacePtr
        (*virDrvInterfaceDefineXML)     (virConnectPtr conn,
                                         const char *xmlDesc,
                                         unsigned int flags);
typedef int
983
        (*virDrvInterfaceUndefine)      (virInterfacePtr iface);
D
Daniel Veillard 已提交
984
typedef int
985
        (*virDrvInterfaceCreate)        (virInterfacePtr iface,
D
Daniel Veillard 已提交
986 987
                                         unsigned int flags);
typedef int
988
        (*virDrvInterfaceDestroy)       (virInterfacePtr iface,
D
Daniel Veillard 已提交
989 990
                                         unsigned int flags);

991 992 993
typedef int
        (*virDrvInterfaceIsActive)(virInterfacePtr iface);

994 995 996 997 998 999 1000 1001 1002
typedef int
        (*virDrvInterfaceChangeBegin)   (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeCommit)  (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeRollback)(virConnectPtr conn,
                                         unsigned int flags);
1003

D
Daniel Veillard 已提交
1004 1005 1006 1007 1008 1009
typedef struct _virInterfaceDriver virInterfaceDriver;
typedef virInterfaceDriver *virInterfaceDriverPtr;

/**
 * _virInterfaceDriver:
 *
1010
 * Structure associated to a network interface driver, defining the various
D
Daniel Veillard 已提交
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022
 * entry points for it.
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
 */
struct _virInterfaceDriver {
    const char                      *name; /* the name of the driver */
    virDrvOpen                       open;
    virDrvClose                      close;
    virDrvNumOfInterfaces            numOfInterfaces;
    virDrvListInterfaces             listInterfaces;
1023 1024
    virDrvNumOfDefinedInterfaces     numOfDefinedInterfaces;
    virDrvListDefinedInterfaces      listDefinedInterfaces;
D
Daniel Veillard 已提交
1025 1026 1027 1028 1029 1030 1031
    virDrvInterfaceLookupByName      interfaceLookupByName;
    virDrvInterfaceLookupByMACString interfaceLookupByMACString;
    virDrvInterfaceGetXMLDesc        interfaceGetXMLDesc;
    virDrvInterfaceDefineXML         interfaceDefineXML;
    virDrvInterfaceUndefine          interfaceUndefine;
    virDrvInterfaceCreate            interfaceCreate;
    virDrvInterfaceDestroy           interfaceDestroy;
1032
    virDrvInterfaceIsActive          interfaceIsActive;
1033 1034 1035
    virDrvInterfaceChangeBegin       interfaceChangeBegin;
    virDrvInterfaceChangeCommit      interfaceChangeCommit;
    virDrvInterfaceChangeRollback    interfaceChangeRollback;
D
Daniel Veillard 已提交
1036 1037
};

1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050

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);
1051 1052 1053 1054 1055
typedef char *
    (*virDrvConnectFindStoragePoolSources)   (virConnectPtr conn,
                                              const char *type,
                                              const char *srcSpec,
                                              unsigned int flags);
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
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);

1127 1128 1129 1130
typedef int
    (*virDrvStorageVolWipe)                  (virStorageVolPtr vol,
                                              unsigned int flags);

1131 1132 1133 1134 1135 1136 1137 1138 1139
typedef int
    (*virDrvStorageVolGetInfo)               (virStorageVolPtr vol,
                                              virStorageVolInfoPtr info);
typedef char *
    (*virDrvStorageVolGetXMLDesc)            (virStorageVolPtr pool,
                                              unsigned int flags);
typedef char *
    (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);

1140 1141 1142 1143 1144
typedef virStorageVolPtr
    (*virDrvStorageVolCreateXMLFrom)         (virStoragePoolPtr pool,
                                              const char *xmldesc,
                                              virStorageVolPtr clone,
                                              unsigned int flags);
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
typedef int
    (*virDrvStorageVolDownload) (virStorageVolPtr vol,
                                 virStreamPtr stream,
                                 unsigned long long offset,
                                 unsigned long long length,
                                 unsigned int flags);
typedef int
    (*virDrvStorageVolUpload) (virStorageVolPtr vol,
                               virStreamPtr stream,
                               unsigned long long offset,
                               unsigned long long length,
                               unsigned int flags);
1157

1158 1159 1160 1161 1162 1163
typedef int
        (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
typedef int
        (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);


1164 1165 1166 1167 1168 1169 1170

typedef struct _virStorageDriver virStorageDriver;
typedef virStorageDriver *virStorageDriverPtr;

/**
 * _virStorageDriver:
 *
1171
 * Structure associated to a storage driver, defining the various
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186
 * 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;
1187
    virDrvConnectFindStoragePoolSources findPoolSources;
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
    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;
1210
    virDrvStorageVolCreateXMLFrom volCreateXMLFrom;
1211 1212
    virDrvStorageVolDownload volDownload;
    virDrvStorageVolUpload volUpload;
1213
    virDrvStorageVolDelete volDelete;
1214
    virDrvStorageVolWipe volWipe;
1215 1216 1217
    virDrvStorageVolGetInfo volGetInfo;
    virDrvStorageVolGetXMLDesc volGetXMLDesc;
    virDrvStorageVolGetPath volGetPath;
1218 1219
    virDrvStoragePoolIsActive   poolIsActive;
    virDrvStoragePoolIsPersistent   poolIsPersistent;
1220 1221
};

1222
# ifdef WITH_LIBVIRTD
1223
typedef int (*virDrvStateInitialize) (int privileged);
1224 1225 1226 1227 1228 1229 1230 1231
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);

typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;

struct _virStateDriver {
1232
    const char *name;
1233 1234 1235 1236 1237
    virDrvStateInitialize  initialize;
    virDrvStateCleanup     cleanup;
    virDrvStateReload      reload;
    virDrvStateActive      active;
};
1238
# endif
1239

1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256

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

1257 1258
typedef char * (*virDevMonDeviceGetXMLDesc)(virNodeDevicePtr dev,
                                            unsigned int flags);
1259 1260 1261 1262 1263 1264 1265 1266 1267

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

typedef int (*virDevMonDeviceNumOfCaps)(virNodeDevicePtr dev);

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

1268 1269 1270 1271 1272
typedef virNodeDevicePtr (*virDrvNodeDeviceCreateXML)(virConnectPtr conn,
                                                      const char *xmlDesc,
                                                      unsigned int flags);
typedef int (*virDrvNodeDeviceDestroy)(virNodeDevicePtr dev);

1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
/**
 * _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;
1287
    virDevMonDeviceGetXMLDesc deviceGetXMLDesc;
1288 1289 1290
    virDevMonDeviceGetParent deviceGetParent;
    virDevMonDeviceNumOfCaps deviceNumOfCaps;
    virDevMonDeviceListCaps deviceListCaps;
1291 1292
    virDrvNodeDeviceCreateXML deviceCreateXML;
    virDrvNodeDeviceDestroy deviceDestroy;
1293 1294
};

1295 1296
enum {
    /* This getValue call is inside libvirt, override the "private" flag.
E
Eric Blake 已提交
1297
       This flag cannot be set by outside callers. */
1298
    VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 0,
1299 1300
};

1301
typedef virSecretPtr
1302 1303
    (*virDrvSecretLookupByUUID)        (virConnectPtr conn,
                                        const unsigned char *uuid);
1304 1305 1306 1307
typedef virSecretPtr
    (*virDrvSecretLookupByUsage)       (virConnectPtr conn,
                                        int usageType,
                                        const char *usageID);
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322
typedef virSecretPtr
    (*virDrvSecretDefineXML)                 (virConnectPtr conn,
                                              const char *xml,
                                              unsigned int flags);
typedef char *
    (*virDrvSecretGetXMLDesc)                (virSecretPtr secret,
                                              unsigned int flags);
typedef int
    (*virDrvSecretSetValue)                  (virSecretPtr secret,
                                              const unsigned char *value,
                                              size_t value_size,
                                              unsigned int flags);
typedef unsigned char *
    (*virDrvSecretGetValue)                  (virSecretPtr secret,
                                              size_t *value_size,
1323 1324
                                              unsigned int flags,
                                              unsigned int internalFlags);
1325 1326 1327
typedef int
    (*virDrvSecretUndefine)                  (virSecretPtr secret);
typedef int
1328
    (*virDrvNumOfSecrets)              (virConnectPtr conn);
1329
typedef int
1330
    (*virDrvListSecrets)               (virConnectPtr conn,
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351
                                              char **uuids,
                                              int maxuuids);

typedef struct _virSecretDriver virSecretDriver;
typedef virSecretDriver *virSecretDriverPtr;

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

1352 1353
    virDrvNumOfSecrets numOfSecrets;
    virDrvListSecrets listSecrets;
1354
    virDrvSecretLookupByUUID lookupByUUID;
1355
    virDrvSecretLookupByUsage lookupByUsage;
1356 1357 1358 1359 1360 1361 1362
    virDrvSecretDefineXML defineXML;
    virDrvSecretGetXMLDesc getXMLDesc;
    virDrvSecretSetValue setValue;
    virDrvSecretGetValue getValue;
    virDrvSecretUndefine undefine;
};

1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397

typedef struct _virStreamDriver virStreamDriver;
typedef virStreamDriver *virStreamDriverPtr;

typedef int (*virDrvStreamSend)(virStreamPtr st,
                                const char *data,
                                size_t nbytes);
typedef int (*virDrvStreamRecv)(virStreamPtr st,
                                char *data,
                                size_t nbytes);

typedef int (*virDrvStreamEventAddCallback)(virStreamPtr stream,
                                            int events,
                                            virStreamEventCallback cb,
                                            void *opaque,
                                            virFreeCallback ff);

typedef int (*virDrvStreamEventUpdateCallback)(virStreamPtr stream,
                                               int events);
typedef int (*virDrvStreamEventRemoveCallback)(virStreamPtr stream);
typedef int (*virDrvStreamFinish)(virStreamPtr st);
typedef int (*virDrvStreamAbort)(virStreamPtr st);


struct _virStreamDriver {
    virDrvStreamSend streamSend;
    virDrvStreamRecv streamRecv;
    virDrvStreamEventAddCallback streamAddCallback;
    virDrvStreamEventUpdateCallback streamUpdateCallback;
    virDrvStreamEventRemoveCallback streamRemoveCallback;
    virDrvStreamFinish streamFinish;
    virDrvStreamAbort streamAbort;
};


S
Stefan Berger 已提交
1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411
typedef int
    (*virDrvConnectNumOfNWFilters)        (virConnectPtr conn);
typedef int
    (*virDrvConnectListNWFilters)         (virConnectPtr conn,
                                           char **const names,
                                           int maxnames);
typedef virNWFilterPtr
    (*virDrvNWFilterLookupByName)             (virConnectPtr conn,
                                               const char *name);
typedef virNWFilterPtr
    (*virDrvNWFilterLookupByUUID)             (virConnectPtr conn,
                                               const unsigned char *uuid);
typedef virNWFilterPtr
    (*virDrvNWFilterDefineXML)                (virConnectPtr conn,
E
Eric Blake 已提交
1412
                                               const char *xmlDesc);
S
Stefan Berger 已提交
1413
typedef int
1414
    (*virDrvNWFilterUndefine)                 (virNWFilterPtr nwfilter);
S
Stefan Berger 已提交
1415 1416

typedef char *
1417
    (*virDrvNWFilterGetXMLDesc)              (virNWFilterPtr nwfilter,
1418
                                              unsigned int flags);
S
Stefan Berger 已提交
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448


typedef struct _virNWFilterDriver virNWFilterDriver;
typedef virNWFilterDriver *virNWFilterDriverPtr;

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

    virDrvConnectNumOfNWFilters numOfNWFilters;
    virDrvConnectListNWFilters listNWFilters;
    virDrvNWFilterLookupByName nwfilterLookupByName;
    virDrvNWFilterLookupByUUID nwfilterLookupByUUID;
    virDrvNWFilterDefineXML defineXML;
    virDrvNWFilterUndefine undefine;
    virDrvNWFilterGetXMLDesc getXMLDesc;
};


1449 1450 1451 1452 1453 1454
/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
1455
int virRegisterNetworkDriver(virNetworkDriverPtr);
D
Daniel Veillard 已提交
1456
int virRegisterInterfaceDriver(virInterfaceDriverPtr);
1457
int virRegisterStorageDriver(virStorageDriverPtr);
1458
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
1459
int virRegisterSecretDriver(virSecretDriverPtr);
S
Stefan Berger 已提交
1460
int virRegisterNWFilterDriver(virNWFilterDriverPtr);
1461
# ifdef WITH_LIBVIRTD
1462
int virRegisterStateDriver(virStateDriverPtr);
1463
# endif
1464
void *virDriverLoadModule(const char *name);
1465 1466

#endif /* __VIR_DRIVER_H__ */