class Libvirt::Domain

Constants

BLOCKED
CRASHED
DEVICE_MODIFY_CONFIG
DEVICE_MODIFY_CURRENT
DEVICE_MODIFY_FORCE
DEVICE_MODIFY_LIVE
DOMAIN_AFFECT_CONFIG
DOMAIN_AFFECT_CURRENT
DOMAIN_AFFECT_LIVE
DOMAIN_BLOCKED_UNKNOWN
DOMAIN_CRASHED_UNKNOWN
DOMAIN_MEM_CONFIG
DOMAIN_MEM_CURRENT
DOMAIN_MEM_LIVE
DOMAIN_MEM_MAXIMUM
DOMAIN_PAUSED_DUMP
DOMAIN_PAUSED_FROM_SNAPSHOT
DOMAIN_PAUSED_IOERROR
DOMAIN_PAUSED_MIGRATION
DOMAIN_PAUSED_SAVE
DOMAIN_PAUSED_UNKNOWN
DOMAIN_PAUSED_USER
DOMAIN_PAUSED_WATCHDOG
DOMAIN_RUNNING_BOOTED
DOMAIN_RUNNING_FROM_SNAPSHOT
DOMAIN_RUNNING_MIGRATED
DOMAIN_RUNNING_MIGRATION_CANCELED
DOMAIN_RUNNING_RESTORED
DOMAIN_RUNNING_SAVE_CANCELED
DOMAIN_RUNNING_UNKNOWN
DOMAIN_RUNNING_UNPAUSED
DOMAIN_SHUTDOWN_UNKNOWN
DOMAIN_SHUTDOWN_USER
DOMAIN_SHUTOFF_CRASHED
DOMAIN_SHUTOFF_DESTROYED
DOMAIN_SHUTOFF_FAILED
DOMAIN_SHUTOFF_FROM_SNAPSHOT
DOMAIN_SHUTOFF_MIGRATED
DOMAIN_SHUTOFF_SAVED
DOMAIN_SHUTOFF_SHUTDOWN
DOMAIN_SHUTOFF_UNKNOWN
DOMAIN_XML_INACTIVE
DOMAIN_XML_SECURE
DOMAIN_XML_UPDATE_CPU
DUMP_CRASH
DUMP_LIVE
MEMORY_PARAM_UNLIMITED
MEMORY_PHYSICAL
MEMORY_VIRTUAL
MIGRATE_LIVE
MIGRATE_NON_SHARED_DISK
MIGRATE_NON_SHARED_INC
MIGRATE_PAUSED
MIGRATE_PEER2PEER
MIGRATE_PERSIST_DEST
MIGRATE_TUNNELLED
MIGRATE_UNDEFINE_SOURCE
NOSTATE
PAUSED
RUNNING
SHUTDOWN
SHUTOFF
START_PAUSED
VCPU_CONFIG
VCPU_LIVE
VCPU_MAXIMUM

Attributes

connection[R]

Public Class Methods

Libvirt::Domain::restore(conn, filename) → nil click to toggle source

Call virDomainRestore[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainRestore] to restore the domain from the filename.

static VALUE libvirt_dom_s_restore(VALUE klass, VALUE c, VALUE from) {
    gen_call_void(virDomainRestore, conn(c), connect_get(c),
                  StringValueCStr(from));
}

Public Instance Methods

abort_job → nil click to toggle source

Call virDomainAbortJob[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAbortJob] to abort the currently running job on this domain.

static VALUE libvirt_dom_abort_job(VALUE d) {
    gen_call_void(virDomainAbortJob, conn(d), domain_get(d));
}
active? → [true|false] click to toggle source

Call virDomainIsActive[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainIsActive] to determine if this domain is currently active.

static VALUE libvirt_dom_active_p(VALUE d) {
    gen_call_truefalse(virDomainIsActive, conn(d), domain_get(d));
}
attach_device(device_xml, flags=0) → nil click to toggle source

Call virDomainAttachDevice[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAttachDevice] to attach the device described by the device_xml to the domain.

