Class: Libvirt::NodeDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/libvirt/node_device.rb

Overview

Represents a device on a node.

Instance Method Summary collapse

Constructor Details

#initialize(pointer) ⇒ NodeDevice

Initializes a node device with the given virNodeDevicePtr. This should not be called directly. Instead, call Libvirt::Node#devices to get a list of the devices.

Parameters:

  • pointer (FFI::Pointer)


9
10
11
12
# File 'lib/libvirt/node_device.rb', line 9

def initialize(pointer)
  @pointer = pointer
  ObjectSpace.define_finalizer(self, method(:finalize))
end

Instance Method Details

#destroyBoolean

Destroy the device, removing the virtual device from the host operating system.

Returns:

  • (Boolean)


55
56
57
# File 'lib/libvirt/node_device.rb', line 55

def destroy
  FFI::Libvirt.virNodeDeviceDestroy(self) == 0
end

#dettachBoolean

Detaches the device from the node itself so that it may be bound to a guest domain.

Returns:

  • (Boolean)


32
33
34
# File 'lib/libvirt/node_device.rb', line 32

def dettach
  FFI::Libvirt.virNodeDeviceDettach(self) == 0
end

#nameString

Returns the name of this device.

Returns:

  • (String)


17
18
19
# File 'lib/libvirt/node_device.rb', line 17

def name
  FFI::Libvirt.virNodeDeviceGetName(self)
end

#reattachBoolena

Reattach the device onto the node.

Returns:

  • (Boolena)


39
40
41
# File 'lib/libvirt/node_device.rb', line 39

def reattach
  FFI::Libvirt.virNodeDeviceReAttach(self) == 0
end

#resetBoolena

Reset the device. The exact semantics of this method are hypervisor specific.

Returns:

  • (Boolena)


47
48
49
# File 'lib/libvirt/node_device.rb', line 47

def reset
  FFI::Libvirt.virNodeDeviceReset(self) == 0
end

#to_ptrFFI::Pointer

Returns the underlying virNodeDevicePtr. This allows this object to be used directly with FFI methods.

Returns:

  • (FFI::Pointer)


63
64
65
# File 'lib/libvirt/node_device.rb', line 63

def to_ptr
  @pointer
end

#xmlString

Returns the XML specification for this device.

Returns:

  • (String)


24
25
26
# File 'lib/libvirt/node_device.rb', line 24

def xml
  FFI::Libvirt.virNodeDeviceGetXMLDesc(self, 0)
end