class Libvirt::NodeDevice
Attributes
Public Instance Methods
Call virNodeDeviceDestroy to shutdown the node device.
static VALUE libvirt_nodedevice_destroy(VALUE n)
{
ruby_libvirt_generate_call_nil(virNodeDeviceDestroy,
ruby_libvirt_connect_get(n),
nodedevice_get(n));
}
Call virNodeDeviceDettach to detach the node device from the node.
static VALUE libvirt_nodedevice_detach(int argc, VALUE *argv, VALUE n)
{
VALUE driver = RUBY_Qnil, flags = RUBY_Qnil;
rb_scan_args(argc, argv, "02", &driver, &flags);
if (ruby_libvirt_value_to_uint(flags) != 0 ||
ruby_libvirt_get_cstring_or_null(driver) != NULL) {
ruby_libvirt_generate_call_nil(virNodeDeviceDetachFlags,
ruby_libvirt_connect_get(n),
nodedevice_get(n),
ruby_libvirt_get_cstring_or_null(driver),
ruby_libvirt_value_to_uint(flags));
} else {
ruby_libvirt_generate_call_nil(virNodeDeviceDettach,
ruby_libvirt_connect_get(n),
nodedevice_get(n));
}
}
Call virNodeDeviceFree to free the node device object. After this call the node device object is no longer valid.
static VALUE libvirt_nodedevice_free(VALUE n)
{
ruby_libvirt_generate_call_free(NodeDevice, n);
}
Call virNodeDeviceListCaps to retrieve a list of capabilities of the node device.
static VALUE libvirt_nodedevice_list_caps(VALUE c)
{
int r, num;
char **names;
num = virNodeDeviceNumOfCaps(nodedevice_get(c));
ruby_libvirt_raise_error_if(num < 0, e_RetrieveError,
"virNodeDeviceNumOfCaps",
ruby_libvirt_connect_get(c));
if (num == 0) {
/* if num is 0, don't call virNodeDeviceListCaps function */
return rb_ary_new2(num);
}
names = alloca(sizeof(char *) * num);
r = virNodeDeviceListCaps(nodedevice_get(c), names, num);
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
"virNodeDeviceListCaps",
ruby_libvirt_connect_get(c));
return ruby_libvirt_generate_list(r, names);
}
Call virNodeDeviceLookupSCSIHostByWWN to look up a SCSI host by its WWNN and WWPN.
static VALUE libvirt_nodedevice_lookup_scsi_host_by_wwn(int argc, VALUE *argv,
VALUE n)
{
VALUE wwnn, wwpn, flags = RUBY_Qnil;
virNodeDevicePtr nd;
rb_scan_args(argc, argv, "21", &wwnn, &wwpn, &flags);
nd = virNodeDeviceLookupSCSIHostByWWN(ruby_libvirt_connect_get(n),
StringValueCStr(wwnn),
StringValueCStr(wwpn),
ruby_libvirt_value_to_uint(flags));
if (nd == NULL) {
return Qnil;
}
return ruby_libvirt_nodedevice_new(nd, ruby_libvirt_conn_attr(n));
}
Call virNodeDeviceGetName to retrieve the name of the node device.
static VALUE libvirt_nodedevice_name(VALUE c)
{
ruby_libvirt_generate_call_string(virNodeDeviceGetName,
ruby_libvirt_connect_get(c), 0,
nodedevice_get(c));
}
Call virNodeDeviceNumOfCaps to retrieve the number of capabilities of the node device.
static VALUE libvirt_nodedevice_num_of_caps(VALUE c)
{
ruby_libvirt_generate_call_int(virNodeDeviceNumOfCaps,
ruby_libvirt_connect_get(c),
nodedevice_get(c));
}
Call virNodeDeviceGetParent to retrieve the parent of the node device.
static VALUE libvirt_nodedevice_parent(VALUE c)
{
/* unfortunately we can't use ruby_libvirt_generate_call_string() here
* because virNodeDeviceGetParent() returns NULL as a valid value (when this
* device has no parent). Hand-code it instead
*/
const char *str;
str = virNodeDeviceGetParent(nodedevice_get(c));
if (str == NULL) {
return Qnil;
}
else {
return rb_str_new2(str);
}
}
Call virNodeDeviceReAttach to reattach the node device to the node.
static VALUE libvirt_nodedevice_reattach(VALUE n)
{
ruby_libvirt_generate_call_nil(virNodeDeviceReAttach,
ruby_libvirt_connect_get(n),
nodedevice_get(n));
}
Call virNodeDeviceReset to reset the node device.
static VALUE libvirt_nodedevice_reset(VALUE n)
{
ruby_libvirt_generate_call_nil(virNodeDeviceReset,
ruby_libvirt_connect_get(n),
nodedevice_get(n));
}
Call virNodeDeviceGetXMLDesc to retrieve the XML for the node device.
static VALUE libvirt_nodedevice_xml_desc(int argc, VALUE *argv, VALUE n)
{
VALUE flags = RUBY_Qnil;
rb_scan_args(argc, argv, "01", &flags);
ruby_libvirt_generate_call_string(virNodeDeviceGetXMLDesc,
ruby_libvirt_connect_get(n),
1, nodedevice_get(n),
ruby_libvirt_value_to_uint(flags));
}