static VALUE libvirt_dom_attach_device(int argc, VALUE *argv, VALUE s) {
    VALUE xml;
    VALUE flags;

    rb_scan_args(argc, argv, "11", &xml, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

#if HAVE_VIRDOMAINATTACHDEVICEFLAGS
    gen_call_void(virDomainAttachDeviceFlags, conn(s), domain_get(s),
                  StringValueCStr(xml), NUM2UINT(flags));
#else
    if (NUM2UINT(flags) != 0)
        rb_raise(e_NoSupportError, "Non-zero flags not supported");
    gen_call_void(virDomainAttachDevice, conn(s), domain_get(s),
                  StringValueCStr(xml));
#endif
}
autostart → [true|false] click to toggle source

Call virDomainGetAutostart[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetAutostart] to find out the state of the autostart flag for a domain.

static VALUE libvirt_dom_autostart(VALUE s){
autostart = [true|false] click to toggle source

Call virDomainSetAutostart[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetAutostart] to make this domain autostart when libvirtd starts up.

static VALUE libvirt_dom_autostart_set(VALUE s, VALUE autostart) {
    if (autostart != Qtrue && autostart != Qfalse)
                rb_raise(rb_eTypeError,
                 "wrong argument type (expected TrueClass or FalseClass)");

    gen_call_void(virDomainSetAutostart, conn(s),
                  domain_get(s), RTEST(autostart) ? 1 : 0);
}
autostart → [true|false] click to toggle source

Call virDomainGetAutostart[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetAutostart] to find out the state of the autostart flag for a domain.

static VALUE libvirt_dom_autostart(VALUE s){
blkio_parameters(flags=0) → Hash click to toggle source

Call virDomainGetBlkioParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetBlkioParameters] to retrieve all of the blkio parameters for this domain. The keys and values in the hash that is returned are hypervisor specific.

static VALUE libvirt_dom_get_blkio_parameters(int argc, VALUE *argv, VALUE d) {
    return internal_get_parameters(argc, argv, d, blkio_nparams, blkio_get);
}
memory_parameters = Hash,flags=0 click to toggle source

Call virDomainSetBlkioParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetBlkioParameters] to set the blkio parameters for this domain. The keys and values in the input hash are hypervisor specific.

static VALUE libvirt_dom_set_blkio_parameters(VALUE d, VALUE in) {
    return internal_set_parameters(d, in, blkio_nparams, blkio_get, blkio_set);
}
block_peek(path, offset, size, flags=0) → string click to toggle source

Call virDomainBlockPeek[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainBlockPeek] to read size number of bytes, starting at offset offset from domain backing file path. Due to limitations of the libvirt remote protocol, the user should never request more than 64k bytes.

static VALUE libvirt_dom_block_peek(int argc, VALUE *argv, VALUE s) {
    virDomainPtr dom = domain_get(s);
    VALUE path_val, offset_val, size_val, flags_val;
    char *buffer;
    int r;
    VALUE ret;
    char *path;
    unsigned int size, flags;
    unsigned long long offset;
    struct rb_str_new_arg args;
    int exception = 0;

    rb_scan_args(argc, argv, "31", &path_val, &offset_val, &size_val,
                 &flags_val);

    if (NIL_P(flags_val))
        flags_val = INT2NUM(0);

    path = StringValueCStr(path_val);
    offset = NUM2ULL(offset_val);
    size = NUM2UINT(size_val);
    flags = NUM2UINT(flags_val);

    buffer = ALLOC_N(char, size);

    r = virDomainBlockPeek(dom, path, offset, size, buffer, flags);

    if (r < 0) {
        xfree(buffer);
        rb_exc_raise(create_error(e_RetrieveError, "virDomainBlockPeek",
                                  conn(s)));
    }

    args.val = buffer;
    args.size = size;
    ret = rb_protect(rb_str_new_wrap, (VALUE)&args, &exception);
    xfree(buffer);
    if (exception)
        rb_jump_tag(exception);

    return ret;
}
block_stats(path) → Libvirt::Domain::BlockStats click to toggle source

Call virDomainBlockStats[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainBlockStats] to retrieve statistics about domain block device path.

static VALUE libvirt_dom_block_stats(VALUE s, VALUE path) {
    virDomainPtr dom = domain_get(s);
    virDomainBlockStatsStruct stats;
    int r;
    VALUE result;

    r = virDomainBlockStats(dom, StringValueCStr(path), &stats, sizeof(stats));
    _E(r < 0, create_error(e_RetrieveError, "virDomainBlockStats", conn(s)));

    result = rb_class_new_instance(0, NULL, c_domain_block_stats);
    rb_iv_set(result, "@rd_req", LL2NUM(stats.rd_req));
    rb_iv_set(result, "@rd_bytes", LL2NUM(stats.rd_bytes));
    rb_iv_set(result, "@wr_req", LL2NUM(stats.wr_req));
    rb_iv_set(result, "@wr_bytes", LL2NUM(stats.wr_bytes));
    rb_iv_set(result, "@errs", LL2NUM(stats.errs));

    return result;
}
blockinfo(path, flags=0) → Libvirt::Domain::BlockInfo click to toggle source

Call virDomainGetBlockInfo[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetBlockInfo] to retrieve information about the backing file path for the domain.

static VALUE libvirt_dom_block_info(int argc, VALUE *argv, VALUE s) {
    virDomainPtr dom = domain_get(s);
    virDomainBlockInfo info;
    int r;
    VALUE result;
    VALUE flags;
    VALUE path;

    rb_scan_args(argc, argv, "11", &path, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    r = virDomainGetBlockInfo(dom, StringValueCStr(path), &info,
                              NUM2UINT(flags));
    _E(r < 0, create_error(e_RetrieveError, "virDomainGetBlockInfo", conn(s)));

    result = rb_class_new_instance(0, NULL, c_domain_block_info);
    rb_iv_set(result, "@capacity", ULL2NUM(info.capacity));
    rb_iv_set(result, "@allocation", ULL2NUM(info.allocation));
    rb_iv_set(result, "@physical", ULL2NUM(info.physical));

    return result;
}
core_dump(filename, flags=0) → nil click to toggle source

Call virDomainCoreDump[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCoreDump] to do a full memory dump of the domain to filename.

static VALUE libvirt_dom_core_dump(int argc, VALUE *argv, VALUE s) {
    VALUE to, flags;

    rb_scan_args(argc, argv, "11", &to, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainCoreDump, conn(s), domain_get(s),
                  StringValueCStr(to), NUM2INT(flags));
}
create(flags=0) → nil click to toggle source

Call virDomainCreate[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreate] to start an already defined domain.

static VALUE libvirt_dom_create(int argc, VALUE *argv, VALUE s) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

#if HAVE_VIRDOMAINCREATEWITHFLAGS
    gen_call_void(virDomainCreateWithFlags, conn(s), domain_get(s),
                  NUM2UINT(flags));
#else
    if (NUM2UINT(flags) != 0)
        rb_raise(e_NoSupportError, "Non-zero flags not supported");
    gen_call_void(virDomainCreate, conn(s), domain_get(s));
#endif
}
current_snapshot(flags=0) → Libvirt::Domain::Snapshot click to toggle source

Call virDomainCurrentSnapshot[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCurrentSnapshot] to retrieve the current snapshot for this domain (if any).

static VALUE libvirt_dom_current_snapshot(int argc, VALUE *argv, VALUE d) {
    VALUE flags;
    virDomainSnapshotPtr snap;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    snap = virDomainSnapshotCurrent(domain_get(d), NUM2UINT(flags));
    _E(snap == NULL, create_error(e_RetrieveError, "virDomainSnapshotCurrent",
                                  conn(d)));

    return domain_snapshot_new(snap, d);
}
destroy → nil click to toggle source

Call virDomainDestroy[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDestroy] to do a hard power-off of the domain.

static VALUE libvirt_dom_destroy(VALUE s) {
    gen_call_void(virDomainDestroy, conn(s), domain_get(s));
}
detach_device(device_xml, flags=0) → nil click to toggle source

Call virDomainDetachDevice[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDetachDevice] to detach the device described by the device_xml from the domain.

static VALUE libvirt_dom_detach_device(int argc, VALUE *argv, VALUE s) {
    VALUE xml;
    VALUE flags;

    rb_scan_args(argc, argv, "11", &xml, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

#if HAVE_VIRDOMAINDETACHDEVICEFLAGS
    gen_call_void(virDomainDetachDeviceFlags, conn(s), domain_get(s),
                  StringValueCStr(xml), NUM2UINT(flags));
#else
    if (NUM2UINT(flags) != 0)
        rb_raise(e_NoSupportError, "Non-zero flags not supported");
    gen_call_void(virDomainDetachDevice, conn(s), domain_get(s),
                  StringValueCStr(xml));
#endif
}
free → nil click to toggle source

Call virDomainFree[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainFree] to free a domain object.

static VALUE libvirt_dom_free(VALUE s) {
    gen_call_free(Domain, s);
}
get_vcpus → [ Libvirt::Domain::VCPUInfo ] click to toggle source

Call virDomainGetVcpus[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetVcpus] to retrieve detailed information about the state of a domain's virtual CPUs.

static VALUE libvirt_dom_get_vcpus(VALUE s) {
    virDomainPtr dom = domain_get(s);
    virNodeInfo nodeinfo;
    virDomainInfo dominfo;
    virVcpuInfoPtr cpuinfo;
    unsigned char *cpumap;
    int cpumaplen;
    int r;
    VALUE result;
    int exception = 0;
    struct create_vcpu_array_args args;

    r = virNodeGetInfo(conn(s), &nodeinfo);
    _E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo", conn(s)));

    r = virDomainGetInfo(dom, &dominfo);
    _E(r < 0, create_error(e_RetrieveError, "virDomainGetInfo", conn(s)));

    cpuinfo = ALLOC_N(virVcpuInfo, dominfo.nrVirtCpu);

    cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));

    /* we use malloc instead of ruby_xmalloc here to avoid a memory leak
     * if ruby_xmalloc raises an exception
     */
    cpumap = malloc(dominfo.nrVirtCpu * cpumaplen);
    if (cpumap == NULL) {
        xfree(cpuinfo);
        rb_memerror();
    }

    r = virDomainGetVcpus(dom, cpuinfo, dominfo.nrVirtCpu, cpumap, cpumaplen);
    if (r < 0) {
        xfree(cpuinfo);
        free(cpumap);
        rb_exc_raise(create_error(e_RetrieveError, "virDomainGetVcpus",
                                  conn(s)));
    }

    args.cpuinfo = cpuinfo;
    args.cpumap = cpumap;
    args.nr_virt_cpu = dominfo.nrVirtCpu;
    args.maxcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
    result = rb_protect(create_vcpu_array, (VALUE)&args, &exception);
    if (exception) {
        xfree(cpuinfo);
        free(cpumap);
        rb_jump_tag(exception);
    }

    free(cpumap);
    xfree(cpuinfo);

    return result;
}
has_current_snapshot?(flags=0) → [true|false] click to toggle source

