You need to sign in or sign up before continuing.
driver.h 60.6 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 <unistd.h>
12
# include <libxml/uri.h>
13

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


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

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

68
typedef virDrvOpenStatus
69
        (*virDrvOpen)			(virConnectPtr conn,
70
                             virConnectAuthPtr auth,
71
                             unsigned int flags);
72
typedef int
73
        (*virDrvClose)			(virConnectPtr conn);
74
typedef int
D
Daniel P. Berrange 已提交
75
    (*virDrvDrvSupportsFeature) (virConnectPtr conn, int feature);
76
typedef const char *
77
        (*virDrvGetType)		(virConnectPtr conn);
78
typedef int
79 80
        (*virDrvGetVersion)		(virConnectPtr conn,
                                         unsigned long *hvVer);
81 82 83
typedef int
        (*virDrvGetLibVersion)      (virConnectPtr conn,
                                     unsigned long *libVer);
84 85 86 87
typedef char *
    (*virDrvGetHostname)    (virConnectPtr conn);
typedef char *
    (*virDrvGetURI)         (virConnectPtr conn);
E
Eric Blake 已提交
88 89 90
typedef char *
    (*virDrvGetSysinfo)     (virConnectPtr conn,
                             unsigned int flags);
91
typedef int
92 93
        (*virDrvGetMaxVcpus)		(virConnectPtr conn,
                                         const char *type);
94
typedef int
95 96
        (*virDrvNodeGetInfo)		(virConnectPtr conn,
                                         virNodeInfoPtr info);
97
typedef char *
98
        (*virDrvGetCapabilities) (virConnectPtr conn);
99
typedef int
100 101 102
        (*virDrvListDomains)		(virConnectPtr conn,
                                         int *ids,
                                         int maxids);
103
typedef int
104
        (*virDrvNumOfDomains)		(virConnectPtr conn);
105
typedef virDomainPtr
106
        (*virDrvDomainCreateXML)	(virConnectPtr conn,
107 108
                                         const char *xmlDesc,
                                         unsigned int flags);
109
typedef virDomainPtr
110 111
        (*virDrvDomainLookupByID)	(virConnectPtr conn,
                                         int id);
112
typedef virDomainPtr
113 114
        (*virDrvDomainLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
115
typedef virDomainPtr
116 117
        (*virDrvDomainLookupByName)	(virConnectPtr conn,
                                         const char *name);
118
typedef int
119
        (*virDrvDomainSuspend)		(virDomainPtr domain);
120
typedef int
121
        (*virDrvDomainResume)		(virDomainPtr domain);
122
typedef int
123
        (*virDrvDomainShutdown)		(virDomainPtr domain);
124
typedef int
125 126
        (*virDrvDomainReboot)		(virDomainPtr domain,
                                         unsigned int flags);
X
Xu He Jie 已提交
127 128 129
typedef int
        (*virDrvDomainReset)        (virDomainPtr domain,
                                         unsigned int flags);
130
typedef int
131
        (*virDrvDomainDestroy)		(virDomainPtr domain);
132 133 134
typedef int
        (*virDrvDomainDestroyFlags) (virDomainPtr domain,
                                         unsigned int flags);
135
typedef char *
136
        (*virDrvDomainGetOSType)	(virDomainPtr domain);
137
typedef unsigned long
138
        (*virDrvDomainGetMaxMemory)	(virDomainPtr domain);
139
typedef int
140 141
        (*virDrvDomainSetMaxMemory)	(virDomainPtr domain,
                                         unsigned long memory);
142
typedef int
143 144
        (*virDrvDomainSetMemory)	(virDomainPtr domain,
                                         unsigned long memory);
145 146 147 148
typedef int
        (*virDrvDomainSetMemoryFlags)	(virDomainPtr domain,
                                         unsigned long memory,
                                         unsigned int flags);
149 150 151
typedef int
        (*virDrvDomainSetMemoryParameters)
                                        (virDomainPtr domain,
152
                                         virTypedParameterPtr params,
153 154 155 156 157
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetMemoryParameters)
                                        (virDomainPtr domain,
158
                                         virTypedParameterPtr params,
159 160
                                         int *nparams,
                                         unsigned int flags);
161 162 163 164 165 166 167 168 169 170 171 172 173
typedef int
        (*virDrvDomainSetNumaParameters)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetNumaParameters)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         unsigned int flags);

