driver.h 59.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);
X
Xu He Jie 已提交
126 127 128
typedef int
        (*virDrvDomainReset)        (virDomainPtr domain,
                                         unsigned int flags);
129
typedef int
130
        (*virDrvDomainDestroy)		(virDomainPtr domain);
131 132 133
typedef int
        (*virDrvDomainDestroyFlags) (virDomainPtr domain,
                                         unsigned int flags);
134
typedef char *
135
        (*virDrvDomainGetOSType)	(virDomainPtr domain);
136
typedef unsigned long
137
        (*virDrvDomainGetMaxMemory)	(virDomainPtr domain);
138
typedef int
139 140
        (*virDrvDomainSetMaxMemory)	(virDomainPtr domain,
                                         unsigned long memory);
141
typedef int
142 143
        (*virDrvDomainSetMemory)	(virDomainPtr domain,
                                         unsigned long memory);
144 145 146 147
typedef int
        (*virDrvDomainSetMemoryFlags)	(virDomainPtr domain,
                                         unsigned long memory,
                                         unsigned int flags);
148 149 150
typedef int
        (*virDrvDomainSetMemoryParameters)
                                        (virDomainPtr domain,
151
                                         virTypedParameterPtr params,
152 153 154 155 156
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetMemoryParameters)
                                        (virDomainPtr domain,
157
                                         virTypedParameterPtr params,
158 159
                                         int *nparams,
                                         unsigned int flags);
160 161 162
typedef int
        (*virDrvDomainSetBlkioParameters)
                                        (virDomainPtr domain,
163
                                         virTypedParameterPtr params,
164 165 166 167 168
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetBlkioParameters)
                                        (virDomainPtr domain,
169
                                         virTypedParameterPtr params,
170 171
                                         int *nparams,
                                         unsigned int flags);
172
typedef int
173 174
        (*virDrvDomainGetInfo)		(virDomainPtr domain,
                                         virDomainInfoPtr info);
175 176 177 178 179
typedef int
        (*virDrvDomainGetState)         (virDomainPtr domain,
                                         int *state,
                                         int *reason,
                                         unsigned int flags);
180 181 182 183
typedef int
        (*virDrvDomainGetControlInfo)   (virDomainPtr domain,
                                         virDomainControlInfoPtr info,
                                         unsigned int flags);
184
typedef int
185 186
        (*virDrvDomainSave)		(virDomainPtr domain,
                                         const char *to);
187 188 189 190 191
typedef int
        (*virDrvDomainSaveFlags)	(virDomainPtr domain,
                                         const char *to,
                                         const char *dxml,
                                         unsigned int flags);
192
typedef int
193 194
        (*virDrvDomainRestore)		(virConnectPtr conn,
                                         const char *from);
195 196 197 198 199
typedef int
        (*virDrvDomainRestoreFlags)	(virConnectPtr conn,
                                         const char *from,
                                         const char *dxml,
                                         unsigned int flags);
200 201 202 203 204 205 206 207 208
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 已提交
209
typedef int
210 211
        (*virDrvDomainCoreDump)		(virDomainPtr domain,
                                         const char *to,
212
                                         unsigned int flags);
213 214 215 216 217
typedef char *
        (*virDrvDomainScreenshot)   (virDomainPtr domain,
                                         virStreamPtr stream,
                                         unsigned int screen,
                                         unsigned int flags);
218
typedef char *
219
        (*virDrvDomainGetXMLDesc)		(virDomainPtr dom,
220
                                                 unsigned int flags);
221 222 223 224 225 226 227 228 229 230
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);
231
typedef int
232 233 234
        (*virDrvListDefinedDomains)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
235
typedef int
236
        (*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
237
typedef int
238
        (*virDrvDomainCreate)		(virDomainPtr dom);
239 240 241
typedef int
        (*virDrvDomainCreateWithFlags)	(virDomainPtr dom,
                                         unsigned int flags);
242
typedef virDomainPtr
243 244
        (*virDrvDomainDefineXML)	(virConnectPtr conn,
                                         const char *xml);
245
typedef int
246
        (*virDrvDomainUndefine)		(virDomainPtr dom);
O
Osier Yang 已提交
247 248 249
typedef int
        (*virDrvDomainUndefineFlags)	(virDomainPtr dom,
                                         unsigned int flags);
250
typedef int
251 252
        (*virDrvDomainSetVcpus)		(virDomainPtr domain,
                                         unsigned int nvcpus);
E
Eric Blake 已提交
253 254 255 256 257 258 259
typedef int
        (*virDrvDomainSetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int nvcpus,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int flags);
260
typedef int
261 262 263 264
        (*virDrvDomainPinVcpu)		(virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen);
265 266 267 268 269 270
typedef int
        (*virDrvDomainPinVcpuFlags)     (virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen,
                                         unsigned int flags);
271
typedef int
E
Eric Blake 已提交
272
        (*virDrvDomainGetVcpuPinInfo)   (virDomainPtr domain,
273 274 275 276 277
                                         int ncpumaps,
                                         unsigned char *cpumaps,
                                         int maplen,
                                         unsigned int flags);

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

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

318
typedef char *
319 320
        (*virDrvDomainGetSchedulerType)	(virDomainPtr domain,
                                         int *nparams);
321

322
typedef int
323 324
        (*virDrvDomainGetSchedulerParameters)
                                        (virDomainPtr domain,
325
                                         virTypedParameterPtr params,
326
                                         int *nparams);
327

328 329 330 331 332 333 334
typedef int
        (*virDrvDomainGetSchedulerParametersFlags)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         unsigned int flags);