Call virDomainHasCurrentSnapshot[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainHasCurrentSnapshot] to find out if this domain has a snapshot active.

static VALUE libvirt_dom_has_current_snapshot_p(int argc, VALUE *argv, VALUE d) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_truefalse(virDomainHasCurrentSnapshot, conn(d), domain_get(d),
                       NUM2UINT(flags));
}
has_managed_save?(flags=0) → [True|False] click to toggle source

Call virDomainHasManagedSaveImage[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainHasManagedSaveImage] to determine if a particular domain has a managed save image.

static VALUE libvirt_dom_has_managed_save(int argc, VALUE *argv, VALUE s) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_truefalse(virDomainHasManagedSaveImage, conn(s), domain_get(s),
                       NUM2UINT(flags));
}
id → fixnum click to toggle source

Call virDomainGetID[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetID] to retrieve the ID of this domain. If the domain isn't running, this will be -1.

static VALUE libvirt_dom_id(VALUE s) {
    virDomainPtr dom = domain_get(s);
    unsigned int id;
    int out;

    id = virDomainGetID(dom);

    /* we need to cast the unsigned int id to a signed int out to handle the
     * -1 case
     */
    out = id;
    _E(out == -1, create_error(e_RetrieveError, "virDomainGetID", conn(s)));

    return INT2NUM(out);
}
ifinfo(if) → Libvirt::Domain::IfInfo click to toggle source

Call virDomainInterfaceStats[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainInterfaceStats] to retrieve statistics about domain interface if.

static VALUE libvirt_dom_if_stats(VALUE s, VALUE sif) {
    virDomainPtr dom = domain_get(s);
    char *ifname = get_string_or_nil(sif);
    virDomainInterfaceStatsStruct ifinfo;
    int r;
    VALUE result = Qnil;

    if (ifname) {
        r = virDomainInterfaceStats(dom, ifname, &ifinfo,
                                    sizeof(virDomainInterfaceStatsStruct));
        _E(r < 0, create_error(e_RetrieveError, "virDomainInterfaceStats",
                               conn(s)));

        result = rb_class_new_instance(0, NULL, c_domain_ifinfo);
        rb_iv_set(result, "@rx_bytes", LL2NUM(ifinfo.rx_bytes));
        rb_iv_set(result, "@rx_packets", LL2NUM(ifinfo.rx_packets));
        rb_iv_set(result, "@rx_errs", LL2NUM(ifinfo.rx_errs));
        rb_iv_set(result, "@rx_drop", LL2NUM(ifinfo.rx_drop));
        rb_iv_set(result, "@tx_bytes", LL2NUM(ifinfo.tx_bytes));
        rb_iv_set(result, "@tx_packets", LL2NUM(ifinfo.tx_packets));
        rb_iv_set(result, "@tx_errs", LL2NUM(ifinfo.tx_errs));
        rb_iv_set(result, "@tx_drop", LL2NUM(ifinfo.tx_drop));
    }
    return result;
}
info → Libvirt::Domain::Info click to toggle source

Call virDomainGetInfo[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo] to retrieve domain information.

static VALUE libvirt_dom_info(VALUE s) {
    virDomainPtr dom = domain_get(s);
    virDomainInfo info;
    int r;
    VALUE result;

    r = virDomainGetInfo(dom, &info);
    _E(r < 0, create_error(e_RetrieveError, "virDomainGetInfo", conn(s)));

    result = rb_class_new_instance(0, NULL, c_domain_info);
    rb_iv_set(result, "@state", CHR2FIX(info.state));
    rb_iv_set(result, "@max_mem", ULONG2NUM(info.maxMem));
    rb_iv_set(result, "@memory", ULONG2NUM(info.memory));
    rb_iv_set(result, "@nr_virt_cpu", INT2NUM((int) info.nrVirtCpu));
    rb_iv_set(result, "@cpu_time", ULL2NUM(info.cpuTime));

    return result;
}
inject_nmi(flags=0) → nil click to toggle source

