ffi-vix_disk_lib 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +202 -0
- data/README.md +33 -0
- data/lib/ffi-vix_disk_lib/api.rb +693 -0
- data/lib/ffi-vix_disk_lib/api_wrapper.rb +451 -0
- data/lib/ffi-vix_disk_lib/const.rb +45 -0
- data/lib/ffi-vix_disk_lib/disk_info.rb +47 -0
- data/lib/ffi-vix_disk_lib/enum.rb +360 -0
- data/lib/ffi-vix_disk_lib/exceptions.rb +8 -0
- data/lib/ffi-vix_disk_lib/libc.rb +19 -0
- data/lib/ffi-vix_disk_lib/safe_connect_params.rb +141 -0
- data/lib/ffi-vix_disk_lib/safe_create_params.rb +31 -0
- data/lib/ffi-vix_disk_lib/struct.rb +89 -0
- data/lib/ffi-vix_disk_lib/version.rb +5 -0
- data/lib/ffi-vix_disk_lib.rb +8 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/version_spec.rb +7 -0
- metadata +109 -0
@@ -0,0 +1,693 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module FFI
|
4
|
+
module VixDiskLib
|
5
|
+
module API
|
6
|
+
extend FFI::Library
|
7
|
+
|
8
|
+
def attach_function(*args)
|
9
|
+
super
|
10
|
+
rescue FFI::NotFoundError
|
11
|
+
warn "unable to attach #{args.first}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.load_error
|
15
|
+
@load_error
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# Make sure we load one and only one version of VixDiskLib
|
20
|
+
#
|
21
|
+
version_load_order = %w( 5.5.2 5.5.1 5.5.0 5.1.3 5.1.2 5.1.1 5.1.0 5.0.4 5.0.0 1.2.0 1.1.2 )
|
22
|
+
bad_versions = {"5.1.0" => "Disk Open May Core Dump without an SSL Thumbprint"}
|
23
|
+
load_errors = []
|
24
|
+
loaded_library = ""
|
25
|
+
version_load_order.each do |version|
|
26
|
+
begin
|
27
|
+
loaded_library = ffi_lib ["vixDiskLib.so.#{version}"]
|
28
|
+
VERSION_MAJOR, VERSION_MINOR = loaded_library.first.name.split(".")[2, 2].collect(&:to_i)
|
29
|
+
if bad_versions.keys.include?(version)
|
30
|
+
loaded_library = ""
|
31
|
+
@load_error = "VixDiskLib #{version} is not supported: #{bad_versions[version]}"
|
32
|
+
end
|
33
|
+
break
|
34
|
+
rescue LoadError => err
|
35
|
+
load_errors << "ffi-vix_disk_lib: failed to load #{version} version with error: #{err.message}."
|
36
|
+
next
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
unless @load_error || loaded_library.length > 0
|
41
|
+
STDERR.puts load_errors.join("\n")
|
42
|
+
@load_error = "ffi-vix_disk_lib: failed to load any version of VixDiskLib!"
|
43
|
+
end
|
44
|
+
LOADED_LIBRARY = loaded_library
|
45
|
+
|
46
|
+
# An error is a 64-bit value. If there is no error, then the value is
|
47
|
+
# set to VIX_OK. If there is an error, then the least significant bits
|
48
|
+
# will be set to one of the integer error codes defined below. The more
|
49
|
+
# significant bits may or may not be set to various values, depending on
|
50
|
+
# the errors.
|
51
|
+
|
52
|
+
def self.vix_error_code(err)
|
53
|
+
err & 0xFFFF
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.vix_succeeded?(err)
|
57
|
+
err == VixErrorType[:VIX_OK]
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.vix_failed?(err)
|
61
|
+
err != VixErrorType[:VIX_OK]
|
62
|
+
end
|
63
|
+
|
64
|
+
callback :GenericLogFunc, [:string, :pointer], :void
|
65
|
+
|
66
|
+
# Prototype for the progress function called by VixDiskLib.
|
67
|
+
#
|
68
|
+
# @scope class
|
69
|
+
# @method ProgressFunc(progress_data, percent_completed)
|
70
|
+
# @param progress_data [FFI::Pointer(*Void)] User supplied opaque pointer.
|
71
|
+
# @param percent_completed [Integer] Completion percent.
|
72
|
+
# @return [Boolean] ignores the return value.
|
73
|
+
# This function may be called with the same percentage completion
|
74
|
+
# multiple times.
|
75
|
+
callback :ProgressFunc, [:pointer, :int], :bool
|
76
|
+
|
77
|
+
# Perform a cleanup after an unclean shutdown of an application using
|
78
|
+
# VixDiskLib.
|
79
|
+
#
|
80
|
+
# When using VixDiskLib_ConnectEx, some state might have not been cleaned
|
81
|
+
# up if the resulting connection was not shut down cleanly. Use
|
82
|
+
# VixDiskLib_Cleanup to remove this extra state.
|
83
|
+
#
|
84
|
+
# @param connection [in] Hostname and login credentials to connect to
|
85
|
+
# a host managing virtual machines that were accessed and need
|
86
|
+
# cleanup. While VixDiskLib_Cleanup can be invoked for local
|
87
|
+
# connections as well, it is a no-op in that case. Also, the
|
88
|
+
# vmxSpec property of connectParams should be set to NULL.
|
89
|
+
# @param numCleanedUp [out] Number of virtual machines that were
|
90
|
+
# successfully cleaned up. -- Can be NULL.
|
91
|
+
# @param numRemaining [out] Number of virutal machines that still
|
92
|
+
# require cleaning up. -- Can be NULL.
|
93
|
+
# @return VIX_OK if all virtual machines were successfully cleaned
|
94
|
+
# up or if no virtual machines required cleanup. VIX error
|
95
|
+
# code otherwise and numRemaning can be used to check for
|
96
|
+
# the number of virtual machines requiring cleanup.
|
97
|
+
#
|
98
|
+
attach_function :cleanup, :VixDiskLib_Cleanup,
|
99
|
+
[
|
100
|
+
ConnectParams, # connectParams,
|
101
|
+
:pointer, # numCleanedUp,
|
102
|
+
:pointer # numRemaining
|
103
|
+
],
|
104
|
+
:VixError
|
105
|
+
|
106
|
+
# Closes the disk.
|
107
|
+
#
|
108
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
109
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
110
|
+
attach_function :close, :VixDiskLib_Close,
|
111
|
+
[
|
112
|
+
:pointer # disk handle
|
113
|
+
],
|
114
|
+
:VixError
|
115
|
+
|
116
|
+
# Connects to a local / remote server.
|
117
|
+
#
|
118
|
+
# @param connectParams [in] NULL if manipulating local disks.
|
119
|
+
# For remote case this includes esx hostName and
|
120
|
+
# user credentials.
|
121
|
+
# @param connection [out] Returned handle to a connection.
|
122
|
+
# @return VIX_OK if success suitable VIX error code otherwise.
|
123
|
+
attach_function :connect, :VixDiskLib_Connect,
|
124
|
+
[
|
125
|
+
ConnectParams, # connectParams,
|
126
|
+
:Connection # connection
|
127
|
+
],
|
128
|
+
:VixError
|
129
|
+
|
130
|
+
# Create a transport context to access disks belonging to a
|
131
|
+
# particular snapshot of a particular virtual machine. Using this
|
132
|
+
# transport context will enable callers to open virtual disks using
|
133
|
+
# the most efficient data acces protocol available for managed
|
134
|
+
# virtual machines, hence getting better I/O performance.
|
135
|
+
#
|
136
|
+
# If this call is used instead of VixDiskLib_Connect, the additional
|
137
|
+
# information passed in will be used in order to optimize the I/O
|
138
|
+
# access path, to maximize I/O throughput.
|
139
|
+
#
|
140
|
+
# Note: For local virtual machines/disks, this call is equivalent
|
141
|
+
# to VixDiskLib_Connect.
|
142
|
+
#
|
143
|
+
# @param connectParams [in] NULL if maniuplating local disks.
|
144
|
+
# For remote case this includes esx hostName and
|
145
|
+
# user credentials.
|
146
|
+
# @param readOnly [in] Should be set to TRUE if no write access is needed
|
147
|
+
# for the disks to be accessed through this connection. In
|
148
|
+
# some cases, a more efficient I/O path can be used for
|
149
|
+
# read-only access.
|
150
|
+
# @param snapshotRef [in] A managed object reference to the specific
|
151
|
+
# snapshot of the virtual machine whose disks will be
|
152
|
+
# accessed with this connection. Specifying this
|
153
|
+
# property is only meaningful if the vmxSpec property in
|
154
|
+
# connectParams is set as well.
|
155
|
+
# @param transportModes [in] An optional list of transport modes that
|
156
|
+
# can be used for this connection, separated by
|
157
|
+
# colons. If NULL is specified, VixDiskLib's default
|
158
|
+
# setting of "file:san:hotadd:nbd" is used. If a disk is
|
159
|
+
# opened through this connection, VixDiskLib will start
|
160
|
+
# with the first entry of the list and attempt to use
|
161
|
+
# this transport mode to gain access to the virtual
|
162
|
+
# disk. If this does not work, the next item in the list
|
163
|
+
# will be used until either the disk was successfully
|
164
|
+
# opened or the end of the list is reached.
|
165
|
+
# @param connection [out] Returned handle to a connection.
|
166
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
167
|
+
attach_function :connect_ex, :VixDiskLib_ConnectEx,
|
168
|
+
[
|
169
|
+
ConnectParams, # connectParams,
|
170
|
+
:bool, # readOnly flag
|
171
|
+
:pointer, # snapshotRef string
|
172
|
+
:pointer, # transportModes string
|
173
|
+
:Connection # connection
|
174
|
+
],
|
175
|
+
:VixError
|
176
|
+
|
177
|
+
# Creates a local disk. Remote disk creation is not supported.
|
178
|
+
#
|
179
|
+
# @param connection [in] A valid connection.
|
180
|
+
# @param path [in] VMDK file name given as absolute path
|
181
|
+
# e.g. "c:\\My Virtual Machines\\MailServer\SystemDisk.vmdk".
|
182
|
+
# @param createParams [in] Specification for the new disk (type, capacity ...).
|
183
|
+
# @param progressFunc [in] Callback to report progress.
|
184
|
+
# @param progressCallbackData [in] Callback data pointer.
|
185
|
+
# @return VIX_OK if success suitable VIX error code otherwise.
|
186
|
+
attach_function :create, :VixDiskLib_Create,
|
187
|
+
[
|
188
|
+
:Connection, # connection,
|
189
|
+
:pointer, # path,
|
190
|
+
CreateParams, # createParams,
|
191
|
+
:ProgressFunc, # progressFunc,
|
192
|
+
:pointer # progressCallbackData
|
193
|
+
],
|
194
|
+
:VixError
|
195
|
+
|
196
|
+
# Creates a redo log from a parent disk.
|
197
|
+
#
|
198
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
199
|
+
# @param childPath [in] Redo log file name given as absolute path
|
200
|
+
# e.g. "c:\\My Virtual Machines\\MailServer\SystemDisk_s0001.vmdk".
|
201
|
+
# @param diskType [in] Either VIXDISKLIB_DISK_MONOLITHIC_SPARSE or
|
202
|
+
# VIXDISKLIB_DISK_SPLIT_SPARSE.
|
203
|
+
# @param progressFunc [in] Callback to report progress.
|
204
|
+
# @param progressCallbackData [in] Callback data pointer.
|
205
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
206
|
+
attach_function :create_child, :VixDiskLib_CreateChild,
|
207
|
+
[
|
208
|
+
:pointer, # diskHandle,
|
209
|
+
:pointer, # childPath,
|
210
|
+
:int, # diskType,
|
211
|
+
:ProgressFunc, # progressFunc,
|
212
|
+
:pointer # progressCallbackData
|
213
|
+
],
|
214
|
+
:VixError
|
215
|
+
|
216
|
+
# Breaks an existing connection.
|
217
|
+
#
|
218
|
+
# @param connection [in] Valid handle to a (local/remote) connection.
|
219
|
+
# @return VIX_OK if success suitable VIX error code otherwise.
|
220
|
+
attach_function :disconnect, :VixDiskLib_Disconnect,
|
221
|
+
[
|
222
|
+
:Connection # connection
|
223
|
+
],
|
224
|
+
:VixError
|
225
|
+
|
226
|
+
# This function is used to notify the host of a virtual machine that the
|
227
|
+
# virtual machine disks are closed and that the operations which rely on the
|
228
|
+
# virtual machine disks to be closed can now be allowed.
|
229
|
+
#
|
230
|
+
# @param connectParams [in] Always used for a remote connection. Must be the
|
231
|
+
# same parameters as used in the corresponding PrepareForAccess call.
|
232
|
+
# @param identity [in] An arbitrary string containing the identity of the
|
233
|
+
# application.
|
234
|
+
# @return VIX_OK of success, suitable VIX error code otherwise.
|
235
|
+
attach_function :end_access, :VixDiskLib_EndAccess,
|
236
|
+
[
|
237
|
+
ConnectParams, # connectParams,
|
238
|
+
:pointer # identity string
|
239
|
+
],
|
240
|
+
:VixError
|
241
|
+
|
242
|
+
# Cleans up VixDiskLib.
|
243
|
+
#
|
244
|
+
# @scope class
|
245
|
+
# @method exit
|
246
|
+
# @return [nil]
|
247
|
+
attach_function :exit, :VixDiskLib_Exit, [], :void
|
248
|
+
|
249
|
+
# Free the error message returned by get_error_text.
|
250
|
+
#
|
251
|
+
# @scope class
|
252
|
+
# @method free_error_text(errMsg)
|
253
|
+
# @param errMsg [FFI:Pointer(*String)] Message string returned by get_error_text.
|
254
|
+
# It is OK to call this function with nil.
|
255
|
+
# @return [nil]
|
256
|
+
attach_function :free_error_text, :VixDiskLib_FreeErrorText,
|
257
|
+
[
|
258
|
+
:pointer # errMsg to free
|
259
|
+
],
|
260
|
+
:void
|
261
|
+
|
262
|
+
# Returns the textual description of an error.
|
263
|
+
#
|
264
|
+
# @scope class
|
265
|
+
# @method get_error_text(err, locale)
|
266
|
+
# @param err [VixError] A VIX error code.
|
267
|
+
# @param locale [String] Language locale - not currently supported and must be nil.
|
268
|
+
# @return [String] The error message string. This should only be deallocated
|
269
|
+
# by free_error_text.
|
270
|
+
# Returns NULL if there is an error in retrieving text.
|
271
|
+
attach_function :get_error_text, :VixDiskLib_GetErrorText,
|
272
|
+
[
|
273
|
+
:VixError, # err
|
274
|
+
:pointer # locale
|
275
|
+
],
|
276
|
+
:pointer
|
277
|
+
|
278
|
+
# Retrieves the list of keys in the metadata table.
|
279
|
+
# Key names are returned as list of null-terminated strings,
|
280
|
+
# followed by an additional NULL character.
|
281
|
+
#
|
282
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
283
|
+
# @param keys [out, optional] Keynames buffer, can be NULL.
|
284
|
+
# @param maxLen [in] Size of the keynames buffer.
|
285
|
+
# @param requiredLen [out, optional] Space required for the keys including the double
|
286
|
+
# end-of-string characters.
|
287
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
288
|
+
attach_function :get_metadata_keys, :VixDiskLib_GetMetadataKeys,
|
289
|
+
[
|
290
|
+
:pointer, # diskHandle,
|
291
|
+
:pointer, # keys,
|
292
|
+
:uint64, # size_t maxLen,
|
293
|
+
:pointer, # requiredLen
|
294
|
+
],
|
295
|
+
:VixError
|
296
|
+
|
297
|
+
# Returns a pointer to a static string identifying the transport mode that
|
298
|
+
# is used to access the virtual disk's data.
|
299
|
+
#
|
300
|
+
# If a disk was opened through a connection obtained by VixDiskLib_Connect,
|
301
|
+
# the return value will be "file" for a local disk and "nbd" or "nbdssl" for
|
302
|
+
# a managed disk.
|
303
|
+
#
|
304
|
+
# The pointer to this string is static and must not be deallocated by the
|
305
|
+
# caller.
|
306
|
+
#
|
307
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
308
|
+
# @return Returns a pointer to a static string identifying the transport
|
309
|
+
# mode used to access the disk's data.
|
310
|
+
attach_function :get_transport_mode, :VixDiskLib_GetTransportMode,
|
311
|
+
[
|
312
|
+
:pointer # diskHandle
|
313
|
+
],
|
314
|
+
:pointer # transport mode
|
315
|
+
|
316
|
+
# Initializes VixDiskLib - deprecated, please use initEx.
|
317
|
+
#
|
318
|
+
# @scope class
|
319
|
+
# @method init(majorVersion, minorVersion, log, warn, panic, libDir)
|
320
|
+
# @param majorVersion [Integer] Required major version number for client.
|
321
|
+
# @param minorVersion [Integer] Required minor version number for client.
|
322
|
+
# @param log [FFI::Pointer(*GenericLogFunc)] Callback for Log entries.
|
323
|
+
# @param warn [FFI::Pointer(*GenericLogFunc)] Callback for warnings.
|
324
|
+
# @param panic [FFI::Pointer(*GenericLogFunc)] Callback for panic.
|
325
|
+
# @param libDir [String] Directory location where dependent libs are located.
|
326
|
+
# @return [VixError] VIX_OK on success, suitable VIX error code otherwise.
|
327
|
+
attach_function :init, :VixDiskLib_Init,
|
328
|
+
[
|
329
|
+
:uint32, # majorVersion
|
330
|
+
:uint32, # minorVersion
|
331
|
+
:GenericLogFunc, # log
|
332
|
+
:GenericLogFunc, # warn
|
333
|
+
:GenericLogFunc, # panic
|
334
|
+
:string, # libDir
|
335
|
+
], :VixError
|
336
|
+
|
337
|
+
# Initializes VixDiskLib.
|
338
|
+
#
|
339
|
+
# @scope class
|
340
|
+
# @method initEx(majorVersion, minorVersion, log, warn, panic, libDir, configFile)
|
341
|
+
# @param majorVersion [Integer] Required major version number for client.
|
342
|
+
# @param minorVersion [Integer] Required minor version number for client.
|
343
|
+
# @param log [FFI::Pointer(*GenericLogFunc)] Callback for Log entries.
|
344
|
+
# @param warn [FFI::Pointer(*GenericLogFunc)] Callback for warnings.
|
345
|
+
# @param panic [FFI::Pointer(*GenericLogFunc)] Callback for panic.
|
346
|
+
# @param libDir [String] Directory location where dependent libs are located.
|
347
|
+
# @param configFile [String] Configuration file path in local encoding.
|
348
|
+
# configuration files are of the format
|
349
|
+
# name = "value"
|
350
|
+
# each name/value pair on a separate line. For a detailed
|
351
|
+
# description of allowed values, refer to the
|
352
|
+
# documentation.
|
353
|
+
# @return [VixError] VIX_OK on success, suitable VIX error code otherwise.
|
354
|
+
attach_function :init_ex, :VixDiskLib_InitEx,
|
355
|
+
[
|
356
|
+
:uint32, # majorVersion
|
357
|
+
:uint32, # minorVersion
|
358
|
+
:GenericLogFunc, # log
|
359
|
+
:GenericLogFunc, # warn
|
360
|
+
:GenericLogFunc, # panic
|
361
|
+
:string, # libDir
|
362
|
+
:string, # configFile
|
363
|
+
],
|
364
|
+
:VixError
|
365
|
+
|
366
|
+
# This function is used to notify the host of the virtual machine that the
|
367
|
+
# disks of the virtual machine will be opened. The host disables operations on
|
368
|
+
# the virtual machine that may be adversely affected if they are performed
|
369
|
+
# while the disks are open by a third party application.
|
370
|
+
#
|
371
|
+
# @param connectParams [in] This is always used on remote connections.
|
372
|
+
# @param identity [in] An arbitrary string containing the identity of the
|
373
|
+
# application.
|
374
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
375
|
+
attach_function :prepare_for_access, :VixDiskLib_PrepareForAccess,
|
376
|
+
[
|
377
|
+
ConnectParams, # connectParams,
|
378
|
+
:pointer # identity
|
379
|
+
],
|
380
|
+
:VixError
|
381
|
+
|
382
|
+
# Get a list of transport modes known to VixDiskLib. This list is also the
|
383
|
+
# default used if VixDiskLib_ConnectEx is called with transportModes set
|
384
|
+
# to NULL.
|
385
|
+
#
|
386
|
+
# The string is a list of transport modes separated by colons. For
|
387
|
+
# example: "file:san:hotadd:nbd". See VixDiskLib_ConnectEx for more details.
|
388
|
+
#
|
389
|
+
# @return Returns a string that is a list of plugins. The caller must not
|
390
|
+
# free the string.
|
391
|
+
attach_function :list_transport_modes, :VixDiskLib_ListTransportModes,
|
392
|
+
[
|
393
|
+
],
|
394
|
+
:pointer # list of transport plugins
|
395
|
+
|
396
|
+
# Opens a local or remote virtual disk.
|
397
|
+
#
|
398
|
+
# @param connection [in] A valid connection.
|
399
|
+
# @param path [in] VMDK file name given as absolute path
|
400
|
+
# e.g. "[storage1] MailServer/SystemDisk.vmdk"
|
401
|
+
# @param flags [in, optional] Bitwise or'ed combination of
|
402
|
+
# VIXDISKLIB_FLAG_OPEN_UNBUFFERED
|
403
|
+
# VIXDISKLIB_FLAG_OPEN_SINGLE_LINK
|
404
|
+
# VIXDISKLIB_FLAG_OPEN_READ_ONLY.
|
405
|
+
# @param diskHandle [out] Handle to opened disk, NULL if disk was not opened.
|
406
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
407
|
+
attach_function :open, :VixDiskLib_Open,
|
408
|
+
[
|
409
|
+
:Connection, # connection
|
410
|
+
:pointer, # path
|
411
|
+
:uint32, # flags
|
412
|
+
:pointer # disk handle
|
413
|
+
],
|
414
|
+
:VixError
|
415
|
+
|
416
|
+
# Reads a sector range.
|
417
|
+
#
|
418
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
419
|
+
# @param startSector [in] Absolute offset.
|
420
|
+
# @param numSectors [in] Number of sectors to read.
|
421
|
+
# @param readBuffer [out] Buffer to read into.
|
422
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
423
|
+
attach_function :read, :VixDiskLib_Read,
|
424
|
+
[
|
425
|
+
:pointer, # disk handle
|
426
|
+
:SectorType, # start sector
|
427
|
+
:SectorType, # number of sectors
|
428
|
+
:pointer # read buffer
|
429
|
+
],
|
430
|
+
:VixError
|
431
|
+
|
432
|
+
# Writes a sector range.
|
433
|
+
#
|
434
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
435
|
+
# @param startSector [in] Absolute offset.
|
436
|
+
# @param numSectors [in] Number of sectors to write.
|
437
|
+
# @param writeBuffer [in] Buffer to write.
|
438
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
439
|
+
attach_function :write, :VixDiskLib_Write,
|
440
|
+
[
|
441
|
+
:pointer, # disk handle
|
442
|
+
:SectorType, # start sector
|
443
|
+
:SectorType, # number of sectors
|
444
|
+
:pointer # write buffer
|
445
|
+
],
|
446
|
+
:VixError
|
447
|
+
|
448
|
+
# Retrieves the value of a metadata entry corresponding to the supplied key.
|
449
|
+
#
|
450
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
451
|
+
# @param key [in] Key name.
|
452
|
+
# @param buf [out, optional] Placeholder for key's value in the metadata store,
|
453
|
+
# can be NULL.
|
454
|
+
# @param bufLen [in] Size of the buffer.
|
455
|
+
# @param requiredLen [out, optional] Size of buffer required for the value (including
|
456
|
+
# end of string character)
|
457
|
+
# @return VIX_OK if success, VIX_E_DISK_BUFFER_TOO_SMALL if too small a buffer
|
458
|
+
# and other errors as applicable.
|
459
|
+
attach_function :read_metadata, :VixDiskLib_ReadMetadata,
|
460
|
+
[
|
461
|
+
:pointer, # diskHandle,
|
462
|
+
:pointer, # key,
|
463
|
+
:pointer, # buf,
|
464
|
+
:uint64, # size_t bufLen,
|
465
|
+
:pointer, # size_t *requiredLen
|
466
|
+
],
|
467
|
+
:VixError
|
468
|
+
|
469
|
+
# Creates or modifies a metadata table entry.
|
470
|
+
#
|
471
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
472
|
+
# @param key [in] Key name.
|
473
|
+
# @param val [in] Key's value.
|
474
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
475
|
+
attach_function :write_metadata, :VixDiskLib_WriteMetadata,
|
476
|
+
[
|
477
|
+
:pointer, # diskHandle,
|
478
|
+
:pointer, # key,
|
479
|
+
:pointer # val
|
480
|
+
],
|
481
|
+
:VixError
|
482
|
+
|
483
|
+
# Deletes all extents of the specified disk link. If the path refers to a
|
484
|
+
# parent disk, the child (redo log) will be orphaned.
|
485
|
+
# Unlinking the child does not affect the parent.
|
486
|
+
#
|
487
|
+
# @param connection [in] A valid connection.
|
488
|
+
# @param path [in] Path to the disk to be deleted.
|
489
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
490
|
+
attach_function :unlink, :VixDiskLib_Unlink,
|
491
|
+
[
|
492
|
+
:Connection, # connection,
|
493
|
+
:pointer # const char *path
|
494
|
+
],
|
495
|
+
:VixError
|
496
|
+
|
497
|
+
# Grows an existing disk, only local disks are grown.
|
498
|
+
#
|
499
|
+
# @pre The specified disk is not open.
|
500
|
+
# @param connection [in] A valid connection.
|
501
|
+
# @param path [in] Path to the disk to be grown.
|
502
|
+
# @param capacity [in] Target size for the disk.
|
503
|
+
# @param updateGeometry [in] Should vixDiskLib update the geometry?
|
504
|
+
# @param progressFunc [in] Callback to report progress (called on the same thread).
|
505
|
+
# @param progressCallbackData [in] Opaque pointer passed along with the percent
|
506
|
+
# complete.
|
507
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
508
|
+
attach_function :grow, :VixDiskLib_Grow,
|
509
|
+
[
|
510
|
+
:Connection, # connection,
|
511
|
+
:pointer, # path,
|
512
|
+
:SectorType, # capacity,
|
513
|
+
:bool, # updateGeometry,
|
514
|
+
:ProgressFunc, # progressFunc,
|
515
|
+
:pointer # progressCallbackData
|
516
|
+
],
|
517
|
+
:VixError
|
518
|
+
|
519
|
+
# Shrinks an existing disk, only local disks are shrunk.
|
520
|
+
#
|
521
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
522
|
+
# @param progressFunc [in] Callback to report progress (called on the same thread).
|
523
|
+
# @param progressCallbackData [in] Opaque pointer passed along with the percent
|
524
|
+
# complete.
|
525
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
526
|
+
attach_function :shrink, :VixDiskLib_Shrink,
|
527
|
+
[
|
528
|
+
:pointer, # diskHandle,
|
529
|
+
:ProgressFunc, # progressFunc,
|
530
|
+
:pointer # progressCallbackData
|
531
|
+
],
|
532
|
+
:VixError
|
533
|
+
|
534
|
+
# Defragments an existing disk.
|
535
|
+
#
|
536
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
537
|
+
# @param progressFunc [in] Callback to report progress (called on the same thread).
|
538
|
+
# @param progressCallbackData [in] Opaque pointer passed along with the percent
|
539
|
+
# complete.
|
540
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
541
|
+
attach_function :defragment, :VixDiskLib_Defragment,
|
542
|
+
[
|
543
|
+
:pointer, # diskHandle,
|
544
|
+
:ProgressFunc, # progressFunc,
|
545
|
+
:pointer # progressCallbackData
|
546
|
+
],
|
547
|
+
:VixError
|
548
|
+
|
549
|
+
# Renames a virtual disk.
|
550
|
+
#
|
551
|
+
# @param srcFileName [in] Virtual disk file to rename.
|
552
|
+
# @param dstFileName [in] New name for the virtual disk.
|
553
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
554
|
+
attach_function :rename, :VixDiskLib_Rename,
|
555
|
+
[
|
556
|
+
:pointer, # srcFileName,
|
557
|
+
:pointer # dstFileName
|
558
|
+
],
|
559
|
+
:VixError
|
560
|
+
|
561
|
+
# Copies a disk with proper conversion.
|
562
|
+
#
|
563
|
+
# @param dstConnection [in] A valid connection to access the destination disk.
|
564
|
+
# @param dstPath [in] Absolute path for the (new) destination disk.
|
565
|
+
# @param srcConnection [in] A valid connection to access the source disk.
|
566
|
+
# @param srcPath [in] Absolute path for the source disk.
|
567
|
+
# @param vixCreateParams [in] creationParameters (disktype, hardware type...).
|
568
|
+
# If the destination is remote, createParams is currently
|
569
|
+
# ignored and disk with default size and adapter type is
|
570
|
+
# created.
|
571
|
+
# @param progressFunc [in] Callback to report progress (called on the same thread).
|
572
|
+
# @param progressCallbackData [in] Opaque pointer passed along with the percent
|
573
|
+
# complete.
|
574
|
+
# @param overWrite [in] TRUE if Clone should overwrite an existing file.
|
575
|
+
# @return VIX_OK if success, suitable VIX error code otherwise (network errors like
|
576
|
+
# file already exists
|
577
|
+
# handshake failure, ...
|
578
|
+
# are all combined into a generic connect message).
|
579
|
+
attach_function :clone, :VixDiskLib_Clone,
|
580
|
+
[
|
581
|
+
:Connection, # dstConnection,
|
582
|
+
:pointer, # dstPath,
|
583
|
+
:Connection, # srcConnection,
|
584
|
+
:pointer, # srcPath,
|
585
|
+
CreateParams, # createParams,
|
586
|
+
:ProgressFunc, # progressFunc,
|
587
|
+
:pointer, # progressCallbackData
|
588
|
+
:bool # overWrite
|
589
|
+
],
|
590
|
+
:VixError
|
591
|
+
|
592
|
+
# Retrieves information about a disk.
|
593
|
+
#
|
594
|
+
# @param diskHandle [in] Handle to an open virtual disk.
|
595
|
+
# @param info [out] Disk information filled up.
|
596
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
597
|
+
attach_function :get_info, :VixDiskLib_GetInfo,
|
598
|
+
[
|
599
|
+
:pointer, # disk handle
|
600
|
+
:pointer # disk info
|
601
|
+
],
|
602
|
+
:VixError
|
603
|
+
|
604
|
+
# Frees memory allocated in get_info
|
605
|
+
#
|
606
|
+
# @param info [in] Disk information to be freed.
|
607
|
+
attach_function :free_info, :VixDiskLib_FreeInfo,
|
608
|
+
[
|
609
|
+
:pointer, # disk info to free
|
610
|
+
],
|
611
|
+
:void
|
612
|
+
|
613
|
+
# Return the details for the connection.
|
614
|
+
#
|
615
|
+
# @param connection [in] A VixDiskLib connection.
|
616
|
+
# @param connectParams [out] Details of the connection.
|
617
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
618
|
+
attach_function :get_connect_params, :VixDiskLib_GetConnectParams,
|
619
|
+
[
|
620
|
+
:pointer, # connection,
|
621
|
+
:pointer # connectParams
|
622
|
+
],
|
623
|
+
:VixError
|
624
|
+
|
625
|
+
# Free the connection details structure allocated during
|
626
|
+
# VixDiskLib_GetConnectParams.
|
627
|
+
#
|
628
|
+
# @param connectParams [out] Connection details to be free'ed.
|
629
|
+
# @return None.
|
630
|
+
attach_function :free_connect_params, :VixDiskLib_FreeConnectParams,
|
631
|
+
[
|
632
|
+
:pointer # connectParams
|
633
|
+
],
|
634
|
+
:void
|
635
|
+
|
636
|
+
# Checks if the child disk chain can be attached to the parent disk chain.
|
637
|
+
#
|
638
|
+
# @param parent [in] Handle to the disk to be attached.
|
639
|
+
# @param child [in] Handle to the disk to attach.
|
640
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
641
|
+
attach_function :is_attach_possible, :VixDiskLib_IsAttachPossible,
|
642
|
+
[
|
643
|
+
:pointer, # parent,
|
644
|
+
:pointer # child
|
645
|
+
],
|
646
|
+
:VixError
|
647
|
+
|
648
|
+
# Attaches the child disk chain to the parent disk chain. Parent handle is
|
649
|
+
# invalid after attaching and child represents the combined disk chain.
|
650
|
+
#
|
651
|
+
# @param parent [in] Handle to the disk to be attached.
|
652
|
+
# @param child [in] Handle to the disk to attach.
|
653
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
654
|
+
attach_function :attach, :VixDiskLib_Attach,
|
655
|
+
[
|
656
|
+
:pointer, # parent,
|
657
|
+
:pointer # child
|
658
|
+
],
|
659
|
+
:VixError
|
660
|
+
|
661
|
+
# Compute the space (in bytes) required to copy a disk chain.
|
662
|
+
#
|
663
|
+
# @param diskHandle [in] Handle to the disk to be copied.
|
664
|
+
# @param cloneDiskType [in] Type of the (to be) newly created disk.
|
665
|
+
# If cloneDiskType is VIXDISKLIB_DISK_UNKNOWN, the source disk
|
666
|
+
# type is assumed.
|
667
|
+
# @param spaceNeeded [out] Place holder for space needed in bytes.
|
668
|
+
# @return VIX_OK if success, suitable VIX error code otherwise.
|
669
|
+
attach_function :space_needed_for_clone, :VixDiskLib_SpaceNeededForClone,
|
670
|
+
[
|
671
|
+
:pointer, # diskHandle,
|
672
|
+
:int, # cloneDiskType,
|
673
|
+
:pointer # spaceNeeded
|
674
|
+
],
|
675
|
+
:VixError
|
676
|
+
|
677
|
+
# Check a sparse disk for internal consistency.
|
678
|
+
#
|
679
|
+
# @param filename [in] Path to disk to be checked.
|
680
|
+
# @param repair [in] TRUE if repair should be attempted, false otherwise.
|
681
|
+
# @return VIX_OK if success, suitable VIX error code otherwise. Note
|
682
|
+
# this refers to the success of the call, not the consistency of
|
683
|
+
# the disk being checked.
|
684
|
+
attach_function :check_repair, :VixDiskLib_CheckRepair,
|
685
|
+
[
|
686
|
+
:pointer, # connection,
|
687
|
+
:pointer, # filename,
|
688
|
+
:bool # repair
|
689
|
+
],
|
690
|
+
:VixError
|
691
|
+
end
|
692
|
+
end
|
693
|
+
end
|