1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
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
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
|
/* -*- c -*-
* libvirt.h:
* Summary: core interfaces for the libvirt library
* Description: Provides the interfaces of the libvirt library to handle
* Xen domains from a process running in domain 0
*
* Copy: Copyright (C) 2005,2006 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Author: Daniel Veillard <veillard@redhat.com>
*/
#ifndef __VIR_VIRLIB_H__
#define __VIR_VIRLIB_H__
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* virConnect:
*
* a virConnect is a private structure representing a connection to
* the Xen Hypervisor.
*/
typedef struct _virConnect virConnect;
/**
* virConnectPtr:
*
* a virConnectPtr is pointer to a virConnect private structure, this is the
* type used to reference a connection to the Xen Hypervisor in the API.
*/
typedef virConnect *virConnectPtr;
/**
* virDomain:
*
* a virDomain is a private structure representing a Xen domain.
*/
typedef struct _virDomain virDomain;
/**
* virDomainPtr:
*
* a virDomainPtr is pointer to a virDomain private structure, this is the
* type used to reference a Xen domain in the API.
*/
typedef virDomain *virDomainPtr;
/**
* virDomainState:
*
* A domain may be in different states at a given point in time
*/
typedef enum {
VIR_DOMAIN_NOSTATE = 0, /* no state */
VIR_DOMAIN_RUNNING = 1, /* the domain is running */
VIR_DOMAIN_BLOCKED = 2, /* the domain is blocked on resource */
VIR_DOMAIN_PAUSED = 3, /* the domain is paused by user */
VIR_DOMAIN_SHUTDOWN= 4, /* the domain is being shut down */
VIR_DOMAIN_SHUTOFF = 5, /* the domain is shut off */
VIR_DOMAIN_CRASHED = 6 /* the domain is crashed */
} virDomainState;
/**
* virDomainInfoPtr:
*
* a virDomainInfo is a structure filled by virDomainGetInfo() and extracting
* runtime information for a given active Domain
*/
typedef struct _virDomainInfo virDomainInfo;
struct _virDomainInfo {
unsigned char state; /* the running state, one of virDomainFlags */
unsigned long maxMem; /* the maximum memory in KBytes allowed */
unsigned long memory; /* the memory in KBytes used by the domain */
unsigned short nrVirtCpu; /* the number of virtual CPUs for the domain */
unsigned long long cpuTime; /* the CPU time used in nanoseconds */
};
/**
* virDomainInfoPtr:
*
* a virDomainInfoPtr is a pointer to a virDomainInfo structure.
*/
typedef virDomainInfo *virDomainInfoPtr;
/**
* virDomainCreateFlags:
*
* Flags OR'ed together to provide specific behaviour when creating a
* Domain.
*/
typedef enum {
VIR_DOMAIN_NONE = 0
} virDomainCreateFlags;
/**
* virNodeInfoPtr:
*
* a virNodeInfo is a structure filled by virNodeGetInfo() and providing
* the information for the Node.
*/
typedef struct _virNodeInfo virNodeInfo;
struct _virNodeInfo {
char model[32]; /* string indicating the CPU model */
unsigned long memory;/* memory size in kilobytes */
unsigned int cpus; /* the number of active CPUs */
unsigned int mhz; /* expected CPU frequency */
unsigned int nodes; /* the number of NUMA cell, 1 for uniform mem access */
unsigned int sockets;/* number of CPU socket per node */
unsigned int cores; /* number of core per socket */
unsigned int threads;/* number of threads per core */
};
/**
* virDomainSchedParameterType:
*
* A scheduler parameter field type
*/
typedef enum {
VIR_DOMAIN_SCHED_FIELD_INT = 1, /* integer case */
VIR_DOMAIN_SCHED_FIELD_UINT = 2, /* unsigned integer case */
VIR_DOMAIN_SCHED_FIELD_LLONG = 3, /* long long case */
VIR_DOMAIN_SCHED_FIELD_ULLONG = 4, /* unsigned long long case */
VIR_DOMAIN_SCHED_FIELD_DOUBLE = 5, /* double case */
VIR_DOMAIN_SCHED_FIELD_BOOLEAN = 6 /* boolean(character) case */
} virSchedParameterType;
/**
* VIR_DOMAIN_SCHED_FIELD_LENGTH:
*
* Macro providing the field length of virSchedParameter
*/
#define VIR_DOMAIN_SCHED_FIELD_LENGTH 80
/**
* virDomainSchedParameter:
*
* a virDomainSchedParameter is the set of scheduler parameters
*/
typedef struct _virSchedParameter virSchedParameter;
struct _virSchedParameter {
char field[VIR_DOMAIN_SCHED_FIELD_LENGTH]; /* parameter name */
int type; /* parameter type */
union {
int i; /* data for integer case */
unsigned int ui; /* data for unsigned integer case */
long long int l; /* data for long long integer case */
unsigned long long int ul; /* data for unsigned long long integer case */
double d; /* data for double case */
char b; /* data for char case */
} value; /* parameter value */
};
/**
* virSchedParameterPtr:
*
* a virSchedParameterPtr is a pointer to a virSchedParameter structure.
*/
typedef virSchedParameter *virSchedParameterPtr;
/*
* Fetch scheduler parameters, caller allocates 'params' field of size 'nparams'
*/
int virDomainGetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int *nparams);
/*
* Change scheduler parameters
*/
int virDomainSetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int nparams);
/**
* virDomainBlockStats:
*
* Block device stats for virDomainBlockStats.
*
* Hypervisors may return a field set to ((long long)-1) which indicates
* that the hypervisor does not support that statistic.
*
* NB. Here 'long long' means 64 bit integer.
*/
typedef struct _virDomainBlockStats virDomainBlockStatsStruct;
struct _virDomainBlockStats {
long long rd_req; /* number of read requests */
long long rd_bytes; /* number of read bytes */
long long wr_req; /* number of write requests */
long long wr_bytes; /* number of written bytes */
long long errs; /* In Xen this returns the mysterious 'oo_req'. */
};
/**
* virDomainBlockStatsPtr:
*
* A pointer to a virDomainBlockStats structure
*/
typedef virDomainBlockStatsStruct *virDomainBlockStatsPtr;
/**
* virDomainInterfaceStats:
*
* Network interface stats for virDomainInterfaceStats.
*
* Hypervisors may return a field set to ((long long)-1) which indicates
* that the hypervisor does not support that statistic.
*
* NB. Here 'long long' means 64 bit integer.
*/
typedef struct _virDomainInterfaceStats virDomainInterfaceStatsStruct;
struct _virDomainInterfaceStats {
long long rx_bytes;
long long rx_packets;
long long rx_errs;
long long rx_drop;
long long tx_bytes;
long long tx_packets;
long long tx_errs;
long long tx_drop;
};
/**
* virDomainInterfaceStatsPtr:
*
* A pointer to a virDomainInterfaceStats structure
*/
typedef virDomainInterfaceStatsStruct *virDomainInterfaceStatsPtr;
/* Domain migration flags. */
typedef enum {
VIR_MIGRATE_LIVE = 1, /* live migration */
} virDomainMigrateFlags;
/* Domain migration. */
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
unsigned long flags, const char *dname,
const char *uri, unsigned long bandwidth);
/**
* VIR_NODEINFO_MAXCPUS:
* @nodeinfo: virNodeInfo instance
*
* This macro is to calculate the total number of CPUs supported
* but not necessary active in the host.
*/
#define VIR_NODEINFO_MAXCPUS(nodeinfo) ((nodeinfo).nodes*(nodeinfo).sockets*(nodeinfo).cores*(nodeinfo).threads)
/**
* virNodeInfoPtr:
*
* a virNodeInfoPtr is a pointer to a virNodeInfo structure.
*/
typedef virNodeInfo *virNodeInfoPtr;
/**
* virConnectFlags
*
* Flags when opening a connection to a hypervisor
*/
typedef enum {
VIR_CONNECT_RO = 1, /* A readonly connection */
} virConnectFlags;
typedef enum {
VIR_CRED_USERNAME = 1, /* Identity to act as */
VIR_CRED_AUTHNAME = 2, /* Identify to authorize as */
VIR_CRED_LANGUAGE = 3, /* RFC 1766 languages, comma separated */
VIR_CRED_CNONCE = 4, /* client supplies a nonce */
VIR_CRED_PASSPHRASE = 5, /* Passphrase secret */
VIR_CRED_ECHOPROMPT = 6, /* Challenge response */
VIR_CRED_NOECHOPROMPT = 7, /* Challenge response */
VIR_CRED_REALM = 8, /* Authentication realm */
VIR_CRED_EXTERNAL = 9, /* Externally managed credential */
/* More may be added - expect the unexpected */
} virConnectCredentialType;
struct _virConnectCredential {
int type; /* One of virConnectCredentialType constants */
const char *prompt; /* Prompt to show to user */
const char *challenge; /* Additional challenge to show */
const char *defresult; /* Optional default result */
char *result; /* Result to be filled with user response (or defresult) */
unsigned int resultlen; /* Length of the result */
};
typedef struct _virConnectCredential virConnectCredential;
typedef virConnectCredential *virConnectCredentialPtr;
/**
* virConnectCredCallbackPtr
*
* @param authtype type of authentication being performed
* @param cred list of virConnectCredential object to fetch from user
* @param ncred size of cred list
* @param cbdata opaque data passed to virConnectOpenAuth
*
* When authentication requires one or more interactions, this callback
* is invoked. For each interaction supplied, data must be gathered
* from the user and filled in to the 'result' and 'resultlen' fields.
* If an interaction can not be filled, fill in NULL and 0.
*
* Return 0 if all interactions were filled, or -1 upon error
*/
typedef int (*virConnectAuthCallbackPtr)(virConnectCredentialPtr cred,
unsigned int ncred,
void *cbdata);
struct _virConnectAuth {
int *credtype; /* List of supported virConnectCredentialType values */
unsigned int ncredtype;
virConnectAuthCallbackPtr cb; /* Callback used to collect credentials */
void *cbdata;
};
typedef struct _virConnectAuth virConnectAuth;
typedef virConnectAuth *virConnectAuthPtr;
extern virConnectAuthPtr virConnectAuthPtrDefault;
/**
* VIR_UUID_BUFLEN:
*
* This macro provides the length of the buffer required
* for virDomainGetUUID()
*/
#define VIR_UUID_BUFLEN (16)
/**
* VIR_UUID_STRING_BUFLEN:
*
* This macro provides the length of the buffer required
* for virDomainGetUUIDString()
*/
#define VIR_UUID_STRING_BUFLEN (36+1)
/* library versionning */
/**
* LIBVIR_VERSION_NUMBER:
*
* Macro providing the version of the library as
* version * 1,000,000 + minor * 1000 + micro
*/
#define LIBVIR_VERSION_NUMBER 4001
int virGetVersion (unsigned long *libVer,
const char *type,
unsigned long *typeVer);
/*
* Connection and disconnections to the Hypervisor
*/
int virInitialize (void);
virConnectPtr virConnectOpen (const char *name);
virConnectPtr virConnectOpenReadOnly (const char *name);
virConnectPtr virConnectOpenAuth (const char *name,
virConnectAuthPtr auth,
int flags);
int virConnectClose (virConnectPtr conn);
const char * virConnectGetType (virConnectPtr conn);
int virConnectGetVersion (virConnectPtr conn,
unsigned long *hvVer);
char * virConnectGetHostname (virConnectPtr conn);
char * virConnectGetURI (virConnectPtr conn);
/*
* Capabilities of the connection / driver.
*/
int virConnectGetMaxVcpus (virConnectPtr conn,
const char *type);
int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
/*
* Gather list of running domains
*/
int virConnectListDomains (virConnectPtr conn,
int *ids,
int maxids);
/*
* Number of domains
*/
int virConnectNumOfDomains (virConnectPtr conn);
/*
* Get connection from domain.
*/
virConnectPtr virDomainGetConnect (virDomainPtr domain);
/*
* Domain creation and destruction
*/
virDomainPtr virDomainCreateLinux (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
virDomainPtr virDomainLookupByName (virConnectPtr conn,
const char *name);
virDomainPtr virDomainLookupByID (virConnectPtr conn,
int id);
virDomainPtr virDomainLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
const char *uuid);
int virDomainShutdown (virDomainPtr domain);
int virDomainReboot (virDomainPtr domain,
unsigned int flags);
int virDomainDestroy (virDomainPtr domain);
int virDomainFree (virDomainPtr domain);
/*
* Domain suspend/resume
*/
int virDomainSuspend (virDomainPtr domain);
int virDomainResume (virDomainPtr domain);
/*
* Domain save/restore
*/
int virDomainSave (virDomainPtr domain,
const char *to);
int virDomainRestore (virConnectPtr conn,
const char *from);
/*
* Domain core dump
*/
int virDomainCoreDump (virDomainPtr domain,
const char *to,
int flags);
/*
* Domain runtime information
*/
int virDomainGetInfo (virDomainPtr domain,
virDomainInfoPtr info);
/*
* Return scheduler type in effect 'sedf', 'credit', 'linux'
*/
char * virDomainGetSchedulerType(virDomainPtr domain,
int *nparams);
/*
* Dynamic control of domains
*/
const char * virDomainGetName (virDomainPtr domain);
unsigned int virDomainGetID (virDomainPtr domain);
int virDomainGetUUID (virDomainPtr domain,
unsigned char *uuid);
int virDomainGetUUIDString (virDomainPtr domain,
char *buf);
char * virDomainGetOSType (virDomainPtr domain);
unsigned long virDomainGetMaxMemory (virDomainPtr domain);
int virDomainSetMaxMemory (virDomainPtr domain,
unsigned long memory);
int virDomainSetMemory (virDomainPtr domain,
unsigned long memory);
int virDomainGetMaxVcpus (virDomainPtr domain);
/*
* XML domain description
*/
/**
* virDomainXMLFlags:
*
* Flags available for virDomainGetXMLDesc
*/
typedef enum {
VIR_DOMAIN_XML_SECURE = 1, /* dump security sensitive information too */
VIR_DOMAIN_XML_INACTIVE = 2/* dump inactive domain information */
} virDomainXMLFlags;
char * virDomainGetXMLDesc (virDomainPtr domain,
int flags);
int virDomainBlockStats (virDomainPtr dom,
const char *path,
virDomainBlockStatsPtr stats,
size_t size);
int virDomainInterfaceStats (virDomainPtr dom,
const char *path,
virDomainInterfaceStatsPtr stats,
size_t size);
/*
* defined but not running domains
*/
virDomainPtr virDomainDefineXML (virConnectPtr conn,
const char *xml);
int virDomainUndefine (virDomainPtr domain);
int virConnectNumOfDefinedDomains (virConnectPtr conn);
int virConnectListDefinedDomains (virConnectPtr conn,
char **const names,
int maxnames);
int virDomainCreate (virDomainPtr domain);
int virDomainGetAutostart (virDomainPtr domain,
int *autostart);
int virDomainSetAutostart (virDomainPtr domain,
int autostart);
/**
* virVcpuInfo: structure for information about a virtual CPU in a domain.
*/
typedef enum {
VIR_VCPU_OFFLINE = 0, /* the virtual CPU is offline */
VIR_VCPU_RUNNING = 1, /* the virtual CPU is running */
VIR_VCPU_BLOCKED = 2, /* the virtual CPU is blocked on resource */
} virVcpuState;
typedef struct _virVcpuInfo virVcpuInfo;
struct _virVcpuInfo {
unsigned int number; /* virtual CPU number */
int state; /* value from virVcpuState */
unsigned long long cpuTime; /* CPU time used, in nanoseconds */
int cpu; /* real CPU number, or -1 if offline */
};
typedef virVcpuInfo *virVcpuInfoPtr;
int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus);
int virDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
/**
* VIR_USE_CPU:
* @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN/OUT)
* @cpu: the physical CPU number
*
* This macro is to be used in conjunction with virDomainPinVcpu() API.
* USE_CPU macro set the bit (CPU usable) of the related cpu in cpumap.
*/
#define VIR_USE_CPU(cpumap,cpu) (cpumap[(cpu)/8] |= (1<<((cpu)%8)))
/**
* VIR_UNUSE_CPU:
* @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN/OUT)
* @cpu: the physical CPU number
*
* This macro is to be used in conjunction with virDomainPinVcpu() API.
* USE_CPU macro reset the bit (CPU not usable) of the related cpu in cpumap.
*/
#define VIR_UNUSE_CPU(cpumap,cpu) (cpumap[(cpu)/8] &= ~(1<<((cpu)%8)))
/**
* VIR_CPU_MAPLEN:
* @cpu: number of physical CPUs
*
* This macro is to be used in conjunction with virDomainPinVcpu() API.
* It returns the length (in bytes) required to store the complete
* CPU map between a single virtual & all physical CPUs of a domain.
*/
#define VIR_CPU_MAPLEN(cpu) (((cpu)+7)/8)
int virDomainGetVcpus (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
/**
* VIR_CPU_USABLE:
* @cpumaps: pointer to an array of cpumap (in 8-bit bytes) (IN)
* @maplen: the length (in bytes) of one cpumap
* @vcpu: the virtual CPU number
* @cpu: the physical CPU number
*
* This macro is to be used in conjunction with virDomainGetVcpus() API.
* VIR_CPU_USABLE macro returns a non zero value (true) if the cpu
* is usable by the vcpu, and 0 otherwise.
*/
#define VIR_CPU_USABLE(cpumaps,maplen,vcpu,cpu) \
(cpumaps[((vcpu)*(maplen))+((cpu)/8)] & (1<<((cpu)%8)))
/**
* VIR_COPY_CPUMAP:
* @cpumaps: pointer to an array of cpumap (in 8-bit bytes) (IN)
* @maplen: the length (in bytes) of one cpumap
* @vcpu: the virtual CPU number
* @cpumap: pointer to a cpumap (in 8-bit bytes) (OUT)
* This cpumap must be previously allocated by the caller
* (ie: malloc(maplen))
*
* This macro is to be used in conjunction with virDomainGetVcpus() and
* virDomainPinVcpu() APIs. VIR_COPY_CPUMAP macro extract the cpumap of
* the specified vcpu from cpumaps array and copy it into cpumap to be used
* later by virDomainPinVcpu() API.
*/
#define VIR_COPY_CPUMAP(cpumaps,maplen,vcpu,cpumap) \
memcpy(cpumap, &(cpumaps[(vcpu)*(maplen)]), (maplen))
/**
* VIR_GET_CPUMAP:
* @cpumaps: pointer to an array of cpumap (in 8-bit bytes) (IN)
* @maplen: the length (in bytes) of one cpumap
* @vcpu: the virtual CPU number
*
* This macro is to be used in conjunction with virDomainGetVcpus() and
* virDomainPinVcpu() APIs. VIR_GET_CPUMAP macro returns a pointer to the
* cpumap of the specified vcpu from cpumaps array.
*/
#define VIR_GET_CPUMAP(cpumaps,maplen,vcpu) &(cpumaps[(vcpu)*(maplen)])
int virDomainAttachDevice(virDomainPtr domain, const char *xml);
int virDomainDetachDevice(virDomainPtr domain, const char *xml);
/*
* NUMA support
*/
int virNodeGetCellsFreeMemory(virConnectPtr conn,
unsigned long long *freeMems,
int startCell,
int maxCells);
/*
* Virtual Networks API
*/
/**
* virNetwork:
*
* a virNetwork is a private structure representing a virtual network.
*/
typedef struct _virNetwork virNetwork;
/**
* virNetworkPtr:
*
* a virNetworkPtr is pointer to a virNetwork private structure, this is the
* type used to reference a virtual network in the API.
*/
typedef virNetwork *virNetworkPtr;
/*
* Get connection from network.
*/
virConnectPtr virNetworkGetConnect (virNetworkPtr network);
/*
* List active networks
*/
int virConnectNumOfNetworks (virConnectPtr conn);
int virConnectListNetworks (virConnectPtr conn,
char **const names,
int maxnames);
/*
* List inactive networks
*/
int virConnectNumOfDefinedNetworks (virConnectPtr conn);
int virConnectListDefinedNetworks (virConnectPtr conn,
char **const names,
int maxnames);
/*
* Lookup network by name or uuid
*/
virNetworkPtr virNetworkLookupByName (virConnectPtr conn,
const char *name);
virNetworkPtr virNetworkLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
virNetworkPtr virNetworkLookupByUUIDString (virConnectPtr conn,
const char *uuid);
/*
* Create active transient network
*/
virNetworkPtr virNetworkCreateXML (virConnectPtr conn,
const char *xmlDesc);
/*
* Define inactive persistent network
*/
virNetworkPtr virNetworkDefineXML (virConnectPtr conn,
const char *xmlDesc);
/*
* Delete persistent network
*/
int virNetworkUndefine (virNetworkPtr network);
/*
* Activate persistent network
*/
int virNetworkCreate (virNetworkPtr network);
/*
* Network destroy/free
*/
int virNetworkDestroy (virNetworkPtr network);
int virNetworkFree (virNetworkPtr network);
/*
* Network information
*/
const char* virNetworkGetName (virNetworkPtr network);
int virNetworkGetUUID (virNetworkPtr network,
unsigned char *uuid);
int virNetworkGetUUIDString (virNetworkPtr network,
char *buf);
char * virNetworkGetXMLDesc (virNetworkPtr network,
int flags);
char * virNetworkGetBridgeName (virNetworkPtr network);
int virNetworkGetAutostart (virNetworkPtr network,
int *autostart);
int virNetworkSetAutostart (virNetworkPtr network,
int autostart);
/**
* virStoragePool:
*
* a virStoragePool is a private structure representing a storage pool
*/
typedef struct _virStoragePool virStoragePool;
/**
* virStoragePoolPtr:
*
* a virStoragePoolPtr is pointer to a virStoragePool private structure, this is the
* type used to reference a storage pool in the API.
*/
typedef virStoragePool *virStoragePoolPtr;
typedef enum {
VIR_STORAGE_POOL_INACTIVE = 0, /* Not running */
VIR_STORAGE_POOL_BUILDING = 1, /* Initializing pool, not available */
VIR_STORAGE_POOL_RUNNING = 2, /* Running normally */
VIR_STORAGE_POOL_DEGRADED = 3, /* Running degraded */
} virStoragePoolState;
typedef enum {
VIR_STORAGE_POOL_BUILD_NEW = 0, /* Regular build from scratch */
VIR_STORAGE_POOL_BUILD_REPAIR = 1, /* Repair / reinitialize */
VIR_STORAGE_POOL_BUILD_RESIZE = 2 /* Extend existing pool */
} virStoragePoolBuildFlags;
typedef enum {
VIR_STORAGE_POOL_DELETE_NORMAL = 0, /* Delete metadata only (fast) */
VIR_STORAGE_POOL_DELETE_ZEROED = 1, /* Clear all data to zeros (slow) */
} virStoragePoolDeleteFlags;
typedef struct _virStoragePoolInfo virStoragePoolInfo;
struct _virStoragePoolInfo {
int state; /* virStoragePoolState flags */
unsigned long long capacity; /* Logical size bytes */
unsigned long long allocation; /* Current allocation bytes */
unsigned long long available; /* Remaining free space bytes */
};
typedef virStoragePoolInfo *virStoragePoolInfoPtr;
/**
* virStorageVol:
*
* a virStorageVol is a private structure representing a storage volume
*/
typedef struct _virStorageVol virStorageVol;
/**
* virStorageVolPtr:
*
* a virStorageVolPtr is pointer to a virStorageVol private structure, this is the
* type used to reference a storage volume in the API.
*/
typedef virStorageVol *virStorageVolPtr;
typedef enum {
VIR_STORAGE_VOL_FILE = 0, /* Regular file based volumes */
VIR_STORAGE_VOL_BLOCK = 1, /* Block based volumes */
} virStorageVolType;
typedef enum {
VIR_STORAGE_VOL_DELETE_NORMAL = 0, /* Delete metadata only (fast) */
VIR_STORAGE_VOL_DELETE_ZEROED = 1, /* Clear all data to zeros (slow) */
} virStorageVolDeleteFlags;
typedef struct _virStorageVolInfo virStorageVolInfo;
struct _virStorageVolInfo {
int type; /* virStorageVolType flags */
unsigned long long capacity; /* Logical size bytes */
unsigned long long allocation; /* Current allocation bytes */
};
typedef virStorageVolInfo *virStorageVolInfoPtr;
/*
* Get connection from pool.
*/
virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool);
/*
* List active storage pools
*/
int virConnectNumOfStoragePools (virConnectPtr conn);
int virConnectListStoragePools (virConnectPtr conn,
char **const names,
int maxnames);
/*
* List inactive storage pools
*/
int virConnectNumOfDefinedStoragePools(virConnectPtr conn);
int virConnectListDefinedStoragePools(virConnectPtr conn,
char **const names,
int maxnames);
/*
* Lookup pool by name or uuid
*/
virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn,
const char *name);
virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
virStoragePoolPtr virStoragePoolLookupByUUIDString(virConnectPtr conn,
const char *uuid);
virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol);
/*
* Creating/destroying pools
*/
virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
int virStoragePoolBuild (virStoragePoolPtr pool,
unsigned int flags);
int virStoragePoolUndefine (virStoragePoolPtr pool);
int virStoragePoolCreate (virStoragePoolPtr pool,
unsigned int flags);
int virStoragePoolDestroy (virStoragePoolPtr pool);
int virStoragePoolDelete (virStoragePoolPtr pool,
unsigned int flags);
int virStoragePoolFree (virStoragePoolPtr pool);
int virStoragePoolRefresh (virStoragePoolPtr pool,
unsigned int flags);
/*
* StoragePool information
*/
const char* virStoragePoolGetName (virStoragePoolPtr pool);
int virStoragePoolGetUUID (virStoragePoolPtr pool,
unsigned char *uuid);
int virStoragePoolGetUUIDString (virStoragePoolPtr pool,
char *buf);
int virStoragePoolGetInfo (virStoragePoolPtr vol,
virStoragePoolInfoPtr info);
char * virStoragePoolGetXMLDesc (virStoragePoolPtr pool,
unsigned int flags);
int virStoragePoolGetAutostart (virStoragePoolPtr pool,
int *autostart);
int virStoragePoolSetAutostart (virStoragePoolPtr pool,
int autostart);
/*
* List/lookup storage volumes within a pool
*/
int virStoragePoolNumOfVolumes (virStoragePoolPtr pool);
int virStoragePoolListVolumes (virStoragePoolPtr pool,
char **const names,
int maxnames);
virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol);
/*
* Lookup volumes based on various attributes
*/
virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool,
const char *name);
virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn,
const char *key);
virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn,
const char *path);
const char* virStorageVolGetName (virStorageVolPtr vol);
const char* virStorageVolGetKey (virStorageVolPtr vol);
virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
const char *xmldesc,
unsigned int flags);
int virStorageVolDelete (virStorageVolPtr vol,
unsigned int flags);
int virStorageVolFree (virStorageVolPtr vol);
int virStorageVolGetInfo (virStorageVolPtr vol,
virStorageVolInfoPtr info);
char * virStorageVolGetXMLDesc (virStorageVolPtr pool,
unsigned int flags);
char * virStorageVolGetPath (virStorageVolPtr vol);
#ifdef __cplusplus
}
#endif
#endif /* __VIR_VIRLIB_H__ */
|