Call virDomainInjectNMI[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainInjectNMI] to send an NMI to the guest.

static VALUE libvirt_dom_inject_nmi(int argc, VALUE *argv, VALUE d) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainInjectNMI, conn(d), domain_get(d), NUM2UINT(flags));
}
job_info → Libvirt::Domain::JobInfo click to toggle source

Call virDomainGetJobInfo[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetJobInfo] to retrieve the current state of the running domain job.

static VALUE libvirt_dom_job_info(VALUE d) {
    int r;
    virDomainJobInfo info;
    VALUE result;

    r = virDomainGetJobInfo(domain_get(d), &info);
    _E(r < 0, create_error(e_RetrieveError, "virDomainGetJobInfo", conn(d)));

    result = rb_class_new_instance(0, NULL, c_domain_job_info);
    rb_iv_set(result, "@type", INT2NUM(info.type));
    rb_iv_set(result, "@time_elapsed", ULL2NUM(info.timeElapsed));
    rb_iv_set(result, "@time_remaining", ULL2NUM(info.timeRemaining));
    rb_iv_set(result, "@data_total", ULL2NUM(info.dataTotal));
    rb_iv_set(result, "@data_processed", ULL2NUM(info.dataProcessed));
    rb_iv_set(result, "@data_remaining", ULL2NUM(info.dataRemaining));
    rb_iv_set(result, "@mem_total", ULL2NUM(info.memTotal));
    rb_iv_set(result, "@mem_processed", ULL2NUM(info.memProcessed));
    rb_iv_set(result, "@mem_remaining", ULL2NUM(info.memRemaining));
    rb_iv_set(result, "@file_total", ULL2NUM(info.fileTotal));
    rb_iv_set(result, "@file_processed", ULL2NUM(info.fileProcessed));
    rb_iv_set(result, "@file_remaining", ULL2NUM(info.fileRemaining));

    return result;
}
list_snapshots(flags=0) → list click to toggle source

Call virDomainSnapshotListNames[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListNames] to retrieve a list of snapshot names available for this domain.

static VALUE libvirt_dom_list_snapshots(int argc, VALUE *argv, VALUE d) {
    VALUE flags_val;
    int r;
    int num;
    virDomainPtr dom = domain_get(d);
    char **names;
    unsigned int flags;

    rb_scan_args(argc, argv, "01", &flags_val);

    if (NIL_P(flags_val))
        flags = 0;
    else
        flags = NUM2UINT(flags_val);

    num = virDomainSnapshotNum(dom, 0);
    _E(num < 0, create_error(e_RetrieveError, "virDomainSnapshotNum", conn(d)));
    if (num == 0)
        /* if num is 0, don't call virDomainSnapshotListNames function */
        return rb_ary_new2(num);

    names = ALLOC_N(char *, num);

    r = virDomainSnapshotListNames(domain_get(d), names, num, flags);
    if (r < 0) {
        xfree(names);
        rb_exc_raise(create_error(e_RetrieveError, "virDomainSnapshotListNames",
                                  conn(d)));
    }

    return gen_list(num, &names);
}
lookup_snapshot_by_name(name, flags=0) → Libvirt::Domain::Snapshot click to toggle source

Call virDomainSnapshotLookupByName[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotLookupByName] to retrieve a snapshot object corresponding to snapshot name.

static VALUE libvirt_dom_lookup_snapshot_by_name(int argc, VALUE *argv, VALUE d) {
    virDomainPtr dom = domain_get(d);
    virDomainSnapshotPtr snap;
    VALUE name, flags;

    rb_scan_args(argc, argv, "11", &name, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    snap = virDomainSnapshotLookupByName(dom, StringValueCStr(name),
                                         NUM2UINT(flags));
    _E(dom == NULL, create_error(e_RetrieveError,
                                 "virDomainSnapshotLookupByName", conn(d)));

    return domain_snapshot_new(snap, d);
}
managed_save(flags=0) → nil click to toggle source

Call virDomainManagedSave[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainManagedSave] to do a managed save of the domain. The domain will be saved to a place of libvirt's choosing.

static VALUE libvirt_dom_managed_save(int argc, VALUE *argv, VALUE s) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainManagedSave, conn(s), domain_get(s),
                  NUM2UINT(flags));
}
managed_save_remove(flags=0) → nil click to toggle source

Call virDomainManagedSaveRemove[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainManagedSaveRemove] to remove the managed save image for a domain.

static VALUE libvirt_dom_managed_save_remove(int argc, VALUE *argv, VALUE s) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainManagedSaveRemove, conn(s), domain_get(s),
                  NUM2UINT(flags));
}
max_memory → fixnum click to toggle source

Call virDomainGetMaxMemory[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMaxMemory] to retrieve the maximum amount of memory this domain is allowed to access. Note that the current amount of memory this domain is allowed to access may be different (see dom.memory_set).

static VALUE libvirt_dom_max_memory(VALUE s) {
    virDomainPtr dom = domain_get(s);
    unsigned long max_memory;

    max_memory = virDomainGetMaxMemory(dom);
    _E(max_memory == 0, create_error(e_RetrieveError, "virDomainGetMaxMemory",
                                     conn(s)));

    return ULONG2NUM(max_memory);
}
max_memory = Fixnum click to toggle source

Call virDomainSetMaxMemory[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetMaxMemory] to set the maximum amount of memory (in kilobytes) this domain should be allowed to access.

static VALUE libvirt_dom_max_memory_set(VALUE s, VALUE max_memory) {
    virDomainPtr dom = domain_get(s);
    int r;

    r = virDomainSetMaxMemory(dom, NUM2ULONG(max_memory));
    _E(r < 0, create_error(e_DefinitionError, "virDomainSetMaxMemory",
                           conn(s)));

    return ULONG2NUM(max_memory);
}
max_vcpus → fixnum click to toggle source

Call virDomainGetMaxVcpus[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMaxVcpus] to retrieve the maximum number of virtual CPUs this domain can use.

static VALUE libvirt_dom_max_vcpus(VALUE s) {
    gen_call_int(virDomainGetMaxVcpus, conn(s), domain_get(s));
}
memory = Fixnum,flags=0 click to toggle source

Call virDomainSetMemory[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetMemory] to set the amount of memory (in kilobytes) this domain should currently have. Note this will only succeed if both the hypervisor and the domain on this connection support ballooning.