174 175 176
typedef int
        (*virDrvDomainSetBlkioParameters)
                                        (virDomainPtr domain,
177
                                         virTypedParameterPtr params,
178 179 180 181 182
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetBlkioParameters)
                                        (virDomainPtr domain,
183
                                         virTypedParameterPtr params,
184 185
                                         int *nparams,
                                         unsigned int flags);
186
typedef int
187 188
        (*virDrvDomainGetInfo)		(virDomainPtr domain,
                                         virDomainInfoPtr info);
189 190 191 192 193
typedef int
        (*virDrvDomainGetState)         (virDomainPtr domain,
                                         int *state,
                                         int *reason,
                                         unsigned int flags);
194 195 196 197
typedef int
        (*virDrvDomainGetControlInfo)   (virDomainPtr domain,
                                         virDomainControlInfoPtr info,
                                         unsigned int flags);
198
typedef int
199 200
        (*virDrvDomainSave)		(virDomainPtr domain,
                                         const char *to);
201 202 203 204 205
typedef int
        (*virDrvDomainSaveFlags)	(virDomainPtr domain,
                                         const char *to,
                                         const char *dxml,
                                         unsigned int flags);
206
typedef int
207 208
        (*virDrvDomainRestore)		(virConnectPtr conn,
                                         const char *from);
209 210 211 212 213
typedef int
        (*virDrvDomainRestoreFlags)	(virConnectPtr conn,
                                         const char *from,
                                         const char *dxml,
                                         unsigned int flags);
214 215 216 217 218 219 220 221 222
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 已提交
223
typedef int
224 225
        (*virDrvDomainCoreDump)		(virDomainPtr domain,
                                         const char *to,
226
                                         unsigned int flags);
227 228 229 230 231
typedef char *
        (*virDrvDomainScreenshot)   (virDomainPtr domain,
                                         virStreamPtr stream,
                                         unsigned int screen,
                                         unsigned int flags);
232
typedef char *
233
        (*virDrvDomainGetXMLDesc)		(virDomainPtr dom,
234
                                                 unsigned int flags);
235 236 237 238 239 240 241 242 243 244
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);
245
typedef int
246 247 248
        (*virDrvListDefinedDomains)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
