driver.h 53.4 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,
32 33 34
} virDrvNo;


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

50
/* Internal feature-detection macro.  Don't call drv->supports_feature
51 52
 * directly if you don't have to, because it may be NULL, use this macro
 * instead.
53
 *
54 55 56
 * 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.
57 58
 *
 * Returns:
59
 *   != 0  Feature is supported.
60 61
 *   0     Feature is not supported.
 */
62 63 64
# define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature)                         \
    ((drv)->supports_feature ?                                              \
        (drv)->supports_feature((conn), (feature)) > 0 : 0)
65

66
typedef virDrvOpenStatus
67
        (*virDrvOpen)			(virConnectPtr conn,
68
                             virConnectAuthPtr auth,
69
                             unsigned int flags);
70
typedef int
71
        (*virDrvClose)			(virConnectPtr conn);
72
typedef int
D
Daniel P. Berrange 已提交
73
    (*virDrvDrvSupportsFeature) (virConnectPtr conn, int feature);
74
typedef const char *
75
        (*virDrvGetType)		(virConnectPtr conn);
76
typedef int
77 78
        (*virDrvGetVersion)		(virConnectPtr conn,
                                         unsigned long *hvVer);
79 80 81
typedef int
        (*virDrvGetLibVersion)      (virConnectPtr conn,
                                     unsigned long *libVer);
82 83 84 85
typedef char *
    (*virDrvGetHostname)    (virConnectPtr conn);
typedef char *
    (*virDrvGetURI)         (virConnectPtr conn);
E
Eric Blake 已提交
86 87 88
typedef char *
    (*virDrvGetSysinfo)     (virConnectPtr conn,
                             unsigned int flags);
89
typedef int
90 91
        (*virDrvGetMaxVcpus)		(virConnectPtr conn,
                                         const char *type);
92
typedef int
93 94
        (*virDrvNodeGetInfo)		(virConnectPtr conn,
                                         virNodeInfoPtr info);
95
typedef char *
96
        (*virDrvGetCapabilities) (virConnectPtr conn);
97
typedef int
98 99 100
        (*virDrvListDomains)		(virConnectPtr conn,
                                         int *ids,
                                         int maxids);
101
typedef int
102
        (*virDrvNumOfDomains)		(virConnectPtr conn);
103
typedef virDomainPtr
104
        (*virDrvDomainCreateXML)	(virConnectPtr conn,
105 106
                                         const char *xmlDesc,
                                         unsigned int flags);
107
typedef virDomainPtr
108 109
        (*virDrvDomainLookupByID)	(virConnectPtr conn,
                                         int id);
110
typedef virDomainPtr
111 112
        (*virDrvDomainLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
113
typedef virDomainPtr
114 115
        (*virDrvDomainLookupByName)	(virConnectPtr conn,
                                         const char *name);
116
typedef int
117
        (*virDrvDomainSuspend)		(virDomainPtr domain);
118
typedef int
119
        (*virDrvDomainResume)		(virDomainPtr domain);
120
typedef int
121
        (*virDrvDomainShutdown)		(virDomainPtr domain);
122
typedef int
123 124
        (*virDrvDomainReboot)		(virDomainPtr domain,
                                         unsigned int flags);
125
typedef int
126
        (*virDrvDomainDestroy)		(virDomainPtr domain);
127
typedef char *
128
        (*virDrvDomainGetOSType)	(virDomainPtr domain);
129
typedef unsigned long
130
        (*virDrvDomainGetMaxMemory)	(virDomainPtr domain);
131
typedef int
132 133
        (*virDrvDomainSetMaxMemory)	(virDomainPtr domain,
                                         unsigned long memory);
134
typedef int
135 136
        (*virDrvDomainSetMemory)	(virDomainPtr domain,
                                         unsigned long memory);
137 138 139 140
typedef int
        (*virDrvDomainSetMemoryFlags)	(virDomainPtr domain,
                                         unsigned long memory,
                                         unsigned int flags);
141 142 143
typedef int
        (*virDrvDomainSetMemoryParameters)
                                        (virDomainPtr domain,
144
                                         virTypedParameterPtr params,
145 146 147 148 149
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetMemoryParameters)
                                        (virDomainPtr domain,
150
                                         virTypedParameterPtr params,
151 152
                                         int *nparams,
                                         unsigned int flags);
153 154 155
typedef int
        (*virDrvDomainSetBlkioParameters)
                                        (virDomainPtr domain,
156
                                         virTypedParameterPtr params,
157 158 159 160 161
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetBlkioParameters)
                                        (virDomainPtr domain,
162
                                         virTypedParameterPtr params,
163 164
                                         int *nparams,
                                         unsigned int flags);
165
typedef int
166 167
        (*virDrvDomainGetInfo)		(virDomainPtr domain,
                                         virDomainInfoPtr info);
168 169 170 171 172
typedef int
        (*virDrvDomainGetState)         (virDomainPtr domain,
                                         int *state,
                                         int *reason,
                                         unsigned int flags);
173 174 175 176
typedef int
        (*virDrvDomainGetControlInfo)   (virDomainPtr domain,
                                         virDomainControlInfoPtr info,
                                         unsigned int flags);
177
typedef int
178 179
        (*virDrvDomainSave)		(virDomainPtr domain,
                                         const char *to);
180
typedef int
181 182
        (*virDrvDomainRestore)		(virConnectPtr conn,
                                         const char *from);
D
Daniel Veillard 已提交
183
typedef int
184 185
        (*virDrvDomainCoreDump)		(virDomainPtr domain,
                                         const char *to,
186
                                         unsigned int flags);
187 188 189 190 191
typedef char *
        (*virDrvDomainScreenshot)   (virDomainPtr domain,
                                         virStreamPtr stream,
                                         unsigned int screen,
                                         unsigned int flags);
192
typedef char *
193
        (*virDrvDomainGetXMLDesc)		(virDomainPtr dom,
194
                                                 unsigned int flags);
195 196 197 198 199 200 201 202 203 204
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);
205
typedef int
206 207 208
        (*virDrvListDefinedDomains)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