static VALUE libvirt_dom_memory_set(VALUE s, VALUE in) {
    VALUE memory;
    VALUE flags;
    virDomainPtr dom = domain_get(s);
    int r;

    if (TYPE(in) == T_FIXNUM) {
        memory = in;
        flags = INT2NUM(0);
    }
    else if (TYPE(in) == T_ARRAY) {
        if (RARRAY_LEN(in) != 2)
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)",
                     RARRAY_LEN(in));
        memory = rb_ary_entry(in, 0);
        flags = rb_ary_entry(in, 1);
    }
    else
        rb_raise(rb_eTypeError,
                 "wrong argument type (expected Number or Array)");

#if HAVE_VIRDOMAINSETMEMORYFLAGS
    r = virDomainSetMemoryFlags(dom, NUM2ULONG(memory), NUM2UINT(flags));
    _E(r < 0, create_error(e_DefinitionError, "virDomainSetMemoryFlags",
                           conn(s)));
#else
    if (NUM2UINT(flags) != 0)
        rb_raise(e_NoSupportError, "Non-zero flags not supported");
    r = virDomainSetMemory(dom, NUM2ULONG(memory));
    _E(r < 0, create_error(e_DefinitionError, "virDomainSetMemory", conn(s)));
#endif

    return ULONG2NUM(memory);
}
memory_parameters(flags=0) → Hash click to toggle source

Call virDomainGetMemoryParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMemoryParameters] to retrieve all of the memory parameters for this domain. The keys and values in the hash that is returned are hypervisor specific.

static VALUE libvirt_dom_get_memory_parameters(int argc, VALUE *argv, VALUE d) {
    return internal_get_parameters(argc, argv, d, memory_nparams, memory_get);
}
memory_parameters = Hash,flags=0 click to toggle source

Call virDomainSetMemoryParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetMemoryParameters] to set the memory parameters for this domain. The keys and values in the input hash are hypervisor specific.

static VALUE libvirt_dom_set_memory_parameters(VALUE d, VALUE in) {
    return internal_set_parameters(d, in, memory_nparams, memory_get,
                                   memory_set);
}
memory_peek(start, size, flags=Libvirt::Domain::MEMORY_VIRTUAL) → string click to toggle source

Call virDomainMemoryPeek[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMemoryPeek] to read size number of bytes from offset start from the domain memory. Due to limitations of the libvirt remote protocol, the user should never request more than 64k bytes.

static VALUE libvirt_dom_memory_peek(int argc, VALUE *argv, VALUE s) {
    virDomainPtr dom = domain_get(s);
    VALUE start_val, size_val, flags_val;
    char *buffer;
    int r;
    VALUE ret;
    unsigned int size, flags;
    unsigned long long start;
    struct rb_str_new_arg args;
    int exception = 0;

    rb_scan_args(argc, argv, "21", &start_val, &size_val, &flags_val);

    if (NIL_P(flags_val))
        flags_val = INT2NUM(VIR_MEMORY_VIRTUAL);

    start = NUM2UINT(start_val);
    size = NUM2UINT(size_val);
    flags = NUM2UINT(flags_val);

    buffer = ALLOC_N(char, size);

    r = virDomainMemoryPeek(dom, start, size, buffer, flags);

    if (r < 0) {
        xfree(buffer);
        rb_exc_raise(create_error(e_RetrieveError, "virDomainMemoryPeek",
                                  conn(s)));
    }

    args.val = buffer;
    args.size = size;
    ret = rb_protect(rb_str_new_wrap, (VALUE)&args, &exception);
    xfree(buffer);
    if (exception)
        rb_jump_tag(exception);

    return ret;
}
memory_stats(flags=0) → [ Libvirt::Domain::MemoryStats ] click to toggle source

Call virDomainMemoryStats[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStats] to retrieve statistics about the amount of memory consumed by a domain.

static VALUE libvirt_dom_memory_stats(int argc, VALUE *argv, VALUE s) {
    virDomainPtr dom = domain_get(s);
    virDomainMemoryStatStruct stats[6];
    int r;
    VALUE result;
    VALUE flags;
    VALUE tmp;
    int i;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    r = virDomainMemoryStats(dom, stats, 6, NUM2UINT(flags));
    _E(r < 0, create_error(e_RetrieveError, "virDomainMemoryStats", conn(s)));

    /* FIXME: the right rubyish way to have done this would have been to
     * create a hash with the values, something like:
     *
     * { 'SWAP_IN' => 0, 'SWAP_OUT' => 98, 'MAJOR_FAULT' => 45,
     *   'MINOR_FAULT' => 55, 'UNUSED' => 455, 'AVAILABLE' => 98 }
     *
     * Unfortunately this has already been released with the array version
     * so we have to maintain compatibility with that.  We should probably add
     * a new memory_stats-like call that properly creates the hash.
     */
    result = rb_ary_new2(r);
    for (i=0; i<r; i++) {
        tmp = rb_class_new_instance(0, NULL, c_domain_memory_stats);
        rb_iv_set(tmp, "@tag", INT2NUM(stats[i].tag));
        rb_iv_set(tmp, "@val", ULL2NUM(stats[i].val));

        rb_ary_push(result, tmp);
    }                                           \

    return result;
}
migrate(dconn, flags=0, dname=nil, uri=nil, bandwidth=0) → Libvirt::Domain click to toggle source

Call virDomainMigrate[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrate] to migrate a domain from the host on this connection to the connection referenced in dconn.

static VALUE libvirt_dom_migrate(int argc, VALUE *argv, VALUE s) {
    VALUE dconn, flags, dname_val, uri_val, bandwidth;
    virDomainPtr ddom = NULL;

    rb_scan_args(argc, argv, "14", &dconn, &flags, &dname_val, &uri_val,
                 &bandwidth);

    if (NIL_P(bandwidth))
        bandwidth = INT2NUM(0);
    if (NIL_P(flags))
        flags = INT2NUM(0);

    ddom = virDomainMigrate(domain_get(s), conn(dconn), NUM2ULONG(flags),
                            get_string_or_nil(dname_val),
                            get_string_or_nil(uri_val), NUM2ULONG(bandwidth));

    _E(ddom == NULL, create_error(e_Error, "virDomainMigrate", conn(s)));

    return domain_new(ddom, dconn);
}
migrate2(dconn, dxml=nil, flags=0, dname=nil, uri=nil, bandwidth=0) → Libvirt::Domain click to toggle source

