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

alive? → [True|False] click to toggle source

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));
}
baseline_cpu([xml, xml2, ...], flags=0) → XML click to toggle source

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;
}
capabilities → String click to toggle source

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));
}
close → nil click to toggle source

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;
}
closed? → [True|False] click to toggle source

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;
}
compare_cpu(xml, flags=0) → compareflag click to toggle source

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));
}
cpu_model_names(arch, flags=0) → Array click to toggle source

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;
}
create_domain_linux(xml, flags=0) → Libvirt::Domain click to toggle source

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);
}
create_domain_xml(xml, flags=0) → Libvirt::Domain click to toggle source

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);
}
create_domain_xml_with_files(xml, fds=nil, flags=0) → Libvirt::Domain click to toggle source

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);
}
create_network_xml(xml) → Libvirt::Network click to toggle source

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);
}
create_nodedevice_xml(xml, flags=0) → Libvirt::NodeDevice click to toggle source

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);
}
create_storage_pool_xml(xml, flags=0) → Libvirt::StoragePool click to toggle source

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);
}
define_domain_xml(xml, flags=0) → Libvirt::Domain click to toggle source

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);
}
define_interface_xml(xml, flags=0) → Libvirt::Interface click to toggle source

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);
}
define_network_xml(xml) → Libvirt::Network click to toggle source

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);
}
define_nwfilter_xml(xml) → Libvirt::NWFilter click to toggle source

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);
}
define_save_image_xml(filename, newxml, flags=0) → nil click to toggle source

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));
}
define_secret_xml(xml, flags=0) → Libvirt::Secret click to toggle source

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);
}
define_storage_pool_xml(xml, flags=0) → Libvirt::StoragePool click to toggle source

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);
}
discover_storage_pool_sources(type, srcSpec=nil, flags=0) → String click to toggle source

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));
}
domain_capabilities(emulatorbin, arch, machine, virttype, flags=0) → String click to toggle source

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));
}
domain_event_deregister(callback) → nil click to toggle source

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);
}
domain_event_deregister_any(callbackID) → nil click to toggle source

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));
}
domain_event_register(callback, opaque=nil) → nil click to toggle source

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);
}
domain_event_register_any(eventID, callback, dom=nil, opaque=nil) → Fixnum click to toggle source

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:

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);
}
domain_xml_from_native(nativeFormat, xml, flags=0) → String click to toggle source

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));
}
domain_xml_to_native(nativeFormat, xml, flags=0) → String click to toggle source

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));
}
encrypted? → [True|False] click to toggle source

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));
}
hostname → String click to toggle source

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));
}
interface_change_begin(flags=0) → nil click to toggle source

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));
}
interface_change_commit(flags=0) → nil click to toggle source

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));
}
interface_change_rollback(flags=0) → nil click to toggle source

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));
}
keepalive = interval,count click to toggle source

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));
}
libversion → Fixnum click to toggle source

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);
}
list_all_domains(flags=0) → Array click to toggle source

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);
}
list_all_interfaces(flags=0) → Array click to toggle source

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);
}
list_all_networks(flags=0) → Array click to toggle source

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);
}
list_all_nodedevices(flags=0) → Array click to toggle source

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);
}
list_all_nwfilters(flags=0) → Array click to toggle source

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);
}
list_all_secrets(flags=0) → Array click to toggle source

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);
}
list_all_storage_pools(flags=0) → Array click to toggle source

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);
}
list_defined_domains → list click to toggle source

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);
}
list_defined_interfaces → list click to toggle source

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);
}
list_of_defined_networks → list click to toggle source

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);
}
list_defined_storage_pools → list click to toggle source

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);
}
list_domains → list click to toggle source

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;
}
list_interfaces → list click to toggle source

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);
}
list_networks → list click to toggle source

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);
}
list_nodedevices(cap=nil, flags=0) → list click to toggle source

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);
}
list_nwfilters → list click to toggle source

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);
}
list_secrets → list click to toggle source

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);
}
list_storage_pools → list click to toggle source

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);
}
lookup_domain_by_id(id) → Libvirt::Domain click to toggle source

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);
}
lookup_domain_by_name(name) → Libvirt::Domain click to toggle source

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);
}
lookup_domain_by_uuid(uuid) → Libvirt::Domain click to toggle source

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);
}
lookup_interface_by_mac(mac) → Libvirt::Interface click to toggle source

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);
}
lookup_interface_by_name(name) → Libvirt::Interface click to toggle source

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);
}
lookup_network_by_name(name) → Libvirt::Network click to toggle source

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);
}
lookup_network_by_uuid(uuid) → Libvirt::Network click to toggle source

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);
}
lookup_nodedevice_by_name(name) → Libvirt::NodeDevice click to toggle source

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);

}
lookup_nwfilter_by_name(name) → Libvirt::NWFilter click to toggle source

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);
}
lookup_nwfilter_by_uuid(uuid) → Libvirt::NWFilter click to toggle source

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);
}
lookup_secret_by_usage(usagetype, usageID) → Libvirt::Secret click to toggle source

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);
}
lookup_secret_by_uuid(uuid) → Libvirt::Secret click to toggle source

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);
}
lookup_storage_pool_by_name(name) → Libvirt::StoragePool click to toggle source

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);
}
lookup_storage_pool_by_uuid(uuid) → Libvirt::StoragePool click to toggle source

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);
}
max_vcpus(type=nil) → Fixnum click to toggle source

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));
}
node_alloc_pages(page_arr, cells=nil, flags=0) → Fixnum click to toggle source

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);
}
node_cells_free_memory(startCell=0, maxCells=#nodeCells) → list click to toggle source

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;
}
node_cpu_map → Hash click to toggle source

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;
}
Also aliased as: node_get_cpu_map
node_cpu_stats(cpuNum=-1, flags=0) → Hash click to toggle source

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);
}
node_free_memory → Fixnum click to toggle source

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);
}
node_free_pages(pages, cells, flags=0) → Hash click to toggle source

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.