249
typedef int
250
        (*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
251
typedef int
252
        (*virDrvDomainCreate)		(virDomainPtr dom);
253 254 255
typedef int
        (*virDrvDomainCreateWithFlags)	(virDomainPtr dom,
                                         unsigned int flags);
256
typedef virDomainPtr
257 258
        (*virDrvDomainDefineXML)	(virConnectPtr conn,
                                         const char *xml);
259
typedef int
260
        (*virDrvDomainUndefine)		(virDomainPtr dom);
O
Osier Yang 已提交
261 262 263
typedef int
        (*virDrvDomainUndefineFlags)	(virDomainPtr dom,
                                         unsigned int flags);
264
typedef int
265 266
        (*virDrvDomainSetVcpus)		(virDomainPtr domain,
                                         unsigned int nvcpus);
E
Eric Blake 已提交
267 268 269 270 271 272 273
typedef int
        (*virDrvDomainSetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int nvcpus,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetVcpusFlags)	(virDomainPtr domain,
                                         unsigned int flags);
274
typedef int
275 276 277 278
        (*virDrvDomainPinVcpu)		(virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen);
279 280 281 282 283 284
typedef int
        (*virDrvDomainPinVcpuFlags)     (virDomainPtr domain,
                                         unsigned int vcpu,
                                         unsigned char *cpumap,
                                         int maplen,
                                         unsigned int flags);
285
typedef int
E
Eric Blake 已提交
286
        (*virDrvDomainGetVcpuPinInfo)   (virDomainPtr domain,
287 288 289 290 291
                                         int ncpumaps,
                                         unsigned char *cpumaps,
                                         int maplen,
                                         unsigned int flags);

292
typedef int
293 294 295 296 297
        (*virDrvDomainGetVcpus)		(virDomainPtr domain,
                                         virVcpuInfoPtr info,
                                         int maxinfo,
                                         unsigned char *cpumaps,
                                         int maplen);
298
typedef int
299
        (*virDrvDomainGetMaxVcpus)	(virDomainPtr domain);
300 301 302 303 304 305 306

typedef int
        (*virDrvDomainGetSecurityLabel)	(virDomainPtr domain,
                                         virSecurityLabelPtr seclabel);
typedef int
        (*virDrvNodeGetSecurityModel)	(virConnectPtr conn,
                                         virSecurityModelPtr secmodel);
307
typedef int
308 309
        (*virDrvDomainAttachDevice)	(virDomainPtr domain,
                                         const char *xml);
J
Jim Fehlig 已提交
310 311 312 313
typedef int
        (*virDrvDomainAttachDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
314
typedef int
315 316
        (*virDrvDomainDetachDevice)	(virDomainPtr domain,
                                         const char *xml);
J
Jim Fehlig 已提交
317 318 319 320
typedef int
        (*virDrvDomainDetachDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
321 322 323 324
typedef int
        (*virDrvDomainUpdateDeviceFlags) (virDomainPtr domain,
                                          const char *xml,
                                          unsigned int flags);
325
typedef int
326 327
        (*virDrvDomainGetAutostart)	(virDomainPtr domain,
                                         int *autostart);
328
typedef int
329 330
        (*virDrvDomainSetAutostart)	(virDomainPtr domain,
                                         int autostart);
331

332
typedef char *
333 334
        (*virDrvDomainGetSchedulerType)	(virDomainPtr domain,
                                         int *nparams);
335

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

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

349
typedef int
350 351
        (*virDrvDomainSetSchedulerParameters)
                                        (virDomainPtr domain,
352
                                         virTypedParameterPtr params,
353
                                         int nparams);
354

355 356 357
typedef int
        (*virDrvDomainSetSchedulerParametersFlags)
                                        (virDomainPtr domain,
358
                                         virTypedParameterPtr params,
359 360 361
                                         int nparams,
                                         unsigned int flags);

362 363 364 365 366
typedef int
    (*virDrvDomainBlockStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainBlockStats *stats);
367 368 369 370 371 372 373
typedef int
    (*virDrvDomainBlockStatsFlags)
                    (virDomainPtr domain,
                     const char *path,
                     virTypedParameterPtr params,
                     int *nparams,
                     unsigned int flags);
374 375 376 377 378
typedef int
    (*virDrvDomainInterfaceStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainInterfaceStats *stats);
379 380 381 382 383 384 385 386 387 388
typedef int
    (*virDrvDomainSetInterfaceParameters) (virDomainPtr dom,
                                          const char *device,
                                          virTypedParameterPtr params,
                                          int nparams, unsigned int flags);
typedef int
    (*virDrvDomainGetInterfaceParameters) (virDomainPtr dom,
                                          const char *device,
                                          virTypedParameterPtr params,
                                          int *nparams, unsigned int flags);
389

390 391 392 393
typedef int
    (*virDrvDomainMemoryStats)
                    (virDomainPtr domain,
                     struct _virDomainMemoryStat *stats,
394 395
                     unsigned int nr_stats,
                     unsigned int flags);
396

R
Richard W.M. Jones 已提交
397 398 399 400 401
typedef int
    (*virDrvDomainBlockPeek)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long offset, size_t size,
402 403
                     void *buffer,
                     unsigned int flags);
O
Osier Yang 已提交
404 405 406 407 408 409
typedef int
    (*virDrvDomainBlockResize)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long size,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
410 411 412 413 414 415
typedef int
    (*virDrvDomainMemoryPeek)
                    (virDomainPtr domain,
                     unsigned long long start, size_t size,
                     void *buffer,
                     unsigned int flags);
416 417 418 419 420 421
typedef int
    (*virDrvDomainGetBlockInfo)
                    (virDomainPtr domain,
                     const char *path,
                     virDomainBlockInfoPtr info,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
422

423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
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);

453 454 455
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;

456 457 458 459
typedef int
    (*virDrvNodeGetCPUStats)
                    (virConnectPtr conn,
                     int cpuNum,
460
                     virNodeCPUStatsPtr params,
461 462 463
                     int *nparams,
                     unsigned int flags);

464 465 466 467
typedef int
    (*virDrvNodeGetMemoryStats)
                    (virConnectPtr conn,
                     int cellNum,
468
                     virNodeMemoryStatsPtr params,
469 470 471
                     int *nparams,
                     unsigned int flags);

472 473 474 475 476 477 478
typedef int
    (*virDrvNodeGetCellsFreeMemory)
                    (virConnectPtr conn,
                     unsigned long long *freeMems,
                     int startCell,
                     int maxCells);

479 480
typedef unsigned long long
    (*virDrvNodeGetFreeMemory)
481
                    (virConnectPtr conn);
482

483 484 485
typedef int
    (*virDrvDomainEventRegister)
                    (virConnectPtr conn,
486
                     virConnectDomainEventCallback cb,
487 488
                     void *opaque,
                     virFreeCallback freecb);
489 490 491 492

typedef int
    (*virDrvDomainEventDeregister)
                    (virConnectPtr conn,
493
                     virConnectDomainEventCallback cb);
494

D
Daniel Veillard 已提交
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
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);

517 518 519 520 521 522 523 524 525 526
typedef int
    (*virDrvNodeDeviceDettach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReAttach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReset)
                    (virNodeDevicePtr dev);

C
Chris Lalancette 已提交
527 528
typedef int
    (*virDrvDomainMigratePrepareTunnel)
529
                    (virConnectPtr dconn,
C
Chris Lalancette 已提交
530 531 532 533 534 535
                     virStreamPtr st,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);

536 537 538 539
typedef int
    (*virDrvConnectIsEncrypted)(virConnectPtr conn);
typedef int
    (*virDrvConnectIsSecure)(virConnectPtr conn);
J
Jiri Denemark 已提交
540 541
typedef int
    (*virDrvConnectIsAlive)(virConnectPtr conn);
542 543 544 545
typedef int
    (*virDrvDomainIsActive)(virDomainPtr dom);
typedef int
    (*virDrvDomainIsPersistent)(virDomainPtr dom);
O
Osier Yang 已提交
546 547
typedef int
    (*virDrvDomainIsUpdated)(virDomainPtr dom);
548

J
Jiri Denemark 已提交
549
typedef int
550
    (*virDrvCompareCPU)(virConnectPtr conn,
J
Jiri Denemark 已提交
551 552
                        const char *cpu,
                        unsigned int flags);
553
typedef char *
554
    (*virDrvBaselineCPU)(virConnectPtr conn,
555 556 557
                         const char **xmlCPUs,
                         unsigned int ncpus,
                         unsigned int flags);
J
Jiri Denemark 已提交
558

559 560 561 562
typedef int
    (*virDrvDomainGetJobInfo)(virDomainPtr domain,
                              virDomainJobInfoPtr info);

563 564 565
typedef int
    (*virDrvDomainAbortJob)(virDomainPtr domain);

566 567 568 569
typedef int
    (*virDrvDomainMigrateSetMaxDowntime)(virDomainPtr domain,
                                         unsigned long long downtime,
                                         unsigned int flags);
570 571 572 573
typedef int
    (*virDrvDomainMigrateSetMaxSpeed)(virDomainPtr domain,
                                      unsigned long bandwidth,
                                      unsigned int flags);
574

575 576 577 578 579
typedef int
    (*virDrvDomainMigrateGetMaxSpeed)(virDomainPtr domain,
                                      unsigned long *bandwidth,
                                      unsigned int flags);

580 581 582 583 584 585 586 587 588 589 590 591
typedef int
    (*virDrvDomainEventRegisterAny)(virConnectPtr conn,
                                    virDomainPtr dom,
                                    int eventID,
                                    virConnectDomainEventGenericCallback cb,
                                    void *opaque,
                                    virFreeCallback freecb);

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

592 593 594 595 596 597 598 599 600
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 已提交
601 602 603 604 605 606
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain,
                                     const char *xmlDesc,
                                     unsigned int flags);