335
typedef int
336 337
        (*virDrvDomainSetSchedulerParameters)
                                        (virDomainPtr domain,
338
                                         virTypedParameterPtr params,
339
                                         int nparams);
340

341 342 343
typedef int
        (*virDrvDomainSetSchedulerParametersFlags)
                                        (virDomainPtr domain,
344
                                         virTypedParameterPtr params,
345 346 347
                                         int nparams,
                                         unsigned int flags);

348 349 350 351 352
typedef int
    (*virDrvDomainBlockStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainBlockStats *stats);
353 354 355 356 357 358 359
typedef int
    (*virDrvDomainBlockStatsFlags)
                    (virDomainPtr domain,
                     const char *path,
                     virTypedParameterPtr params,
                     int *nparams,
                     unsigned int flags);
360 361 362 363 364 365
typedef int
    (*virDrvDomainInterfaceStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainInterfaceStats *stats);

366 367 368 369
typedef int
    (*virDrvDomainMemoryStats)
                    (virDomainPtr domain,
                     struct _virDomainMemoryStat *stats,
370 371
                     unsigned int nr_stats,
                     unsigned int flags);
372

R
Richard W.M. Jones 已提交
373 374 375 376 377
typedef int
    (*virDrvDomainBlockPeek)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long offset, size_t size,
378 379
                     void *buffer,
                     unsigned int flags);
O
Osier Yang 已提交
380 381 382 383 384 385
typedef int
    (*virDrvDomainBlockResize)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long size,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
386 387 388 389 390 391
typedef int
    (*virDrvDomainMemoryPeek)
                    (virDomainPtr domain,
                     unsigned long long start, size_t size,
                     void *buffer,
                     unsigned int flags);
392 393 394 395 396 397
typedef int
    (*virDrvDomainGetBlockInfo)
                    (virDomainPtr domain,
                     const char *path,
                     virDomainBlockInfoPtr info,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
398

399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
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);

429 430 431
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;

432 433 434 435
typedef int
    (*virDrvNodeGetCPUStats)
                    (virConnectPtr conn,
                     int cpuNum,
436
                     virNodeCPUStatsPtr params,
437 438 439
                     int *nparams,
                     unsigned int flags);

440 441 442 443
typedef int
    (*virDrvNodeGetMemoryStats)
                    (virConnectPtr conn,
                     int cellNum,
444
                     virNodeMemoryStatsPtr params,
445 446 447
                     int *nparams,
                     unsigned int flags);

448 449 450 451 452 453 454
typedef int
    (*virDrvNodeGetCellsFreeMemory)
                    (virConnectPtr conn,
                     unsigned long long *freeMems,
                     int startCell,
                     int maxCells);

455 456
typedef unsigned long long
    (*virDrvNodeGetFreeMemory)
457
                    (virConnectPtr conn);
458

459 460 461
typedef int
    (*virDrvDomainEventRegister)
                    (virConnectPtr conn,
462
                     virConnectDomainEventCallback cb,
463 464
                     void *opaque,
                     virFreeCallback freecb);
465 466 467 468

typedef int
    (*virDrvDomainEventDeregister)
                    (virConnectPtr conn,
469
                     virConnectDomainEventCallback cb);
470

D
Daniel Veillard 已提交
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
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);

493 494 495 496 497 498 499 500 501 502
typedef int
    (*virDrvNodeDeviceDettach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReAttach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReset)
                    (virNodeDevicePtr dev);

C
Chris Lalancette 已提交
503 504
typedef int
    (*virDrvDomainMigratePrepareTunnel)
505
                    (virConnectPtr dconn,
C
Chris Lalancette 已提交
506 507 508 509 510 511
                     virStreamPtr st,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);

512 513 514 515
typedef int
    (*virDrvConnectIsEncrypted)(virConnectPtr conn);
typedef int
    (*virDrvConnectIsSecure)(virConnectPtr conn);
J
Jiri Denemark 已提交
516 517
typedef int
    (*virDrvConnectIsAlive)(virConnectPtr conn);
518 519 520 521
typedef int
    (*virDrvDomainIsActive)(virDomainPtr dom);
typedef int
    (*virDrvDomainIsPersistent)(virDomainPtr dom);
O
Osier Yang 已提交
522 523
typedef int
    (*virDrvDomainIsUpdated)(virDomainPtr dom);
