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

#ifndef __VIR_DRIVER_H__
7
# define __VIR_DRIVER_H__
8

9
# include "config.h"
10

11
# include <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 123 124 125 126
typedef int
        (*virDrvDomainPMSuspendForDuration) (virDomainPtr,
                                             unsigned int target,
                                             unsigned long long duration,
                                             unsigned int flags);
127
typedef int
128
        (*virDrvDomainShutdown)		(virDomainPtr domain);
129
typedef int
130 131
        (*virDrvDomainReboot)		(virDomainPtr domain,
                                         unsigned int flags);
X
Xu He Jie 已提交
132 133 134
typedef int
        (*virDrvDomainReset)        (virDomainPtr domain,
                                         unsigned int flags);
135
typedef int
136
        (*virDrvDomainDestroy)		(virDomainPtr domain);
137 138 139
typedef int
        (*virDrvDomainDestroyFlags) (virDomainPtr domain,
                                         unsigned int flags);
140
typedef char *
141
        (*virDrvDomainGetOSType)	(virDomainPtr domain);
142
typedef unsigned long
143
        (*virDrvDomainGetMaxMemory)	(virDomainPtr domain);
144
typedef int
145 146
        (*virDrvDomainSetMaxMemory)	(virDomainPtr domain,
                                         unsigned long memory);
147
typedef int
148 149
        (*virDrvDomainSetMemory)	(virDomainPtr domain,
                                         unsigned long memory);
150 151 152 153
typedef int
        (*virDrvDomainSetMemoryFlags)	(virDomainPtr domain,
                                         unsigned long memory,
                                         unsigned int flags);
154 155 156
typedef int
        (*virDrvDomainSetMemoryParameters)
                                        (virDomainPtr domain,
157
                                         virTypedParameterPtr params,
158 159 160 161 162
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetMemoryParameters)
                                        (virDomainPtr domain,
163
                                         virTypedParameterPtr params,
164 165
                                         int *nparams,
                                         unsigned int flags);
166 167 168 169 170 171 172 173 174 175 176 177 178
typedef int
        (*virDrvDomainSetNumaParameters)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int nparams,
                                         unsigned int flags);
typedef int
        (*virDrvDomainGetNumaParameters)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         unsigned int flags);

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

297
typedef int
298 299 300 301 302
        (*virDrvDomainGetVcpus)		(virDomainPtr domain,
                                         virVcpuInfoPtr info,
                                         int maxinfo,
                                         unsigned char *cpumaps,
                                         int maplen);
303
typedef int
304
        (*virDrvDomainGetMaxVcpus)	(virDomainPtr domain);
305 306 307 308 309 310 311

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

337
typedef char *
338 339
        (*virDrvDomainGetSchedulerType)	(virDomainPtr domain,
                                         int *nparams);
340

341
typedef int
342 343
        (*virDrvDomainGetSchedulerParameters)
                                        (virDomainPtr domain,
344
                                         virTypedParameterPtr params,
345
                                         int *nparams);
346

347 348 349 350 351 352 353
typedef int
        (*virDrvDomainGetSchedulerParametersFlags)
                                        (virDomainPtr domain,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         unsigned int flags);

354
typedef int
355 356
        (*virDrvDomainSetSchedulerParameters)
                                        (virDomainPtr domain,
357
                                         virTypedParameterPtr params,
358
                                         int nparams);
359

360 361 362
typedef int
        (*virDrvDomainSetSchedulerParametersFlags)
                                        (virDomainPtr domain,
363
                                         virTypedParameterPtr params,
364 365 366
                                         int nparams,
                                         unsigned int flags);

367 368 369 370 371
typedef int
    (*virDrvDomainBlockStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainBlockStats *stats);
372 373 374 375 376 377 378
typedef int
    (*virDrvDomainBlockStatsFlags)
                    (virDomainPtr domain,
                     const char *path,
                     virTypedParameterPtr params,
                     int *nparams,
                     unsigned int flags);
379 380 381 382 383
typedef int
    (*virDrvDomainInterfaceStats)
                    (virDomainPtr domain,
                     const char *path,
                     struct _virDomainInterfaceStats *stats);
384 385 386 387 388 389 390 391 392 393
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);
394

395 396 397 398
typedef int
    (*virDrvDomainMemoryStats)
                    (virDomainPtr domain,
                     struct _virDomainMemoryStat *stats,
399 400
                     unsigned int nr_stats,
                     unsigned int flags);
401

R
Richard W.M. Jones 已提交
402 403 404 405 406
typedef int
    (*virDrvDomainBlockPeek)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long offset, size_t size,
