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.
- checksums.yaml +4 -4
- data/.rubocop.yml +78 -0
- data/Gemfile +7 -2
- data/Rakefile +6 -1
- data/bin/console +1 -0
- data/exe/libvirt +1 -0
- data/lib/libvirt.rb +14 -13
- data/lib/libvirt/base_info.rb +34 -0
- data/lib/libvirt/connection.rb +156 -47
- data/lib/libvirt/domain.rb +136 -8
- data/lib/libvirt/domain_callback_storage.rb +69 -0
- data/lib/libvirt/errors.rb +65 -0
- data/lib/libvirt/event.rb +60 -38
- data/lib/libvirt/ffi.rb +17 -0
- data/lib/libvirt/ffi/common.rb +8 -1
- data/lib/libvirt/ffi/domain.rb +796 -69
- data/lib/libvirt/ffi/error.rb +243 -0
- data/lib/libvirt/ffi/event.rb +30 -36
- data/lib/libvirt/ffi/helpers.rb +17 -0
- data/lib/libvirt/ffi/host.rb +122 -0
- data/lib/libvirt/ffi/storage.rb +149 -0
- data/lib/libvirt/ffi/stream.rb +74 -0
- data/lib/libvirt/node_info.rb +2 -41
- data/lib/libvirt/storage_pool.rb +70 -0
- data/lib/libvirt/storage_pool_info.rb +7 -0
- data/lib/libvirt/storage_volume.rb +51 -0
- data/lib/libvirt/storage_volume_info.rb +7 -0
- data/lib/libvirt/stream.rb +124 -0
- data/lib/libvirt/util.rb +75 -8
- data/lib/libvirt/version.rb +1 -1
- data/lib/libvirt/xml.rb +23 -0
- data/lib/libvirt/xml/disk.rb +59 -0
- data/lib/libvirt/xml/domain.rb +76 -0
- data/lib/libvirt/xml/generic.rb +252 -0
- data/lib/libvirt/xml/graphics.rb +14 -0
- data/lib/libvirt/xml/max_vcpu.rb +12 -0
- data/lib/libvirt/xml/memory.rb +14 -0
- data/lib/libvirt/xml/storage_pool.rb +24 -0
- data/lib/libvirt/xml/storage_volume.rb +32 -0
- data/lib/libvirt/xml/vcpu.rb +12 -0
- data/lib/libvirt_ffi.rb +2 -0
- data/libvirt.gemspec +5 -1
- data/test_usage/support/libvirt_async.rb +33 -31
- data/test_usage/support/log_formatter.rb +5 -10
- data/test_usage/test_domain.rb +43 -0
- data/test_usage/test_event_loop.rb +134 -33
- data/test_usage/test_libvirtd_restart.rb +63 -0
- data/test_usage/test_metadata.rb +104 -0
- data/test_usage/test_screenshot.rb +197 -0
- data/test_usage/test_storage.rb +52 -0
- metadata +46 -6
- data/lib/libvirt/error.rb +0 -6
- data/lib/libvirt/ffi/connection.rb +0 -84
- data/lib/libvirt/ffi/libvirt.rb +0 -17
- data/lib/libvirt/ffi/node_info.rb +0 -37
data/lib/libvirt/error.rb
DELETED
@@ -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
|
data/lib/libvirt/ffi/libvirt.rb
DELETED
@@ -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
|