209
typedef int
210
        (*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
211
typedef int
212
        (*virDrvDomainCreate)		(virDomainPtr dom);
213 214 215
typedef int
        (*virDrvDomainCreateWithFlags)	(virDomainPtr dom,
                                         unsigned int flags);
216
typedef virDomainPtr
217 218
        (*virDrvDomainDefineXML)	(virConnectPtr conn,
                                         const char *xml);
219
typedef int
220
        (*virDrvDomainUndefine)		(virDomainPtr dom);
221
typedef int
222 223
        (*virDrvDomainSetVcpus)		(virDomainPtr domain,
                                         unsigned int nvcpus);
E
Eric Blake 已提交
224 225 226 227 228 229 230
typedef int
        (*virDrvDomainSetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int nvcpus,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int flags);
231
typedef int
232 233 234 235
        (*virDrvDomainPinVcpu)		(virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen);
236 237 238 239 240 241
typedef int
        (*virDrvDomainPinVcpuFlags)     (virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen,
                                         unsigned int flags);
242
typedef int
E
Eric Blake 已提交
243
        (*virDrvDomainGetVcpuPinInfo)   (virDomainPtr domain,
244 245 246 247 248
                                         int ncpumaps,
                                         unsigned char *cpumaps,
                                         int maplen,
                                         unsigned int flags);

249
typedef int
250 251 252 253 254
        (*virDrvDomainGetVcpus)		(virDomainPtr domain,
                                         virVcpuInfoPtr info,
                                         int maxinfo,
                                         unsigned char *cpumaps,
                                         int maplen);
255
typedef int
256
        (*virDrvDomainGetMaxVcpus)	(virDomainPtr domain);
257 258 259 260 261 262 263

typedef int
        (*virDrvDomainGetSecurityLabel)	(virDomainPtr domain,
                                         virSecurityLabelPtr seclabel);
typedef int
        (*virDrvNodeGetSecurityModel)	(virConnectPtr conn,
                                         virSecurityModelPtr secmodel);
264
typedef int
265 266
        (*virDrvDomainAttachDevice)	(virDomainPtr domain,
                                         const char *xml);
J
Jim Fehlig 已提交
267 268 269 270
typedef int
        (*virDrvDomainAttachDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
271
typedef int
272 273
        (*virDrvDomainDetachDevice)	(virDomainPtr domain,
                                         const char *xml);
J
Jim Fehlig 已提交
274 275 276 277
typedef int
        (*virDrvDomainDetachDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
278 279 280 281
typedef int
        (*virDrvDomainUpdateDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
282
typedef int
283 284
        (*virDrvDomainGetAutostart)	(virDomainPtr domain,
                                         int *autostart);
285
typedef int
286 287
        (*virDrvDomainSetAutostart)	(virDomainPtr domain,
                                         int autostart);
288

289
typedef char *
290 291
        (*virDrvDomainGetSchedulerType)	(virDomainPtr domain,
                                         int *nparams);
292

293
typedef int
294 295
        (*virDrvDomainGetSchedulerParameters)
                                        (virDomainPtr domain,
296
                                         virTypedParameterPtr params,
297
                                         int *nparams);
298

299 300 301 302 303 304 305
typedef int
        (*virDrvDomainGetSchedulerParametersFlags)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         unsigned int flags);

306
typedef int
307 308
        (*virDrvDomainSetSchedulerParameters)
                                        (virDomainPtr domain,
309
                                         virTypedParameterPtr params,
310
                                         int nparams);
311

312 313 314
typedef int
        (*virDrvDomainSetSchedulerParametersFlags)
                                        (virDomainPtr domain,
315
                                         virTypedParameterPtr params,
316 317 318
                                         int nparams,
                                         unsigned int flags);

319 320 321 322 323 324 325 326 327 328 329
typedef int
    (*virDrvDomainBlockStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainBlockStats *stats);
typedef int
    (*virDrvDomainInterfaceStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainInterfaceStats *stats);

330 331 332 333
typedef int
    (*virDrvDomainMemoryStats)
                    (virDomainPtr domain,
                     struct _virDomainMemoryStat *stats,
334 335
                     unsigned int nr_stats,
                     unsigned int flags);
336

R
Richard W.M. Jones 已提交
337 338 339 340 341
typedef int
    (*virDrvDomainBlockPeek)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long offset, size_t size,
342 343
                     void *buffer,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
344

R
Richard W.M. Jones 已提交
345 346 347 348 349 350
typedef int
    (*virDrvDomainMemoryPeek)
                    (virDomainPtr domain,
                     unsigned long long start, size_t size,
                     void *buffer,
                     unsigned int flags);
351 352 353 354 355 356
typedef int
    (*virDrvDomainGetBlockInfo)
                    (virDomainPtr domain,
                     const char *path,
                     virDomainBlockInfoPtr info,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
357

358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
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);

388 389 390
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;

391 392 393 394
typedef int
    (*virDrvNodeGetCPUStats)
                    (virConnectPtr conn,
                     int cpuNum,
395
                     virNodeCPUStatsPtr params,
396 397 398
                     int *nparams,
                     unsigned int flags);

399 400 401 402
typedef int
    (*virDrvNodeGetMemoryStats)
                    (virConnectPtr conn,
                     int cellNum,
403
                     virNodeMemoryStatsPtr params,
404 405 406
                     int *nparams,
                     unsigned int flags);

407 408 409 410 411 412 413
typedef int
    (*virDrvNodeGetCellsFreeMemory)
                    (virConnectPtr conn,
                     unsigned long long *freeMems,
                     int startCell,
                     int maxCells);

414 415
typedef unsigned long long
    (*virDrvNodeGetFreeMemory)
416
                    (virConnectPtr conn);
417

418 419 420
typedef int
    (*virDrvDomainEventRegister)
                    (virConnectPtr conn,
421
                     virConnectDomainEventCallback cb,
422 423
                     void *opaque,
                     virFreeCallback freecb);
424 425 426 427

typedef int
    (*virDrvDomainEventDeregister)
                    (virConnectPtr conn,
428
                     virConnectDomainEventCallback cb);
429

D
Daniel Veillard 已提交
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
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);

452 453 454 455 456 457 458 459 460 461
typedef int
    (*virDrvNodeDeviceDettach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReAttach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReset)
                    (virNodeDevicePtr dev);

C
Chris Lalancette 已提交
462 463
typedef int
    (*virDrvDomainMigratePrepareTunnel)
464
                    (virConnectPtr dconn,
C
Chris Lalancette 已提交
465 466 467 468 469 470
                     virStreamPtr st,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);

471 472 473 474 475 476 477 478
typedef int
    (*virDrvConnectIsEncrypted)(virConnectPtr conn);
typedef int
    (*virDrvConnectIsSecure)(virConnectPtr conn);
typedef int
    (*virDrvDomainIsActive)(virDomainPtr dom);
typedef int
    (*virDrvDomainIsPersistent)(virDomainPtr dom);
O
Osier Yang 已提交
479 480
typedef int
    (*virDrvDomainIsUpdated)(virDomainPtr dom);
481

J
Jiri Denemark 已提交
482
typedef int
483
    (*virDrvCompareCPU)(virConnectPtr conn,
J
Jiri Denemark 已提交
484 485
                        const char *cpu,
                        unsigned int flags);
486
typedef char *
487
    (*virDrvBaselineCPU)(virConnectPtr conn,
488 489 490
                         const char **xmlCPUs,
                         unsigned int ncpus,
                         unsigned int flags);
J
Jiri Denemark 已提交
491

492 493 494 495
typedef int
    (*virDrvDomainGetJobInfo)(virDomainPtr domain,
                              virDomainJobInfoPtr info);

496 497 498
typedef int
    (*virDrvDomainAbortJob)(virDomainPtr domain);

499 500 501 502
typedef int
    (*virDrvDomainMigrateSetMaxDowntime)(virDomainPtr domain,
                                         unsigned long long downtime,
                                         unsigned int flags);
503 504 505 506
typedef int
    (*virDrvDomainMigrateSetMaxSpeed)(virDomainPtr domain,
                                      unsigned long bandwidth,
                                      unsigned int flags);
507

508 509 510 511 512 513 514 515 516 517 518 519
typedef int
    (*virDrvDomainEventRegisterAny)(virConnectPtr conn,
                                    virDomainPtr dom,
                                    int eventID,
                                    virConnectDomainEventGenericCallback cb,
                                    void *opaque,
                                    virFreeCallback freecb);

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

520 521 522 523 524 525 526 527 528
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 已提交
529 530 531 532 533 534
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain,
                                     const char *xmlDesc,
                                     unsigned int flags);

typedef char *
535 536
    (*virDrvDomainSnapshotGetXMLDesc)(virDomainSnapshotPtr snapshot,
                                      unsigned int flags);
C
Chris Lalancette 已提交
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

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 已提交
566
typedef int
567
    (*virDrvDomainQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
C
Chris Lalancette 已提交
568 569
                                      char **result, unsigned int flags);

570 571 572 573 574
typedef virDomainPtr
    (*virDrvDomainQemuAttach)(virConnectPtr conn,
                              unsigned int pid,
                              unsigned int flags);

575 576 577 578 579
typedef int
    (*virDrvDomainOpenConsole)(virDomainPtr dom,
                               const char *devname,
                               virStreamPtr st,
                               unsigned int flags);
C
Chris Lalancette 已提交
580

581 582 583
typedef int
    (*virDrvDomainInjectNMI)(virDomainPtr dom, unsigned int flags);

584 585 586 587
typedef int
    (*virDrvDomainSendKey)(virDomainPtr dom, unsigned int codeset,
                           unsigned int holdtime,
                           unsigned int *keycodes,
588
                           int nkeycodes,
589 590
                           unsigned int flags);

591 592 593
typedef char *
    (*virDrvDomainMigrateBegin3)
                    (virDomainPtr domain,
594
                     const char *xmlin,
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 620 621 622 623 624 625 626 627 628 629 630 631
                     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,
632
                     const char *xmlin,
633 634 635 636
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
637
                     const char *dconnuri,
638 639 640 641 642
                     const char *uri,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

643
typedef virDomainPtr
644 645 646 647 648 649 650
    (*virDrvDomainMigrateFinish3)
                    (virConnectPtr dconn,
                     const char *dname,
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
651
                     const char *dconnuri,
652 653
                     const char *uri,
                     unsigned long flags,
654
                     int cancelled);
655 656 657 658 659 660 661 662

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

664 665 666 667 668
/**
 * _virDriver:
 *
 * Structure associated to a virtualization driver, defining the various
 * entry points for it.
669 670 671 672 673 674
 *
 * All drivers must support the following fields/methods:
 *  - no
 *  - name
 *  - open
 *  - close
675 676
 */
struct _virDriver {
677
    int        no;	/* the number virDrvNo */
678 679 680
    const char * name;	/* the name of the driver */
    virDrvOpen			open;
    virDrvClose			close;
D
Daniel P. Berrange 已提交
681
    virDrvDrvSupportsFeature   supports_feature;
682 683
    virDrvGetType			type;
    virDrvGetVersion		version;
684
    virDrvGetLibVersion		libvirtVersion;
685
    virDrvGetHostname       getHostname;
E
Eric Blake 已提交
686
    virDrvGetSysinfo            getSysinfo;
687 688 689 690 691
    virDrvGetMaxVcpus		getMaxVcpus;
    virDrvNodeGetInfo		nodeGetInfo;
    virDrvGetCapabilities		getCapabilities;
    virDrvListDomains		listDomains;
    virDrvNumOfDomains		numOfDomains;
692
    virDrvDomainCreateXML		domainCreateXML;
693 694 695 696 697 698 699 700 701 702 703 704
    virDrvDomainLookupByID		domainLookupByID;
    virDrvDomainLookupByUUID	domainLookupByUUID;
    virDrvDomainLookupByName	domainLookupByName;
    virDrvDomainSuspend		domainSuspend;
    virDrvDomainResume		domainResume;
    virDrvDomainShutdown		domainShutdown;
    virDrvDomainReboot		domainReboot;
    virDrvDomainDestroy		domainDestroy;
    virDrvDomainGetOSType		domainGetOSType;
    virDrvDomainGetMaxMemory	domainGetMaxMemory;
    virDrvDomainSetMaxMemory	domainSetMaxMemory;
    virDrvDomainSetMemory		domainSetMemory;
705
    virDrvDomainSetMemoryFlags  domainSetMemoryFlags;
706 707 708 709
    virDrvDomainSetMemoryParameters domainSetMemoryParameters;
    virDrvDomainGetMemoryParameters domainGetMemoryParameters;
    virDrvDomainSetBlkioParameters domainSetBlkioParameters;
    virDrvDomainGetBlkioParameters domainGetBlkioParameters;
710
    virDrvDomainGetInfo		domainGetInfo;
711
    virDrvDomainGetState	domainGetState;
712
    virDrvDomainGetControlInfo  domainGetControlInfo;
713 714
    virDrvDomainSave		domainSave;
    virDrvDomainRestore		domainRestore;
715 716
    virDrvDomainCoreDump        domainCoreDump;
    virDrvDomainScreenshot      domainScreenshot;
717
    virDrvDomainSetVcpus		domainSetVcpus;
E
Eric Blake 已提交
718 719
    virDrvDomainSetVcpusFlags		domainSetVcpusFlags;
    virDrvDomainGetVcpusFlags		domainGetVcpusFlags;
720
    virDrvDomainPinVcpu		domainPinVcpu;
721
    virDrvDomainPinVcpuFlags    domainPinVcpuFlags;
E
Eric Blake 已提交
722
    virDrvDomainGetVcpuPinInfo  domainGetVcpuPinInfo;
723 724
    virDrvDomainGetVcpus		domainGetVcpus;
    virDrvDomainGetMaxVcpus		domainGetMaxVcpus;
725 726
    virDrvDomainGetSecurityLabel     domainGetSecurityLabel;
    virDrvNodeGetSecurityModel  nodeGetSecurityModel;
727
    virDrvDomainGetXMLDesc		domainGetXMLDesc;
728 729
    virDrvConnectDomainXMLFromNative domainXMLFromNative;
    virDrvConnectDomainXMLToNative domainXMLToNative;
730 731 732
    virDrvListDefinedDomains	listDefinedDomains;
    virDrvNumOfDefinedDomains	numOfDefinedDomains;
    virDrvDomainCreate		domainCreate;
733
    virDrvDomainCreateWithFlags	domainCreateWithFlags;
734 735 736
    virDrvDomainDefineXML           domainDefineXML;
    virDrvDomainUndefine            domainUndefine;
    virDrvDomainAttachDevice	domainAttachDevice;
J
Jim Fehlig 已提交
737
    virDrvDomainAttachDeviceFlags	domainAttachDeviceFlags;
738
    virDrvDomainDetachDevice	domainDetachDevice;
J
Jim Fehlig 已提交
739
    virDrvDomainDetachDeviceFlags	domainDetachDeviceFlags;
740
    virDrvDomainUpdateDeviceFlags	domainUpdateDeviceFlags;
741 742 743 744
    virDrvDomainGetAutostart	domainGetAutostart;
    virDrvDomainSetAutostart	domainSetAutostart;
    virDrvDomainGetSchedulerType	domainGetSchedulerType;
    virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
745
    virDrvDomainGetSchedulerParametersFlags domainGetSchedulerParametersFlags;
746
    virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
747
    virDrvDomainSetSchedulerParametersFlags domainSetSchedulerParametersFlags;
748 749 750
    virDrvDomainMigratePrepare	domainMigratePrepare;
    virDrvDomainMigratePerform	domainMigratePerform;
    virDrvDomainMigrateFinish	domainMigrateFinish;
751 752
    virDrvDomainBlockStats      domainBlockStats;
    virDrvDomainInterfaceStats  domainInterfaceStats;
753
    virDrvDomainMemoryStats     domainMemoryStats;
R
Richard W.M. Jones 已提交
754
    virDrvDomainBlockPeek	domainBlockPeek;
R
Richard W.M. Jones 已提交
755
    virDrvDomainMemoryPeek      domainMemoryPeek;
756
    virDrvDomainGetBlockInfo    domainGetBlockInfo;
757
    virDrvNodeGetCPUStats       nodeGetCPUStats;
758
    virDrvNodeGetMemoryStats	nodeGetMemoryStats;
759
    virDrvNodeGetCellsFreeMemory	nodeGetCellsFreeMemory;
760
    virDrvNodeGetFreeMemory		nodeGetFreeMemory;
761 762
    virDrvDomainEventRegister         domainEventRegister;
    virDrvDomainEventDeregister       domainEventDeregister;
D
Daniel Veillard 已提交
763 764
    virDrvDomainMigratePrepare2	domainMigratePrepare2;
    virDrvDomainMigrateFinish2	domainMigrateFinish2;
765 766 767
    virDrvNodeDeviceDettach     nodeDeviceDettach;
    virDrvNodeDeviceReAttach    nodeDeviceReAttach;
    virDrvNodeDeviceReset       nodeDeviceReset;
C
Chris Lalancette 已提交
768
    virDrvDomainMigratePrepareTunnel domainMigratePrepareTunnel;
769 770 771 772
    virDrvConnectIsEncrypted   isEncrypted;
    virDrvConnectIsSecure      isSecure;
    virDrvDomainIsActive       domainIsActive;
    virDrvDomainIsPersistent   domainIsPersistent;
O
Osier Yang 已提交
773
    virDrvDomainIsUpdated      domainIsUpdated;
774 775
    virDrvCompareCPU            cpuCompare;
    virDrvBaselineCPU           cpuBaseline;
776
    virDrvDomainGetJobInfo     domainGetJobInfo;
777
    virDrvDomainAbortJob     domainAbortJob;
778
    virDrvDomainMigrateSetMaxDowntime  domainMigrateSetMaxDowntime;
779
    virDrvDomainMigrateSetMaxSpeed  domainMigrateSetMaxSpeed;
780 781
    virDrvDomainEventRegisterAny domainEventRegisterAny;
    virDrvDomainEventDeregisterAny domainEventDeregisterAny;
782 783 784
    virDrvDomainManagedSave domainManagedSave;
    virDrvDomainHasManagedSaveImage domainHasManagedSaveImage;
    virDrvDomainManagedSaveRemove domainManagedSaveRemove;
C
Chris Lalancette 已提交
785
    virDrvDomainSnapshotCreateXML domainSnapshotCreateXML;
786
    virDrvDomainSnapshotGetXMLDesc domainSnapshotGetXMLDesc;
C
Chris Lalancette 已提交
787 788 789 790 791 792 793
    virDrvDomainSnapshotNum domainSnapshotNum;
    virDrvDomainSnapshotListNames domainSnapshotListNames;
    virDrvDomainSnapshotLookupByName domainSnapshotLookupByName;
    virDrvDomainHasCurrentSnapshot domainHasCurrentSnapshot;
    virDrvDomainSnapshotCurrent domainSnapshotCurrent;
    virDrvDomainRevertToSnapshot domainRevertToSnapshot;
    virDrvDomainSnapshotDelete domainSnapshotDelete;
794
    virDrvDomainQemuMonitorCommand qemuDomainMonitorCommand;
795
    virDrvDomainQemuAttach qemuDomainAttach;
796
    virDrvDomainOpenConsole domainOpenConsole;
797
    virDrvDomainInjectNMI domainInjectNMI;
798 799 800 801 802 803
    virDrvDomainMigrateBegin3	domainMigrateBegin3;
    virDrvDomainMigratePrepare3	domainMigratePrepare3;
    virDrvDomainMigratePrepareTunnel3	domainMigratePrepareTunnel3;
    virDrvDomainMigratePerform3	domainMigratePerform3;
    virDrvDomainMigrateFinish3	domainMigrateFinish3;
    virDrvDomainMigrateConfirm3	domainMigrateConfirm3;
804
    virDrvDomainSendKey domainSendKey;
805 806
};

807
typedef int
808
        (*virDrvNumOfNetworks)		(virConnectPtr conn);
809
typedef int
810 811 812
        (*virDrvListNetworks)		(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
813
typedef int
814
        (*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
815
typedef int
816 817 818
        (*virDrvListDefinedNetworks)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
819
typedef virNetworkPtr
820 821
        (*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
822
typedef virNetworkPtr
823 824
        (*virDrvNetworkLookupByName)	(virConnectPtr conn,
                                         const char *name);
825
typedef virNetworkPtr
826 827
        (*virDrvNetworkCreateXML)	(virConnectPtr conn,
                                         const char *xmlDesc);
828
typedef virNetworkPtr
829 830
        (*virDrvNetworkDefineXML)	(virConnectPtr conn,
                                         const char *xml);
831
typedef int
832
        (*virDrvNetworkUndefine)	(virNetworkPtr network);
833
typedef int
834
        (*virDrvNetworkCreate)		(virNetworkPtr network);
835
typedef int
836
        (*virDrvNetworkDestroy)		(virNetworkPtr network);
837
typedef char *
838
        (*virDrvNetworkGetXMLDesc)		(virNetworkPtr network,
839
                                         unsigned int flags);
840
typedef char *
841
        (*virDrvNetworkGetBridgeName)	(virNetworkPtr network);
842
typedef int
843 844
        (*virDrvNetworkGetAutostart)	(virNetworkPtr network,
                                         int *autostart);
845
typedef int
846 847
        (*virDrvNetworkSetAutostart)	(virNetworkPtr network,
                                         int autostart);
848

849 850 851 852 853 854
typedef int
        (*virDrvNetworkIsActive)(virNetworkPtr net);
typedef int
        (*virDrvNetworkIsPersistent)(virNetworkPtr net);


855 856 857 858 859 860 861 862 863

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

/**
 * _virNetworkDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
864 865 866 867
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
868 869
 */
struct _virNetworkDriver {
870 871 872 873 874 875 876 877 878 879 880 881 882 883
        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;
884
        virDrvNetworkGetXMLDesc		networkGetXMLDesc;
885 886 887
        virDrvNetworkGetBridgeName	networkGetBridgeName;
        virDrvNetworkGetAutostart	networkGetAutostart;
        virDrvNetworkSetAutostart	networkSetAutostart;
888 889
        virDrvNetworkIsActive           networkIsActive;
        virDrvNetworkIsPersistent       networkIsPersistent;
890 891
};

D
Daniel Veillard 已提交
892 893 894 895 896 897 898
/*-------*/
typedef int
        (*virDrvNumOfInterfaces)        (virConnectPtr conn);
typedef int
        (*virDrvListInterfaces)         (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
899 900 901 902 903 904
typedef int
        (*virDrvNumOfDefinedInterfaces) (virConnectPtr conn);
typedef int
        (*virDrvListDefinedInterfaces)  (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
D
Daniel Veillard 已提交
905 906 907 908 909 910 911 912
typedef virInterfacePtr
        (*virDrvInterfaceLookupByName)  (virConnectPtr conn,
                                         const char *name);
typedef virInterfacePtr
        (*virDrvInterfaceLookupByMACString)   (virConnectPtr conn,
                                               const char *mac);

typedef char *
913
        (*virDrvInterfaceGetXMLDesc)    (virInterfacePtr iface,
D
Daniel Veillard 已提交
914 915 916 917 918 919 920
                                         unsigned int flags);

typedef virInterfacePtr
        (*virDrvInterfaceDefineXML)     (virConnectPtr conn,
                                         const char *xmlDesc,
                                         unsigned int flags);
typedef int
921
        (*virDrvInterfaceUndefine)      (virInterfacePtr iface);
D
Daniel Veillard 已提交
922
typedef int
923
        (*virDrvInterfaceCreate)        (virInterfacePtr iface,
D
Daniel Veillard 已提交
924 925
                                         unsigned int flags);
typedef int
926
        (*virDrvInterfaceDestroy)       (virInterfacePtr iface,
D
Daniel Veillard 已提交
927 928
                                         unsigned int flags);

929 930 931
typedef int
        (*virDrvInterfaceIsActive)(virInterfacePtr iface);

932 933 934 935 936 937 938 939 940
typedef int
        (*virDrvInterfaceChangeBegin)   (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeCommit)  (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeRollback)(virConnectPtr conn,
                                         unsigned int flags);
941

D
Daniel Veillard 已提交
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
typedef struct _virInterfaceDriver virInterfaceDriver;
typedef virInterfaceDriver *virInterfaceDriverPtr;

/**
 * _virInterfaceDriver:
 *
 * 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 _virInterfaceDriver {
    const char                      *name; /* the name of the driver */
    virDrvOpen                       open;
    virDrvClose                      close;
    virDrvNumOfInterfaces            numOfInterfaces;
    virDrvListInterfaces             listInterfaces;
961 962
    virDrvNumOfDefinedInterfaces     numOfDefinedInterfaces;
    virDrvListDefinedInterfaces      listDefinedInterfaces;
D
Daniel Veillard 已提交
963 964 965 966 967 968 969
    virDrvInterfaceLookupByName      interfaceLookupByName;
    virDrvInterfaceLookupByMACString interfaceLookupByMACString;
    virDrvInterfaceGetXMLDesc        interfaceGetXMLDesc;
    virDrvInterfaceDefineXML         interfaceDefineXML;
    virDrvInterfaceUndefine          interfaceUndefine;
    virDrvInterfaceCreate            interfaceCreate;
    virDrvInterfaceDestroy           interfaceDestroy;
970
    virDrvInterfaceIsActive          interfaceIsActive;
971 972 973
    virDrvInterfaceChangeBegin       interfaceChangeBegin;
    virDrvInterfaceChangeCommit      interfaceChangeCommit;
    virDrvInterfaceChangeRollback    interfaceChangeRollback;
D
Daniel Veillard 已提交
974 975
};

976 977 978 979 980 981 982 983 984 985 986 987 988

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);
989 990 991 992 993
typedef char *
    (*virDrvConnectFindStoragePoolSources)   (virConnectPtr conn,
                                              const char *type,
                                              const char *srcSpec,
                                              unsigned int flags);
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
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);

1065 1066 1067 1068
typedef int
    (*virDrvStorageVolWipe)                  (virStorageVolPtr vol,
                                              unsigned int flags);

1069 1070 1071 1072 1073 1074 1075 1076 1077
typedef int
    (*virDrvStorageVolGetInfo)               (virStorageVolPtr vol,
                                              virStorageVolInfoPtr info);
typedef char *
    (*virDrvStorageVolGetXMLDesc)            (virStorageVolPtr pool,
                                              unsigned int flags);
typedef char *
    (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);

1078 1079 1080 1081 1082
typedef virStorageVolPtr
    (*virDrvStorageVolCreateXMLFrom)         (virStoragePoolPtr pool,
                                              const char *xmldesc,
                                              virStorageVolPtr clone,
                                              unsigned int flags);
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094
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);
1095

1096 1097 1098 1099 1100 1101
typedef int
        (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
typedef int
        (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);


1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124

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;
1125
    virDrvConnectFindStoragePoolSources findPoolSources;
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
    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;
1148
    virDrvStorageVolCreateXMLFrom volCreateXMLFrom;
1149 1150
    virDrvStorageVolDownload volDownload;
    virDrvStorageVolUpload volUpload;
1151
    virDrvStorageVolDelete volDelete;
1152
    virDrvStorageVolWipe volWipe;
1153 1154 1155
    virDrvStorageVolGetInfo volGetInfo;
    virDrvStorageVolGetXMLDesc volGetXMLDesc;
    virDrvStorageVolGetPath volGetPath;
1156 1157
    virDrvStoragePoolIsActive   poolIsActive;
    virDrvStoragePoolIsPersistent   poolIsPersistent;
1158 1159
};

1160
# ifdef WITH_LIBVIRTD
1161
typedef int (*virDrvStateInitialize) (int privileged);
1162 1163 1164 1165 1166 1167 1168 1169
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);

typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;

struct _virStateDriver {
1170
    const char *name;
1171 1172 1173 1174 1175
    virDrvStateInitialize  initialize;
    virDrvStateCleanup     cleanup;
    virDrvStateReload      reload;
    virDrvStateActive      active;
};
1176
# endif
1177

1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194

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

1195 1196
typedef char * (*virDevMonDeviceGetXMLDesc)(virNodeDevicePtr dev,
                                            unsigned int flags);
1197 1198 1199 1200 1201 1202 1203 1204 1205

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

typedef int (*virDevMonDeviceNumOfCaps)(virNodeDevicePtr dev);

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

1206 1207 1208 1209 1210
typedef virNodeDevicePtr (*virDrvNodeDeviceCreateXML)(virConnectPtr conn,
                                                      const char *xmlDesc,
                                                      unsigned int flags);
typedef int (*virDrvNodeDeviceDestroy)(virNodeDevicePtr dev);

1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224
/**
 * _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;
1225
    virDevMonDeviceGetXMLDesc deviceGetXMLDesc;
1226 1227 1228
    virDevMonDeviceGetParent deviceGetParent;
    virDevMonDeviceNumOfCaps deviceNumOfCaps;
    virDevMonDeviceListCaps deviceListCaps;
1229 1230
    virDrvNodeDeviceCreateXML deviceCreateXML;
    virDrvNodeDeviceDestroy deviceDestroy;
1231 1232
};

1233 1234
enum {
    /* This getValue call is inside libvirt, override the "private" flag.
E
Eric Blake 已提交
1235
       This flag cannot be set by outside callers. */
1236
    VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 0,
1237 1238
};

1239
typedef virSecretPtr
1240 1241
    (*virDrvSecretLookupByUUID)        (virConnectPtr conn,
                                        const unsigned char *uuid);
1242 1243 1244 1245
typedef virSecretPtr
    (*virDrvSecretLookupByUsage)       (virConnectPtr conn,
                                        int usageType,
                                        const char *usageID);
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
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,
1261 1262
                                              unsigned int flags,
                                              unsigned int internalFlags);
