Class: Libvirt::StorageVolume
- Inherits:
-
Object
- Object
- Libvirt::StorageVolume
- Defined in:
- lib/libvirt/storage_volume.rb
Class Method Summary collapse
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(pointer) ⇒ StorageVolume
constructor
A new instance of StorageVolume.
- #to_ptr ⇒ Object
- #xml_desc(options_or_flags = nil) ⇒ Object
Constructor Details
#initialize(pointer) ⇒ StorageVolume
Returns a new instance of StorageVolume.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/libvirt/storage_volume.rb', line 12 def initialize(pointer) @ptr = pointer free = ->(obj_id) do Util.log(:debug) { "Finalize Libvirt::StorageVolume 0x#{obj_id.to_s(16)} @ptr=#{@ptr}," } return unless @ptr fr_result = FFI::Storage.virStorageVolFree(@ptr) warn "Couldn't free Libvirt::StorageVolume (0x#{obj_id.to_s(16)}) pointer #{@ptr.address}" if fr_result.negative? end ObjectSpace.define_finalizer(self, free) end |
Class Method Details
Instance Method Details
#info ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/libvirt/storage_volume.rb', line 29 def info info_ptr = ::FFI::MemoryPointer.new(FFI::Storage::VolumeInfoStruct.by_value) result = FFI::Storage.virStorageVolGetInfo(@ptr, info_ptr) raise Errors::LibError, "Couldn't get storage volume info" if result.negative? StorageVolumeInfo.new(info_ptr) end |
#to_ptr ⇒ Object
25 26 27 |
# File 'lib/libvirt/storage_volume.rb', line 25 def to_ptr @ptr end |
#xml_desc(options_or_flags = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/libvirt/storage_volume.rb', line 37 def xml_desc( = nil) flags = Util.parse_flags , FFI::Storage.enum_type(:xml_flags) result = FFI::Storage.virStorageVolGetXMLDesc(@ptr, flags) raise Errors::LibError, "Couldn't get storage volume xml desc" if result.nil? result end |