driver.h 62.9 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

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);
783 784 785 786
typedef int
    (*virDrvDomainBlockRebase)(virDomainPtr dom, const char *path,
                               const char *base, unsigned long bandwidth,
                               unsigned int flags);
787

J
Jiri Denemark 已提交
788 789 790 791
typedef int
    (*virDrvSetKeepAlive)(virConnectPtr conn,
                          int interval,
                          unsigned int count);
792

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

809 810 811 812 813 814 815
typedef int
    (*virDrvDomainGetCPUStats)(virDomainPtr domain,
                               virTypedParameterPtr params,
                               unsigned int nparams,
                               int start_cpu,
                               unsigned int ncpus,
                               unsigned int flags);
816

817 818 819 820 821 822
typedef int
    (*virDrvDomainGetDiskErrors)(virDomainPtr dom,
                                 virDomainDiskErrorPtr errors,
                                 unsigned int maxerrors,
                                 unsigned int flags);

823 824 825 826 827 828 829 830 831 832 833 834 835 836
typedef int
    (*virDrvDomainSetMetadata)(virDomainPtr dom,
                               int type,
                               const char *metadata,
                               const char *key,
                               const char *uri,
                               unsigned int flags);

typedef char *
    (*virDrvDomainGetMetadata)(virDomainPtr dom,
                               int type,
                               const char *uri,
                               unsigned int flags);

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

1014
typedef int
1015
        (*virDrvNumOfNetworks)		(virConnectPtr conn);
