Class: Libvirt::Connection
- Inherits:
-
Object
- Object
- Libvirt::Connection
- Includes:
- Loggable
- Defined in:
- lib/libvirt/connection.rb
Constant Summary collapse
- DOMAIN_EVENT_IDS =
FFI::Domain.enum_type(:event_id).symbols.dup.freeze
- POOL_EVENT_IDS =
FFI::Storage.enum_type(:event_id).symbols.dup.freeze
- NETWORK_EVENT_IDS =
FFI::Network.enum_type(:event_id).symbols.dup.freeze
- DOMAIN_STORAGE =
HostCallbackStorage.new(:domain_event)
- POOL_STORAGE =
HostCallbackStorage.new(:storage_pool_event)
- NETWORK_STORAGE =
HostCallbackStorage.new(:network_event)
- CLOSE_STORAGE =
HostCallbackStorage.new(:close)
- DOMAIN_EVENT_CALLBACKS =
DOMAIN_EVENT_IDS.map do |event_id_sym| func = FFI::Domain.event_callback_for(event_id_sym) do |conn_ptr, dom_ptr, *args, op_ptr| Util.log(:debug, "DOMAIN_EVENT_CALLBACKS[#{event_id_sym}]") do "inside callback conn_ptr=#{conn_ptr}, pool_ptr=#{dom_ptr}, args=#{args}, op_ptr=#{op_ptr}" end connection = Connection.load_ref(conn_ptr) domain = Domain.load_ref(dom_ptr) block, opaque = DOMAIN_STORAGE.retrieve_from_pointer(op_ptr) block.call(connection, domain, *args, opaque) end [event_id_sym, func] end.to_h.freeze
- POOL_EVENT_CALLBACKS =
POOL_EVENT_IDS.map do |event_id_sym| func = FFI::Storage.event_callback_for(event_id_sym) do |conn_ptr, pool_ptr, *args, op_ptr| Util.log(:debug, "POOL_EVENT_CALLBACKS[#{event_id_sym}]") do "inside callback conn_ptr=#{conn_ptr}, pool_ptr=#{pool_ptr}, args=#{args}, op_ptr=#{op_ptr}" end connection = Connection.load_ref(conn_ptr) pool = StoragePool.load_ref(pool_ptr) block, opaque = POOL_STORAGE.retrieve_from_pointer(op_ptr) block.call(connection, pool, *args, opaque) end [event_id_sym, func] end.to_h.freeze
- NETWORK_EVENT_CALLBACKS =
NETWORK_EVENT_IDS.map do |event_id_sym| func = FFI::Network.event_callback_for(event_id_sym) do |conn_ptr, pool_ptr, *args, op_ptr| Util.log(:debug, "NETWORK_EVENT_CALLBACKS[#{event_id_sym}]") do "inside callback conn_ptr=#{conn_ptr}, pool_ptr=#{pool_ptr}, args=#{args}, op_ptr=#{op_ptr}" end connection = Connection.load_ref(conn_ptr) pool = Network.load_ref(pool_ptr) block, opaque = NETWORK_STORAGE.retrieve_from_pointer(op_ptr) block.call(connection, pool, *args, opaque) end [event_id_sym, func] end.to_h.freeze
- CLOSE_CALLBACK =
FFI::Host.callback_function(:virConnectCloseFunc) do |conn_ptr, reason, op_ptr| Util.log(:debug, 'CLOSE_CALLBACK') { "inside callback conn_ptr=#{conn_ptr}, reason=#{reason}, op_ptr=#{op_ptr}" } connection = Connection.load_ref(conn_ptr) block, opaque = CLOSE_STORAGE.retrieve_from_pointer(op_ptr) block.call(connection, reason, opaque) end
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #begin_interface_change ⇒ Object
- #capabilities ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
- #commit_interface_change ⇒ Object
- #create_network(xml) ⇒ Object
- #define_domain(xml, options_or_flags = nil) ⇒ Object
- #define_interface(xml) ⇒ Object
- #define_network(xml) ⇒ Object
- #deregister_close_callback ⇒ Object
- #deregister_domain_event_callback(callback_id) ⇒ Object
- #deregister_network_event_callback(callback_id) ⇒ Object
- #deregister_storage_pool_event_callback(callback_id) ⇒ Object
- #free_memory ⇒ Object
- #hostname ⇒ Object
-
#initialize(uri) ⇒ Connection
constructor
A new instance of Connection.
- #inspect ⇒ Object
- #lib_version ⇒ Object
- #list_all_domains(flags = 0) ⇒ Object
- #list_all_domains_qty(flags = 0) ⇒ Object
- #list_all_interfaces(options_or_flags = nil) ⇒ Array<Libvirt::Interface>, Array
- #list_all_interfaces_qty(options_or_flags = nil) ⇒ Integer
- #list_all_networks(options_or_flags = nil) ⇒ Array<Libvirt::Network>, Array
- #list_all_networks_qty(options_or_flags = nil) ⇒ Integer
- #list_all_storage_pools(options_or_flags = nil) ⇒ Object
- #list_all_storage_pools_qty(options_or_flags = nil) ⇒ Object
- #max_vcpus(type = nil) ⇒ Object
- #node_info ⇒ Object
- #open ⇒ Object
- #opened? ⇒ Boolean
- #register_close_callback(opaque = nil, &block) ⇒ Object
- #register_domain_event_callback(event_id, domain = nil, opaque = nil) { ... } ⇒ Object
- #register_network_event_callback(event_id, network = nil, opaque = nil, &block) ⇒ Object
- #register_storage_pool_event_callback(event_id, storage_pool = nil, opaque = nil, &block) ⇒ Object
- #rollback_interface_change ⇒ Object
- #set_keep_alive(interval, count) ⇒ Object
- #stream(flags = 0) ⇒ Object
- #to_ptr ⇒ Object
- #to_s ⇒ Object
- #version ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(uri) ⇒ Connection
Returns a new instance of Connection.
72 73 74 75 76 77 78 |
# File 'lib/libvirt/connection.rb', line 72 def initialize(uri) @uri = uri @ptr = ::FFI::Pointer.new(0) @close_data = nil Util.define_finalizer(self) { |pointer| FFI::Host.virConnectClose(pointer) } end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
70 71 72 |
# File 'lib/libvirt/connection.rb', line 70 def uri @uri end |
Class Method Details
.load_ref(ptr) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/libvirt/connection.rb', line 62 def self.load_ref(ptr) result = FFI::Host.virConnectRef(ptr) raise Errors::LibError, "Couldn't retrieve connection reference" if result.negative? uri = FFI::Host.virConnectGetURI(ptr) new(uri).tap { |c| c.instance_variable_set(:@ptr, ptr) } end |
Instance Method Details
#begin_interface_change ⇒ Object
481 482 483 484 |
# File 'lib/libvirt/connection.rb', line 481 def begin_interface_change result = FFI::Interface.virInterfaceChangeBegin(@ptr, 0) raise Errors::LibError, "Couldn't begin interface change" if result.negative? end |
#capabilities ⇒ Object
426 427 428 |
# File 'lib/libvirt/connection.rb', line 426 def capabilities FFI::Host.virConnectGetCapabilities(@ptr) end |
#close ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/libvirt/connection.rb', line 101 def close result = FFI::Host.virConnectClose(@ptr) raise Errors::LibError, "Couldn't close connection to #{@uri.inspect}" if result.negative? dbg { 'closed' } @ptr = ::FFI::Pointer.new(0) true end |
#closed? ⇒ Boolean
115 116 117 |
# File 'lib/libvirt/connection.rb', line 115 def closed? !opened? end |
#commit_interface_change ⇒ Object
487 488 489 490 |
# File 'lib/libvirt/connection.rb', line 487 def commit_interface_change result = FFI::Interface.virInterfaceChangeCommit(@ptr, 0) raise Errors::LibError, "Couldn't commit interface change" if result.negative? end |
#create_network(xml) ⇒ Object
455 456 457 458 459 460 |
# File 'lib/libvirt/connection.rb', line 455 def create_network(xml) pointer = FFI::Network.virNetworkCreateXML(@ptr, xml) raise Errors::LibError, "Couldn't create network with xml" if pointer.null? Network.new(pointer) end |
#define_domain(xml, options_or_flags = nil) ⇒ Object
445 446 447 448 449 450 451 |
# File 'lib/libvirt/connection.rb', line 445 def define_domain(xml, = nil) flags = Util.parse_flags , FFI::Domain.enum_type(:define_flags) pointer = FFI::Domain.virDomainDefineXMLFlags(@ptr, xml, flags) raise Errors::LibError, "Couldn't define domain" if pointer.null? Domain.new(pointer) end |
#define_interface(xml) ⇒ Object
473 474 475 476 477 478 |
# File 'lib/libvirt/connection.rb', line 473 def define_interface(xml) pointer = FFI::Interface.virInterfaceDefineXML(@ptr, xml, 0) raise Errors::LibError, "Couldn't define interface with xml" if pointer.null? Interface.new(pointer) end |
#define_network(xml) ⇒ Object
464 465 466 467 468 469 |
# File 'lib/libvirt/connection.rb', line 464 def define_network(xml) pointer = FFI::Network.virNetworkDefineXML(@ptr, xml) raise Errors::LibError, "Couldn't define network with xml" if pointer.null? Network.new(pointer) end |
#deregister_close_callback ⇒ Object
264 265 266 267 268 269 270 271 272 273 |
# File 'lib/libvirt/connection.rb', line 264 def deregister_close_callback dbg { 'deregister' } result = FFI::Host.virConnectUnregisterCloseCallback(@ptr, CLOSE_CALLBACK) raise Errors::LibError, "Couldn't deregister close callback" if result.negative? # virConnectUnregisterCloseCallback will call free func # So we don't need to remove object from CLOSE_STORAGE here. true end |
#deregister_domain_event_callback(callback_id) ⇒ Object
309 310 311 312 313 314 315 316 317 318 |
# File 'lib/libvirt/connection.rb', line 309 def deregister_domain_event_callback(callback_id) dbg { "callback_id=#{callback_id}" } result = FFI::Domain.virConnectDomainEventDeregisterAny(@ptr, callback_id) raise Errors::LibError, "Couldn't deregister domain event callback" if result.negative? # virConnectDomainEventDeregisterAny will call free func # So we don't need to remove object from DOMAIN_STORAGE here. true end |
#deregister_network_event_callback(callback_id) ⇒ Object
397 398 399 400 401 402 403 404 405 406 |
# File 'lib/libvirt/connection.rb', line 397 def deregister_network_event_callback(callback_id) dbg { "callback_id=#{callback_id}" } result = FFI::Network.virConnectNetworkEventDeregisterAny(@ptr, callback_id) raise Errors::LibError, "Couldn't deregister network event callback" if result.negative? # virConnectNetworkEventDeregisterAny will call free func # So we don't need to remove object from NETWORK_STORAGE here. true end |
#deregister_storage_pool_event_callback(callback_id) ⇒ Object
353 354 355 356 357 358 359 360 361 362 |
# File 'lib/libvirt/connection.rb', line 353 def deregister_storage_pool_event_callback(callback_id) dbg { "callback_id=#{callback_id}" } result = FFI::Storage.virConnectStoragePoolEventDeregisterAny(@ptr, callback_id) raise Errors::LibError, "Couldn't deregister storage pool event callback" if result.negative? # virConnectStoragePoolEventDeregisterAny will call free func # So we don't need to remove object from POOL_STORAGE here. true end |
#free_memory ⇒ Object
137 138 139 140 141 142 |
# File 'lib/libvirt/connection.rb', line 137 def free_memory result = FFI::Host.virNodeGetFreeMemory(@ptr) raise Errors::LibError, "Couldn't set connection keep_alive" if result.negative? result end |
#hostname ⇒ Object
417 418 419 |
# File 'lib/libvirt/connection.rb', line 417 def hostname FFI::Host.virConnectGetHostname(@ptr) end |
#inspect ⇒ Object
84 85 86 |
# File 'lib/libvirt/connection.rb', line 84 def inspect to_s end |
#lib_version ⇒ Object
408 409 410 411 412 413 414 415 |
# File 'lib/libvirt/connection.rb', line 408 def lib_version version_ptr = ::FFI::MemoryPointer.new(:ulong) result = FFI::Host.virConnectGetLibVersion(@ptr, version_ptr) raise Errors::LibError, "Couldn't get connection lib version" if result.negative? version_number = version_ptr.get_ulong(0) Util.parse_version(version_number) end |
#list_all_domains(flags = 0) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/libvirt/connection.rb', line 151 def list_all_domains(flags = 0) size = list_all_domains_qty(flags) return [] if size.zero? domains_ptr = ::FFI::MemoryPointer.new(:pointer, size) result = FFI::Domain.virConnectListAllDomains(@ptr, domains_ptr, flags) raise Errors::LibError, "Couldn't retrieve domains list with flags #{flags.to_s(16)}" if result.negative? ptr = domains_ptr.read_pointer ptr.get_array_of_pointer(0, size).map { |dom_ptr| Libvirt::Domain.new(dom_ptr) } end |
#list_all_domains_qty(flags = 0) ⇒ Object
144 145 146 147 148 149 |
# File 'lib/libvirt/connection.rb', line 144 def list_all_domains_qty(flags = 0) result = FFI::Domain.virConnectListAllDomains(@ptr, nil, flags) raise Errors::LibError, "Couldn't retrieve domains qty with flags #{flags.to_s(16)}" if result.negative? result end |
#list_all_interfaces(options_or_flags = nil) ⇒ Array<Libvirt::Interface>, Array
225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/libvirt/connection.rb', line 225 def list_all_interfaces( = nil) flags = Util.parse_flags , FFI::Interface.enum_type(:list_all_flags) size = list_all_interfaces_qty(flags) return [] if size.zero? interfaces_ptr = ::FFI::MemoryPointer.new(:pointer, size) result = FFI::Interface.virConnectListAllInterfaces(@ptr, interfaces_ptr, 0) raise Errors::LibError, "Couldn't retrieve interfaces list" if result.negative? ptr = interfaces_ptr.read_pointer ptr.get_array_of_pointer(0, size).map { |i_ptr| Interface.new(i_ptr) } end |
#list_all_interfaces_qty(options_or_flags = nil) ⇒ Integer
214 215 216 217 218 219 220 |
# File 'lib/libvirt/connection.rb', line 214 def list_all_interfaces_qty( = nil) flags = Util.parse_flags , FFI::Interface.enum_type(:list_all_flags) result = FFI::Interface.virConnectListAllInterfaces(@ptr, nil, flags) raise Errors::LibError, "Couldn't retrieve interfaces qty with flags #{flags.to_s(16)}" if result.negative? result end |
#list_all_networks(options_or_flags = nil) ⇒ Array<Libvirt::Network>, Array
198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/libvirt/connection.rb', line 198 def list_all_networks( = nil) flags = Util.parse_flags , FFI::Network.enum_type(:list_all_flags) size = list_all_networks_qty(flags) return [] if size.zero? networks_ptr = ::FFI::MemoryPointer.new(:pointer, size) result = FFI::Network.virConnectListAllNetworks(@ptr, networks_ptr, 0) raise Errors::LibError, "Couldn't retrieve networks list" if result.negative? ptr = networks_ptr.read_pointer ptr.get_array_of_pointer(0, size).map { |n_ptr| Network.new(n_ptr) } end |
#list_all_networks_qty(options_or_flags = nil) ⇒ Integer
187 188 189 190 191 192 193 |
# File 'lib/libvirt/connection.rb', line 187 def list_all_networks_qty( = nil) flags = Util.parse_flags , FFI::Network.enum_type(:list_all_flags) result = FFI::Network.virConnectListAllNetworks(@ptr, nil, flags) raise Errors::LibError, "Couldn't retrieve networks qty with flags #{flags.to_s(16)}" if result.negative? result end |
#list_all_storage_pools(options_or_flags = nil) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/libvirt/connection.rb', line 171 def list_all_storage_pools( = nil) flags = Util.parse_flags , FFI::Storage.enum_type(:list_all_pools_flags) size = list_all_storage_pools_qty(flags) return [] if size.zero? storage_pools_ptr = ::FFI::MemoryPointer.new(:pointer, size) result = FFI::Storage.virConnectListAllStoragePools(@ptr, storage_pools_ptr, flags) raise Errors::LibError, "Couldn't retrieve storage pools list with flags #{flags.to_s(16)}" if result.negative? ptr = storage_pools_ptr.read_pointer ptr.get_array_of_pointer(0, size).map { |stp_ptr| StoragePool.new(stp_ptr) } end |
#list_all_storage_pools_qty(options_or_flags = nil) ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/libvirt/connection.rb', line 163 def list_all_storage_pools_qty( = nil) flags = Util.parse_flags , FFI::Storage.enum_type(:list_all_pools_flags) result = FFI::Storage.virConnectListAllStoragePools(@ptr, nil, flags) raise Errors::LibError, "Couldn't retrieve storage pools qty with flags #{flags.to_s(16)}" if result.negative? result end |
#max_vcpus(type = nil) ⇒ Object
422 423 424 |
# File 'lib/libvirt/connection.rb', line 422 def max_vcpus(type = nil) FFI::Host.virConnectGetMaxVcpus(@ptr, type) end |
#node_info ⇒ Object
430 431 432 433 434 435 436 |
# File 'lib/libvirt/connection.rb', line 430 def node_info node_info_ptr = ::FFI::MemoryPointer.new(FFI::Host::NodeInfoStruct.by_value) result = FFI::Host.virNodeGetInfo(@ptr, node_info_ptr) raise Errors::LibError, "Couldn't get connection node info" if result.negative? NodeInfo.new(node_info_ptr) end |
#open ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/libvirt/connection.rb', line 92 def open @ptr = FFI::Host.virConnectOpen(@uri) raise Errors::LibError, "Couldn't open connection to #{@uri.inspect}" if @ptr.null? dbg { 'opened' } true end |
#opened? ⇒ Boolean
111 112 113 |
# File 'lib/libvirt/connection.rb', line 111 def opened? !@ptr.null? end |
#register_close_callback(opaque = nil, &block) ⇒ Object
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 |
# File 'lib/libvirt/connection.rb', line 238 def register_close_callback(opaque = nil, &block) dbg { "opaque=#{opaque}" } cb_data, cb_data_free_func = CLOSE_STORAGE.allocate_struct result = FFI::Host.virConnectRegisterCloseCallback( @ptr, CLOSE_CALLBACK, cb_data.pointer, cb_data_free_func ) if result.negative? cb_data.pointer.free raise Errors::LibError, "Couldn't register connection close callback" end CLOSE_STORAGE.store_struct( cb_data, connection_pointer: @ptr, callback_id: result, cb: block, opaque: opaque, free_func: cb_data_free_func ) result end |
#register_domain_event_callback(event_id, domain = nil, opaque = nil) { ... } ⇒ Object
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 |
# File 'lib/libvirt/connection.rb', line 276 def register_domain_event_callback(event_id, domain = nil, opaque = nil, &block) dbg { "event_id=#{event_id}" } enum = FFI::Domain.enum_type(:event_id) event_id, event_id_sym = Util.parse_enum(enum, event_id) cb = DOMAIN_EVENT_CALLBACKS.fetch(event_id_sym) cb_data, cb_data_free_func = DOMAIN_STORAGE.allocate_struct result = FFI::Domain.virConnectDomainEventRegisterAny( @ptr, domain&.to_ptr, event_id, cb, cb_data.pointer, cb_data_free_func ) if result.negative? cb_data.pointer.free raise Errors::LibError, "Couldn't register domain event callback" end DOMAIN_STORAGE.store_struct( cb_data, connection_pointer: @conn_ptr, callback_id: result, cb: block, opaque: opaque, free_func: cb_data_free_func ) result end |
#register_network_event_callback(event_id, network = nil, opaque = nil, &block) ⇒ Object
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 |
# File 'lib/libvirt/connection.rb', line 364 def register_network_event_callback(event_id, network = nil, opaque = nil, &block) dbg { "event_id=#{event_id}" } enum = FFI::Network.enum_type(:event_id) event_id, event_id_sym = Util.parse_enum(enum, event_id) cb = NETWORK_EVENT_CALLBACKS.fetch(event_id_sym) cb_data, cb_data_free_func = NETWORK_STORAGE.allocate_struct result = FFI::Network.virConnectNetworkEventRegisterAny( @ptr, network&.to_ptr, event_id, cb, cb_data.pointer, cb_data_free_func ) if result.negative? cb_data.pointer.free raise Errors::LibError, "Couldn't register network event callback" end NETWORK_STORAGE.store_struct( cb_data, connection_pointer: @ptr, callback_id: result, cb: block, opaque: opaque, free_func: cb_data_free_func ) result end |
#register_storage_pool_event_callback(event_id, storage_pool = nil, opaque = nil, &block) ⇒ Object
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 |
# File 'lib/libvirt/connection.rb', line 320 def register_storage_pool_event_callback(event_id, storage_pool = nil, opaque = nil, &block) dbg { "event_id=#{event_id}" } enum = FFI::Storage.enum_type(:event_id) event_id, event_id_sym = Util.parse_enum(enum, event_id) cb = POOL_EVENT_CALLBACKS.fetch(event_id_sym) cb_data, cb_data_free_func = POOL_STORAGE.allocate_struct result = FFI::Storage.virConnectStoragePoolEventRegisterAny( @ptr, storage_pool&.to_ptr, event_id, cb, cb_data.pointer, cb_data_free_func ) if result.negative? cb_data.pointer.free raise Errors::LibError, "Couldn't register storage pool event callback" end POOL_STORAGE.store_struct( cb_data, connection_pointer: @ptr, callback_id: result, cb: block, opaque: opaque, free_func: cb_data_free_func ) result end |
#rollback_interface_change ⇒ Object
493 494 495 496 |
# File 'lib/libvirt/connection.rb', line 493 def rollback_interface_change result = FFI::Interface.virInterfaceChangeRollback(@ptr, 0) raise Errors::LibError, "Couldn't rollback interface change" if result.negative? end |
#set_keep_alive(interval, count) ⇒ Object
130 131 132 133 134 135 |
# File 'lib/libvirt/connection.rb', line 130 def set_keep_alive(interval, count) result = FFI::Host.virConnectSetKeepAlive(@ptr, interval, count) raise Errors::LibError, "Couldn't set connection keep_alive" if result.negative? result.zero? end |
#stream(flags = 0) ⇒ Object
438 439 440 441 442 443 |
# File 'lib/libvirt/connection.rb', line 438 def stream(flags = 0) pointer = FFI::Stream.virStreamNew(@ptr, flags) raise Errors::LibError, "Couldn't create stream" if pointer.null? Stream.new(pointer) end |
#to_ptr ⇒ Object
88 89 90 |
# File 'lib/libvirt/connection.rb', line 88 def to_ptr @ptr end |
#to_s ⇒ Object
80 81 82 |
# File 'lib/libvirt/connection.rb', line 80 def to_s "#<#{self.class}:0x#{object_id.to_s(16)} @uri=#{@uri.inspect} @ptr=0x#{@ptr.address.to_s(16)}>" end |
#version ⇒ Object
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/libvirt/connection.rb', line 119 def version check_open! version_ptr = ::FFI::MemoryPointer.new(:ulong) result = FFI::Host.virConnectGetVersion(@ptr, version_ptr) raise Errors::LibError, "Couldn't retrieve connection version" if result.negative? version_number = version_ptr.get_ulong(0) Util.parse_version(version_number) end |