524

J
Jiri Denemark 已提交
525
typedef int
526
    (*virDrvCompareCPU)(virConnectPtr conn,
J
Jiri Denemark 已提交
527 528
                        const char *cpu,
                        unsigned int flags);
529
typedef char *
530
    (*virDrvBaselineCPU)(virConnectPtr conn,
531 532 533
                         const char **xmlCPUs,
                         unsigned int ncpus,
                         unsigned int flags);
J
Jiri Denemark 已提交
534

535 536 537 538
typedef int
    (*virDrvDomainGetJobInfo)(virDomainPtr domain,
                              virDomainJobInfoPtr info);

539 540 541
typedef int
    (*virDrvDomainAbortJob)(virDomainPtr domain);

542 543 544 545
typedef int
    (*virDrvDomainMigrateSetMaxDowntime)(virDomainPtr domain,
                                         unsigned long long downtime,
                                         unsigned int flags);
546 547 548 549
typedef int
    (*virDrvDomainMigrateSetMaxSpeed)(virDomainPtr domain,
                                      unsigned long bandwidth,
                                      unsigned int flags);
550

551 552 553 554 555
typedef int
    (*virDrvDomainMigrateGetMaxSpeed)(virDomainPtr domain,
                                      unsigned long *bandwidth,
                                      unsigned int flags);

556 557 558 559 560 561 562 563 564 565 566 567
typedef int
    (*virDrvDomainEventRegisterAny)(virConnectPtr conn,
                                    virDomainPtr dom,
                                    int eventID,
                                    virConnectDomainEventGenericCallback cb,
                                    void *opaque,
                                    virFreeCallback freecb);

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

568 569 570 571 572 573 574 575 576
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 已提交
577 578 579 580 581 582
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain,
                                     const char *xmlDesc,
                                     unsigned int flags);

typedef char *
583 584
    (*virDrvDomainSnapshotGetXMLDesc)(virDomainSnapshotPtr snapshot,
                                      unsigned int flags);
C
Chris Lalancette 已提交
585 586 587 588 589 590 591 592 593

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

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

594 595 596 597 598 599 600 601 602 603
typedef int
    (*virDrvDomainSnapshotNumChildren)(virDomainSnapshotPtr snapshot,
                                       unsigned int flags);

typedef int
    (*virDrvDomainSnapshotListChildrenNames)(virDomainSnapshotPtr snapshot,
                                             char **names,
                                             int nameslen,
                                             unsigned int flags);

C
Chris Lalancette 已提交
604 605 606 607 608 609 610 611
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotLookupByName)(virDomainPtr domain,
                                        const char *name,
                                        unsigned int flags);

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

612 613 614 615
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotGetParent)(virDomainSnapshotPtr snapshot,
                                     unsigned int flags);

C
Chris Lalancette 已提交
616 617 618 619 620 621 622 623 624 625 626 627
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 已提交
628
typedef int
629
    (*virDrvDomainQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
C
Chris Lalancette 已提交
630 631
                                      char **result, unsigned int flags);

632 633 634 635 636
typedef virDomainPtr
    (*virDrvDomainQemuAttach)(virConnectPtr conn,
                              unsigned int pid,
                              unsigned int flags);

637 638
typedef int
    (*virDrvDomainOpenConsole)(virDomainPtr dom,
639
                               const char *dev_name,
640 641
                               virStreamPtr st,
                               unsigned int flags);
642 643 644 645 646
typedef int
    (*virDrvDomainOpenGraphics)(virDomainPtr dom,
                                unsigned int idx,
                                int fd,
                                unsigned int flags);
C
Chris Lalancette 已提交
647

648 649 650
typedef int
    (*virDrvDomainInjectNMI)(virDomainPtr dom, unsigned int flags);

651 652 653 654
typedef int
    (*virDrvDomainSendKey)(virDomainPtr dom, unsigned int codeset,
                           unsigned int holdtime,
                           unsigned int *keycodes,
655
                           int nkeycodes,
656 657
                           unsigned int flags);