1016
typedef int
1017 1018 1019
        (*virDrvListNetworks)		(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
1020
typedef int
1021
        (*virDrvNumOfDefinedNetworks)	(virConnectPtr conn);
1022
typedef int
1023 1024 1025
        (*virDrvListDefinedNetworks)	(virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
1026
typedef virNetworkPtr
1027 1028
        (*virDrvNetworkLookupByUUID)	(virConnectPtr conn,
                                         const unsigned char *uuid);
1029
typedef virNetworkPtr
1030 1031
        (*virDrvNetworkLookupByName)	(virConnectPtr conn,
                                         const char *name);
1032
typedef virNetworkPtr
1033 1034
        (*virDrvNetworkCreateXML)	(virConnectPtr conn,
                                         const char *xmlDesc);
1035
typedef virNetworkPtr
1036 1037
        (*virDrvNetworkDefineXML)	(virConnectPtr conn,
                                         const char *xml);
1038
typedef int
1039
        (*virDrvNetworkUndefine)	(virNetworkPtr network);
1040
typedef int
1041
        (*virDrvNetworkCreate)		(virNetworkPtr network);
1042
typedef int
1043
        (*virDrvNetworkDestroy)		(virNetworkPtr network);
1044
typedef char *
1045
        (*virDrvNetworkGetXMLDesc)		(virNetworkPtr network,
1046
                                         unsigned int flags);
1047
typedef char *
1048
        (*virDrvNetworkGetBridgeName)	(virNetworkPtr network);
1049
typedef int
1050 1051
        (*virDrvNetworkGetAutostart)	(virNetworkPtr network,
                                         int *autostart);
1052
typedef int
1053 1054
        (*virDrvNetworkSetAutostart)	(virNetworkPtr network,
                                         int autostart);
1055

1056 1057 1058 1059 1060 1061
typedef int
        (*virDrvNetworkIsActive)(virNetworkPtr net);
typedef int
        (*virDrvNetworkIsPersistent)(virNetworkPtr net);


1062 1063 1064 1065 1066 1067 1068 1069 1070

typedef struct _virNetworkDriver virNetworkDriver;
typedef virNetworkDriver *virNetworkDriverPtr;

/**
 * _virNetworkDriver:
 *
 * Structure associated to a network virtualization driver, defining the various
 * entry points for it.
1071 1072 1073 1074
 *
 * All drivers must support the following fields/methods:
 *  - open
 *  - close
1075 1076
 */
struct _virNetworkDriver {
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
        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;
1091
        virDrvNetworkGetXMLDesc		networkGetXMLDesc;
1092 1093 1094
        virDrvNetworkGetBridgeName	networkGetBridgeName;
        virDrvNetworkGetAutostart	networkGetAutostart;
        virDrvNetworkSetAutostart	networkSetAutostart;
1095 1096
        virDrvNetworkIsActive           networkIsActive;
        virDrvNetworkIsPersistent       networkIsPersistent;
1097 1098
};

D
Daniel Veillard 已提交
1099 1100 1101 1102 1103 1104 1105
/*-------*/
typedef int
        (*virDrvNumOfInterfaces)        (virConnectPtr conn);
typedef int
        (*virDrvListInterfaces)         (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
1106 1107 1108 1109 1110 1111
typedef int
        (*virDrvNumOfDefinedInterfaces) (virConnectPtr conn);
typedef int
        (*virDrvListDefinedInterfaces)  (virConnectPtr conn,
                                         char **const names,
                                         int maxnames);
D
Daniel Veillard 已提交
1112 1113 1114 1115 1116 1117 1118 1119
typedef virInterfacePtr
        (*virDrvInterfaceLookupByName)  (virConnectPtr conn,
                                         const char *name);
typedef virInterfacePtr
        (*virDrvInterfaceLookupByMACString)   (virConnectPtr conn,
                                               const char *mac);

typedef char *
1120
        (*virDrvInterfaceGetXMLDesc)    (virInterfacePtr iface,
D
Daniel Veillard 已提交
1121 1122 1123 1124 1125 1126 1127
                                         unsigned int flags);

typedef virInterfacePtr
        (*virDrvInterfaceDefineXML)     (virConnectPtr conn,
                                         const char *xmlDesc,
                                         unsigned int flags);
typedef int
1128
        (*virDrvInterfaceUndefine)      (virInterfacePtr iface);
D
Daniel Veillard 已提交
1129
typedef int
1130
        (*virDrvInterfaceCreate)        (virInterfacePtr iface,
D
Daniel Veillard 已提交
1131 1132
                                         unsigned int flags);
typedef int
1133
        (*virDrvInterfaceDestroy)       (virInterfacePtr iface,
D
Daniel Veillard 已提交
1134 1135
                                         unsigned int flags);

1136 1137 1138
typedef int
        (*virDrvInterfaceIsActive)(virInterfacePtr iface);

1139 1140 1141 1142 1143 1144 1145 1146 1147
typedef int
        (*virDrvInterfaceChangeBegin)   (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeCommit)  (virConnectPtr conn,
                                         unsigned int flags);
typedef int
        (*virDrvInterfaceChangeRollback)(virConnectPtr conn,
                                         unsigned int flags);
1148

D
Daniel Veillard 已提交
1149 1150 1151 1152 1153 1154
typedef struct _virInterfaceDriver virInterfaceDriver;
typedef virInterfaceDriver *virInterfaceDriverPtr;

/**
 * _virInterfaceDriver:
 *
1155
 * Structure associated to a network interface driver, defining the various
D
Daniel Veillard 已提交
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
 * 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;
1168 1169
    virDrvNumOfDefinedInterfaces     numOfDefinedInterfaces;
    virDrvListDefinedInterfaces      listDefinedInterfaces;
D
Daniel Veillard 已提交
1170 1171 1172 1173 1174 1175 1176
    virDrvInterfaceLookupByName      interfaceLookupByName;
    virDrvInterfaceLookupByMACString interfaceLookupByMACString;
    virDrvInterfaceGetXMLDesc        interfaceGetXMLDesc;
    virDrvInterfaceDefineXML         interfaceDefineXML;
    virDrvInterfaceUndefine          interfaceUndefine;
    virDrvInterfaceCreate            interfaceCreate;
    virDrvInterfaceDestroy           interfaceDestroy;
1177
    virDrvInterfaceIsActive          interfaceIsActive;
1178 1179 1180
    virDrvInterfaceChangeBegin       interfaceChangeBegin;
    virDrvInterfaceChangeCommit      interfaceChangeCommit;
    virDrvInterfaceChangeRollback    interfaceChangeRollback;
D
Daniel Veillard 已提交
1181 1182
};

1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195

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);
1196 1197 1198 1199 1200
typedef char *
    (*virDrvConnectFindStoragePoolSources)   (virConnectPtr conn,
                                              const char *type,
                                              const char *srcSpec,
                                              unsigned int flags);
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 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271
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);

1272 1273 1274
typedef int
    (*virDrvStorageVolWipe)                  (virStorageVolPtr vol,
                                              unsigned int flags);
1275 1276 1277 1278
typedef int
    (*virDrvStorageVolWipePattern)           (virStorageVolPtr vol,
                                              unsigned int algorithm,
                                              unsigned int flags);
1279

1280 1281 1282 1283 1284 1285 1286 1287 1288
typedef int
    (*virDrvStorageVolGetInfo)               (virStorageVolPtr vol,
                                              virStorageVolInfoPtr info);
typedef char *
    (*virDrvStorageVolGetXMLDesc)            (virStorageVolPtr pool,
                                              unsigned int flags);
typedef char *
    (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);

1289 1290 1291 1292 1293
typedef virStorageVolPtr
    (*virDrvStorageVolCreateXMLFrom)         (virStoragePoolPtr pool,
                                              const char *xmldesc,
                                              virStorageVolPtr clone,
                                              unsigned int flags);
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305
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);
1306 1307
typedef int
        (*virDrvStorageVolResize) (virStorageVolPtr vol,
E
Eric Blake 已提交
1308
                                   unsigned long long capacity,
1309
                                   unsigned int flags);
1310

1311 1312 1313 1314 1315 1316
typedef int
        (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
typedef int
        (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);


1317 1318 1319 1320 1321 1322 1323

typedef struct _virStorageDriver virStorageDriver;
typedef virStorageDriver *virStorageDriverPtr;

/**
 * _virStorageDriver:
 *
1324
 * Structure associated to a storage driver, defining the various
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
 * 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;
1340
    virDrvConnectFindStoragePoolSources findPoolSources;
1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362
    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;
1363
    virDrvStorageVolCreateXMLFrom volCreateXMLFrom;
1364 1365
    virDrvStorageVolDownload volDownload;
    virDrvStorageVolUpload volUpload;
1366
    virDrvStorageVolDelete volDelete;
1367
    virDrvStorageVolWipe volWipe;
1368
    virDrvStorageVolWipePattern volWipePattern;
1369 1370 1371
    virDrvStorageVolGetInfo volGetInfo;
    virDrvStorageVolGetXMLDesc volGetXMLDesc;
    virDrvStorageVolGetPath volGetPath;
1372
    virDrvStorageVolResize volResize;
1373 1374
    virDrvStoragePoolIsActive   poolIsActive;
    virDrvStoragePoolIsPersistent   poolIsPersistent;
1375 1376
};

1377
# ifdef WITH_LIBVIRTD
1378
typedef int (*virDrvStateInitialize) (int privileged);
1379 1380 1381 1382 1383 1384 1385 1386
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);

typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;

struct _virStateDriver {
1387
    const char *name;
1388 1389 1390 1391 1392
    virDrvStateInitialize  initialize;
    virDrvStateCleanup     cleanup;
    virDrvStateReload      reload;
    virDrvStateActive      active;
};
1393
# endif
1394

1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411

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

1412 1413
typedef char * (*virDevMonDeviceGetXMLDesc)(virNodeDevicePtr dev,
                                            unsigned int flags);
1414 1415 1416 1417 1418 1419 1420 1421 1422

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

typedef int (*virDevMonDeviceNumOfCaps)(virNodeDevicePtr dev);

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

1423 1424 1425 1426 1427
typedef virNodeDevicePtr (*virDrvNodeDeviceCreateXML)(virConnectPtr conn,
                                                      const char *xmlDesc,
                                                      unsigned int flags);
typedef int (*virDrvNodeDeviceDestroy)(virNodeDevicePtr dev);

1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441
/**
 * _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;
1442
    virDevMonDeviceGetXMLDesc deviceGetXMLDesc;
1443 1444 1445
    virDevMonDeviceGetParent deviceGetParent;
    virDevMonDeviceNumOfCaps deviceNumOfCaps;
    virDevMonDeviceListCaps deviceListCaps;
1446 1447
    virDrvNodeDeviceCreateXML deviceCreateXML;
    virDrvNodeDeviceDestroy deviceDestroy;
1448 1449
};

1450 1451
enum {
    /* This getValue call is inside libvirt, override the "private" flag.
E
Eric Blake 已提交
1452
       This flag cannot be set by outside callers. */
1453
    VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 0,
1454 1455
};

1456
typedef virSecretPtr
1457 1458
    (*virDrvSecretLookupByUUID)        (virConnectPtr conn,
                                        const unsigned char *uuid);
1459 1460 1461 1462
typedef virSecretPtr
    (*virDrvSecretLookupByUsage)       (virConnectPtr conn,
                                        int usageType,
                                        const char *usageID);
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477
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,
1478 1479
                                              unsigned int flags,
                                              unsigned int internalFlags);
1480 1481 1482
typedef int
    (*virDrvSecretUndefine)                  (virSecretPtr secret);
typedef int
1483
    (*virDrvNumOfSecrets)              (virConnectPtr conn);
1484
typedef int
1485
    (*virDrvListSecrets)               (virConnectPtr conn,
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506
                                              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;

1507 1508
    virDrvNumOfSecrets numOfSecrets;
    virDrvListSecrets listSecrets;
1509
    virDrvSecretLookupByUUID lookupByUUID;
1510
    virDrvSecretLookupByUsage lookupByUsage;
1511 1512 1513 1514 1515 1516 1517
    virDrvSecretDefineXML defineXML;
    virDrvSecretGetXMLDesc getXMLDesc;
    virDrvSecretSetValue setValue;
    virDrvSecretGetValue getValue;
    virDrvSecretUndefine undefine;
};

1518 1519 1520 1521 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 1552

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 已提交
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566
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 已提交
1567
                                               const char *xmlDesc);