typedef char *
607 608
    (*virDrvDomainSnapshotGetXMLDesc)(virDomainSnapshotPtr snapshot,
                                      unsigned int flags);
C
Chris Lalancette 已提交
609 610 611 612 613 614 615 616 617

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

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

618 619 620 621 622 623 624 625 626 627
typedef int
    (*virDrvDomainSnapshotNumChildren)(virDomainSnapshotPtr snapshot,
                                       unsigned int flags);

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

C
Chris Lalancette 已提交
628 629 630 631 632 633 634 635
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotLookupByName)(virDomainPtr domain,
                                        const char *name,
                                        unsigned int flags);

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

636 637 638 639
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotGetParent)(virDomainSnapshotPtr snapshot,
                                     unsigned int flags);

C
Chris Lalancette 已提交
640 641 642 643 644 645 646 647 648 649 650 651
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 已提交
652
typedef int
653
    (*virDrvDomainQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
C
Chris Lalancette 已提交
654 655
                                      char **result, unsigned int flags);

656 657 658 659 660
typedef virDomainPtr
    (*virDrvDomainQemuAttach)(virConnectPtr conn,
                              unsigned int pid,
                              unsigned int flags);

661 662
typedef int
    (*virDrvDomainOpenConsole)(virDomainPtr dom,
663
                               const char *dev_name,
664 665
                               virStreamPtr st,
                               unsigned int flags);