407 408
                     void *buffer,
                     unsigned int flags);
O
Osier Yang 已提交
409 410 411 412 413 414
typedef int
    (*virDrvDomainBlockResize)
                    (virDomainPtr domain,
                     const char *path,
                     unsigned long long size,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
415 416 417 418 419 420
typedef int
    (*virDrvDomainMemoryPeek)
                    (virDomainPtr domain,
                     unsigned long long start, size_t size,
                     void *buffer,
                     unsigned int flags);
421 422 423 424 425 426
typedef int
    (*virDrvDomainGetBlockInfo)
                    (virDomainPtr domain,
                     const char *path,
                     virDomainBlockInfoPtr info,
                     unsigned int flags);
R
Richard W.M. Jones 已提交
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 453 454 455 456 457
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);

458 459 460
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;

461 462 463 464
typedef int
    (*virDrvNodeGetCPUStats)
                    (virConnectPtr conn,
                     int cpuNum,
465
                     virNodeCPUStatsPtr params,
466 467 468
                     int *nparams,
                     unsigned int flags);

469 470 471 472
typedef int
    (*virDrvNodeGetMemoryStats)
                    (virConnectPtr conn,
                     int cellNum,
473
                     virNodeMemoryStatsPtr params,
474 475 476
                     int *nparams,
                     unsigned int flags);

477 478 479 480 481 482 483
typedef int
    (*virDrvNodeGetCellsFreeMemory)
                    (virConnectPtr conn,
                     unsigned long long *freeMems,
                     int startCell,
                     int maxCells);

484 485
typedef unsigned long long
    (*virDrvNodeGetFreeMemory)
486
                    (virConnectPtr conn);
487

488 489 490
typedef int
    (*virDrvDomainEventRegister)
                    (virConnectPtr conn,
491
                     virConnectDomainEventCallback cb,
492 493
                     void *opaque,
                     virFreeCallback freecb);
494 495 496 497

typedef int
    (*virDrvDomainEventDeregister)
                    (virConnectPtr conn,
498
                     virConnectDomainEventCallback cb);
499

D
Daniel Veillard 已提交
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
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);

522 523 524 525 526 527 528 529 530 531
typedef int
    (*virDrvNodeDeviceDettach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReAttach)
                    (virNodeDevicePtr dev);
typedef int
    (*virDrvNodeDeviceReset)
                    (virNodeDevicePtr dev);

C
Chris Lalancette 已提交
532 533
typedef int
    (*virDrvDomainMigratePrepareTunnel)
534
                    (virConnectPtr dconn,
C
Chris Lalancette 已提交
535 536 537 538 539 540
                     virStreamPtr st,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource,
                     const char *dom_xml);

541 542 543 544
typedef int
    (*virDrvConnectIsEncrypted)(virConnectPtr conn);
typedef int
    (*virDrvConnectIsSecure)(virConnectPtr conn);
J
Jiri Denemark 已提交
545 546
typedef int
    (*virDrvConnectIsAlive)(virConnectPtr conn);
547 548 549 550
typedef int
    (*virDrvDomainIsActive)(virDomainPtr dom);
typedef int
    (*virDrvDomainIsPersistent)(virDomainPtr dom);
O
Osier Yang 已提交
551 552
typedef int
    (*virDrvDomainIsUpdated)(virDomainPtr dom);
553

J
Jiri Denemark 已提交
554
typedef int
555
    (*virDrvCompareCPU)(virConnectPtr conn,
J
Jiri Denemark 已提交
556 557
                        const char *cpu,
                        unsigned int flags);
558
typedef char *
559
    (*virDrvBaselineCPU)(virConnectPtr conn,
560 561 562
                         const char **xmlCPUs,
                         unsigned int ncpus,
                         unsigned int flags);
J
Jiri Denemark 已提交
563

564 565 566 567
typedef int
    (*virDrvDomainGetJobInfo)(virDomainPtr domain,
                              virDomainJobInfoPtr info);

568 569 570
typedef int
    (*virDrvDomainAbortJob)(virDomainPtr domain);

571 572 573 574
typedef int
    (*virDrvDomainMigrateSetMaxDowntime)(virDomainPtr domain,
                                         unsigned long long downtime,
                                         unsigned int flags);
575 576 577 578
typedef int
    (*virDrvDomainMigrateSetMaxSpeed)(virDomainPtr domain,
                                      unsigned long bandwidth,
                                      unsigned int flags);
579

580 581 582 583 584
typedef int
    (*virDrvDomainMigrateGetMaxSpeed)(virDomainPtr domain,
                                      unsigned long *bandwidth,
                                      unsigned int flags);