Call virDomainMigrate2[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrate2] to migrate a domain from the host on this connection to the connection referenced in dconn.

static VALUE libvirt_dom_migrate2(int argc, VALUE *argv, VALUE s) {
    VALUE dconn, dxml, flags, dname_val, uri_val, bandwidth;
    virDomainPtr ddom = NULL;

    rb_scan_args(argc, argv, "15", &dconn, &dxml, &flags, &dname_val, &uri_val,
                 &bandwidth);

    if (NIL_P(bandwidth))
        bandwidth = INT2NUM(0);
    if (NIL_P(flags))
        flags = INT2NUM(0);

    ddom = virDomainMigrate2(domain_get(s), conn(dconn),
                             get_string_or_nil(dxml), NUM2ULONG(flags),
                             get_string_or_nil(dname_val),
                             get_string_or_nil(uri_val), NUM2ULONG(bandwidth));

    _E(ddom == NULL, create_error(e_Error, "virDomainMigrate2", conn(s)));

    return domain_new(ddom, dconn);
}
migrate_set_max_downtime(downtime, flags=0) → nil click to toggle source

Call virDomainMigrateSetMaxDowntime[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateSetMaxDowntime] to set the maximum downtime desired for live migration.

static VALUE libvirt_dom_migrate_set_max_downtime(int argc, VALUE *argv,
                                                  VALUE s) {
    VALUE downtime, flags;

    rb_scan_args(argc, argv, "11", &downtime, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainMigrateSetMaxDowntime, conn(s), domain_get(s),
                  NUM2ULL(downtime), NUM2UINT(flags));
}
migrate_set_max_speed(bandwidth, flags=0) → nil click to toggle source

Call virDomainMigrateSetMaxSpeed[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateSetMaxSpeed] to set the maximum bandwidth allowed for live migration.

static VALUE libvirt_dom_migrate_set_max_speed(int argc, VALUE *argv, VALUE s) {
    VALUE bandwidth, flags;

    rb_scan_args(argc, argv, "11", &bandwidth, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainMigrateSetMaxSpeed, conn(s), domain_get(s),
                  NUM2ULONG(bandwidth), NUM2UINT(flags));
}
migrate_to_uri(duri, flags=0, dname=nil, bandwidth=0) → nil click to toggle source

Call virDomainMigrateToURI[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI] to migrate a domain from the host on this connection to the host whose libvirt URI is duri.

static VALUE libvirt_dom_migrate_to_uri(int argc, VALUE *argv, VALUE s) {
    VALUE duri, flags, dname, bandwidth;

    rb_scan_args(argc, argv, "13", &duri, &flags, &dname, &bandwidth);

    if (NIL_P(bandwidth))
        bandwidth = INT2NUM(0);
    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainMigrateToURI, conn(s), domain_get(s),
                  StringValueCStr(duri), NUM2ULONG(flags),
                  get_string_or_nil(dname), NUM2ULONG(bandwidth));
}
migrate_to_uri2(duri=nil, migrate_uri=nil, dxml=nil, flags=0, dname=nil, bandwidth=0) → nil click to toggle source

Call virDomainMigrateToURI2[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI2] to migrate a domain from the host on this connection to the host whose libvirt URI is duri.

static VALUE libvirt_dom_migrate_to_uri2(int argc, VALUE *argv, VALUE s) {
    VALUE duri, migrate_uri, dxml, flags, dname, bandwidth;

    rb_scan_args(argc, argv, "06", &duri, &migrate_uri, &dxml, &flags, &dname,
                 &bandwidth);

    if (NIL_P(bandwidth))
        bandwidth = INT2NUM(0);
    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainMigrateToURI2, conn(s), domain_get(s),
                  get_string_or_nil(duri), get_string_or_nil(migrate_uri),
                  get_string_or_nil(dxml), NUM2ULONG(flags),
                  get_string_or_nil(dname), NUM2ULONG(bandwidth));
}
name → string click to toggle source

Call virDomainGetName[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetName] to retrieve the name of this domain.

static VALUE libvirt_dom_name(VALUE s) {
    gen_call_string(virDomainGetName, conn(s), 0, domain_get(s));
}
num_of_snapshots(flags=0) → fixnum click to toggle source

Call virDomainSnapshotNum[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotNum] to retrieve the number of available snapshots for this domain.

static VALUE libvirt_dom_num_of_snapshots(int argc, VALUE *argv, VALUE d) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_int(virDomainSnapshotNum, conn(d), domain_get(d),
                 NUM2UINT(flags));
}
num_vcpus(flags) → fixnum click to toggle source

Call virDomainGetVcpusFlags[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetVcpusFlags] to retrieve the number of virtual CPUs assigned to this domain.

static VALUE libvirt_dom_num_vcpus(VALUE d, VALUE flags) {
    gen_call_int(virDomainGetVcpusFlags, conn(d), domain_get(d),
                 NUM2UINT(flags));
}
open_console(device, stream, flags=0) → nil click to toggle source

Call virDomainOpenConsole[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainOpenConsole] to open up a console to device over stream.

static VALUE libvirt_dom_open_console(int argc, VALUE *argv, VALUE d) {
    VALUE dev, st, flags;

    rb_scan_args(argc, argv, "21", &dev, &st, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainOpenConsole, conn(d), domain_get(d),
                  StringValueCStr(dev), stream_get(st), NUM2INT(flags));
}
os_type → string click to toggle source

Call virDomainGetOSType[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetOSType] to retrieve the #os_type of this domain. In libvirt terms, #os_type determines whether this domain is fully virtualized, paravirtualized, or a container.

static VALUE libvirt_dom_os_type(VALUE s) {
    gen_call_string(virDomainGetOSType, conn(s), 1, domain_get(s));
}
persistent? → [true|false] click to toggle source

Call virDomainIsPersistent[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainIsPersistent] to determine if this is a persistent domain.

static VALUE libvirt_dom_persistent_p(VALUE d) {
    gen_call_truefalse(virDomainIsPersistent, conn(d), domain_get(d));
}
pin_vcpu(vcpu, cpulist) → nil click to toggle source

Call virDomainPinVcpu[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainPinVcpu] to pin a particular virtual CPU to a range of physical processors. The cpulist should be an array of Fixnums representing the physical processors this virtual CPU should be allowed to be scheduled on.

