libvirt_ffi 0.6.1 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,6 +56,24 @@ module Libvirt
56
56
  FFI::Domain.virDomainGetMaxVcpus(@dom_ptr)
57
57
  end
58
58
 
59
+ # @return [Boolean]
60
+ # @raise [Libvirt::Errors::LibError]
61
+ def auto_start
62
+ value = ::FFI::MemoryPointer.new(:int)
63
+ result = FFI::Domain.virDomainGetAutostart(@dom_ptr, value)
64
+ raise Errors::LibError, "Couldn't get domain auto_start" if result.negative?
65
+
66
+ value.read_int == 1
67
+ end
68
+
69
+ # @param value [Boolean]
70
+ # @raise [Libvirt::Errors::LibError]
71
+ def set_auto_start(value)
72
+ value = value ? 1 : 0
73
+ result = FFI::Domain.virDomainSetAutostart(@dom_ptr, value)
74
+ raise Errors::LibError, "Couldn't set domain auto_start" if result.negative?
75
+ end
76
+
59
77
  # def vcpus
60
78
  # # https://github.com/libvirt/ruby-libvirt/blob/9f71ff5add1f57ffef7cf513b72638d92d9fd84f/ext/libvirt/domain.c#L787
61
79
  # # dominfo = virDomainGetInfo
@@ -290,17 +290,17 @@ module Libvirt
290
290
  :MIGRATABLE, 0x8 # dump XML suitable for migration
291
291
  ]
292
292
 
293
- # int virDomainFree (
293
+ # int virDomainFree (
294
294
  # virDomainPtr domain
295
295
  # )
296
296
  attach_function :virDomainFree, [:pointer], :int
297
297
 
298
- # int virDomainRef (
298
+ # int virDomainRef (
299
299
  # virDomainPtr domain
300
300
  # )
301
301
  attach_function :virDomainRef, [:pointer], :int
302
302
 
303
- # int virConnectDomainEventRegisterAny(
303
+ # int virConnectDomainEventRegisterAny(
304
304
  # virConnectPtr conn,
305
305
  # virDomainPtr dom,
306
306
  # int eventID,
@@ -317,20 +317,20 @@ module Libvirt
317
317
  :pointer
318
318
  ], :int
319
319
 
320
- # int virConnectDomainEventDeregisterAny (
320
+ # int virConnectDomainEventDeregisterAny (
321
321
  # virConnectPtr conn,
322
322
  # int callbackID
323
323
  # )
324
324
  attach_function :virConnectDomainEventDeregisterAny, [:pointer, :int], :int
325
325
 
326
- # int virConnectListAllDomains (
326
+ # int virConnectListAllDomains (
327
327
  # virConnectPtr conn,
328
328
  # virDomainPtr **domains,
329
329
  # unsigned int flags
330
330
  # )
331
331
  attach_function :virConnectListAllDomains, [:pointer, :pointer, :uint], :int
332
332
 
333
- # int virDomainGetState (
333
+ # int virDomainGetState (
334
334
  # virDomainPtr domain,
335
335
  # int *state,
336
336
  # int *reason,
@@ -343,12 +343,12 @@ module Libvirt
343
343
  # )
344
344
  attach_function :virDomainGetName, [:pointer], :string
345
345
 
346
- # int virDomainGetMaxVcpus (
346
+ # int virDomainGetMaxVcpus (
347
347
  # virDomainPtr domain
348
348
  # )
349
349
  attach_function :virDomainGetMaxVcpus, [:pointer], :int
350
350
 
351
- # int virDomainGetVcpus (
351
+ # int virDomainGetVcpus (
352
352
  # virDomainPtr domain,
353
353
  # virVcpuInfoPtr info,
354
354
  # int maxinfo,
@@ -357,18 +357,18 @@ module Libvirt
357
357
  # )
358
358
  attach_function :virDomainGetVcpus, [:pointer, :pointer, :int, :pointer, :int], :int
359
359
 