585 586 587 588 589 590 591 592 593 594 595 596
typedef int
    (*virDrvDomainEventRegisterAny)(virConnectPtr conn,
                                    virDomainPtr dom,
                                    int eventID,
                                    virConnectDomainEventGenericCallback cb,
                                    void *opaque,
                                    virFreeCallback freecb);

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

597 598 599 600 601 602 603 604 605
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 已提交
606 607 608 609 610 611
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain,
                                     const char *xmlDesc,
                                     unsigned int flags);

typedef char *
612 613
    (*virDrvDomainSnapshotGetXMLDesc)(virDomainSnapshotPtr snapshot,
                                      unsigned int flags);
C
Chris Lalancette 已提交
614 615 616 617 618 619 620 621 622

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

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

623 624 625 626 627 628 629 630 631 632
typedef int
    (*virDrvDomainSnapshotNumChildren)(virDomainSnapshotPtr snapshot,
                                       unsigned int flags);

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

C
Chris Lalancette 已提交
633 634 635 636 637 638 639 640
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotLookupByName)(virDomainPtr domain,
                                        const char *name,
                                        unsigned int flags);

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

641 642 643 644
typedef virDomainSnapshotPtr
    (*virDrvDomainSnapshotGetParent)(virDomainSnapshotPtr snapshot,
                                     unsigned int flags);

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

661 662 663 664 665
typedef virDomainPtr
    (*virDrvDomainQemuAttach)(virConnectPtr conn,
                              unsigned int pid,
                              unsigned int flags);

666 667
typedef int
    (*virDrvDomainOpenConsole)(virDomainPtr dom,
668
                               const char *dev_name,
669 670
                               virStreamPtr st,
                               unsigned int flags);
671 672 673 674 675
typedef int
    (*virDrvDomainOpenGraphics)(virDomainPtr dom,
                                unsigned int idx,
                                int fd,
                                unsigned int flags);
C
Chris Lalancette 已提交
676

677 678 679
typedef int
    (*virDrvDomainInjectNMI)(virDomainPtr dom, unsigned int flags);

680 681 682 683
typedef int
    (*virDrvDomainSendKey)(virDomainPtr dom, unsigned int codeset,
                           unsigned int holdtime,
                           unsigned int *keycodes,
684
                           int nkeycodes,
685 686
                           unsigned int flags);

687 688 689
typedef char *
    (*virDrvDomainMigrateBegin3)
                    (virDomainPtr domain,
690
                     const char *xmlin,
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 723 724 725 726 727
                     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,
728
                     const char *xmlin,
729 730 731 732
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
733
                     const char *dconnuri,
734 735 736 737 738
                     const char *uri,
                     unsigned long flags,
                     const char *dname,
                     unsigned long resource);

739
typedef virDomainPtr
740 741 742 743 744 745 746
    (*virDrvDomainMigrateFinish3)
                    (virConnectPtr dconn,
                     const char *dname,
                     const char *cookiein,
                     int cookieinlen,
                     char **cookieout,
                     int *cookieoutlen,
747
                     const char *dconnuri,
748 749
                     const char *uri,
                     unsigned long flags,
750
                     int cancelled);
751 752 753 754 755 756 757 758

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

760 761 762 763 764
typedef int
    (*virDrvNodeSuspendForDuration)(virConnectPtr conn, unsigned int target,
                                     unsigned long long duration,
                                     unsigned int flags);

765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783

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 已提交
784 785 786 787
typedef int
    (*virDrvSetKeepAlive)(virConnectPtr conn,
                          int interval,
                          unsigned int count);
788

789 790 791 792 793 794 795 796 797 798 799 800
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);
801 802 803 804
typedef int
    (*virDrvDomainShutdownFlags)(virDomainPtr domain,
                                 unsigned int flags);

805

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

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

1020 1021 1022 1023 1024 1025
typedef int
        (*virDrvNetworkIsActive)(virNetworkPtr net);
typedef int
        (*virDrvNetworkIsPersistent)(virNetworkPtr net);


1026 1027 1028 1029 1030 1031 1032 1033 1034

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

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

D
Daniel Veillard 已提交
1063 1064 1065 1066 1067 1068 1069
/*-------*/
typedef int
        (*virDrvNumOfInterfaces)        (virConnectPtr conn);
