class Libvirt::Connect
Constants
- BASELINE_CPU_EXPAND_FEATURES
- COMPARE_CPU_FAIL_INCOMPATIBLE
- CPU_COMPARE_ERROR
- CPU_COMPARE_IDENTICAL
- CPU_COMPARE_INCOMPATIBLE
- CPU_COMPARE_SUPERSET
- DOMAIN_DEFINE_VALIDATE
- DOMAIN_EVENT_CRASHED
- DOMAIN_EVENT_CRASHED_PANICKED
- DOMAIN_EVENT_DEFINED
- DOMAIN_EVENT_DEFINED_ADDED
- DOMAIN_EVENT_DEFINED_UPDATED
- DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4
- DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6
- DOMAIN_EVENT_GRAPHICS_ADDRESS_UNIX
- DOMAIN_EVENT_GRAPHICS_CONNECT
- DOMAIN_EVENT_GRAPHICS_DISCONNECT
- DOMAIN_EVENT_GRAPHICS_INITIALIZE
- DOMAIN_EVENT_ID_CONTROL_ERROR
- DOMAIN_EVENT_ID_GRAPHICS
- DOMAIN_EVENT_ID_IO_ERROR
- DOMAIN_EVENT_ID_IO_ERROR_REASON
- DOMAIN_EVENT_ID_LIFECYCLE
- DOMAIN_EVENT_ID_REBOOT
- DOMAIN_EVENT_ID_RTC_CHANGE
- DOMAIN_EVENT_ID_WATCHDOG
- DOMAIN_EVENT_IO_ERROR_NONE
- DOMAIN_EVENT_IO_ERROR_PAUSE
- DOMAIN_EVENT_IO_ERROR_REPORT
- DOMAIN_EVENT_PMSUSPENDED
- DOMAIN_EVENT_PMSUSPENDED_DISK
- DOMAIN_EVENT_PMSUSPENDED_MEMORY
- DOMAIN_EVENT_RESUMED
- DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT
- DOMAIN_EVENT_RESUMED_MIGRATED
- DOMAIN_EVENT_RESUMED_UNPAUSED
- DOMAIN_EVENT_SHUTDOWN
- DOMAIN_EVENT_SHUTDOWN_FINISHED
- DOMAIN_EVENT_STARTED
- DOMAIN_EVENT_STARTED_BOOTED
- DOMAIN_EVENT_STARTED_FROM_SNAPSHOT
- DOMAIN_EVENT_STARTED_MIGRATED
- DOMAIN_EVENT_STARTED_RESTORED
- DOMAIN_EVENT_STARTED_WAKEUP
- DOMAIN_EVENT_STOPPED
- DOMAIN_EVENT_STOPPED_CRASHED
- DOMAIN_EVENT_STOPPED_DESTROYED
- DOMAIN_EVENT_STOPPED_FAILED
- DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT
- DOMAIN_EVENT_STOPPED_MIGRATED
- DOMAIN_EVENT_STOPPED_SAVED
- DOMAIN_EVENT_STOPPED_SHUTDOWN
- DOMAIN_EVENT_SUSPENDED
- DOMAIN_EVENT_SUSPENDED_API_ERROR
- DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT
- DOMAIN_EVENT_SUSPENDED_IOERROR
- DOMAIN_EVENT_SUSPENDED_MIGRATED
- DOMAIN_EVENT_SUSPENDED_PAUSED
- DOMAIN_EVENT_SUSPENDED_RESTORED
- DOMAIN_EVENT_SUSPENDED_WATCHDOG
- DOMAIN_EVENT_UNDEFINED
- DOMAIN_EVENT_UNDEFINED_REMOVED
- DOMAIN_EVENT_WATCHDOG_DEBUG
- DOMAIN_EVENT_WATCHDOG_NONE
- DOMAIN_EVENT_WATCHDOG_PAUSE
- DOMAIN_EVENT_WATCHDOG_POWEROFF
- DOMAIN_EVENT_WATCHDOG_RESET
- DOMAIN_EVENT_WATCHDOG_SHUTDOWN
- LIST_DOMAINS_ACTIVE
- LIST_DOMAINS_AUTOSTART
- LIST_DOMAINS_HAS_SNAPSHOT
- LIST_DOMAINS_INACTIVE
- LIST_DOMAINS_MANAGEDSAVE
- LIST_DOMAINS_NO_AUTOSTART
- LIST_DOMAINS_NO_MANAGEDSAVE
- LIST_DOMAINS_NO_SNAPSHOT
- LIST_DOMAINS_OTHER
- LIST_DOMAINS_PAUSED
- LIST_DOMAINS_PERSISTENT
- LIST_DOMAINS_RUNNING
- LIST_DOMAINS_SHUTOFF
- LIST_DOMAINS_TRANSIENT
- LIST_INTERFACES_ACTIVE
- LIST_INTERFACES_INACTIVE
- LIST_NETWORKS_ACTIVE
- LIST_NETWORKS_AUTOSTART
- LIST_NETWORKS_INACTIVE
- LIST_NETWORKS_NO_AUTOSTART
- LIST_NETWORKS_PERSISTENT
- LIST_NETWORKS_TRANSIENT
- LIST_NODE_DEVICES_CAP_FC_HOST
- LIST_NODE_DEVICES_CAP_NET
- LIST_NODE_DEVICES_CAP_PCI_DEV
- LIST_NODE_DEVICES_CAP_SCSI
- LIST_NODE_DEVICES_CAP_SCSI_GENERIC
- LIST_NODE_DEVICES_CAP_SCSI_HOST
- LIST_NODE_DEVICES_CAP_SCSI_TARGET
- LIST_NODE_DEVICES_CAP_STORAGE
- LIST_NODE_DEVICES_CAP_SYSTEM
- LIST_NODE_DEVICES_CAP_USB_DEV
- LIST_NODE_DEVICES_CAP_USB_INTERFACE
- LIST_NODE_DEVICES_CAP_VPORTS
- LIST_SECRETS_EPHEMERAL
- LIST_SECRETS_NO_EPHEMERAL
- LIST_SECRETS_NO_PRIVATE
- LIST_SECRETS_PRIVATE
- LIST_STORAGE_POOLS_ACTIVE
- LIST_STORAGE_POOLS_AUTOSTART
- LIST_STORAGE_POOLS_DIR
- LIST_STORAGE_POOLS_DISK
- LIST_STORAGE_POOLS_FS
- LIST_STORAGE_POOLS_GLUSTER
- LIST_STORAGE_POOLS_INACTIVE
- LIST_STORAGE_POOLS_ISCSI
- LIST_STORAGE_POOLS_LOGICAL
- LIST_STORAGE_POOLS_MPATH
- LIST_STORAGE_POOLS_NETFS
- LIST_STORAGE_POOLS_NO_AUTOSTART
- LIST_STORAGE_POOLS_PERSISTENT
- LIST_STORAGE_POOLS_RBD
- LIST_STORAGE_POOLS_SCSI
- LIST_STORAGE_POOLS_SHEEPDOG
- LIST_STORAGE_POOLS_TRANSIENT
- LIST_STORAGE_POOLS_ZFS
- NODE_ALLOC_PAGES_ADD
- NODE_ALLOC_PAGES_SET
- NODE_CPU_STATS_ALL_CPUS
- NODE_MEMORY_STATS_ALL_CELLS
- NODE_SUSPEND_TARGET_DISK
- NODE_SUSPEND_TARGET_HYBRID
- NODE_SUSPEND_TARGET_MEM
Public Instance Methods
Call virConnectIsAlive to determine if the connection is alive.
static VALUE libvirt_connect_alive_p(VALUE c) { ruby_libvirt_generate_call_truefalse(virConnectIsAlive, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c)); }
Call virConnectBaselineCPU to compare the most feature-rich CPU which is compatible with all given host CPUs.
static VALUE libvirt_connect_baseline_cpu(int argc, VALUE *argv, VALUE c) { VALUE xmlcpus, flags, retval, entry; char *r; unsigned int ncpus; const char **xmllist; int exception = 0; unsigned int i; rb_scan_args(argc, argv, "11", &xmlcpus, &flags); Check_Type(xmlcpus, T_ARRAY); if (RARRAY_LEN(xmlcpus) < 1) { rb_raise(rb_eArgError, "wrong number of cpu arguments (%ld for 1 or more)", RARRAY_LEN(xmlcpus)); } ncpus = RARRAY_LEN(xmlcpus); xmllist = alloca(sizeof(const char *) * ncpus); for (i = 0; i < ncpus; i++) { entry = rb_ary_entry(xmlcpus, i); xmllist[i] = StringValueCStr(entry); } r = virConnectBaselineCPU(ruby_libvirt_connect_get(c), xmllist, ncpus, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r == NULL, e_RetrieveError, "virConnectBaselineCPU", ruby_libvirt_connect_get(c)); retval = rb_protect(ruby_libvirt_str_new2_wrap, (VALUE)&r, &exception); free(r); if (exception) { rb_jump_tag(exception); } return retval; }
Call virConnectGetCapabilities to retrieve the capabilities XML for this connection.
static VALUE libvirt_connect_capabilities(VALUE c) { ruby_libvirt_generate_call_string(virConnectGetCapabilities, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c)); }
Call virConnectClose to close the connection.
static VALUE libvirt_connect_close(VALUE c) { virConnectPtr conn; Data_Get_Struct(c, virConnect, conn); if (conn) { connect_close(conn); DATA_PTR(c) = NULL; } return Qnil; }
Return true
if the connection is closed, false
if it is open.
static VALUE libvirt_connect_closed_p(VALUE c) { virConnectPtr conn; Data_Get_Struct(c, virConnect, conn); return (conn == NULL) ? Qtrue : Qfalse; }
Call virConnectCompareCPU to compare the host CPU with the XML contained in xml. Returns one of Libvirt::CPU_COMPARE_ERROR, Libvirt::CPU_COMPARE_INCOMPATIBLE, Libvirt::CPU_COMPARE_IDENTICAL, or Libvirt::CPU_COMPARE_SUPERSET.
static VALUE libvirt_connect_compare_cpu(int argc, VALUE *argv, VALUE c) { VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); ruby_libvirt_generate_call_int(virConnectCompareCPU, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); }
Call virConnectGetCPUModelNames to get an array of CPU model names.
static VALUE libvirt_connect_cpu_model_names(int argc, VALUE *argv, VALUE c) { VALUE arch, flags, result; char **models; int i = 0, j, elems = 0; struct ruby_libvirt_str_new2_and_ary_store_arg args; int exception; rb_scan_args(argc, argv, "11", &arch, &flags); elems = virConnectGetCPUModelNames(ruby_libvirt_connect_get(c), StringValueCStr(arch), &models, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(elems < 0, e_RetrieveError, "virConnectGetCPUModelNames", ruby_libvirt_connect_get(c)); result = rb_protect(ruby_libvirt_ary_new2_wrap, (VALUE)&elems, &exception); if (exception) { goto error; } for (i = 0; i < elems; i++) { args.arr = result; args.index = i; args.value = models[i]; rb_protect(ruby_libvirt_str_new2_and_ary_store_wrap, (VALUE)&args, &exception); if (exception) { goto error; } free(models[i]); } free(models); return result; error: for (j = i; j < elems; j++) { free(models[j]); } free(models); rb_jump_tag(exception); return Qnil; }
Call virDomainCreateLinux to start a transient domain from the given XML. Deprecated; use conn.create_domain_xml instead.
static VALUE libvirt_connect_create_linux(int argc, VALUE *argv, VALUE c) { virDomainPtr dom; VALUE flags, xml; rb_scan_args(argc, argv, "11", &xml, &flags); dom = virDomainCreateLinux(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(dom == NULL, e_Error, "virDomainCreateLinux", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virDomainCreateXML to start a transient domain from the given XML.
static VALUE libvirt_connect_create_domain_xml(int argc, VALUE *argv, VALUE c) { virDomainPtr dom; VALUE flags, xml; rb_scan_args(argc, argv, "11", &xml, &flags); dom = virDomainCreateXML(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(dom == NULL, e_Error, "virDomainCreateXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virDomainCreateXMLWithFiles to launch a new guest domain with a set of open file descriptors.
static VALUE libvirt_connect_create_domain_xml_with_files(int argc, VALUE *argv, VALUE c) { VALUE xml, fds, flags; int *files; unsigned int numfiles, i; virDomainPtr dom; rb_scan_args(argc, argv, "12", &xml, &fds, &flags); Check_Type(xml, T_STRING); if (TYPE(fds) == T_NIL) { files = NULL; numfiles = 0; } else if (TYPE(fds) == T_ARRAY) { numfiles = RARRAY_LEN(fds); files = alloca(numfiles * sizeof(int)); for (i = 0; i < numfiles; i++) { files[i] = NUM2INT(rb_ary_entry(fds, i)); } } else { rb_raise(rb_eTypeError, "wrong argument type (expected Array)"); } dom = virDomainCreateXMLWithFiles(ruby_libvirt_connect_get(c), ruby_libvirt_get_cstring_or_null(xml), numfiles, files, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(dom == NULL, e_Error, "virDomainCreateXMLWithFiles", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virNetworkCreateXML to start a new transient network from xml.
static VALUE libvirt_connect_create_network_xml(VALUE c, VALUE xml) { virNetworkPtr netw; netw = virNetworkCreateXML(ruby_libvirt_connect_get(c), StringValueCStr(xml)); ruby_libvirt_raise_error_if(netw == NULL, e_Error, "virNetworkCreateXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_network_new(netw, c); }
Call virNodeDeviceCreateXML to create a new node device from xml.
static VALUE libvirt_connect_create_nodedevice_xml(int argc, VALUE *argv, VALUE c) { virNodeDevicePtr nodedev; VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); nodedev = virNodeDeviceCreateXML(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(nodedev == NULL, e_Error, "virNodeDeviceCreateXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_nodedevice_new(nodedev, c); }
Call virStoragePoolCreateXML to start a new transient storage pool from xml.
static VALUE libvirt_connect_create_pool_xml(int argc, VALUE *argv, VALUE c) { virStoragePoolPtr pool; VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); pool = virStoragePoolCreateXML(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(pool == NULL, e_Error, "virStoragePoolCreateXML", ruby_libvirt_connect_get(c)); return pool_new(pool, c); }
Call virDomainDefineXML to define a permanent domain on this connection.
static VALUE libvirt_connect_define_domain_xml(int argc, VALUE *argv, VALUE c) { virDomainPtr dom; VALUE xml; VALUE flags; rb_scan_args(argc, argv, "11", &xml, &flags); if (ruby_libvirt_value_to_uint(flags) != 0) { dom = virDomainDefineXMLFlags(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); } else { dom = virDomainDefineXML(ruby_libvirt_connect_get(c), StringValueCStr(xml)); } ruby_libvirt_raise_error_if(dom == NULL, e_DefinitionError, "virDomainDefineXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virInterfaceDefineXML to define a new interface from xml.
static VALUE libvirt_connect_define_interface_xml(int argc, VALUE *argv, VALUE c) { virInterfacePtr iface; VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); iface = virInterfaceDefineXML(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(iface == NULL, e_DefinitionError, "virInterfaceDefineXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_interface_new(iface, c); }
Call virNetworkDefineXML to define a new permanent network from xml.
static VALUE libvirt_connect_define_network_xml(VALUE c, VALUE xml) { virNetworkPtr netw; netw = virNetworkDefineXML(ruby_libvirt_connect_get(c), StringValueCStr(xml)); ruby_libvirt_raise_error_if(netw == NULL, e_DefinitionError, "virNetworkDefineXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_network_new(netw, c); }
Call virNWFilterDefineXML to define a new network filter from xml.
static VALUE libvirt_connect_define_nwfilter_xml(VALUE c, VALUE xml) { virNWFilterPtr nwfilter; nwfilter = virNWFilterDefineXML(ruby_libvirt_connect_get(c), StringValueCStr(xml)); ruby_libvirt_raise_error_if(nwfilter == NULL, e_DefinitionError, "virNWFilterDefineXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_nwfilter_new(nwfilter, c); }
Call virDomainSaveImageDefineXML to define new XML for a saved image.
static VALUE libvirt_connect_define_save_image_xml(int argc, VALUE *argv, VALUE c) { VALUE filename, newxml, flags; rb_scan_args(argc, argv, "21", &filename, &newxml, &flags); ruby_libvirt_generate_call_nil(virDomainSaveImageDefineXML, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), StringValueCStr(filename), StringValueCStr(newxml), ruby_libvirt_value_to_uint(flags)); }
Call virSecretDefineXML to define a new secret from xml.
static VALUE libvirt_connect_define_secret_xml(int argc, VALUE *argv, VALUE c) { virSecretPtr secret; VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); secret = virSecretDefineXML(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(secret == NULL, e_DefinitionError, "virSecretDefineXML", ruby_libvirt_connect_get(c)); return ruby_libvirt_secret_new(secret, c); }
Call virStoragePoolDefineXML to define a permanent storage pool from xml.
static VALUE libvirt_connect_define_pool_xml(int argc, VALUE *argv, VALUE c) { virStoragePoolPtr pool; VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); pool = virStoragePoolDefineXML(ruby_libvirt_connect_get(c), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(pool == NULL, e_DefinitionError, "virStoragePoolDefineXML", ruby_libvirt_connect_get(c)); return pool_new(pool, c); }
Call virConnectFindStoragePoolSources to find the storage pool sources corresponding to type.
static VALUE libvirt_connect_find_storage_pool_sources(int argc, VALUE *argv, VALUE c) { VALUE type, srcSpec, flags; rb_scan_args(argc, argv, "12", &type, &srcSpec, &flags); ruby_libvirt_generate_call_string(virConnectFindStoragePoolSources, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c), StringValueCStr(type), ruby_libvirt_get_cstring_or_null(srcSpec), ruby_libvirt_value_to_uint(flags)); }
Call virConnectGetDomainCapabilities to get the capabilities of the underlying emulator.
static VALUE libvirt_connect_domain_capabilities(int argc, VALUE *argv, VALUE c) { VALUE emulatorbin, arch, machine, virttype, flags; rb_scan_args(argc, argv, "41", &emulatorbin, &arch, &machine, &virttype, &flags); ruby_libvirt_generate_call_string(virConnectGetDomainCapabilities, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c), ruby_libvirt_get_cstring_or_null(emulatorbin), ruby_libvirt_get_cstring_or_null(arch), ruby_libvirt_get_cstring_or_null(machine), ruby_libvirt_get_cstring_or_null(virttype), NUM2UINT(flags)); }
Call virConnectDomainEventDeregister to deregister the event callback from libvirt. This method is deprecated in favor of domain_event_deregister_any
(though they cannot be mixed; if the callback was registered with domain_event_register
, it must be deregistered with domain_event_deregister
).
static VALUE libvirt_connect_domain_event_deregister(VALUE c) { ruby_libvirt_generate_call_nil(virConnectDomainEventDeregister, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), domain_event_callback); }
Call virConnectDomainEventDeregisterAny to deregister a callback from libvirt. The callbackID must be a libvirt-specific handle returned by domain_event_register_any.
static VALUE libvirt_connect_domain_event_deregister_any(VALUE c, VALUE callbackID) { ruby_libvirt_generate_call_nil(virConnectDomainEventDeregisterAny, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), NUM2INT(callbackID)); }
Call virConnectDomainEventRegister to register callback for domain lifecycle events with libvirt. The callback can either be a Symbol (that is the name of a method to callback) or a Proc. The callback must accept 5 parameters: Libvirt::Connect
, Libvirt::Domain
, event, detail, opaque. The opaque parameter to domain_event_register
can be any valid ruby type, and will be passed into callback as “opaque”. This method is deprecated in favor of domain_event_register_any.
static VALUE libvirt_connect_domain_event_register(int argc, VALUE *argv, VALUE c) { VALUE cb, opaque, passthrough; rb_scan_args(argc, argv, "11", &cb, &opaque); if (!ruby_libvirt_is_symbol_or_proc(cb)) { rb_raise(rb_eTypeError, "wrong argument type (expected Symbol or Proc)"); } passthrough = rb_ary_new(); rb_ary_store(passthrough, 0, cb); rb_ary_store(passthrough, 1, opaque); ruby_libvirt_generate_call_nil(virConnectDomainEventRegister, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), domain_event_callback, (void *)passthrough, NULL); }
Call virConnectDomainEventRegisterAny to register callback for eventID with libvirt. The eventID must be one of the Libvirt::Connect::DOMAIN_EVENT_ID_* constants. The callback can either be a Symbol (that is the name of a method to callback) or a Proc. Note that the callback must accept different numbers of arguments depending on the eventID passed in. The arguments are as follows:
-
DOMAIN_EVENT_ID_LIFECYCLE
:Libvirt::Connect
,Libvirt::Domain
, event, detail, opaque -
DOMAIN_EVENT_ID_REBOOT
:Libvirt::Connect
,Libvirt::Domain
, opaque -
DOMAIN_EVENT_ID_RTC_CHANGE
:Libvirt::Connect
,Libvirt::Domain
, utc_offset, opaque -
DOMAIN_EVENT_ID_WATCHDOG
:Libvirt::Connect
,Libvirt::Domain
, action, opaque -
DOMAIN_EVENT_ID_IO_ERROR
:Libvirt::Connect
,Libvirt::Domain
, src_path, dev_alias, action, opaque -
DOMAIN_EVENT_ID_IO_ERROR_REASON
:Libvirt::Connect
,Libvirt::Domain
, src_path, dev_alias, action, reason, opaque -
DOMAIN_EVENT_ID_GRAPHICS
:Libvirt::Connect
,Libvirt::Domain
, phase, local, remote, auth_scheme, subject, opaque
If dom is a valid Libvirt::Domain
object, then only events from that domain will be seen. The opaque parameter can be any valid ruby type, and will be passed into callback as “opaque”. This method returns a libvirt-specific handle, which must be used by the application to deregister the callback later (see domain_event_deregister_any
).
static VALUE libvirt_connect_domain_event_register_any(int argc, VALUE *argv, VALUE c) { VALUE eventID, cb, dom, opaque, passthrough; virDomainPtr domain; virConnectDomainEventGenericCallback internalcb = NULL; rb_scan_args(argc, argv, "22", &eventID, &cb, &dom, &opaque); if (!ruby_libvirt_is_symbol_or_proc(cb)) { rb_raise(rb_eTypeError, "wrong argument type (expected Symbol or Proc)"); } if (NIL_P(dom)) { domain = NULL; } else { domain = ruby_libvirt_domain_get(dom); } switch(NUM2INT(eventID)) { case VIR_DOMAIN_EVENT_ID_LIFECYCLE: internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_lifecycle_callback); break; case VIR_DOMAIN_EVENT_ID_REBOOT: internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_reboot_callback); break; case VIR_DOMAIN_EVENT_ID_RTC_CHANGE: internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_rtc_callback); break; case VIR_DOMAIN_EVENT_ID_WATCHDOG: internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_watchdog_callback); break; case VIR_DOMAIN_EVENT_ID_IO_ERROR: internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_io_error_callback); break; case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON: internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_io_error_reason_callback); break; case VIR_DOMAIN_EVENT_ID_GRAPHICS: internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_graphics_callback); break; default: rb_raise(rb_eArgError, "invalid eventID argument %d", NUM2INT(eventID)); break; } passthrough = rb_ary_new(); rb_ary_store(passthrough, 0, cb); rb_ary_store(passthrough, 1, opaque); ruby_libvirt_generate_call_int(virConnectDomainEventRegisterAny, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), domain, NUM2INT(eventID), internalcb, (void *)passthrough, NULL); }
Call virConnectDomainXMLFromNative to convert a native hypervisor domain representation to libvirt XML.
static VALUE libvirt_connect_domain_xml_from_native(int argc, VALUE *argv, VALUE c) { VALUE nativeFormat, xml, flags; rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags); ruby_libvirt_generate_call_string(virConnectDomainXMLFromNative, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c), StringValueCStr(nativeFormat), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); }
Call virConnectDomainXMLToNative to convert libvirt XML to a native domain hypervisor representation.
static VALUE libvirt_connect_domain_xml_to_native(int argc, VALUE *argv, VALUE c) { VALUE nativeFormat, xml, flags; rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags); ruby_libvirt_generate_call_string(virConnectDomainXMLToNative, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c), StringValueCStr(nativeFormat), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); }
Call virConnectIsEncrypted to determine if the connection is encrypted.
static VALUE libvirt_connect_encrypted_p(VALUE c) { ruby_libvirt_generate_call_truefalse(virConnectIsEncrypted, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c)); }
Call virConnectGetHostname to retrieve the hostname of the hypervisor for this connection.
static VALUE libvirt_connect_hostname(VALUE c) { ruby_libvirt_generate_call_string(virConnectGetHostname, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c)); }
Call virInterfaceChangeBegin to create a restore point for interface changes. Once changes have been made, conn.interface_change_commit can be used to commit the result or conn.interface_change_rollback can be used to rollback to this restore point.
static VALUE libvirt_connect_interface_change_begin(int argc, VALUE *argv, VALUE c) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virInterfaceChangeBegin, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), ruby_libvirt_value_to_uint(flags)); }
Call virInterfaceChangeCommit to commit the interface changes since the last conn.interface_change_begin.
static VALUE libvirt_connect_interface_change_commit(int argc, VALUE *argv, VALUE c) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virInterfaceChangeCommit, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), ruby_libvirt_value_to_uint(flags)); }
Call virInterfaceChangeRollback to rollback to the restore point saved by conn.interface_change_begin.
static VALUE libvirt_connect_interface_change_rollback(int argc, VALUE *argv, VALUE c) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virInterfaceChangeRollback, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), ruby_libvirt_value_to_uint(flags)); }
Call virConnectSetKeepAlive to start sending keepalive messages.
static VALUE libvirt_connect_keepalive_equal(VALUE c, VALUE in) { VALUE interval, count; Check_Type(in, T_ARRAY); if (RARRAY_LEN(in) != 2) { rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)", RARRAY_LEN(in)); } interval = rb_ary_entry(in, 0); count = rb_ary_entry(in, 1); ruby_libvirt_generate_call_int(virConnectSetKeepAlive, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), NUM2INT(interval), NUM2UINT(count)); }
Call virConnectGetLibVersion to retrieve the version of the libvirt library for this connection.
static VALUE libvirt_connect_libversion(VALUE c) { int r; unsigned long v; r = virConnectGetLibVersion(ruby_libvirt_connect_get(c), &v); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virConnectGetLibVersion", ruby_libvirt_connect_get(c)); return ULONG2NUM(v); }
Call virConnectListAllDomains to get an array of domain objects for all domains.
static VALUE libvirt_connect_list_all_domains(int argc, VALUE *argv, VALUE c) { ruby_libvirt_generate_call_list_all(virDomainPtr, argc, argv, virConnectListAllDomains, ruby_libvirt_connect_get(c), c, ruby_libvirt_domain_new, virDomainFree); }
Call virConnectListAllInterfaces to get an array of interface objects for all interfaces.
static VALUE libvirt_connect_list_all_interfaces(int argc, VALUE *argv, VALUE c) { ruby_libvirt_generate_call_list_all(virInterfacePtr, argc, argv, virConnectListAllInterfaces, ruby_libvirt_connect_get(c), c, ruby_libvirt_interface_new, virInterfaceFree); }
Call virConnectListAllNetworks to get an array of network objects for all networks.
static VALUE libvirt_connect_list_all_networks(int argc, VALUE *argv, VALUE c) { ruby_libvirt_generate_call_list_all(virNetworkPtr, argc, argv, virConnectListAllNetworks, ruby_libvirt_connect_get(c), c, ruby_libvirt_network_new, virNetworkFree); }
Call virConnectListAllNodeDevices to get an array of nodedevice objects for all nodedevices.
static VALUE libvirt_connect_list_all_nodedevices(int argc, VALUE *argv, VALUE c) { ruby_libvirt_generate_call_list_all(virNodeDevicePtr, argc, argv, virConnectListAllNodeDevices, ruby_libvirt_connect_get(c), c, ruby_libvirt_nodedevice_new, virNodeDeviceFree); }
Call virConnectListAllNWFilters to get an array of nwfilters for all nwfilter objects.
static VALUE libvirt_connect_list_all_nwfilters(int argc, VALUE *argv, VALUE c) { ruby_libvirt_generate_call_list_all(virNWFilterPtr, argc, argv, virConnectListAllNWFilters, ruby_libvirt_connect_get(c), c, ruby_libvirt_nwfilter_new, virNWFilterFree); }
Call virConnectListAllSecrets to get an array of secret objects for all secrets.
static VALUE libvirt_connect_list_all_secrets(int argc, VALUE *argv, VALUE c) { ruby_libvirt_generate_call_list_all(virSecretPtr, argc, argv, virConnectListAllSecrets, ruby_libvirt_connect_get(c), c, ruby_libvirt_secret_new, virSecretFree); }
Call virConnectListAllStoragePools to get an array of storage pool objects for all storage pools.
static VALUE libvirt_connect_list_all_storage_pools(int argc, VALUE *argv, VALUE c) { ruby_libvirt_generate_call_list_all(virStoragePoolPtr, argc, argv, virConnectListAllStoragePools, ruby_libvirt_connect_get(c), c, pool_new, virStoragePoolFree); }
Call virConnectListDefinedDomains to retrieve a list of inactive domain names on this connection.
static VALUE libvirt_connect_list_defined_domains(VALUE c) { gen_conn_list_names(c, DefinedDomains); }
Call virConnectListDefinedInterfaces to retrieve a list of inactive interface names on this connection.
static VALUE libvirt_connect_list_defined_interfaces(VALUE c) { gen_conn_list_names(c, DefinedInterfaces); }
Call virConnectListDefinedNetworks to retrieve a list of inactive network names on this connection.
static VALUE libvirt_connect_list_defined_networks(VALUE c) { gen_conn_list_names(c, DefinedNetworks); }
Call virConnectListDefinedStoragePools to retrieve a list of inactive storage pool names on this connection.
static VALUE libvirt_connect_list_defined_storage_pools(VALUE c) { gen_conn_list_names(c, DefinedStoragePools); }
Call virConnectListDomains to retrieve a list of active domain IDs on this connection.
static VALUE libvirt_connect_list_domains(VALUE c) { int i, r, num, *ids; VALUE result; num = virConnectNumOfDomains(ruby_libvirt_connect_get(c)); ruby_libvirt_raise_error_if(num < 0, e_RetrieveError, "virConnectNumOfDomains", ruby_libvirt_connect_get(c)); result = rb_ary_new2(num); if (num == 0) { return result; } ids = alloca(sizeof(int) * num); r = virConnectListDomains(ruby_libvirt_connect_get(c), ids, num); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virConnectListDomains", ruby_libvirt_connect_get(c)); for (i = 0; i < num; i++) { rb_ary_store(result, i, INT2NUM(ids[i])); } return result; }
Call virConnectListInterfaces to retrieve a list of active interface names on this connection.
static VALUE libvirt_connect_list_interfaces(VALUE c) { gen_conn_list_names(c, Interfaces); }
Call virConnectListNetworks to retrieve a list of active network names on this connection.
static VALUE libvirt_connect_list_networks(VALUE c) { gen_conn_list_names(c, Networks); }
Call virNodeListDevices to retrieve a list of node device names on this connection.
static VALUE libvirt_connect_list_nodedevices(int argc, VALUE *argv, VALUE c) { int r, num; VALUE cap, flags; char *capstr; char **names; rb_scan_args(argc, argv, "02", &cap, &flags); if (TYPE(flags) != T_NIL && TYPE(flags) != T_FIXNUM) { rb_raise(rb_eTypeError, "wrong argument type (expected Number)"); } capstr = ruby_libvirt_get_cstring_or_null(cap); num = virNodeNumOfDevices(ruby_libvirt_connect_get(c), capstr, 0); ruby_libvirt_raise_error_if(num < 0, e_RetrieveError, "virNodeNumOfDevices", ruby_libvirt_connect_get(c)); if (num == 0) { /* if num is 0, don't call virNodeListDevices function */ return rb_ary_new2(num); } names = alloca(sizeof(char *) * num); r = virNodeListDevices(ruby_libvirt_connect_get(c), capstr, names, num, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeListDevices", ruby_libvirt_connect_get(c)); return ruby_libvirt_generate_list(r, names); }
Call virConnectListNWFilters to retrieve a list of network filter names on this connection.
static VALUE libvirt_connect_list_nwfilters(VALUE c) { gen_conn_list_names(c, NWFilters); }
Call virConnectListSecrets to retrieve a list of secret UUIDs on this connection.
static VALUE libvirt_connect_list_secrets(VALUE c) { gen_conn_list_names(c, Secrets); }
Call virConnectListStoragePools to retrieve a list of active storage pool names on this connection.
static VALUE libvirt_connect_list_storage_pools(VALUE c) { gen_conn_list_names(c, StoragePools); }
Call virDomainLookupByID to retrieve a domain object for id.
static VALUE libvirt_connect_lookup_domain_by_id(VALUE c, VALUE id) { virDomainPtr dom; dom = virDomainLookupByID(ruby_libvirt_connect_get(c), NUM2INT(id)); ruby_libvirt_raise_error_if(dom == NULL, e_RetrieveError, "virDomainLookupByID", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virDomainLookupByName to retrieve a domain object for name.
static VALUE libvirt_connect_lookup_domain_by_name(VALUE c, VALUE name) { virDomainPtr dom; dom = virDomainLookupByName(ruby_libvirt_connect_get(c), StringValueCStr(name)); ruby_libvirt_raise_error_if(dom == NULL, e_RetrieveError, "virDomainLookupByName", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virDomainLookupByUUIDString to retrieve a domain object for uuid.
static VALUE libvirt_connect_lookup_domain_by_uuid(VALUE c, VALUE uuid) { virDomainPtr dom; dom = virDomainLookupByUUIDString(ruby_libvirt_connect_get(c), StringValueCStr(uuid)); ruby_libvirt_raise_error_if(dom == NULL, e_RetrieveError, "virDomainLookupByUUID", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virInterfaceLookupByMACString to retrieve an interface object by MAC address.
static VALUE libvirt_connect_lookup_interface_by_mac(VALUE c, VALUE mac) { virInterfacePtr iface; iface = virInterfaceLookupByMACString(ruby_libvirt_connect_get(c), StringValueCStr(mac)); ruby_libvirt_raise_error_if(iface == NULL, e_RetrieveError, "virInterfaceLookupByMACString", ruby_libvirt_connect_get(c)); return ruby_libvirt_interface_new(iface, c); }
Call virInterfaceLookupByName to retrieve an interface object by name.
static VALUE libvirt_connect_lookup_interface_by_name(VALUE c, VALUE name) { virInterfacePtr iface; iface = virInterfaceLookupByName(ruby_libvirt_connect_get(c), StringValueCStr(name)); ruby_libvirt_raise_error_if(iface == NULL, e_RetrieveError, "virInterfaceLookupByName", ruby_libvirt_connect_get(c)); return ruby_libvirt_interface_new(iface, c); }
Call virNetworkLookupByName to retrieve a network object by name.
static VALUE libvirt_connect_lookup_network_by_name(VALUE c, VALUE name) { virNetworkPtr netw; netw = virNetworkLookupByName(ruby_libvirt_connect_get(c), StringValueCStr(name)); ruby_libvirt_raise_error_if(netw == NULL, e_RetrieveError, "virNetworkLookupByName", ruby_libvirt_connect_get(c)); return ruby_libvirt_network_new(netw, c); }
Call virNetworkLookupByUUIDString to retrieve a network object by UUID.
static VALUE libvirt_connect_lookup_network_by_uuid(VALUE c, VALUE uuid) { virNetworkPtr netw; netw = virNetworkLookupByUUIDString(ruby_libvirt_connect_get(c), StringValueCStr(uuid)); ruby_libvirt_raise_error_if(netw == NULL, e_RetrieveError, "virNetworkLookupByUUID", ruby_libvirt_connect_get(c)); return ruby_libvirt_network_new(netw, c); }
Call virNodeDeviceLookupByName to retrieve a nodedevice object by name.
static VALUE libvirt_connect_lookup_nodedevice_by_name(VALUE c, VALUE name) { virNodeDevicePtr nodedev; nodedev = virNodeDeviceLookupByName(ruby_libvirt_connect_get(c), StringValueCStr(name)); ruby_libvirt_raise_error_if(nodedev == NULL, e_RetrieveError, "virNodeDeviceLookupByName", ruby_libvirt_connect_get(c)); return ruby_libvirt_nodedevice_new(nodedev, c); }
Call virNWFilterLookupByName to retrieve a network filter object by name.
static VALUE libvirt_connect_lookup_nwfilter_by_name(VALUE c, VALUE name) { virNWFilterPtr nwfilter; nwfilter = virNWFilterLookupByName(ruby_libvirt_connect_get(c), StringValueCStr(name)); ruby_libvirt_raise_error_if(nwfilter == NULL, e_RetrieveError, "virNWFilterLookupByName", ruby_libvirt_connect_get(c)); return ruby_libvirt_nwfilter_new(nwfilter, c); }
Call virNWFilterLookupByUUIDString to retrieve a network filter object by UUID.
static VALUE libvirt_connect_lookup_nwfilter_by_uuid(VALUE c, VALUE uuid) { virNWFilterPtr nwfilter; nwfilter = virNWFilterLookupByUUIDString(ruby_libvirt_connect_get(c), StringValueCStr(uuid)); ruby_libvirt_raise_error_if(nwfilter == NULL, e_RetrieveError, "virNWFilterLookupByUUIDString", ruby_libvirt_connect_get(c)); return ruby_libvirt_nwfilter_new(nwfilter, c); }
Call virSecretLookupByUsage to retrieve a secret by usagetype.
static VALUE libvirt_connect_lookup_secret_by_usage(VALUE c, VALUE usagetype, VALUE usageID) { virSecretPtr secret; secret = virSecretLookupByUsage(ruby_libvirt_connect_get(c), NUM2UINT(usagetype), StringValueCStr(usageID)); ruby_libvirt_raise_error_if(secret == NULL, e_RetrieveError, "virSecretLookupByUsage", ruby_libvirt_connect_get(c)); return ruby_libvirt_secret_new(secret, c); }
Call virSecretLookupByUUID to retrieve a network object from uuid.
static VALUE libvirt_connect_lookup_secret_by_uuid(VALUE c, VALUE uuid) { virSecretPtr secret; secret = virSecretLookupByUUIDString(ruby_libvirt_connect_get(c), StringValueCStr(uuid)); ruby_libvirt_raise_error_if(secret == NULL, e_RetrieveError, "virSecretLookupByUUID", ruby_libvirt_connect_get(c)); return ruby_libvirt_secret_new(secret, c); }
Call virStoragePoolLookupByName to retrieve a storage pool object by name.
static VALUE libvirt_connect_lookup_pool_by_name(VALUE c, VALUE name) { virStoragePoolPtr pool; pool = virStoragePoolLookupByName(ruby_libvirt_connect_get(c), StringValueCStr(name)); ruby_libvirt_raise_error_if(pool == NULL, e_RetrieveError, "virStoragePoolLookupByName", ruby_libvirt_connect_get(c)); return pool_new(pool, c); }
Call virStoragePoolLookupByUUIDString to retrieve a storage pool object by uuid.
static VALUE libvirt_connect_lookup_pool_by_uuid(VALUE c, VALUE uuid) { virStoragePoolPtr pool; pool = virStoragePoolLookupByUUIDString(ruby_libvirt_connect_get(c), StringValueCStr(uuid)); ruby_libvirt_raise_error_if(pool == NULL, e_RetrieveError, "virStoragePoolLookupByUUID", ruby_libvirt_connect_get(c)); return pool_new(pool, c); }
Call virConnectGetMaxVcpus to retrieve the maximum number of virtual cpus supported by the hypervisor for this connection.
static VALUE libvirt_connect_max_vcpus(int argc, VALUE *argv, VALUE c) { VALUE type; rb_scan_args(argc, argv, "01", &type); ruby_libvirt_generate_call_int(virConnectGetMaxVcpus, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), ruby_libvirt_get_cstring_or_null(type)); }
Call virNodeAllocPages to reserve huge pages in the system pool.
static VALUE libvirt_connect_node_alloc_pages(int argc, VALUE *argv, VALUE c) { VALUE page_arr, cells, flags, entry, size, count, tmp; int i, arraylen, start_cell, ret; unsigned int *page_sizes; unsigned long long *page_counts; unsigned int cell_count; rb_scan_args(argc, argv, "12", &page_arr, &cells, &flags); Check_Type(page_arr, T_ARRAY); arraylen = RARRAY_LEN(page_arr); page_sizes = alloca(arraylen * sizeof(unsigned int)); page_counts = alloca(arraylen * sizeof(unsigned long long)); for (i = 0; i < arraylen; i++) { entry = rb_ary_entry(page_arr, i); Check_Type(entry, T_HASH); size = rb_hash_aref(entry, rb_str_new2("size")); Check_Type(size, T_FIXNUM); count = rb_hash_aref(entry, rb_str_new2("count")); Check_Type(count, T_FIXNUM); page_sizes[i] = NUM2UINT(size); page_counts[i] = NUM2ULL(count); } if (NIL_P(cells)) { start_cell = -1; cell_count = 0; } else { Check_Type(cells, T_HASH); tmp = rb_hash_aref(cells, rb_str_new2("start")); Check_Type(tmp, T_FIXNUM); start_cell = NUM2INT(tmp); tmp = rb_hash_aref(cells, rb_str_new2("count")); Check_Type(tmp, T_FIXNUM); cell_count = NUM2UINT(tmp); } ret = virNodeAllocPages(ruby_libvirt_connect_get(c), arraylen, page_sizes, page_counts, start_cell, cell_count, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_Error, "virNodeAllocPages", ruby_libvirt_connect_get(c)); return INT2NUM(ret); }
Call virNodeGetCellsFreeMemory to retrieve the amount of free memory in each NUMA cell on the host for this connection.
static VALUE libvirt_connect_node_cells_free_memory(int argc, VALUE *argv, VALUE c) { int i, r; VALUE cells, start, max; unsigned long long *freeMems; virNodeInfo nodeinfo; unsigned int startCell, maxCells; rb_scan_args(argc, argv, "02", &start, &max); if (NIL_P(start)) { startCell = 0; } else { startCell = NUM2UINT(start); } if (NIL_P(max)) { r = virNodeGetInfo(ruby_libvirt_connect_get(c), &nodeinfo); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeGetInfo", ruby_libvirt_connect_get(c)); maxCells = nodeinfo.nodes; } else { maxCells = NUM2UINT(max); } freeMems = alloca(sizeof(unsigned long long) * maxCells); r = virNodeGetCellsFreeMemory(ruby_libvirt_connect_get(c), freeMems, startCell, maxCells); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeGetCellsFreeMemory", ruby_libvirt_connect_get(c)); cells = rb_ary_new2(r); for (i = 0; i < r; i++) { rb_ary_store(cells, i, ULL2NUM(freeMems[i])); } return cells; }
Call virNodeGetCPUMap to get a map of online host CPUs.
static VALUE libvirt_connect_node_cpu_map(int argc, VALUE *argv, VALUE c) { VALUE flags, result; unsigned char *map; unsigned int online; int ret, i, exception = 0; struct cpu_map_field_to_value ftv; rb_scan_args(argc, argv, "01", &flags); ret = virNodeGetCPUMap(ruby_libvirt_connect_get(c), &map, &online, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virNodeGetCPUMap", ruby_libvirt_connect_get(c)); result = rb_hash_new(); for (i = 0; i < ret; i++) { ftv.result = result; ftv.cpu = i; ftv.used = VIR_CPU_USED(map, i); rb_protect(cpu_map_field_to_value, (VALUE)&ftv, &exception); if (exception) { free(map); rb_jump_tag(exception); } } free(map); return result; }
Call virNodeGetCPUStats to retrieve cpu statistics from the virtualization host.
static VALUE libvirt_connect_node_cpu_stats(int argc, VALUE *argv, VALUE c) { VALUE intparam, flags; int tmp; rb_scan_args(argc, argv, "02", &intparam, &flags); if (NIL_P(intparam)) { tmp = -1; } else { tmp = ruby_libvirt_value_to_int(intparam); } return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags), (void *)&tmp, sizeof(virNodeCPUStats), cpu_stats_nparams, cpu_stats_get, cpu_stats_set); }
Call virNodeGetFreeMemory to retrieve the amount of free memory available on the host for this connection.
static VALUE libvirt_connect_node_free_memory(VALUE c) { unsigned long long freemem; freemem = virNodeGetFreeMemory(ruby_libvirt_connect_get(c)); ruby_libvirt_raise_error_if(freemem == 0, e_RetrieveError, "virNodeGetFreeMemory", ruby_libvirt_connect_get(c)); return ULL2NUM(freemem); }
Call virNodeGetFreePages to query the host system on free pages of specified size.
static VALUE libvirt_connect_node_free_pages(int argc, VALUE *argv, VALUE c) { VALUE pageArr = RUBY_Qnil, cells = RUBY_Qnil, flags = RUBY_Qnil, result; unsigned int *pages; unsigned int npages, i, cellCount; int startCell, ret; unsigned long long *counts; rb_scan_args(argc, argv, "21", &pageArr, &cells, &flags); Check_Type(pageArr, T_ARRAY); Check_Type(cells, T_HASH); npages = RARRAY_LEN(pageArr); pages = alloca(npages); for (i = 0; i < npages; i++) { pages[i] = NUM2UINT(rb_ary_entry(pageArr, i)); } startCell = NUM2INT(rb_hash_aref(cells, rb_str_new2("startCell"))); cellCount = NUM2UINT(rb_hash_aref(cells, rb_str_new2("cellCount"))); counts = alloca(npages * cellCount * sizeof(long long)); ret = virNodeGetFreePages(ruby_libvirt_connect_get(c), npages, pages, startCell, cellCount, counts, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_Error, "virNodeGetFreePages", ruby_libvirt_connect_get(c)); result = rb_hash_new(); for (i = 0; i < npages; i++) { rb_hash_aset(result, UINT2NUM(pages[i]), ULL2NUM(counts[i])); } return result; }
Call virNodeGetCPUMap to get a map of online host CPUs.
Call virNodeGetInfo to retrieve information about the node for this connection.
Call virNodeGetSecurityModel to retrieve the security model in use on the host for this connection.
Call virNodeGetInfo to retrieve information about the node for this connection.
static VALUE libvirt_connect_node_info(VALUE c) { int r; virNodeInfo nodeinfo; VALUE result; r = virNodeGetInfo(ruby_libvirt_connect_get(c), &nodeinfo); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeGetInfo", ruby_libvirt_connect_get(c)); result = rb_class_new_instance(0, NULL, c_node_info); rb_iv_set(result, "@model", rb_str_new2(nodeinfo.model)); rb_iv_set(result, "@memory", ULONG2NUM(nodeinfo.memory)); rb_iv_set(result, "@cpus", UINT2NUM(nodeinfo.cpus)); rb_iv_set(result, "@mhz", UINT2NUM(nodeinfo.mhz)); rb_iv_set(result, "@nodes", UINT2NUM(nodeinfo.nodes)); rb_iv_set(result, "@sockets", UINT2NUM(nodeinfo.sockets)); rb_iv_set(result, "@cores", UINT2NUM(nodeinfo.cores)); rb_iv_set(result, "@threads", UINT2NUM(nodeinfo.threads)); return result; }
Call virNodeGetMemoryParameters to get information about memory on the host node.
static VALUE libvirt_connect_node_memory_parameters(int argc, VALUE *argv, VALUE c) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); return ruby_libvirt_get_typed_parameters(c, ruby_libvirt_value_to_uint(flags), NULL, node_memory_nparams, node_memory_get); }
Call virNodeSetMemoryParameters to set the memory parameters for this host node.
static VALUE libvirt_connect_node_memory_parameters_equal(VALUE c, VALUE input) { VALUE hash, flags; ruby_libvirt_assign_hash_and_flags(input, &hash, &flags); return ruby_libvirt_set_typed_parameters(c, hash, NUM2UINT(flags), NULL, memory_allowed, ARRAY_SIZE(memory_allowed), node_memory_set); }
Call virNodeGetMemoryStats to retrieve memory statistics from the virtualization host.
static VALUE libvirt_connect_node_memory_stats(int argc, VALUE *argv, VALUE c) { VALUE intparam, flags; int tmp; rb_scan_args(argc, argv, "02", &intparam, &flags); if (NIL_P(intparam)) { tmp = -1; } else { tmp = ruby_libvirt_value_to_int(intparam); } return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags), (void *)&tmp, sizeof(virNodeMemoryStats), memory_stats_nparams, memory_stats_get, memory_stats_set); }
Call virNodeGetSecurityModel to retrieve the security model in use on the host for this connection.
static VALUE libvirt_connect_node_security_model(VALUE c) { virSecurityModel secmodel; int r; VALUE result; r = virNodeGetSecurityModel(ruby_libvirt_connect_get(c), &secmodel); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeGetSecurityModel", ruby_libvirt_connect_get(c)); result = rb_class_new_instance(0, NULL, c_node_security_model); rb_iv_set(result, "@model", rb_str_new2(secmodel.model)); rb_iv_set(result, "@doi", rb_str_new2(secmodel.doi)); return result; }
Call virNodeSuspendForDuration to suspend the hypervisor for the specified duration.
static VALUE libvirt_connect_node_suspend_for_duration(int argc, VALUE *argv, VALUE c) { VALUE target, duration, flags; rb_scan_args(argc, argv, "21", &target, &duration, &flags); ruby_libvirt_generate_call_nil(virNodeSuspendForDuration, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), NUM2UINT(target), NUM2ULL(duration), ruby_libvirt_value_to_uint(flags)); }
Call virConnectNumOfDefinedDomains to retrieve the number of inactive domains on this connection.
static VALUE libvirt_connect_num_of_defined_domains(VALUE c) { gen_conn_num_of(c, DefinedDomains); }
Call virConnectNumOfDefinedInterfaces to retrieve the number of inactive interfaces on this connection.
static VALUE libvirt_connect_num_of_defined_interfaces(VALUE c) { gen_conn_num_of(c, DefinedInterfaces); }
Call virConnectNumOfDefinedNetworks to retrieve the number of inactive networks on this connection.
static VALUE libvirt_connect_num_of_defined_networks(VALUE c) { gen_conn_num_of(c, DefinedNetworks); }
Call virConnectNumOfDefinedStoragePools to retrieve the number of inactive storage pools on this connection.
static VALUE libvirt_connect_num_of_defined_storage_pools(VALUE c) { gen_conn_num_of(c, DefinedStoragePools); }
Call virConnectNumOfDomains to retrieve the number of active domains on this connection.
static VALUE libvirt_connect_num_of_domains(VALUE c) { gen_conn_num_of(c, Domains); }
Call virConnectNumOfInterfaces to retrieve the number of active interfaces on this connection.
static VALUE libvirt_connect_num_of_interfaces(VALUE c) { gen_conn_num_of(c, Interfaces); }
Call virConnectNumOfNetworks to retrieve the number of active networks on this connection.
static VALUE libvirt_connect_num_of_networks(VALUE c) { gen_conn_num_of(c, Networks); }
Call virNodeNumOfDevices to retrieve the number of node devices on this connection.
static VALUE libvirt_connect_num_of_nodedevices(int argc, VALUE *argv, VALUE c) { int result; VALUE cap, flags; rb_scan_args(argc, argv, "02", &cap, &flags); result = virNodeNumOfDevices(ruby_libvirt_connect_get(c), ruby_libvirt_get_cstring_or_null(cap), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(result < 0, e_RetrieveError, "virNodeNumOfDevices", ruby_libvirt_connect_get(c)); return INT2NUM(result); }
Call virConnectNumOfNWFilters to retrieve the number of network filters on this connection.
static VALUE libvirt_connect_num_of_nwfilters(VALUE c) { gen_conn_num_of(c, NWFilters); }
Call virConnectNumOfSecrets to retrieve the number of secrets on this connection.
static VALUE libvirt_connect_num_of_secrets(VALUE c) { gen_conn_num_of(c, Secrets); }
Call virConnectNumOfStoragePools to retrieve the number of active storage pools on this connection.
static VALUE libvirt_connect_num_of_storage_pools(VALUE c) { gen_conn_num_of(c, StoragePools); }
Call virDomainQemuAttach to attach to the Qemu process pid.
static VALUE libvirt_connect_qemu_attach(int argc, VALUE *argv, VALUE c) { VALUE pid, flags; virDomainPtr dom; rb_scan_args(argc, argv, "11", &pid, &flags); dom = virDomainQemuAttach(ruby_libvirt_connect_get(c), NUM2UINT(pid), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(dom == NULL, e_Error, "virDomainQemuAttach", ruby_libvirt_connect_get(c)); return ruby_libvirt_domain_new(dom, c); }
Call virDomainSaveImageGetXMLDesc to get the XML corresponding to a save file.
static VALUE libvirt_connect_save_image_xml_desc(int argc, VALUE *argv, VALUE c) { VALUE filename, flags; rb_scan_args(argc, argv, "11", &filename, &flags); ruby_libvirt_generate_call_string(virDomainSaveImageGetXMLDesc, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c), StringValueCStr(filename), ruby_libvirt_value_to_uint(flags)); }
Call virConnectIsSecure to determine if the connection is secure.
static VALUE libvirt_connect_secure_p(VALUE c) { ruby_libvirt_generate_call_truefalse(virConnectIsSecure, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c)); }
Call virConnectSetKeepAlive to start sending keepalive messages. Deprecated; use conn.keepalive= instead.
static VALUE libvirt_connect_set_keepalive(VALUE c, VALUE interval, VALUE count) { ruby_libvirt_generate_call_int(virConnectSetKeepAlive, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), NUM2INT(interval), NUM2UINT(count)); }
Call virStreamNew to create a new stream.
static VALUE libvirt_connect_stream(int argc, VALUE *argv, VALUE c) { VALUE flags; virStreamPtr stream; rb_scan_args(argc, argv, "01", &flags); stream = virStreamNew(ruby_libvirt_connect_get(c), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(stream == NULL, e_RetrieveError, "virStreamNew", ruby_libvirt_connect_get(c)); return ruby_libvirt_stream_new(stream, c); }
Call virConnectGetSysinfo to get machine-specific information about the hypervisor. This may include data such as the host UUID, the BIOS version, etc.
static VALUE libvirt_connect_sys_info(int argc, VALUE *argv, VALUE c) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_string(virConnectGetSysinfo, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c), ruby_libvirt_value_to_uint(flags)); }
Call virConnectGetType to retrieve the type of hypervisor for this connection.
static VALUE libvirt_connect_type(VALUE c) { ruby_libvirt_generate_call_string(virConnectGetType, ruby_libvirt_connect_get(c), 0, ruby_libvirt_connect_get(c)); }
Call virConnectGetURI to retrieve the canonical URI for this connection.
static VALUE libvirt_connect_uri(VALUE c) { ruby_libvirt_generate_call_string(virConnectGetURI, ruby_libvirt_connect_get(c), 1, ruby_libvirt_connect_get(c)); }
Call virConnectGetVersion to retrieve the version of the hypervisor for this connection.
static VALUE libvirt_connect_version(VALUE c) { int r; unsigned long v; r = virConnectGetVersion(ruby_libvirt_connect_get(c), &v); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virConnectGetVersion", ruby_libvirt_connect_get(c)); return ULONG2NUM(v); }