666 667 668 669 670
typedef int
    (*virDrvDomainOpenGraphics)(virDomainPtr dom,
                                unsigned int idx,
                                int fd,
                                unsigned int flags);
C
Chris Lalancette 已提交
671

672 673 674
typedef int
    (*virDrvDomainInjectNMI)(virDomainPtr dom, unsigned int flags);

675 676 677 678
typedef int
    (*virDrvDomainSendKey)(virDomainPtr dom, unsigned int codeset,
                           unsigned int holdtime,
                           unsigned int *keycodes,
679
                           int nkeycodes,
680 681
                           unsigned int flags);

682 683 684
typedef char *
    (*virDrvDomainMigrateBegin3)
                    (virDomainPtr domain,
685
                     const char *xmlin,
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722
                     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,
723
                     const char *xmlin,
724 725 726 727
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
728
                     const char *dconnuri,
729 730 731 732 733
                     const char *uri,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

734
typedef virDomainPtr
735 736 737 738 739 740 741
    (*virDrvDomainMigrateFinish3)
                    (virConnectPtr dconn,
                     const char *dname,
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
742
                     const char *dconnuri,
743 744
                     const char *uri,
                     unsigned long flags,
745
                     int cancelled);
746 747 748 749 750 751 752 753

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

755 756 757 758 759
typedef int
    (*virDrvNodeSuspendForDuration)(virConnectPtr conn, unsigned int target,
                                     unsigned long long duration,
                                     unsigned int flags);

760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778

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 已提交
779 780 781 782
typedef int
    (*virDrvSetKeepAlive)(virConnectPtr conn,
                          int interval,
                          unsigned int count);
783

784 785 786 787 788 789 790 791 792 793 794 795
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);
796 797 798 799
typedef int
    (*virDrvDomainShutdownFlags)(virDomainPtr domain,
                                 unsigned int flags);

800

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

972
typedef int
973
        (*virDrvNumOfNetworks)		(virConnectPtr conn);