static VALUE libvirt_dom_pin_vcpu(VALUE s, VALUE vcpu, VALUE cpulist) {
    virDomainPtr dom = domain_get(s);
    int r, i, len, maplen;
    unsigned char *cpumap;
    virNodeInfo nodeinfo;
    virConnectPtr c = conn(s);
    unsigned int vcpunum;

    vcpunum = NUM2UINT(vcpu);
    Check_Type(cpulist, T_ARRAY);

    r = virNodeGetInfo(c, &nodeinfo);
    _E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo", c));

    maplen = VIR_CPU_MAPLEN(nodeinfo.cpus);
    cpumap = ALLOC_N(unsigned char, maplen);
    MEMZERO(cpumap, unsigned char, maplen);

    len = RARRAY_LEN(cpulist);
    for(i = 0; i < len; i++) {
        VALUE e = rb_ary_entry(cpulist, i);
        VIR_USE_CPU(cpumap, NUM2UINT(e));
    }

    r = virDomainPinVcpu(dom, vcpunum, cpumap, maplen);
    xfree(cpumap);
    _E(r < 0, create_error(e_RetrieveError, "virDomainPinVcpu", c));

    return Qnil;
}
qemu_monitor_command(cmd, flags=0) → string click to toggle source

Call virDomainQemuMonitorCommand to send a qemu command directly to the monitor. Note that this will only work on qemu hypervisors, and the input and output formats are not guaranteed to be stable. Also note that using this command can severly impede libvirt's ability to manage the domain; use with caution!

static VALUE libvirt_dom_qemu_monitor_command(int argc, VALUE *argv, VALUE d) {
    VALUE cmd, flags;
    char *result;
    VALUE ret;
    int exception;
    virConnectPtr c;
    const char *type;
    int r;

    rb_scan_args(argc, argv, "11", &cmd, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    c = conn(d);
    type = virConnectGetType(c);
    _E(type == NULL, create_error(e_Error, "virConnectGetType", c));
    if (strcmp(type, "QEMU") != 0)
        rb_raise(rb_eTypeError,
                 "Tried to use virDomainQemuMonitor command on %s connection",
                 type);

    r = virDomainQemuMonitorCommand(domain_get(d), StringValueCStr(cmd),
                                    &result, NUM2UINT(flags));
    _E(r < 0, create_error(e_RetrieveError, "virDomainQemuMonitorCommand", c));

    ret = rb_protect(rb_str_new2_wrap, (VALUE)&result, &exception);
    free(result);
    if (exception)
        rb_jump_tag(exception);

    return ret;
}
reboot(flags=0) → nil click to toggle source

Call virDomainReboot[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainReboot] to do a reboot of the domain.

static VALUE libvirt_dom_reboot(int argc, VALUE *argv, VALUE s) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainReboot, conn(s), domain_get(s), NUM2UINT(flags));
}
restore(filename) → nil click to toggle source

Call virDomainRestore[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainRestore] to restore the domain from the filename.

static VALUE libvirt_dom_restore(VALUE s, VALUE from) {
    gen_call_void(virDomainRestore, conn(s), connect_get(s),
                  StringValueCStr(from));
}
resume → nil click to toggle source

Call virDomainResume[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainResume] to resume a suspended domain. After this call the domain will start consuming CPU resources again.

static VALUE libvirt_dom_resume(VALUE s) {
    gen_call_void(virDomainResume, conn(s), domain_get(s));
}
revert_to_snapshot(snapshot_object, flags=0) → nil click to toggle source

Call virDomainRevertToSnapshot[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainRevertToSnapshot] to restore this domain to a previously saved snapshot.

static VALUE libvirt_dom_revert_to_snapshot(int argc, VALUE *argv, VALUE d) {
    VALUE snap, flags;

    rb_scan_args(argc, argv, "11", &snap, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainRevertToSnapshot, conn(d),
                  domain_snapshot_get(snap), NUM2UINT(flags));
}
save(filename) → nil click to toggle source

Call virDomainSave[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSave] to save the domain state to filename. After this call, the domain will no longer be consuming any resources.

static VALUE libvirt_dom_save(VALUE s, VALUE to) {
    gen_call_void(virDomainSave, conn(s), domain_get(s), StringValueCStr(to));
}
scheduler_parameters(flags=0) → Hash click to toggle source

Call virDomainGetSchedulerParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetSchedulerParameters] to retrieve all of the scheduler parameters for this domain. The keys and values in the hash that is returned are hypervisor specific.

static VALUE libvirt_dom_get_scheduler_parameters(int argc, VALUE *argv,
                                                  VALUE d) {
    return internal_get_parameters(argc, argv, d, scheduler_nparams,
                                   scheduler_get);
}
scheduler_parameters = Hash,flags=0 click to toggle source

Call virDomainSetSchedulerParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetSchedulerParameters] to set the scheduler parameters for this domain. The keys and values in the input hash are hypervisor specific. If an empty hash is given, no changes are made (and no error is raised).

