libvirt_ffi 0.2.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +78 -0
  3. data/Gemfile +7 -2
  4. data/Rakefile +6 -1
  5. data/bin/console +1 -0
  6. data/exe/libvirt +1 -0
  7. data/lib/libvirt.rb +14 -13
  8. data/lib/libvirt/base_info.rb +34 -0
  9. data/lib/libvirt/connection.rb +156 -47
  10. data/lib/libvirt/domain.rb +136 -8
  11. data/lib/libvirt/domain_callback_storage.rb +69 -0
  12. data/lib/libvirt/errors.rb +65 -0
  13. data/lib/libvirt/event.rb +60 -38
  14. data/lib/libvirt/ffi.rb +17 -0
  15. data/lib/libvirt/ffi/common.rb +8 -1
  16. data/lib/libvirt/ffi/domain.rb +796 -69
  17. data/lib/libvirt/ffi/error.rb +243 -0
  18. data/lib/libvirt/ffi/event.rb +30 -36
  19. data/lib/libvirt/ffi/helpers.rb +17 -0
  20. data/lib/libvirt/ffi/host.rb +122 -0
  21. data/lib/libvirt/ffi/storage.rb +149 -0
  22. data/lib/libvirt/ffi/stream.rb +74 -0
  23. data/lib/libvirt/node_info.rb +2 -41
  24. data/lib/libvirt/storage_pool.rb +70 -0
  25. data/lib/libvirt/storage_pool_info.rb +7 -0
  26. data/lib/libvirt/storage_volume.rb +51 -0
  27. data/lib/libvirt/storage_volume_info.rb +7 -0
  28. data/lib/libvirt/stream.rb +124 -0
  29. data/lib/libvirt/util.rb +75 -8
  30. data/lib/libvirt/version.rb +1 -1
  31. data/lib/libvirt/xml.rb +23 -0
  32. data/lib/libvirt/xml/disk.rb +59 -0
  33. data/lib/libvirt/xml/domain.rb +76 -0
  34. data/lib/libvirt/xml/generic.rb +252 -0
  35. data/lib/libvirt/xml/graphics.rb +14 -0
  36. data/lib/libvirt/xml/max_vcpu.rb +12 -0
  37. data/lib/libvirt/xml/memory.rb +14 -0
  38. data/lib/libvirt/xml/storage_pool.rb +24 -0
  39. data/lib/libvirt/xml/storage_volume.rb +32 -0
  40. data/lib/libvirt/xml/vcpu.rb +12 -0
  41. data/lib/libvirt_ffi.rb +2 -0
  42. data/libvirt.gemspec +5 -1
  43. data/test_usage/support/libvirt_async.rb +33 -31
  44. data/test_usage/support/log_formatter.rb +5 -10
  45. data/test_usage/test_domain.rb +43 -0
  46. data/test_usage/test_event_loop.rb +134 -33
  47. data/test_usage/test_libvirtd_restart.rb +63 -0
  48. data/test_usage/test_metadata.rb +104 -0
  49. data/test_usage/test_screenshot.rb +197 -0
  50. data/test_usage/test_storage.rb +52 -0
  51. metadata +46 -6
  52. data/lib/libvirt/error.rb +0 -6
  53. data/lib/libvirt/ffi/connection.rb +0 -84
  54. data/lib/libvirt/ffi/libvirt.rb +0 -17
  55. data/lib/libvirt/ffi/node_info.rb +0 -37
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Libvirt
4
- class Error < StandardError
5
- end
6
- end
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Libvirt
4
- module FFI
5
- module Connection
6
- extend ::FFI::Library
7
- ffi_lib Util.library_path
8
-
9
- # struct virNodeInfo {
10
- #
11
- # char model[32] model - string indicating the CPU model
12
- # unsigned long memory - memory size in kilobytes
13
- # unsigned int cpus - the number of active CPUs
14
- # unsigned int mhz - expected CPU frequency, 0 if not known or on unusual architectures
15
- # unsigned int nodes - the number of NUMA cell, 1 for unusual NUMA topologies or uniform memory access; check capabilities XML for the actual NUMA topology
16
- # unsigned int sockets - number of CPU sockets per node if nodes > 1, 1 in case of unusual NUMA topology
17
- # unsigned int cores - number of cores per socket, total number of processors in case of unusual NUMA topolog
18
- # unsigned int threads - number of threads per core, 1 in case of unusual numa topology
19
- # }
20
- class NodeInfoStruct < ::FFI::Struct
21
- layout :model, [:char, 32],
22
- :memory, :ulong,
23
- :cpus, :ulong,
24
- :mhz, :ulong,
25
- :nodes, :ulong,
26
- :sockets, :ulong,
27
- :cores, :ulong,
28
- :threads, :ulong
29
- end
30
-
31
- class NodeInfo
32
- def initialize(node_info_ptr, node_info_struct)
33
- @node_info_ptr = node_info_ptr
34
- @node_info_struct = node_info_struct
35
- end
36
-
37
- def [](attr)
38
- @node_info_struct[attr]
39
- end
40
- end
41
-
42
- # virConnectPtr virConnectOpen (const char * name)
43
- attach_function :virConnectOpen, [:string], :pointer
44
-
45
- # int virConnectGetVersion (virConnectPtr conn, unsigned long *hvVer)
46
- attach_function :virConnectGetVersion, [:pointer, :pointer], :int
47
-
48
- # int virConnectSetKeepAlive (
49
- # virConnectPtr conn,
50
- # int interval,
51
- # unsigned int count
52
- # )
53
- attach_function :virConnectSetKeepAlive, [:pointer, :int, :uint], :int
54
-
55
- # int virConnectGetVersion (
56
- # virConnectPtr conn,
57
- # unsigned long * hvVer
58
- # )
59
- attach_function :virConnectGetVersion, [:pointer, :pointer], :int
60
-
61
- # int virConnectGetLibVersion (
62
- # virConnectPtr conn,
63
- # unsigned long * libVer
64
- # )
65
- attach_function :virConnectGetLibVersion, [:pointer, :pointer], :int
66
-
67
- # char * virConnectGetHostname (
68
- # virConnectPtr conn
69
- # )
70
- attach_function :virConnectGetHostname, [:pointer], :string # strptr ?
71
-
72
- # int virConnectGetMaxVcpus (
73
- # virConnectPtr conn,
74
- # const char * type
75
- # )
76
- attach_function :virConnectGetMaxVcpus, [:pointer, :string], :int
77
-
78
- # char * virConnectGetCapabilities (
79
- # virConnectPtr conn
80
- # )
81
- attach_function :virConnectGetCapabilities, [:pointer], :string # strptr ?
82
- end
83
- end
84
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Libvirt
4
- module FFI
5
- module Libvirt
6
- extend ::FFI::Library
7
- ffi_lib Util.library_path
8
-
9
- # int virGetVersion (
10
- # unsigned long *libVer,
11
- # const char *type,
12
- # unsigned long *typeVer
13
- # )
14
- attach_function :virGetVersion, [:pointer, :string, :pointer], :int
15
- end
16
- end
17
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Libvirt
4
- module FFI
5
- module NodeInfo
6
- extend ::FFI::Library
7
- ffi_lib Util.library_path
8
-
9
- # struct virNodeInfo {
10
- #
11
- # char model[32] model - string indicating the CPU model
12
- # unsigned long memory - memory size in kilobytes
13
- # unsigned int cpus - the number of active CPUs
14
- # unsigned int mhz - expected CPU frequency, 0 if not known or on unusual architectures
15
- # unsigned int nodes - the number of NUMA cell, 1 for unusual NUMA topologies or uniform memory access;
16
- # check capabilities XML for the actual NUMA topology
17
- # unsigned int sockets - number of CPU sockets per node if nodes > 1, 1 in case of unusual NUMA topology
18
- # unsigned int cores - number of cores per socket, total number of processors in case of unusual NUMA topolog
19
- # unsigned int threads - number of threads per core, 1 in case of unusual numa topology
20
- # }
21
- class Struct < ::FFI::Struct
22
- layout :model, [:char, 32],
23
- :memory, :ulong,
24
- :cpus, :uint,
25
- :mhz, :uint,
26
- :nodes, :uint,
27
- :sockets, :uint,
28
- :cores, :uint,
29
- :threads, :uint
30
- end
31
-
32
- # int virNodeGetInfo (virConnectPtr conn,
33
- # virNodeInfoPtr info)
34
- attach_function :virNodeGetInfo, [:pointer, :pointer], :int
35
- end
36
- end
37
- end