360
- # int virDomainGetUUIDString (
360
+ # int virDomainGetUUIDString (
361
361
  # virDomainPtr domain,
362
362
  # char * buf
363
363
  # )
364
364
  attach_function :virDomainGetUUIDString, [:pointer, :pointer], :int
365
365
 
366
- # unsigned long virDomainGetMaxMemory (
366
+ # unsigned long virDomainGetMaxMemory (
367
367
  # virDomainPtr domain
368
368
  # )
369
369
  attach_function :virDomainGetMaxMemory, [:pointer], :ulong
370
370
 
371
- # char *virDomainGetXMLDesc (
371
+ # char *virDomainGetXMLDesc (
372
372
  # virDomainPtr domain,
373
373
  # unsigned int flags
374
374
  # )
@@ -382,7 +382,7 @@ module Libvirt
382
382
  # )
383
383
  attach_function :virDomainScreenshot, [:pointer, :pointer, :uint, :uint], :strptr
384
384
 
385
- # typedef int (*virConnectDomainEventCallback) (
385
+ # typedef int (*virConnectDomainEventCallback) (
386
386
  # virConnectPtr conn,
387
387
  # virDomainPtr dom,
388
388
  # int event,
@@ -411,7 +411,7 @@ module Libvirt
411
411
  :pointer
412
412
  ], :void
413
413
 
414
- # typedef void (*virConnectDomainEventWatchdogCallback) (
414
+ # typedef void (*virConnectDomainEventWatchdogCallback) (
415
415
  # virConnectPtr conn,
416
416
  # virDomainPtr dom,
417
417
  # int action,
@@ -441,7 +441,7 @@ module Libvirt
441
441
  :pointer
442
442
  ], :void
443
443
 
444
- # typedef void (*virConnectDomainEventGraphicsCallback) (
444
+ # typedef void (*virConnectDomainEventGraphicsCallback) (
445
445
  # virConnectPtr conn,
446
446
  # virDomainPtr dom,
447
447
  # int phase,
@@ -462,7 +462,7 @@ module Libvirt
462
462
  :pointer
463
463
  ], :void
464
464
 
465
- # typedef void (*virConnectDomainEventIOErrorReasonCallback) (
465
+ # typedef void (*virConnectDomainEventIOErrorReasonCallback) (
466
466
  # virConnectPtr conn,
467
467
  # virDomainPtr dom,
468
468
  # const char * srcPath,
@@ -481,7 +481,7 @@ module Libvirt
481
481
  :pointer
482
482
  ], :void
483
483
 
484
- # typedef void (*virConnectDomainEventBlockJobCallback) (
484
+ # typedef void (*virConnectDomainEventBlockJobCallback) (
485
485
  # virConnectPtr conn,
486
486
  # virDomainPtr dom,
487
487
  # const char * disk,
@@ -498,7 +498,7 @@ module Libvirt
498
498
  :pointer
499
499
  ], :void
500
500
 
501
- # typedef void (*virConnectDomainEventDiskChangeCallback) (
501
+ # typedef void (*virConnectDomainEventDiskChangeCallback) (
502
502
  # virConnectPtr conn,
503
503
  # virDomainPtr dom,
504
504
  # const char * oldSrcPath,
@@ -517,7 +517,7 @@ module Libvirt
517
517
  :pointer
518
518
  ], :void
519
519
 
520
- # typedef void (*virConnectDomainEventTrayChangeCallback) (
520
+ # typedef void (*virConnectDomainEventTrayChangeCallback) (
521
521
  # virConnectPtr conn,
522
522
  # virDomainPtr dom,
523
523
  # const char * devAlias,
@@ -532,7 +532,7 @@ module Libvirt
532
532
  :pointer
533
533
  ], :void
534
534
 
535
- # typedef void (*virConnectDomainEventPMWakeupCallback) (
535
+ # typedef void (*virConnectDomainEventPMWakeupCallback) (
536
536
  # virConnectPtr conn,