S
Stefan Berger 已提交
1568
typedef int
1569
    (*virDrvNWFilterUndefine)                 (virNWFilterPtr nwfilter);
S
Stefan Berger 已提交
1570 1571

typedef char *
1572
    (*virDrvNWFilterGetXMLDesc)              (virNWFilterPtr nwfilter,
1573
                                              unsigned int flags);
S
Stefan Berger 已提交
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603


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


1604 1605 1606 1607 1608 1609
/*
 * Registration
 * TODO: also need ways to (des)activate a given driver
 *       lookup based on the URI given in a virConnectOpen(ReadOnly)
 */
int virRegisterDriver(virDriverPtr);
1610
int virRegisterNetworkDriver(virNetworkDriverPtr);
D
Daniel Veillard 已提交
1611
int virRegisterInterfaceDriver(virInterfaceDriverPtr);
1612
int virRegisterStorageDriver(virStorageDriverPtr);
1613
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
1614
int virRegisterSecretDriver(virSecretDriverPtr);
S
Stefan Berger 已提交
1615
int virRegisterNWFilterDriver(virNWFilterDriverPtr);
1616
# ifdef WITH_LIBVIRTD
1617
int virRegisterStateDriver(virStateDriverPtr);
1618
# endif
1619
void *virDriverLoadModule(const char *name);
1620 1621

#endif /* __VIR_DRIVER_H__ */