Alias for: node_cpu_map

Call virNodeGetInfo to retrieve information about the node for this connection.

Alias for: node_info

Call virNodeGetSecurityModel to retrieve the security model in use on the host for this connection.

Alias for: node_security_model
node_info → Libvirt::Connect::Nodeinfo click to toggle source

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;
}
Also aliased as: node_get_info
node_memory_parameters(flags=0) → Hash click to toggle source

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);
}
node_memory_parameters = Hash,flags=0 click to toggle source

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);
}
node_memory_stats(cellNum=-1, flags=0) → Hash click to toggle source

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);
}
node_security_model → Libvirt::Connect::NodeSecurityModel click to toggle source

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;
}
Also aliased as: node_get_security_model
node_suspend_for_duration(target, duration, flags=0) → nil click to toggle source

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));
}
num_of_defined_domains → Fixnum click to toggle source

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);
}
num_of_defined_interfaces → Fixnum click to toggle source

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);
}
num_of_defined_networks → Fixnum click to toggle source

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);
}
num_of_defined_storage_pools → Fixnum click to toggle source

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);
}
num_of_domains → Fixnum click to toggle source

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);
}
num_of_interfaces → Fixnum click to toggle source

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);
}
num_of_networks → Fixnum click to toggle source

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);
}
num_of_nodedevices(cap=nil, flags=0) → Fixnum click to toggle source

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);
}
num_of_nwfilters → Fixnum click to toggle source

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);
}
num_of_secrets → Fixnum click to toggle source

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);
}
num_of_storage_pools → Fixnum click to toggle source

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);
}
qemu_attach(pid, flags=0) → Libvirt::Domain click to toggle source

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);
}
save_image_xml_desc(filename, flags=0) → String click to toggle source

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));
}
secure? → [True|False] click to toggle source

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));
}
set_keepalive(interval, count) → Fixnum click to toggle source

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));
}
stream(flags=0) → Libvirt::Stream click to toggle source

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);
}
sys_info(flags=0) → String click to toggle source

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));
}
type → String click to toggle source

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));
}
uri → String click to toggle source

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));
}
version → Fixnum click to toggle source

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);
}