537
537
  # virDomainPtr dom,
538
538
  # int reason,
@@ -545,7 +545,7 @@ module Libvirt
545
545
  :pointer
546
546
  ], :void
547
547
 
548
- # typedef void (*virConnectDomainEventPMSuspendCallback) (
548
+ # typedef void (*virConnectDomainEventPMSuspendCallback) (
549
549
  # virConnectPtr conn,
550
550
  # virDomainPtr dom,
551
551
  # int reason,
@@ -558,7 +558,7 @@ module Libvirt
558
558
  :pointer
559
559
  ], :void
560
560
 
561
- # typedef void (*virConnectDomainEventBalloonChangeCallback) (
561
+ # typedef void (*virConnectDomainEventBalloonChangeCallback) (
562
562
  # virConnectPtr conn,
563
563
  # virDomainPtr dom,
564
564
  # unsigned long long actual,
@@ -571,7 +571,7 @@ module Libvirt
571
571
  :pointer
572
572
  ], :void
573
573
 
574
- # typedef void (*virConnectDomainEventPMSuspendDiskCallback) (
574
+ # typedef void (*virConnectDomainEventPMSuspendDiskCallback) (
575
575
  # virConnectPtr conn,
576
576
  # virDomainPtr dom,
577
577
  # int reason,
@@ -584,7 +584,7 @@ module Libvirt
584
584
  :pointer
585
585
  ], :void
586
586
 
587
- # typedef void (*virConnectDomainEventDeviceRemovedCallback) (
587
+ # typedef void (*virConnectDomainEventDeviceRemovedCallback) (
588
588
  # virConnectPtr conn,
589
589
  # virDomainPtr dom,
590
590
  # const char * devAlias,
@@ -597,7 +597,7 @@ module Libvirt
597
597
  :pointer
598
598
  ], :void
599
599
 
600
- # typedef void (*virConnectDomainEventTunableCallback) (
600
+ # typedef void (*virConnectDomainEventTunableCallback) (
601
601
  # virConnectPtr conn,
602
602
  # virDomainPtr dom,
603
603
  # virTypedParameterPtr params,
@@ -612,7 +612,7 @@ module Libvirt
612
612
  :pointer
613
613
  ], :void
614
614
 
615
- # typedef void (*virConnectDomainEventAgentLifecycleCallback) (
615
+ # typedef void (*virConnectDomainEventAgentLifecycleCallback) (
616
616
  # virConnectPtr conn,
617
617
  # virDomainPtr dom,
618
618
  # int state,
@@ -627,7 +627,7 @@ module Libvirt
627
627
  :pointer
628
628
  ], :void
629
629
 
630
- # typedef void (*virConnectDomainEventDeviceAddedCallback) (
630
+ # typedef void (*virConnectDomainEventDeviceAddedCallback) (
631
631
  # virConnectPtr conn,
632
632
  # virDomainPtr dom,
633
633
  # const char * devAlias,
@@ -640,7 +640,7 @@ module Libvirt
640
640
  :pointer
641
641
  ], :void
642
642
 
643
- # typedef void (*virConnectDomainEventMigrationIterationCallback) (
643
+ # typedef void (*virConnectDomainEventMigrationIterationCallback) (
644
644
  # virConnectPtr conn,
645
645
  # virDomainPtr dom,
646
646
  # int iteration,
@@ -653,7 +653,7 @@ module Libvirt
653
653
  :pointer
654
654
  ], :void
655
655
 
656
- # typedef void (*virConnectDomainEventJobCompletedCallback) (
656
+ # typedef void (*virConnectDomainEventJobCompletedCallback) (
657
657
  # virConnectPtr conn,
658
658
  # virDomainPtr dom,
659
659
  # virTypedParameterPtr params,
@@ -668,7 +668,7 @@ module Libvirt
668
668
  :pointer
669
669
  ], :void
670
670
 