1263 1264 1265
typedef int
    (*virDrvSecretUndefine)                  (virSecretPtr secret);
typedef int
1266
    (*virDrvNumOfSecrets)              (virConnectPtr conn);
1267
typedef int
1268
    (*virDrvListSecrets)               (virConnectPtr conn,
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
                                              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;

1290 1291
    virDrvNumOfSecrets numOfSecrets;
    virDrvListSecrets listSecrets;
1292
    virDrvSecretLookupByUUID lookupByUUID;
1293
    virDrvSecretLookupByUsage lookupByUsage;
1294 1295 1296 1297 1298 1299 1300
    virDrvSecretDefineXML defineXML;
    virDrvSecretGetXMLDesc getXMLDesc;
    virDrvSecretSetValue setValue;
    virDrvSecretGetValue getValue;
    virDrvSecretUndefine undefine;
};

1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335

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 已提交
1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
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 已提交
1350
                                               const char *xmlDesc);
S
Stefan Berger 已提交
1351
typedef int
1352
    (*virDrvNWFilterUndefine)                 (virNWFilterPtr nwfilter);
S
Stefan Berger 已提交
1353 1354

typedef char *
1355
    (*virDrvNWFilterGetXMLDesc)              (virNWFilterPtr nwfilter,
1356
                                              unsigned int flags);
S
Stefan Berger 已提交
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386


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


1387 1388 1389 1390 1391 1392
/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
1393
int virRegisterNetworkDriver(virNetworkDriverPtr);
D
Daniel Veillard 已提交
1394
int virRegisterInterfaceDriver(virInterfaceDriverPtr);
1395
int virRegisterStorageDriver(virStorageDriverPtr);
1396
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
1397
int virRegisterSecretDriver(virSecretDriverPtr);
S
Stefan Berger 已提交
1398
int virRegisterNWFilterDriver(virNWFilterDriverPtr);
1399
# ifdef WITH_LIBVIRTD
1400
int virRegisterStateDriver(virStateDriverPtr);
1401
# endif
1402
void *virDriverLoadModule(const char *name);
1403 1404

#endif /* __VIR_DRIVER_H__ */