typedef int
        (*virDrvListInterfaces)         (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
1070 1071 1072 1073 1074 1075
typedef int
        (*virDrvNumOfDefinedInterfaces) (virConnectPtr conn);
typedef int
        (*virDrvListDefinedInterfaces)  (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
D
Daniel Veillard 已提交
1076 1077 1078 1079 1080 1081 1082 1083
typedef virInterfacePtr
        (*virDrvInterfaceLookupByName)  (virConnectPtr conn,
                                         const char *name);
typedef virInterfacePtr
        (*virDrvInterfaceLookupByMACString)   (virConnectPtr conn,
                                               const char *mac);

typedef char *
1084
        (*virDrvInterfaceGetXMLDesc)    (virInterfacePtr iface,
D
Daniel Veillard 已提交
1085 1086 1087 1088 1089 1090 1091
                                         unsigned int flags);

typedef virInterfacePtr
        (*virDrvInterfaceDefineXML)     (virConnectPtr conn,
                                         const char *xmlDesc,
                                         unsigned int flags);
typedef int
1092
        (*virDrvInterfaceUndefine)      (virInterfacePtr iface);
D
Daniel Veillard 已提交
1093
typedef int
1094
        (*virDrvInterfaceCreate)        (virInterfacePtr iface,
D
Daniel Veillard 已提交
1095 1096
                                         unsigned int flags);
typedef int
1097
        (*virDrvInterfaceDestroy)       (virInterfacePtr iface,
D
Daniel Veillard 已提交
1098 1099
                                         unsigned int flags);

1100 1101 1102
typedef int
        (*virDrvInterfaceIsActive)(virInterfacePtr iface);

1103 1104 1105 1106 1107 1108 1109 1110 1111
typedef int
        (*virDrvInterfaceChangeBegin)   (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeCommit)  (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeRollback)(virConnectPtr conn,
                                         unsigned int flags);
1112

D
Daniel Veillard 已提交
1113 1114 1115 1116 1117 1118
typedef struct _virInterfaceDriver virInterfaceDriver;
typedef virInterfaceDriver *virInterfaceDriverPtr;

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

1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159

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);
1160 1161 1162 1163 1164
typedef char *
    (*virDrvConnectFindStoragePoolSources)   (virConnectPtr conn,
                                              const char *type,
                                              const char *srcSpec,
                                              unsigned int flags);
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 1230 1231 1232 1233 1234 1235
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);

1236 1237 1238
typedef int
    (*virDrvStorageVolWipe)                  (virStorageVolPtr vol,
                                              unsigned int flags);
1239 1240 1241 1242
typedef int
    (*virDrvStorageVolWipePattern)           (virStorageVolPtr vol,
                                              unsigned int algorithm,
                                              unsigned int flags);
1243

1244 1245 1246 1247 1248 1249 1250 1251 1252
typedef int
    (*virDrvStorageVolGetInfo)               (virStorageVolPtr vol,
                                              virStorageVolInfoPtr info);
typedef char *
    (*virDrvStorageVolGetXMLDesc)            (virStorageVolPtr pool,
                                              unsigned int flags);
typedef char *
    (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);

1253 1254 1255 1256 1257
typedef virStorageVolPtr
    (*virDrvStorageVolCreateXMLFrom)         (virStoragePoolPtr pool,
                                              const char *xmldesc,
                                              virStorageVolPtr clone,
                                              unsigned int flags);
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269
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);
1270 1271 1272 1273
typedef int
        (*virDrvStorageVolResize) (virStorageVolPtr vol,
                                   long long capacity,
                                   unsigned int flags);
1274