671
- # typedef void (*virConnectDomainEventDeviceRemovalFailedCallback) (
671
+ # typedef void (*virConnectDomainEventDeviceRemovalFailedCallback) (
672
672
  # virConnectPtr conn,
673
673
  # virDomainPtr dom,
674
674
  # const char * devAlias,
@@ -681,7 +681,7 @@ module Libvirt
681
681
  :pointer
682
682
  ], :void
683
683
 
684
- # typedef void (*virConnectDomainEventMetadataChangeCallback) (
684
+ # typedef void (*virConnectDomainEventMetadataChangeCallback) (
685
685
  # virConnectPtr conn,
686
686
  # virDomainPtr dom,
687
687
  # int type,
@@ -696,7 +696,7 @@ module Libvirt
696
696
  :pointer
697
697
  ], :void
698
698
 
699
- # typedef void (*virConnectDomainEventBlockThresholdCallback) (
699
+ # typedef void (*virConnectDomainEventBlockThresholdCallback) (
700
700
  # virConnectPtr conn,
701
701
  # virDomainPtr dom,
702
702
  # const char * dev,
@@ -715,53 +715,53 @@ module Libvirt
715
715
  :pointer
716
716
  ], :void
717
717
 
718
- # int virDomainReboot (
718
+ # int virDomainReboot (
719
719
  # virDomainPtr domain,
720
720
  # unsigned int flags
721
721
  # )
722
722
  attach_function :virDomainReboot, [:pointer, :uint], :int
723
723
 
724
- # int virDomainShutdownFlags (
724
+ # int virDomainShutdownFlags (
725
725
  # virDomainPtr domain,
726
726
  # unsigned int flags
727
727
  # )
728
728
  attach_function :virDomainShutdownFlags, [:pointer, :shutdown_flags], :int
729
729
 
730
- # int virDomainDestroyFlags (
730
+ # int virDomainDestroyFlags (
731
731
  # virDomainPtr domain,
732
732
  # unsigned int flags
733
733
  # )
734
734
  attach_function :virDomainDestroyFlags, [:pointer, :uint], :int
735
735
 
736
- # int virDomainReset (
736
+ # int virDomainReset (
737
737
  # virDomainPtr domain,
738
738
  # unsigned int flags
739
739
  # )
740
740
  attach_function :virDomainReset, [:pointer, :uint], :int
741
741
 
742
- # int virDomainSuspend (
742
+ # int virDomainSuspend (
743
743
  # virDomainPtr domain
744
744
  # )
745
745
  attach_function :virDomainSuspend, [:pointer], :int
746
746
 
747
- # int virDomainResume (
747
+ # int virDomainResume (
748
748
  # virDomainPtr domain
749
749
  # )
750
750
  attach_function :virDomainResume, [:pointer], :int
751
751
 
752
- # int virDomainCreateWithFlags (
752
+ # int virDomainCreateWithFlags (
753
753
  # virDomainPtr domain,
754
754
  # unsigned int flags
755
755
  # )
756
756
  attach_function :virDomainCreateWithFlags, [:pointer, :uint], :int
757
757
 
758
- # int virDomainManagedSave (
758
+ # int virDomainManagedSave (
759
759
  # virDomainPtr dom,
760
760
  # unsigned int flags
761
761
  # )
762
762
  attach_function :virDomainManagedSave, [:pointer, :save_restore_flags], :int
763
763
 
764
- # int virDomainUndefineFlags (
764
+ # int virDomainUndefineFlags (
765
765
  # virDomainPtr domain,
766
766
  # unsigned int flags
767
767
  # )
@@ -774,7 +774,7 @@ module Libvirt
774
774
  # )
775
775
  attach_function :virDomainDefineXMLFlags, [:pointer, :string, :uint], :pointer
776
776
 
777
- # int virDomainSetMetadata (
777
+ # int virDomainSetMetadata (
778
778
  # virDomainPtr domain,
779
779
  # int type,
780
780
  # const char * metadata,