static VALUE libvirt_dom_set_scheduler_parameters(VALUE d, VALUE input) {
    return internal_set_parameters(d, input, scheduler_nparams, scheduler_get,
                                   scheduler_set);
}
scheduler_type → [type, #params] click to toggle source

Call virDomainGetSchedulerType[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetSchedulerType] to retrieve the scheduler type used on this domain.

static VALUE libvirt_dom_scheduler_type(VALUE d) {
    int nparams;
    char *type;
    VALUE result;
    int exception = 0;
    struct create_sched_type_args args;

    type = virDomainGetSchedulerType(domain_get(d), &nparams);

    _E(type == NULL, create_error(e_RetrieveError, "virDomainGetSchedulerType",
                                  conn(d)));

    args.type = type;
    args.nparams = nparams;
    result = rb_protect(create_sched_type_array, (VALUE)&args, &exception);
    if (exception) {
        free(type);
        rb_jump_tag(exception);
    }

    return result;
}
screenshot(stream, screen, flags=0) → nil click to toggle source

Call virDomainScreenshot[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainScreenshot] to take a screenshot of the domain console as a stream.

static VALUE libvirt_dom_screenshot(int argc, VALUE *argv, VALUE d) {
    VALUE st, screen, flags;

    rb_scan_args(argc, argv, "21", &st, &screen, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_string(virDomainScreenshot, conn(d), 1, domain_get(d),
                    stream_get(st), NUM2UINT(screen), NUM2UINT(flags));
}
security_label → Libvirt::Domain::SecurityLabel click to toggle source

Call virDomainGetSecurityLabel[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetSecurityLabel] to retrieve the security label applied to this domain.

static VALUE libvirt_dom_security_label(VALUE s) {
    virDomainPtr dom = domain_get(s);
    virSecurityLabel seclabel;
    int r;
    VALUE result;

    r = virDomainGetSecurityLabel(dom, &seclabel);
    _E(r < 0, create_error(e_RetrieveError, "virDomainGetSecurityLabel",
                           conn(s)));

    result = rb_class_new_instance(0, NULL, c_domain_security_label);
    rb_iv_set(result, "@label", rb_str_new2(seclabel.label));
    rb_iv_set(result, "@enforcing", INT2NUM(seclabel.enforcing));

    return result;
}
shutdown → nil click to toggle source

Call virDomainShutdown[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainShutdown] to do a soft shutdown of the domain. The mechanism for doing the shutdown is hypervisor specific, and may require software running inside the domain to succeed.

static VALUE libvirt_dom_shutdown(VALUE s) {
    gen_call_void(virDomainShutdown, conn(s), domain_get(s));
}
snapshot_create_xml(snapshot_xml, flags=0) → Libvirt::Domain::Snapshot click to toggle source

Call virDomainSnapshotCreateXML[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotCreateXML] to create a new snapshot based on snapshot_xml.

static VALUE libvirt_dom_snapshot_create_xml(int argc, VALUE *argv, VALUE d) {
    VALUE xmlDesc, flags;
    virDomainSnapshotPtr ret;

    rb_scan_args(argc, argv, "11", &xmlDesc, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    ret = virDomainSnapshotCreateXML(domain_get(d), StringValueCStr(xmlDesc),
                                     NUM2UINT(flags));

    _E(ret == NULL, create_error(e_Error, "virDomainSnapshotCreateXML",
                                 conn(d)));

    return domain_snapshot_new(ret, d);
}
state(flags=0) → state, reason click to toggle source

Call virDomainGetState[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetState] to get the current state of the domain.

static VALUE libvirt_dom_get_state(int argc, VALUE *argv, VALUE d) {
    VALUE flags;
    int state, reason;
    VALUE result;
    int retval;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    retval = virDomainGetState(domain_get(d), &state, &reason, NUM2INT(flags));
    _E(retval < 0, create_error(e_Error, "virDomainGetState", conn(d)));

    result = rb_ary_new();

    rb_ary_push(result, INT2NUM(state));
    rb_ary_push(result, INT2NUM(reason));

    return result;
}
suspend → nil click to toggle source

Call virDomainSuspend[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSuspend] to stop the domain from executing. The domain will still continue to consume memory, but will not take any CPU time.

static VALUE libvirt_dom_suspend(VALUE s) {
    gen_call_void(virDomainSuspend, conn(s), domain_get(s));
}
undefine → nil click to toggle source

Call virDomainUndefine[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainUndefine] to undefine the domain. After this call, the domain object is no longer valid.

static VALUE libvirt_dom_undefine(VALUE s) {
    gen_call_void(virDomainUndefine, conn(s), domain_get(s));
}
update_device(device_xml, flags=0) → nil click to toggle source

Call virDomainUpdateDeviceFlags[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainUpdateDeviceFlags] to update the device described by the device_xml.

static VALUE libvirt_dom_update_device(int argc, VALUE *argv, VALUE s) {
    VALUE xml;
    VALUE flags;

    rb_scan_args(argc, argv, "11", &xml, &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_void(virDomainUpdateDeviceFlags, conn(s), domain_get(s),
                  StringValueCStr(xml), NUM2UINT(flags));
}
updated? → [True|False] click to toggle source
Call +virDomainIsUpdated+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainIsUpdated]
to determine whether the definition for this domain has been updated.
static VALUE libvirt_dom_is_updated(VALUE d) {
    gen_call_truefalse(virDomainIsUpdated, conn(d), domain_get(d));
}
uuid → string click to toggle source

Call virDomainGetUUIDString[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetUUIDString] to retrieve the UUID of this domain.

static VALUE libvirt_dom_uuid(VALUE s) {
    virDomainPtr dom = domain_get(s);
    char uuid[VIR_UUID_STRING_BUFLEN];
    int r;

    r = virDomainGetUUIDString(dom, uuid);
    _E(r < 0, create_error(e_RetrieveError, "virDomainGetUUIDString", conn(s)));

    return rb_str_new2((char *) uuid);
}
vcpus = Fixnum click to toggle source

Call virDomainSetVcpus[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetVcpus] to set the current number of virtual CPUs this domain should have. Note that this will only work if both the hypervisor and domain on this connection support virtual CPU hotplug/hot-unplug.

static VALUE libvirt_dom_vcpus_set(VALUE s, VALUE nvcpus) {
    gen_call_void(virDomainSetVcpus, conn(s), domain_get(s), NUM2UINT(nvcpus));
}
vcpus_flags = Fixnum,flags click to toggle source

Call virDomainSetVcpusFlags[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetVcpusFlags] to set the current number of virtual CPUs this domain should have. The flags parameter controls whether the change is made to the running domain the domain configuration, or both, and must not be 0.

static VALUE libvirt_dom_vcpus_set_flags(VALUE s, VALUE vcpus) {
    VALUE nvcpus;
    VALUE flags;

    Check_Type(vcpus, T_ARRAY);

    if (RARRAY_LEN(vcpus) != 2)
        rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
                 RARRAY_LEN(vcpus));

    nvcpus = rb_ary_entry(vcpus, 0);
    flags = rb_ary_entry(vcpus, 1);

    gen_call_void(virDomainSetVcpusFlags, conn(s), domain_get(s),
                  NUM2UINT(nvcpus), NUM2UINT(flags));
}
xml_desc(flags=0) → string click to toggle source

Call virDomainGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetXMLDesc] to retrieve the XML describing this domain.

static VALUE libvirt_dom_xml_desc(int argc, VALUE *argv, VALUE s) {
    VALUE flags;

    rb_scan_args(argc, argv, "01", &flags);

    if (NIL_P(flags))
        flags = INT2NUM(0);

    gen_call_string(virDomainGetXMLDesc, conn(s), 1, domain_get(s),
                    NUM2INT(flags));
}