1275 1276 1277 1278 1279 1280
typedef int
        (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
typedef int
        (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);


1281 1282 1283 1284 1285 1286 1287

typedef struct _virStorageDriver virStorageDriver;
typedef virStorageDriver *virStorageDriverPtr;

/**
 * _virStorageDriver:
 *
1288
 * Structure associated to a storage driver, defining the various
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303
 * 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;
1304
    virDrvConnectFindStoragePoolSources findPoolSources;
1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326
    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;
1327
    virDrvStorageVolCreateXMLFrom volCreateXMLFrom;
1328 1329
    virDrvStorageVolDownload volDownload;
    virDrvStorageVolUpload volUpload;
1330
    virDrvStorageVolDelete volDelete;
1331
    virDrvStorageVolWipe volWipe;
1332
    virDrvStorageVolWipePattern volWipePattern;
1333 1334 1335
    virDrvStorageVolGetInfo volGetInfo;
    virDrvStorageVolGetXMLDesc volGetXMLDesc;
    virDrvStorageVolGetPath volGetPath;
1336
    virDrvStorageVolResize volResize;
1337 1338
    virDrvStoragePoolIsActive   poolIsActive;
    virDrvStoragePoolIsPersistent   poolIsPersistent;
1339 1340
};

1341
# ifdef WITH_LIBVIRTD
1342
typedef int (*virDrvStateInitialize) (int privileged);
1343 1344 1345 1346 1347 1348 1349 1350
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);

typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;

struct _virStateDriver {
1351
    const char *name;
1352 1353 1354 1355 1356
    virDrvStateInitialize  initialize;
    virDrvStateCleanup     cleanup;
    virDrvStateReload      reload;
    virDrvStateActive      active;
};
1357
# endif
1358

1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375

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

1376 1377
typedef char * (*virDevMonDeviceGetXMLDesc)(virNodeDevicePtr dev,
                                            unsigned int flags);
1378 1379 1380 1381 1382 1383 1384 1385 1386

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

typedef int (*virDevMonDeviceNumOfCaps)(virNodeDevicePtr dev);

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

1387 1388 1389 1390 1391
typedef virNodeDevicePtr (*virDrvNodeDeviceCreateXML)(virConnectPtr conn,
                                                      const char *xmlDesc,
                                                      unsigned int flags);
typedef int (*virDrvNodeDeviceDestroy)(virNodeDevicePtr dev);

1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405
/**
 * _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;
1406
    virDevMonDeviceGetXMLDesc deviceGetXMLDesc;
1407 1408 1409
    virDevMonDeviceGetParent deviceGetParent;
    virDevMonDeviceNumOfCaps deviceNumOfCaps;
    virDevMonDeviceListCaps deviceListCaps;
1410 1411
    virDrvNodeDeviceCreateXML deviceCreateXML;
    virDrvNodeDeviceDestroy deviceDestroy;
1412 1413
};

1414 1415
enum {
    /* This getValue call is inside libvirt, override the "private" flag.
E
Eric Blake 已提交
1416
       This flag cannot be set by outside callers. */
1417
    VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 0,
1418 1419
};

1420
typedef virSecretPtr
1421 1422
    (*virDrvSecretLookupByUUID)        (virConnectPtr conn,
                                        const unsigned char *uuid);
1423 1424 1425 1426
typedef virSecretPtr
    (*virDrvSecretLookupByUsage)       (virConnectPtr conn,
                                        int usageType,
                                        const char *usageID);
1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441
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,
1442 1443
                                              unsigned int flags,
                                              unsigned int internalFlags);
1444 1445 1446
typedef int
    (*virDrvSecretUndefine)                  (virSecretPtr secret);
typedef int
1447
    (*virDrvNumOfSecrets)              (virConnectPtr conn);
1448
typedef int
1449
    (*virDrvListSecrets)               (virConnectPtr conn,
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470
                                              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;

1471 1472
    virDrvNumOfSecrets numOfSecrets;
    virDrvListSecrets listSecrets;
1473
    virDrvSecretLookupByUUID lookupByUUID;
1474
    virDrvSecretLookupByUsage lookupByUsage;
1475 1476 1477 1478 1479 1480 1481
    virDrvSecretDefineXML defineXML;
    virDrvSecretGetXMLDesc getXMLDesc;
    virDrvSecretSetValue setValue;
    virDrvSecretGetValue getValue;
    virDrvSecretUndefine undefine;
};

1482 1483 1484 1485 1486 1487 1488 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

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 已提交
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530
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 已提交
1531
                                               const char *xmlDesc);
S
Stefan Berger 已提交
1532
typedef int
1533
    (*virDrvNWFilterUndefine)                 (virNWFilterPtr nwfilter);
S
Stefan Berger 已提交
1534 1535

typedef char *
1536
    (*virDrvNWFilterGetXMLDesc)              (virNWFilterPtr nwfilter,
1537
                                              unsigned int flags);
S
Stefan Berger 已提交
1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567


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


1568 1569 1570 1571 1572 1573
/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
1574
int virRegisterNetworkDriver(virNetworkDriverPtr);
D
Daniel Veillard 已提交
1575
int virRegisterInterfaceDriver(virInterfaceDriverPtr);
1576
int virRegisterStorageDriver(virStorageDriverPtr);
1577
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
1578
int virRegisterSecretDriver(virSecretDriverPtr);
S
Stefan Berger 已提交
1579
int virRegisterNWFilterDriver(virNWFilterDriverPtr);
1580
# ifdef WITH_LIBVIRTD
1581
int virRegisterStateDriver(virStateDriverPtr);
1582
# endif
1583
void *virDriverLoadModule(const char *name);
1584 1585

#endif /* __VIR_DRIVER_H__ */