@@ -801,6 +801,18 @@ module Libvirt
801
801
  # )
802
802
  attach_function :virDomainIsPersistent, [:pointer], :int
803
803
 
804
+ # int virDomainGetAutostart (
805
+ # virDomainPtr domain,
806
+ # int * autostart
807
+ # )
808
+ attach_function :virDomainGetAutostart, [:pointer, :pointer], :int
809
+
810
+ # int virDomainSetAutostart (
811
+ # virDomainPtr domain,
812
+ # int autostart
813
+ # )
814
+ attach_function :virDomainSetAutostart, [:pointer, :int], :int
815
+
804
816
  # Converts detail from lifecycle callback from integer to symbol name.
805
817
  # @param event [Symbol] enum :event_type (virDomainEventType)
806
818
  # @param detail [Integer]
@@ -33,103 +33,142 @@ module Libvirt
33
33
 
34
34
  # enum virConnectCloseReason
35
35
  enum :close_reason, [
36
- :ERROR, 0x0, # Misc I/O error
37
- :EOF, 0x1, # End-of-file from server
38
- :KEEPALIVE, 0x2, # Keepalive timer triggered
39
- :CLIENT, 0x3 # Client requested it
36
+ :ERROR, 0x0, # Misc I/O error
37
+ :EOF, 0x1, # End-of-file from server
38
+ :KEEPALIVE, 0x2, # Keepalive timer triggered
39
+ :CLIENT, 0x3 # Client requested it
40
40
  ]
41
41
 
42
- # int virGetVersion (
42
+ # int virGetVersion (
43
43
  # unsigned long *libVer,
44
44
  # const char *type,
45
45
  # unsigned long *typeVer
46
46
  # )
47
- attach_function :virGetVersion, [:pointer, :string, :pointer], :int
47
+ attach_function :virGetVersion,
48
+ [:pointer, :string, :pointer],
49
+ :int
48
50
 
49
- # int virNodeGetInfo (
51
+ # int virNodeGetInfo (
50
52
  # virConnectPtr conn,
51
53
  # virNodeInfoPtr info
52
54
  # )
53
- attach_function :virNodeGetInfo, [:pointer, :pointer], :int
55
+ attach_function :virNodeGetInfo,
56
+ [:pointer, :pointer],
57
+ :int
54
58
 
55
- # typedef void (*virConnectCloseFunc) (
59
+ # typedef void (*virConnectCloseFunc) (
56
60
  # virConnectPtr conn,
57
61
  # int reason,
58
62
  # void * opaque
59
63
  # )
60
- callback :virConnectCloseFunc, [:pointer, :close_reason, :pointer], :void
64
+ callback :virConnectCloseFunc,
65
+ [:pointer, :close_reason, :pointer],
66
+ :void
61
67
 
62
- # virConnectPtr virConnectOpen (const char * name)
63
- attach_function :virConnectOpen, [:string], :pointer
68
+ # virConnectPtr virConnectOpen (
69
+ # const char * name
70
+ # )
71
+ attach_function :virConnectOpen,
72
+ [:string],
73
+ :pointer
64
74
 
65
- # int virConnectSetKeepAlive (
75
+ # int virConnectSetKeepAlive (
66
76
  # virConnectPtr conn,
67
77
  # int interval,
68
78
  # unsigned int count
69
79
  # )
70
- attach_function :virConnectSetKeepAlive, [:pointer, :int, :uint], :int
80
+ attach_function :virConnectSetKeepAlive,
81
+ [:pointer, :int, :uint],
82
+ :int
71
83
 
72
- # int virConnectGetVersion (
84
+ # int virConnectGetVersion (
73
85
  # virConnectPtr conn,
74
86
  # unsigned long * hvVer
75
87
  # )
76
- attach_function :virConnectGetVersion, [:pointer, :pointer], :int
88
+ attach_function :virConnectGetVersion,
89
+ [:pointer, :pointer],
90
+ :int
77
91
 