658 659 660
typedef char *
    (*virDrvDomainMigrateBegin3)
                    (virDomainPtr domain,
661
                     const char *xmlin,
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698
                     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,
699
                     const char *xmlin,
700 701 702 703
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
704
                     const char *dconnuri,
705 706 707 708 709
                     const char *uri,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

710
typedef virDomainPtr
711 712 713 714 715 716 717
    (*virDrvDomainMigrateFinish3)
                    (virConnectPtr dconn,
                     const char *dname,
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
718
                     const char *dconnuri,
719 720
                     const char *uri,
                     unsigned long flags,
721
                     int cancelled);
722 723 724 725 726 727 728 729

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

731 732 733 734 735
typedef int
    (*virDrvNodeSuspendForDuration)(virConnectPtr conn, unsigned int target,
                                     unsigned long long duration,
                                     unsigned int flags);

736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754

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

J
Jiri Denemark 已提交
755 756 757 758
typedef int
    (*virDrvSetKeepAlive)(virConnectPtr conn,
                          int interval,
                          unsigned int count);
759

760 761 762 763 764 765 766 767 768 769 770 771 772
typedef int
    (*virDrvDomainSetBlockIoTune)(virDomainPtr dom,
                                  const char *disk,
                                  virTypedParameterPtr params,
                                  int nparams,
                                  unsigned int flags);
typedef int
    (*virDrvDomainGetBlockIoTune)(virDomainPtr dom,
                                  const char *disk,
                                  virTypedParameterPtr params,
                                  int *nparams,
                                  unsigned int flags);

773 774 775 776 777
/**
 * _virDriver:
 *
 * Structure associated to a virtualization driver, defining the various
 * entry points for it.
778 779 780 781 782 783
 *
 * All drivers must support the following fields/methods:
 *  - no
 *  - name
 *  - open
 *  - close
784 785
 */
struct _virDriver {
786
    int        no;	/* the number virDrvNo */
787 788 789
    const char * name;	/* the name of the driver */
    virDrvOpen			open;
    virDrvClose			close;
D
Daniel P. Berrange 已提交
790
    virDrvDrvSupportsFeature   supports_feature;
791 792
    virDrvGetType			type;
    virDrvGetVersion		version;
793
    virDrvGetLibVersion		libvirtVersion;
794
    virDrvGetHostname       getHostname;
E
Eric Blake 已提交
795
    virDrvGetSysinfo            getSysinfo;
796 797 798 799 800
    virDrvGetMaxVcpus		getMaxVcpus;
    virDrvNodeGetInfo		nodeGetInfo;
    virDrvGetCapabilities		getCapabilities;
    virDrvListDomains		listDomains;
    virDrvNumOfDomains		numOfDomains;
801
    virDrvDomainCreateXML		domainCreateXML;
802 803 804 805 806 807 808
    virDrvDomainLookupByID		domainLookupByID;
    virDrvDomainLookupByUUID	domainLookupByUUID;
    virDrvDomainLookupByName	domainLookupByName;
    virDrvDomainSuspend		domainSuspend;
    virDrvDomainResume		domainResume;
    virDrvDomainShutdown		domainShutdown;
    virDrvDomainReboot		domainReboot;
X
Xu He Jie 已提交
809
    virDrvDomainReset       domainReset;
810
    virDrvDomainDestroy		domainDestroy;
811
    virDrvDomainDestroyFlags    domainDestroyFlags;
812 813 814 815
    virDrvDomainGetOSType		domainGetOSType;
    virDrvDomainGetMaxMemory	domainGetMaxMemory;
    virDrvDomainSetMaxMemory	domainSetMaxMemory;
    virDrvDomainSetMemory		domainSetMemory;
816
    virDrvDomainSetMemoryFlags  domainSetMemoryFlags;
817 818 819 820
    virDrvDomainSetMemoryParameters domainSetMemoryParameters;
    virDrvDomainGetMemoryParameters domainGetMemoryParameters;
    virDrvDomainSetBlkioParameters domainSetBlkioParameters;
    virDrvDomainGetBlkioParameters domainGetBlkioParameters;
821
    virDrvDomainGetInfo		domainGetInfo;
822
    virDrvDomainGetState	domainGetState;
823
    virDrvDomainGetControlInfo  domainGetControlInfo;
824
    virDrvDomainSave		domainSave;
825
    virDrvDomainSaveFlags	domainSaveFlags;
826
    virDrvDomainRestore		domainRestore;
827
    virDrvDomainRestoreFlags	domainRestoreFlags;
828 829
    virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
    virDrvDomainSaveImageDefineXML domainSaveImageDefineXML;
830 831
    virDrvDomainCoreDump        domainCoreDump;
    virDrvDomainScreenshot      domainScreenshot;
832
    virDrvDomainSetVcpus		domainSetVcpus;
E
Eric Blake 已提交
833 834
    virDrvDomainSetVcpusFlags		domainSetVcpusFlags;
    virDrvDomainGetVcpusFlags		domainGetVcpusFlags;
835
    virDrvDomainPinVcpu		domainPinVcpu;
836
    virDrvDomainPinVcpuFlags    domainPinVcpuFlags;
E
Eric Blake 已提交
837
    virDrvDomainGetVcpuPinInfo  domainGetVcpuPinInfo;
838 839
    virDrvDomainGetVcpus		domainGetVcpus;
    virDrvDomainGetMaxVcpus		domainGetMaxVcpus;
840 841
    virDrvDomainGetSecurityLabel     domainGetSecurityLabel;
    virDrvNodeGetSecurityModel  nodeGetSecurityModel;
842
    virDrvDomainGetXMLDesc		domainGetXMLDesc;
843 844
    virDrvConnectDomainXMLFromNative domainXMLFromNative;
    virDrvConnectDomainXMLToNative domainXMLToNative;
845 846 847
    virDrvListDefinedDomains	listDefinedDomains;
    virDrvNumOfDefinedDomains	numOfDefinedDomains;
    virDrvDomainCreate		domainCreate;
848
    virDrvDomainCreateWithFlags	domainCreateWithFlags;
849 850
    virDrvDomainDefineXML           domainDefineXML;
    virDrvDomainUndefine            domainUndefine;
O
Osier Yang 已提交
851
    virDrvDomainUndefineFlags       domainUndefineFlags;
852
    virDrvDomainAttachDevice	domainAttachDevice;
J
Jim Fehlig 已提交
853
    virDrvDomainAttachDeviceFlags	domainAttachDeviceFlags;
854
    virDrvDomainDetachDevice	domainDetachDevice;
J
Jim Fehlig 已提交
855
    virDrvDomainDetachDeviceFlags	domainDetachDeviceFlags;
856
    virDrvDomainUpdateDeviceFlags	domainUpdateDeviceFlags;
857 858 859 860
    virDrvDomainGetAutostart	domainGetAutostart;
    virDrvDomainSetAutostart	domainSetAutostart;
    virDrvDomainGetSchedulerType	domainGetSchedulerType;
    virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
861
    virDrvDomainGetSchedulerParametersFlags domainGetSchedulerParametersFlags;
862
    virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
863
    virDrvDomainSetSchedulerParametersFlags domainSetSchedulerParametersFlags;
864 865 866
    virDrvDomainMigratePrepare	domainMigratePrepare;
    virDrvDomainMigratePerform	domainMigratePerform;
    virDrvDomainMigrateFinish	domainMigrateFinish;
O
Osier Yang 已提交
867
    virDrvDomainBlockResize     domainBlockResize;
868
    virDrvDomainBlockStats      domainBlockStats;
869
    virDrvDomainBlockStatsFlags domainBlockStatsFlags;
870
    virDrvDomainInterfaceStats  domainInterfaceStats;
871
    virDrvDomainMemoryStats     domainMemoryStats;
R
Richard W.M. Jones 已提交
872
    virDrvDomainBlockPeek	domainBlockPeek;
R
Richard W.M. Jones 已提交
873
    virDrvDomainMemoryPeek      domainMemoryPeek;
874
    virDrvDomainGetBlockInfo    domainGetBlockInfo;
875
    virDrvNodeGetCPUStats       nodeGetCPUStats;
876
    virDrvNodeGetMemoryStats	nodeGetMemoryStats;
877
    virDrvNodeGetCellsFreeMemory	nodeGetCellsFreeMemory;
878
    virDrvNodeGetFreeMemory		nodeGetFreeMemory;
879 880
    virDrvDomainEventRegister         domainEventRegister;
    virDrvDomainEventDeregister       domainEventDeregister;
D
Daniel Veillard 已提交
881 882
    virDrvDomainMigratePrepare2	domainMigratePrepare2;
    virDrvDomainMigrateFinish2	domainMigrateFinish2;
883 884 885
    virDrvNodeDeviceDettach     nodeDeviceDettach;
    virDrvNodeDeviceReAttach    nodeDeviceReAttach;
    virDrvNodeDeviceReset       nodeDeviceReset;
C
Chris Lalancette 已提交
886
    virDrvDomainMigratePrepareTunnel domainMigratePrepareTunnel;
887 888 889 890
    virDrvConnectIsEncrypted   isEncrypted;
    virDrvConnectIsSecure      isSecure;
    virDrvDomainIsActive       domainIsActive;
    virDrvDomainIsPersistent   domainIsPersistent;
O
Osier Yang 已提交
891
    virDrvDomainIsUpdated      domainIsUpdated;
892 893
    virDrvCompareCPU            cpuCompare;
    virDrvBaselineCPU           cpuBaseline;
894
    virDrvDomainGetJobInfo     domainGetJobInfo;
895
    virDrvDomainAbortJob     domainAbortJob;
896
    virDrvDomainMigrateSetMaxDowntime  domainMigrateSetMaxDowntime;
897
    virDrvDomainMigrateGetMaxSpeed  domainMigrateGetMaxSpeed;
898
    virDrvDomainMigrateSetMaxSpeed  domainMigrateSetMaxSpeed;
899 900
    virDrvDomainEventRegisterAny domainEventRegisterAny;
    virDrvDomainEventDeregisterAny domainEventDeregisterAny;
901 902 903
    virDrvDomainManagedSave domainManagedSave;
    virDrvDomainHasManagedSaveImage domainHasManagedSaveImage;
    virDrvDomainManagedSaveRemove domainManagedSaveRemove;
C
Chris Lalancette 已提交
904
    virDrvDomainSnapshotCreateXML domainSnapshotCreateXML;
905
    virDrvDomainSnapshotGetXMLDesc domainSnapshotGetXMLDesc;
C
Chris Lalancette 已提交
906 907
    virDrvDomainSnapshotNum domainSnapshotNum;
    virDrvDomainSnapshotListNames domainSnapshotListNames;
908 909
    virDrvDomainSnapshotNumChildren domainSnapshotNumChildren;
    virDrvDomainSnapshotListChildrenNames domainSnapshotListChildrenNames;
C
Chris Lalancette 已提交
910 911
    virDrvDomainSnapshotLookupByName domainSnapshotLookupByName;
    virDrvDomainHasCurrentSnapshot domainHasCurrentSnapshot;
912
    virDrvDomainSnapshotGetParent domainSnapshotGetParent;
C
Chris Lalancette 已提交
913 914 915
    virDrvDomainSnapshotCurrent domainSnapshotCurrent;
    virDrvDomainRevertToSnapshot domainRevertToSnapshot;
    virDrvDomainSnapshotDelete domainSnapshotDelete;
916
    virDrvDomainQemuMonitorCommand qemuDomainMonitorCommand;
917
    virDrvDomainQemuAttach qemuDomainAttach;
918
    virDrvDomainOpenConsole domainOpenConsole;
919
    virDrvDomainOpenGraphics domainOpenGraphics;
920
    virDrvDomainInjectNMI domainInjectNMI;
921 922 923 924 925 926
    virDrvDomainMigrateBegin3	domainMigrateBegin3;
    virDrvDomainMigratePrepare3	domainMigratePrepare3;
    virDrvDomainMigratePrepareTunnel3	domainMigratePrepareTunnel3;
    virDrvDomainMigratePerform3	domainMigratePerform3;
    virDrvDomainMigrateFinish3	domainMigrateFinish3;
    virDrvDomainMigrateConfirm3	domainMigrateConfirm3;
927
    virDrvDomainSendKey domainSendKey;
928 929 930 931
    virDrvDomainBlockJobAbort domainBlockJobAbort;
    virDrvDomainGetBlockJobInfo domainGetBlockJobInfo;
    virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
    virDrvDomainBlockPull domainBlockPull;
J
Jiri Denemark 已提交
932
    virDrvSetKeepAlive setKeepAlive;
J
Jiri Denemark 已提交
933
    virDrvConnectIsAlive isAlive;
934
    virDrvNodeSuspendForDuration nodeSuspendForDuration;
935 936
    virDrvDomainSetBlockIoTune domainSetBlockIoTune;
    virDrvDomainGetBlockIoTune domainGetBlockIoTune;
937 938
};

939
typedef int
940
        (*virDrvNumOfNetworks)		(virConnectPtr conn);
941
typedef int
942 943 944
        (*virDrvListNetworks)		(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
945
typedef int
946
        (*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
947
typedef int
948 949 950
        (*virDrvListDefinedNetworks)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
951
typedef virNetworkPtr
952 953
        (*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
954
typedef virNetworkPtr
955 956
        (*virDrvNetworkLookupByName)	(virConnectPtr conn,
                                         const char *name);
957
typedef virNetworkPtr
958 959
        (*virDrvNetworkCreateXML)	(virConnectPtr conn,
                                         const char *xmlDesc);
960
typedef virNetworkPtr
961 962
        (*virDrvNetworkDefineXML)	(virConnectPtr conn,
                                         const char *xml);
963
typedef int
964
        (*virDrvNetworkUndefine)	(virNetworkPtr network);
965
typedef int
966
        (*virDrvNetworkCreate)		(virNetworkPtr network);
967
typedef int
968
        (*virDrvNetworkDestroy)		(virNetworkPtr network);
969
typedef char *
970
        (*virDrvNetworkGetXMLDesc)		(virNetworkPtr network,
971
                                         unsigned int flags);
972
typedef char *
973
        (*virDrvNetworkGetBridgeName)	(virNetworkPtr network);
974
typedef int
975 976
        (*virDrvNetworkGetAutostart)	(virNetworkPtr network,
                                         int *autostart);
977
typedef int
978 979
        (*virDrvNetworkSetAutostart)	(virNetworkPtr network,
                                         int autostart);
980

981 982 983 984 985 986
typedef int
        (*virDrvNetworkIsActive)(virNetworkPtr net);
typedef int
        (*virDrvNetworkIsPersistent)(virNetworkPtr net);


987 988 989 990 991 992 993 994 995

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

/**
 * _virNetworkDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
996 997 998 999
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
1000 1001
 */
struct _virNetworkDriver {
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
        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;
1016
        virDrvNetworkGetXMLDesc		networkGetXMLDesc;
1017 1018 1019
        virDrvNetworkGetBridgeName	networkGetBridgeName;
        virDrvNetworkGetAutostart	networkGetAutostart;
        virDrvNetworkSetAutostart	networkSetAutostart;
1020 1021
        virDrvNetworkIsActive           networkIsActive;
        virDrvNetworkIsPersistent       networkIsPersistent;
1022 1023
};

D
Daniel Veillard 已提交
1024 1025 1026 1027 1028 1029 1030
/*-------*/
typedef int
        (*virDrvNumOfInterfaces)        (virConnectPtr conn);
typedef int
        (*virDrvListInterfaces)         (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
1031 1032 1033 1034 1035 1036
typedef int
        (*virDrvNumOfDefinedInterfaces) (virConnectPtr conn);
typedef int
        (*virDrvListDefinedInterfaces)  (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
D
Daniel Veillard 已提交
1037 1038 1039 1040 1041 1042 1043 1044
typedef virInterfacePtr
        (*virDrvInterfaceLookupByName)  (virConnectPtr conn,
                                         const char *name);
typedef virInterfacePtr
        (*virDrvInterfaceLookupByMACString)   (virConnectPtr conn,
                                               const char *mac);

typedef char *
1045
        (*virDrvInterfaceGetXMLDesc)    (virInterfacePtr iface,
D
Daniel Veillard 已提交
1046 1047 1048 1049 1050 1051 1052
                                         unsigned int flags);

typedef virInterfacePtr
        (*virDrvInterfaceDefineXML)     (virConnectPtr conn,
                                         const char *xmlDesc,
                                         unsigned int flags);
typedef int
1053
        (*virDrvInterfaceUndefine)      (virInterfacePtr iface);
D
Daniel Veillard 已提交
1054
typedef int
1055
        (*virDrvInterfaceCreate)        (virInterfacePtr iface,
D
Daniel Veillard 已提交
1056 1057
                                         unsigned int flags);
typedef int
1058
        (*virDrvInterfaceDestroy)       (virInterfacePtr iface,
D
Daniel Veillard 已提交
1059 1060
                                         unsigned int flags);

1061 1062 1063
typedef int
        (*virDrvInterfaceIsActive)(virInterfacePtr iface);

1064 1065 1066 1067 1068 1069 1070 1071 1072
typedef int
        (*virDrvInterfaceChangeBegin)   (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeCommit)  (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeRollback)(virConnectPtr conn,
                                         unsigned int flags);
1073

D
Daniel Veillard 已提交
1074 1075 1076 1077 1078 1079
typedef struct _virInterfaceDriver virInterfaceDriver;
typedef virInterfaceDriver *virInterfaceDriverPtr;

/**
 * _virInterfaceDriver:
 *
1080
 * Structure associated to a network interface driver, defining the various
D
Daniel Veillard 已提交
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
 * 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;
1093 1094
    virDrvNumOfDefinedInterfaces     numOfDefinedInterfaces;
    virDrvListDefinedInterfaces      listDefinedInterfaces;
D
Daniel Veillard 已提交
1095 1096 1097 1098 1099 1100 1101
    virDrvInterfaceLookupByName      interfaceLookupByName;
    virDrvInterfaceLookupByMACString interfaceLookupByMACString;
    virDrvInterfaceGetXMLDesc        interfaceGetXMLDesc;
    virDrvInterfaceDefineXML         interfaceDefineXML;
    virDrvInterfaceUndefine          interfaceUndefine;
    virDrvInterfaceCreate            interfaceCreate;
    virDrvInterfaceDestroy           interfaceDestroy;
1102
    virDrvInterfaceIsActive          interfaceIsActive;
1103 1104 1105
    virDrvInterfaceChangeBegin       interfaceChangeBegin;
    virDrvInterfaceChangeCommit      interfaceChangeCommit;
    virDrvInterfaceChangeRollback    interfaceChangeRollback;
D
Daniel Veillard 已提交
1106 1107
};

1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120

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);
1121 1122 1123 1124 1125
typedef char *
    (*virDrvConnectFindStoragePoolSources)   (virConnectPtr conn,
                                              const char *type,
                                              const char *srcSpec,
                                              unsigned int flags);
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196
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);

1197 1198 1199 1200
typedef int
    (*virDrvStorageVolWipe)                  (virStorageVolPtr vol,
                                              unsigned int flags);

1201 1202 1203 1204 1205 1206 1207 1208 1209
typedef int
    (*virDrvStorageVolGetInfo)               (virStorageVolPtr vol,
                                              virStorageVolInfoPtr info);
typedef char *
    (*virDrvStorageVolGetXMLDesc)            (virStorageVolPtr pool,
                                              unsigned int flags);
typedef char *
    (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);

1210 1211 1212 1213 1214
typedef virStorageVolPtr
    (*virDrvStorageVolCreateXMLFrom)         (virStoragePoolPtr pool,
                                              const char *xmldesc,
                                              virStorageVolPtr clone,
                                              unsigned int flags);
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
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);
1227

1228 1229 1230 1231 1232 1233
typedef int
        (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
typedef int
        (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);


1234 1235 1236 1237 1238 1239 1240

typedef struct _virStorageDriver virStorageDriver;
typedef virStorageDriver *virStorageDriverPtr;

/**
 * _virStorageDriver:
 *
1241
 * Structure associated to a storage driver, defining the various
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
 * 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;
1257
    virDrvConnectFindStoragePoolSources findPoolSources;
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279
    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;
1280
    virDrvStorageVolCreateXMLFrom volCreateXMLFrom;
1281 1282
    virDrvStorageVolDownload volDownload;
    virDrvStorageVolUpload volUpload;
1283
    virDrvStorageVolDelete volDelete;
1284
    virDrvStorageVolWipe volWipe;
1285 1286 1287
    virDrvStorageVolGetInfo volGetInfo;
    virDrvStorageVolGetXMLDesc volGetXMLDesc;
    virDrvStorageVolGetPath volGetPath;
1288 1289
    virDrvStoragePoolIsActive   poolIsActive;
    virDrvStoragePoolIsPersistent   poolIsPersistent;
1290 1291
};

1292
# ifdef WITH_LIBVIRTD
1293
typedef int (*virDrvStateInitialize) (int privileged);
1294 1295 1296 1297 1298 1299 1300 1301
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);

typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;

struct _virStateDriver {
1302
    const char *name;
1303 1304 1305 1306 1307
    virDrvStateInitialize  initialize;
    virDrvStateCleanup     cleanup;
    virDrvStateReload      reload;
    virDrvStateActive      active;
};
1308
# endif
1309

1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326

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

1327 1328
typedef char * (*virDevMonDeviceGetXMLDesc)(virNodeDevicePtr dev,
                                            unsigned int flags);
1329 1330 1331 1332 1333 1334 1335 1336 1337

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

typedef int (*virDevMonDeviceNumOfCaps)(virNodeDevicePtr dev);

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

1338 1339 1340 1341 1342
typedef virNodeDevicePtr (*virDrvNodeDeviceCreateXML)(virConnectPtr conn,
                                                      const char *xmlDesc,
                                                      unsigned int flags);
typedef int (*virDrvNodeDeviceDestroy)(virNodeDevicePtr dev);

1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
/**
 * _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;
1357
    virDevMonDeviceGetXMLDesc deviceGetXMLDesc;
1358 1359 1360
    virDevMonDeviceGetParent deviceGetParent;
    virDevMonDeviceNumOfCaps deviceNumOfCaps;
    virDevMonDeviceListCaps deviceListCaps;
1361 1362
    virDrvNodeDeviceCreateXML deviceCreateXML;
    virDrvNodeDeviceDestroy deviceDestroy;
1363 1364
};

1365 1366
enum {
    /* This getValue call is inside libvirt, override the "private" flag.
E
Eric Blake 已提交
1367
       This flag cannot be set by outside callers. */
1368
    VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 0,
1369 1370
};

1371
typedef virSecretPtr
1372 1373
    (*virDrvSecretLookupByUUID)        (virConnectPtr conn,
                                        const unsigned char *uuid);
1374 1375 1376 1377
typedef virSecretPtr
    (*virDrvSecretLookupByUsage)       (virConnectPtr conn,
                                        int usageType,
                                        const char *usageID);
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392
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,
1393 1394
                                              unsigned int flags,
                                              unsigned int internalFlags);
1395 1396 1397
typedef int
    (*virDrvSecretUndefine)                  (virSecretPtr secret);
typedef int
1398
    (*virDrvNumOfSecrets)              (virConnectPtr conn);
1399
typedef int
1400
    (*virDrvListSecrets)               (virConnectPtr conn,
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421
                                              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;

1422 1423
    virDrvNumOfSecrets numOfSecrets;
    virDrvListSecrets listSecrets;
1424
    virDrvSecretLookupByUUID lookupByUUID;
1425
    virDrvSecretLookupByUsage lookupByUsage;
1426 1427 1428 1429 1430 1431 1432
    virDrvSecretDefineXML defineXML;
    virDrvSecretGetXMLDesc getXMLDesc;
    virDrvSecretSetValue setValue;
    virDrvSecretGetValue getValue;
    virDrvSecretUndefine undefine;
};

1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467

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 已提交
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481
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 已提交
1482
                                               const char *xmlDesc);
S
Stefan Berger 已提交
1483
typedef int
1484
    (*virDrvNWFilterUndefine)                 (virNWFilterPtr nwfilter);
S
Stefan Berger 已提交
1485 1486

typedef char *
1487
    (*virDrvNWFilterGetXMLDesc)              (virNWFilterPtr nwfilter,
1488
                                              unsigned int flags);
S
Stefan Berger 已提交
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518


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


1519 1520 1521 1522 1523 1524
/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
1525
int virRegisterNetworkDriver(virNetworkDriverPtr);
D
Daniel Veillard 已提交
1526
int virRegisterInterfaceDriver(virInterfaceDriverPtr);
1527
int virRegisterStorageDriver(virStorageDriverPtr);
1528
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
1529
int virRegisterSecretDriver(virSecretDriverPtr);
S
Stefan Berger 已提交
1530
int virRegisterNWFilterDriver(virNWFilterDriverPtr);
1531
# ifdef WITH_LIBVIRTD
1532
int virRegisterStateDriver(virStateDriverPtr);
1533
# endif
1534
void *virDriverLoadModule(const char *name);
1535 1536

#endif /* __VIR_DRIVER_H__ */