974
typedef int
975 976 977
        (*virDrvListNetworks)		(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
978
typedef int
979
        (*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
980
typedef int
981 982 983
        (*virDrvListDefinedNetworks)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
984
typedef virNetworkPtr
985 986
        (*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
987
typedef virNetworkPtr
988 989
        (*virDrvNetworkLookupByName)	(virConnectPtr conn,
                                         const char *name);
990
typedef virNetworkPtr
991 992
        (*virDrvNetworkCreateXML)	(virConnectPtr conn,
                                         const char *xmlDesc);
993
typedef virNetworkPtr
994 995
        (*virDrvNetworkDefineXML)	(virConnectPtr conn,
                                         const char *xml);
996
typedef int
997
        (*virDrvNetworkUndefine)	(virNetworkPtr network);
998
typedef int
999
        (*virDrvNetworkCreate)		(virNetworkPtr network);
1000
typedef int
1001
        (*virDrvNetworkDestroy)		(virNetworkPtr network);
1002
typedef char *
1003
        (*virDrvNetworkGetXMLDesc)		(virNetworkPtr network,
1004
                                         unsigned int flags);
1005
typedef char *
1006
        (*virDrvNetworkGetBridgeName)	(virNetworkPtr network);
1007
typedef int
1008 1009
        (*virDrvNetworkGetAutostart)	(virNetworkPtr network,
                                         int *autostart);
1010
typedef int
1011 1012
        (*virDrvNetworkSetAutostart)	(virNetworkPtr network,
                                         int autostart);
1013

1014 1015 1016 1017 1018 1019
typedef int
        (*virDrvNetworkIsActive)(virNetworkPtr net);
typedef int
        (*virDrvNetworkIsPersistent)(virNetworkPtr net);


1020 1021 1022 1023 1024 1025 1026 1027 1028

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

/**
 * _virNetworkDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
1029 1030 1031 1032
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
1033 1034
 */
struct _virNetworkDriver {
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
        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;
1049
        virDrvNetworkGetXMLDesc		networkGetXMLDesc;
1050 1051 1052
        virDrvNetworkGetBridgeName	networkGetBridgeName;
        virDrvNetworkGetAutostart	networkGetAutostart;
        virDrvNetworkSetAutostart	networkSetAutostart;
1053 1054
        virDrvNetworkIsActive           networkIsActive;
        virDrvNetworkIsPersistent       networkIsPersistent;
1055 1056
};

D
Daniel Veillard 已提交
1057 1058 1059 1060 1061 1062 1063
/*-------*/
typedef int
        (*virDrvNumOfInterfaces)        (virConnectPtr conn);
typedef int
        (*virDrvListInterfaces)         (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
1064 1065 1066 1067 1068 1069
typedef int
        (*virDrvNumOfDefinedInterfaces) (virConnectPtr conn);
typedef int
        (*virDrvListDefinedInterfaces)  (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
D
Daniel Veillard 已提交
1070 1071 1072 1073 1074 1075 1076 1077
typedef virInterfacePtr
        (*virDrvInterfaceLookupByName)  (virConnectPtr conn,
                                         const char *name);
typedef virInterfacePtr
        (*virDrvInterfaceLookupByMACString)   (virConnectPtr conn,
                                               const char *mac);

typedef char *
1078
        (*virDrvInterfaceGetXMLDesc)    (virInterfacePtr iface,
D
Daniel Veillard 已提交
1079 1080 1081 1082 1083 1084 1085
                                         unsigned int flags);

typedef virInterfacePtr
        (*virDrvInterfaceDefineXML)     (virConnectPtr conn,
                                         const char *xmlDesc,
                                         unsigned int flags);
typedef int
1086
        (*virDrvInterfaceUndefine)      (virInterfacePtr iface);
D
Daniel Veillard 已提交
1087
typedef int
1088
        (*virDrvInterfaceCreate)        (virInterfacePtr iface,
D
Daniel Veillard 已提交
1089 1090
                                         unsigned int flags);
typedef int
1091
        (*virDrvInterfaceDestroy)       (virInterfacePtr iface,
D
Daniel Veillard 已提交
1092 1093
                                         unsigned int flags);

1094 1095 1096
typedef int
        (*virDrvInterfaceIsActive)(virInterfacePtr iface);

1097 1098 1099 1100 1101 1102 1103 1104 1105
typedef int
        (*virDrvInterfaceChangeBegin)   (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeCommit)  (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeRollback)(virConnectPtr conn,
                                         unsigned int flags);
1106

D
Daniel Veillard 已提交
1107 1108 1109 1110 1111 1112
typedef struct _virInterfaceDriver virInterfaceDriver;
typedef virInterfaceDriver *virInterfaceDriverPtr;

/**
 * _virInterfaceDriver:
 *
1113
 * Structure associated to a network interface driver, defining the various
D
Daniel Veillard 已提交
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
 * 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;
1126 1127
    virDrvNumOfDefinedInterfaces     numOfDefinedInterfaces;
    virDrvListDefinedInterfaces      listDefinedInterfaces;
D
Daniel Veillard 已提交
1128 1129 1130 1131 1132 1133 1134
    virDrvInterfaceLookupByName      interfaceLookupByName;
    virDrvInterfaceLookupByMACString interfaceLookupByMACString;
    virDrvInterfaceGetXMLDesc        interfaceGetXMLDesc;
    virDrvInterfaceDefineXML         interfaceDefineXML;
    virDrvInterfaceUndefine          interfaceUndefine;
    virDrvInterfaceCreate            interfaceCreate;
    virDrvInterfaceDestroy           interfaceDestroy;
1135
    virDrvInterfaceIsActive          interfaceIsActive;
1136 1137 1138
    virDrvInterfaceChangeBegin       interfaceChangeBegin;
    virDrvInterfaceChangeCommit      interfaceChangeCommit;
    virDrvInterfaceChangeRollback    interfaceChangeRollback;
D
Daniel Veillard 已提交
1139 1140
};

1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153

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);
1154 1155 1156 1157 1158
typedef char *
    (*virDrvConnectFindStoragePoolSources)   (virConnectPtr conn,
                                              const char *type,
                                              const char *srcSpec,
                                              unsigned int flags);
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 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229
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);

1230 1231 1232 1233
typedef int
    (*virDrvStorageVolWipe)                  (virStorageVolPtr vol,
                                              unsigned int flags);

1234 1235 1236 1237 1238 1239 1240 1241 1242
typedef int
    (*virDrvStorageVolGetInfo)               (virStorageVolPtr vol,
                                              virStorageVolInfoPtr info);
typedef char *
    (*virDrvStorageVolGetXMLDesc)            (virStorageVolPtr pool,
                                              unsigned int flags);
typedef char *
    (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);

1243 1244 1245 1246 1247
typedef virStorageVolPtr
    (*virDrvStorageVolCreateXMLFrom)         (virStoragePoolPtr pool,
                                              const char *xmldesc,
                                              virStorageVolPtr clone,
                                              unsigned int flags);
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259
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);
1260

1261 1262 1263 1264 1265 1266
typedef int
        (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
typedef int
        (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);


1267 1268 1269 1270 1271 1272 1273

typedef struct _virStorageDriver virStorageDriver;
typedef virStorageDriver *virStorageDriverPtr;

/**
 * _virStorageDriver:
 *
1274
 * Structure associated to a storage driver, defining the various
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
 * 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;
1290
    virDrvConnectFindStoragePoolSources findPoolSources;
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312
    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;
1313
    virDrvStorageVolCreateXMLFrom volCreateXMLFrom;
1314 1315
    virDrvStorageVolDownload volDownload;
    virDrvStorageVolUpload volUpload;
1316
    virDrvStorageVolDelete volDelete;
1317
    virDrvStorageVolWipe volWipe;
1318 1319 1320
    virDrvStorageVolGetInfo volGetInfo;
    virDrvStorageVolGetXMLDesc volGetXMLDesc;
    virDrvStorageVolGetPath volGetPath;
1321 1322
    virDrvStoragePoolIsActive   poolIsActive;
    virDrvStoragePoolIsPersistent   poolIsPersistent;
1323 1324
};

1325
# ifdef WITH_LIBVIRTD
1326
typedef int (*virDrvStateInitialize) (int privileged);
1327 1328 1329 1330 1331 1332 1333 1334
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);

typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;

struct _virStateDriver {
1335
    const char *name;
1336 1337 1338 1339 1340
    virDrvStateInitialize  initialize;
    virDrvStateCleanup     cleanup;
    virDrvStateReload      reload;
    virDrvStateActive      active;
};
1341
# endif
1342

1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359

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

1360 1361
typedef char * (*virDevMonDeviceGetXMLDesc)(virNodeDevicePtr dev,
                                            unsigned int flags);
1362 1363 1364 1365 1366 1367 1368 1369 1370

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

typedef int (*virDevMonDeviceNumOfCaps)(virNodeDevicePtr dev);

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

1371 1372 1373 1374 1375
typedef virNodeDevicePtr (*virDrvNodeDeviceCreateXML)(virConnectPtr conn,
                                                      const char *xmlDesc,
                                                      unsigned int flags);
typedef int (*virDrvNodeDeviceDestroy)(virNodeDevicePtr dev);

1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
/**
 * _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;
1390
    virDevMonDeviceGetXMLDesc deviceGetXMLDesc;
1391 1392 1393
    virDevMonDeviceGetParent deviceGetParent;
    virDevMonDeviceNumOfCaps deviceNumOfCaps;
    virDevMonDeviceListCaps deviceListCaps;
1394 1395
    virDrvNodeDeviceCreateXML deviceCreateXML;
    virDrvNodeDeviceDestroy deviceDestroy;
1396 1397
};

1398 1399
enum {
    /* This getValue call is inside libvirt, override the "private" flag.
E
Eric Blake 已提交
1400
       This flag cannot be set by outside callers. */
1401
    VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 0,
1402 1403
};

1404
typedef virSecretPtr
1405 1406
    (*virDrvSecretLookupByUUID)        (virConnectPtr conn,
                                        const unsigned char *uuid);
1407 1408 1409 1410
typedef virSecretPtr
    (*virDrvSecretLookupByUsage)       (virConnectPtr conn,
                                        int usageType,
                                        const char *usageID);
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425
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,
1426 1427
                                              unsigned int flags,
                                              unsigned int internalFlags);
1428 1429 1430
typedef int
    (*virDrvSecretUndefine)                  (virSecretPtr secret);
typedef int
1431
    (*virDrvNumOfSecrets)              (virConnectPtr conn);
1432
typedef int
1433
    (*virDrvListSecrets)               (virConnectPtr conn,
1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454
                                              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;

1455 1456
    virDrvNumOfSecrets numOfSecrets;
    virDrvListSecrets listSecrets;
1457
    virDrvSecretLookupByUUID lookupByUUID;
1458
    virDrvSecretLookupByUsage lookupByUsage;
1459 1460 1461 1462 1463 1464 1465
    virDrvSecretDefineXML defineXML;
    virDrvSecretGetXMLDesc getXMLDesc;
    virDrvSecretSetValue setValue;
    virDrvSecretGetValue getValue;
    virDrvSecretUndefine undefine;
};

1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500

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 已提交
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514
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 已提交
1515
                                               const char *xmlDesc);
S
Stefan Berger 已提交
1516
typedef int
1517
    (*virDrvNWFilterUndefine)                 (virNWFilterPtr nwfilter);
S
Stefan Berger 已提交
1518 1519

typedef char *
1520
    (*virDrvNWFilterGetXMLDesc)              (virNWFilterPtr nwfilter,
1521
                                              unsigned int flags);
S
Stefan Berger 已提交
1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551


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


1552 1553 1554 1555 1556 1557
/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
1558
int virRegisterNetworkDriver(virNetworkDriverPtr);
D
Daniel Veillard 已提交
1559
int virRegisterInterfaceDriver(virInterfaceDriverPtr);
1560
int virRegisterStorageDriver(virStorageDriverPtr);
1561
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
1562
int virRegisterSecretDriver(virSecretDriverPtr);
S
Stefan Berger 已提交
1563
int virRegisterNWFilterDriver(virNWFilterDriverPtr);
1564
# ifdef WITH_LIBVIRTD
1565
int virRegisterStateDriver(virStateDriverPtr);
1566
# endif
1567
void *virDriverLoadModule(const char *name);
1568 1569

#endif /* __VIR_DRIVER_H__ */