78
- # int virConnectGetLibVersion (
92
+ # int virConnectGetLibVersion (
79
93
  # virConnectPtr conn,
80
94
  # unsigned long * libVer
81
95
  # )
82
- attach_function :virConnectGetLibVersion, [:pointer, :pointer], :int
96
+ attach_function :virConnectGetLibVersion,
97
+ [:pointer, :pointer],
98
+ :int
83
99
 
84
- # char * virConnectGetHostname (
100
+ # char * virConnectGetHostname (
85
101
  # virConnectPtr conn
86
102
  # )
87
- attach_function :virConnectGetHostname, [:pointer], :string # strptr ?
103
+ attach_function :virConnectGetHostname,
104
+ [:pointer],
105
+ :string
88
106
 
89
- # int virConnectGetMaxVcpus (
107
+ # int virConnectGetMaxVcpus (
90
108
  # virConnectPtr conn,
91
109
  # const char * type
92
110
  # )
93
- attach_function :virConnectGetMaxVcpus, [:pointer, :string], :int
111
+ attach_function :virConnectGetMaxVcpus,
112
+ [:pointer, :string],
113
+ :int
94
114
 
95
- # char * virConnectGetCapabilities (
115
+ # char * virConnectGetCapabilities (
96
116
  # virConnectPtr conn
97
117
  # )
98
- attach_function :virConnectGetCapabilities, [:pointer], :string # strptr ?
118
+ attach_function :virConnectGetCapabilities,
119
+ [:pointer],
120
+ :string
99
121
 
100
- # int virConnectClose (
122
+ # int virConnectClose (
101
123
  # virConnectPtr conn
102
124
  # )
103
- attach_function :virConnectClose, [:pointer], :int
125
+ attach_function :virConnectClose,
126
+ [:pointer],
127
+ :int
104
128
 
105
- # int virConnectRegisterCloseCallback (
129
+ # int virConnectRegisterCloseCallback (
106
130
  # virConnectPtr conn,
107
131
  # virConnectCloseFunc cb,
108
132
  # void * opaque,
109
133
  # virFreeCallback freecb
110
134
  # )
111
- attach_function :virConnectRegisterCloseCallback, [
112
- :pointer,
113
- :virConnectCloseFunc,
114
- :pointer,
115
- FFI::Common::FREE_CALLBACK
116
- ], :int
117
-
118
- # int virConnectUnregisterCloseCallback (
135
+ attach_function :virConnectRegisterCloseCallback,
136
+ [
137
+ :pointer,
138
+ :virConnectCloseFunc,
139
+ :pointer,
140
+ FFI::Common::FREE_CALLBACK
141
+ ],
142
+ :int
143
+
144
+ # int virConnectUnregisterCloseCallback (
119
145
  # virConnectPtr conn,
120
146
  # virConnectCloseFunc cb
121
147
  # )
122
- attach_function :virConnectUnregisterCloseCallback, [:pointer, :pointer], :int
148
+ attach_function :virConnectUnregisterCloseCallback,
149
+ [:pointer, :pointer],
150
+ :int
123
151
 
124
- # int virConnectRef (
152
+ # int virConnectRef (
125
153
  # virConnectPtr conn
126
154
  # )
127
- attach_function :virConnectRef, [:pointer], :int
155
+ attach_function :virConnectRef,
156
+ [:pointer],
157
+ :int
128
158
 
129
159
  # unsigned long long virNodeGetFreeMemory (
130
160
  # virConnectPtr conn
131
161
  # )
132
- attach_function :virNodeGetFreeMemory, [:pointer], :ulong_long
162
+ attach_function :virNodeGetFreeMemory,
163
+ [:pointer],
164
+ :ulong_long
165
+
166
+ # char * virConnectGetURI (
167
+ # virConnectPtr conn
168
+ # )
169
+ attach_function :virConnectGetURI,
170
+ [:pointer],
171
+ :string
133
172
  end
134
173
  end
135
174
  end