class Libvirt::Domain
Constants
- AFFECT_CONFIG
Ideally we would just have the “AFFECT_CONFIG” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_AFFECT_CONFIG” for backwards compatibility.
- AFFECT_CURRENT
Ideally we would just have the “AFFECT_CURRENT” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_AFFECT_CURRENT” for backwards compatibility.
- AFFECT_LIVE
Ideally we would just have the “AFFECT_LIVE” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_AFFECT_LIVE” for backwards compatibility.
- BLOCKED
- BLOCKED_UNKNOWN
Ideally we would just have the “BLOCKED_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_BLOCKED_UNKNOWN” for backwards compatibility.
- BLOCK_COMMIT_ACTIVE
- BLOCK_COMMIT_BANDWIDTH_BYTES
- BLOCK_COMMIT_DELETE
- BLOCK_COMMIT_RELATIVE
- BLOCK_COMMIT_SHALLOW
- BLOCK_JOB_ABORT_ASYNC
- BLOCK_JOB_ABORT_PIVOT
- BLOCK_JOB_CANCELED
- BLOCK_JOB_COMPLETED
- BLOCK_JOB_FAILED
- BLOCK_JOB_INFO_BANDWIDTH_BYTES
- BLOCK_JOB_READY
- BLOCK_JOB_SPEED_BANDWIDTH_BYTES
- BLOCK_JOB_TYPE_ACTIVE_COMMIT
- BLOCK_JOB_TYPE_COMMIT
- BLOCK_JOB_TYPE_COPY
- BLOCK_JOB_TYPE_PULL
- BLOCK_JOB_TYPE_UNKNOWN
- BLOCK_REBASE_COPY
- BLOCK_REBASE_COPY_RAW
- BLOCK_REBASE_REUSE_EXT
- BLOCK_REBASE_SHALLOW
- BLOCK_RESIZE_BYTES
- BYPASS_CACHE
- CHANNEL_FORCE
- CONSOLE_FORCE
- CONSOLE_SAFE
- CORE_DUMP_FORMAT_KDUMP_LZO
- CORE_DUMP_FORMAT_KDUMP_SNAPPY
- CORE_DUMP_FORMAT_KDUMP_ZLIB
- CORE_DUMP_FORMAT_RAW
- CRASHED
- CRASHED_PANICKED
- CRASHED_UNKNOWN
Ideally we would just have the “CRASHED_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_CRASHED_UNKNOWN” for backwards compatibility.
- DESTROY_DEFAULT
- DESTROY_GRACEFUL
- DEVICE_MODIFY_CONFIG
- DEVICE_MODIFY_CURRENT
- DEVICE_MODIFY_FORCE
- DEVICE_MODIFY_LIVE
- DISK_ERROR_NONE
- DISK_ERROR_NO_SPACE
- DISK_ERROR_UNSPEC
- 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_SHUTTING_DOWN
- DOMAIN_PAUSED_SNAPSHOT
- DOMAIN_PAUSED_UNKNOWN
- DOMAIN_PAUSED_USER
- DOMAIN_PAUSED_WATCHDOG
- DOMAIN_PMSUSPENDED_DISK_UNKNOWN
- DOMAIN_PMSUSPENDED_UNKNOWN
- 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_RUNNING_WAKEUP
- 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
- KEYCODE_SET_ATSET1
- KEYCODE_SET_ATSET2
- KEYCODE_SET_ATSET3
- KEYCODE_SET_LINUX
- KEYCODE_SET_OSX
- KEYCODE_SET_RFB
- KEYCODE_SET_USB
- KEYCODE_SET_WIN32
- KEYCODE_SET_XT
- KEYCODE_SET_XT_KBD
- MEMORY_ONLY
- MEMORY_PARAM_UNLIMITED
- MEMORY_PHYSICAL
- MEMORY_VIRTUAL
- MEM_CONFIG
Ideally we would just have the “MEM_CONFIG” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_MEM_CONFIG” for backwards compatibility.
- MEM_CURRENT
Ideally we would just have the “MEM_CURRENT” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_MEM_CURRENT” for backwards compatibility.
- MEM_LIVE
Ideally we would just have the “MEM_LIVE” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_MEM_LIVE” for backwards compatibility.
- MEM_MAXIMUM
Ideally we would just have the “MEM_MAXIMUM” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_MEM_MAXIMUM” for backwards compatibility.
- METADATA_DESCRIPTION
- METADATA_ELEMENT
- METADATA_TITLE
- MIGRATE_ABORT_ON_ERROR
- MIGRATE_AUTO_CONVERGE
- MIGRATE_CHANGE_PROTECTION
- MIGRATE_COMPRESSED
- MIGRATE_LIVE
virDomainMigrateFlags
- MIGRATE_NON_SHARED_DISK
- MIGRATE_NON_SHARED_INC
- MIGRATE_OFFLINE
- MIGRATE_PAUSED
- MIGRATE_PEER2PEER
- MIGRATE_PERSIST_DEST
- MIGRATE_RDMA_PIN_ALL
- MIGRATE_TUNNELLED
- MIGRATE_UNDEFINE_SOURCE
- MIGRATE_UNSAFE
- NOSTATE
- NOSTATE_UNKNOWN
- OPEN_GRAPHICS_SKIPAUTH
- PASSWORD_ENCRYPTED
- PAUSED
- PAUSED_CRASHED
- PAUSED_DUMP
Ideally we would just have the “PAUSED_DUMP” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_DUMP” for backwards compatibility.
- PAUSED_FROM_SNAPSHOT
Ideally we would just have the “PAUSED_FROM_SNAPSHOT” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_FROM_SNAPSHOT” for backwards compatibility.
- PAUSED_IOERROR
Ideally we would just have the “PAUSED_IOERROR” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_IOERROR” for backwards compatibility.
- PAUSED_MIGRATION
Ideally we would just have the “PAUSED_MIGRATION” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_MIGRATION” for backwards compatibility.
- PAUSED_SAVE
Ideally we would just have the “PAUSED_SAVE” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_SAVE” for backwards compatibility.
- PAUSED_SHUTTING_DOWN
Ideally we would just have the “PAUSED_SHUTTING_DOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_SHUTTING_DOWN” for backwards compatibility.
- PAUSED_SNAPSHOT
Ideally we would just have the “PAUSED_SNAPSHOT” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_SNAPSHOT” for backwards compatibility.
- PAUSED_UNKNOWN
Ideally we would just have the “PAUSED_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_UNKNOWN” for backwards compatibility.
- PAUSED_USER
Ideally we would just have the “PAUSED_USER” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_USER” for backwards compatibility.
- PAUSED_WATCHDOG
Ideally we would just have the “PAUSED_WATCHDOG” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PAUSED_WATCHDOG” for backwards compatibility.
- PMSUSPENDED
- PMSUSPENDED_DISK_UNKNOWN
Ideally we would just have the “PMSUSPENDED_DISK_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PMSUSPENDED_DISK_UNKNOWN” for backwards compatibility.
- PMSUSPENDED_UNKNOWN
Ideally we would just have the “PMSUSPENDED_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_PMSUSPENDED_UNKNOWN” for backwards compatibility.
- PROCESS_SIGNAL_ABRT
- PROCESS_SIGNAL_ALRM
- PROCESS_SIGNAL_BUS
- PROCESS_SIGNAL_CHLD
- PROCESS_SIGNAL_CONT
- PROCESS_SIGNAL_FPE
- PROCESS_SIGNAL_HUP
- PROCESS_SIGNAL_ILL
- PROCESS_SIGNAL_INT
- PROCESS_SIGNAL_KILL
- PROCESS_SIGNAL_NOP
- PROCESS_SIGNAL_PIPE
- PROCESS_SIGNAL_POLL
- PROCESS_SIGNAL_PROF
- PROCESS_SIGNAL_PWR
- PROCESS_SIGNAL_QUIT
- PROCESS_SIGNAL_RT0
- PROCESS_SIGNAL_RT1
- PROCESS_SIGNAL_RT10
- PROCESS_SIGNAL_RT11
- PROCESS_SIGNAL_RT12
- PROCESS_SIGNAL_RT13
- PROCESS_SIGNAL_RT14
- PROCESS_SIGNAL_RT15
- PROCESS_SIGNAL_RT16
- PROCESS_SIGNAL_RT17
- PROCESS_SIGNAL_RT18
- PROCESS_SIGNAL_RT19
- PROCESS_SIGNAL_RT2
- PROCESS_SIGNAL_RT20
- PROCESS_SIGNAL_RT21
- PROCESS_SIGNAL_RT22
- PROCESS_SIGNAL_RT23
- PROCESS_SIGNAL_RT24
- PROCESS_SIGNAL_RT25
- PROCESS_SIGNAL_RT26
- PROCESS_SIGNAL_RT27
- PROCESS_SIGNAL_RT28
- PROCESS_SIGNAL_RT29
- PROCESS_SIGNAL_RT3
- PROCESS_SIGNAL_RT30
- PROCESS_SIGNAL_RT31
- PROCESS_SIGNAL_RT32
- PROCESS_SIGNAL_RT4
- PROCESS_SIGNAL_RT5
- PROCESS_SIGNAL_RT6
- PROCESS_SIGNAL_RT7
- PROCESS_SIGNAL_RT8
- PROCESS_SIGNAL_RT9
- PROCESS_SIGNAL_SEGV
- PROCESS_SIGNAL_STKFLT
- PROCESS_SIGNAL_STOP
- PROCESS_SIGNAL_SYS
- PROCESS_SIGNAL_TERM
- PROCESS_SIGNAL_TRAP
- PROCESS_SIGNAL_TSTP
- PROCESS_SIGNAL_TTIN
- PROCESS_SIGNAL_TTOU
- PROCESS_SIGNAL_URG
- PROCESS_SIGNAL_USR1
- PROCESS_SIGNAL_USR2
- PROCESS_SIGNAL_VTALRM
- PROCESS_SIGNAL_WINCH
- PROCESS_SIGNAL_XCPU
- PROCESS_SIGNAL_XFSZ
- QEMU_AGENT_COMMAND_BLOCK
- QEMU_AGENT_COMMAND_DEFAULT
- QEMU_AGENT_COMMAND_NOWAIT
- QEMU_AGENT_COMMAND_SHUTDOWN
- QEMU_MONITOR_COMMAND_DEFAULT
- QEMU_MONITOR_COMMAND_HMP
- REBOOT_ACPI_POWER_BTN
- REBOOT_DEFAULT
- REBOOT_GUEST_AGENT
- REBOOT_INITCTL
- REBOOT_PARAVIRT
- REBOOT_SIGNAL
- RESET
- RUNNING
- RUNNING_BOOTED
Ideally we would just have the “RUNNING_BOOTED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_BOOTED” for backwards compatibility.
- RUNNING_CRASHED
- RUNNING_FROM_SNAPSHOT
Ideally we would just have the “RUNNING_FROM_SNAPSHOT” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_FROM_SNAPSHOT” for backwards compatibility.
- RUNNING_MIGRATED
Ideally we would just have the “RUNNING_MIGRATED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_MIGRATED” for backwards compatibility.
- RUNNING_MIGRATION_CANCELED
Ideally we would just have the “RUNNING_MIGRATION_CANCELED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_MIGRATION_CANCELED” for backwards compatibility.
- RUNNING_RESTORED
Ideally we would just have the “RUNNING_RESTORED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_RESTORED” for backwards compatibility.
- RUNNING_SAVE_CANCELED
Ideally we would just have the “RUNNING_SAVE_CANCELED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_SAVE_CANCELED” for backwards compatibility.
- RUNNING_UNKNOWN
Ideally we would just have the “RUNNING_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_UNKNOWN” for backwards compatibility.
- RUNNING_UNPAUSED
Ideally we would just have the “RUNNING_UNPAUSED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_UNPAUSED” for backwards compatibility.
- RUNNING_WAKEUP
Ideally we would just have the “RUNNING_WAKEUP” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_RUNNING_WAKEUP” for backwards compatibility.
- SAVE_BYPASS_CACHE
- SAVE_PAUSED
- SAVE_RUNNING
- SHUTDOWN
- SHUTDOWN_ACPI_POWER_BTN
- SHUTDOWN_DEFAULT
- SHUTDOWN_GUEST_AGENT
- SHUTDOWN_INITCTL
- SHUTDOWN_PARAVIRT
- SHUTDOWN_SIGNAL
- SHUTDOWN_UNKNOWN
Ideally we would just have the “SHUTDOWN_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTDOWN_UNKNOWN” for backwards compatibility.
- SHUTDOWN_USER
Ideally we would just have the “SHUTDOWN_USER” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTDOWN_USER” for backwards compatibility.
- SHUTOFF
- SHUTOFF_CRASHED
Ideally we would just have the “SHUTOFF_CRASHED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_CRASHED” for backwards compatibility.
- SHUTOFF_DESTROYED
Ideally we would just have the “SHUTOFF_DESTROYED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_DESTROYED” for backwards compatibility.
- SHUTOFF_FAILED
Ideally we would just have the “SHUTOFF_FAILED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_FAILED” for backwards compatibility.
- SHUTOFF_FROM_SNAPSHOT
Ideally we would just have the “SHUTOFF_FROM_SNAPSHOT” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_FROM_SNAPSHOT” for backwards compatibility.
- SHUTOFF_MIGRATED
Ideally we would just have the “SHUTOFF_MIGRATED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_MIGRATED” for backwards compatibility.
- SHUTOFF_SAVED
Ideally we would just have the “SHUTOFF_SAVED” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_SAVED” for backwards compatibility.
- SHUTOFF_SHUTDOWN
Ideally we would just have the “SHUTOFF_SHUTDOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_SHUTDOWN” for backwards compatibility.
- SHUTOFF_UNKNOWN
Ideally we would just have the “SHUTOFF_UNKNOWN” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_SHUTOFF_UNKNOWN” for backwards compatibility.
- START_AUTODESTROY
- START_BYPASS_CACHE
- START_FORCE_BOOT
- START_PAUSED
- TIME_SYNC
- UNDEFINE_CHECKPOINTS_METADATA
- UNDEFINE_KEEP_NVRAM
- UNDEFINE_MANAGED_SAVE
- UNDEFINE_NVRAM
- UNDEFINE_SNAPSHOTS_METADATA
- VCPU_CONFIG
- VCPU_CURRENT
- VCPU_GUEST
- VCPU_LIVE
- VCPU_MAXIMUM
- XML_INACTIVE
Ideally we would just have the “XML_INACTIVE” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_XML_INACTIVE” for backwards compatibility.
- XML_MIGRATABLE
- XML_SECURE
Ideally we would just have the “XML_SECURE” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_XML_SECURE” for backwards compatibility.
- XML_UPDATE_CPU
Ideally we would just have the “XML_UPDATE_CPU” constant. Unfortunately we screwed up long ago, and we have to leave “DOMAIN_XML_UPDATE_CPU” for backwards compatibility.
Attributes
Public Class Methods
Call virDomainRestore to restore the domain from the filename.
static VALUE libvirt_domain_s_restore(VALUE RUBY_LIBVIRT_UNUSED(klass), VALUE c, VALUE from) { ruby_libvirt_generate_call_nil(virDomainRestore, ruby_libvirt_connect_get(c), ruby_libvirt_connect_get(c), StringValueCStr(from)); }
Public Instance Methods
Call virDomainAbortJob to abort the currently running job on this domain.
static VALUE libvirt_domain_abort_job(VALUE d) { ruby_libvirt_generate_call_nil(virDomainAbortJob, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
Call virDomainIsActive to determine if this domain is currently active.
static VALUE libvirt_domain_active_p(VALUE d) { ruby_libvirt_generate_call_truefalse(virDomainIsActive, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
Call virDomainAttachDeviceFlags to attach the device described by the device_xml to the domain.
static VALUE libvirt_domain_attach_device(int argc, VALUE *argv, VALUE d) { VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); /* NOTE: can't use virDomainAttachDevice() when flags==0 here * because that function only works on active domains and * VIR_DOMAIN_AFFECT_CURRENT==0. * * See https://gitlab.com/libvirt/libvirt-ruby/-/issues/11 */ ruby_libvirt_generate_call_nil(virDomainAttachDeviceFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetAutostart to find out the state of the autostart flag for a domain.
static VALUE libvirt_domain_autostart(VALUE d) { int r, autostart; r = virDomainGetAutostart(ruby_libvirt_domain_get(d), &autostart); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainAutostart", ruby_libvirt_connect_get(d)); return autostart ? Qtrue : Qfalse; }
Call virDomainSetAutostart to make this domain autostart when libvirtd starts up.
static VALUE libvirt_domain_autostart_equal(VALUE d, VALUE autostart) { if (autostart != Qtrue && autostart != Qfalse) { rb_raise(rb_eTypeError, "wrong argument type (expected TrueClass or FalseClass)"); } ruby_libvirt_generate_call_nil(virDomainSetAutostart, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), RTEST(autostart) ? 1 : 0); }
Call virDomainGetAutostart to find out the state of the autostart flag for a domain.
Call 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_domain_blkio_parameters(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); return ruby_libvirt_get_typed_parameters(d, ruby_libvirt_value_to_uint(flags), NULL, blkio_nparams, blkio_get); }
Call virDomainSetBlkioParameters to set the blkio parameters for this domain. The keys and values in the input hash are hypervisor specific.
static VALUE libvirt_domain_blkio_parameters_equal(VALUE d, VALUE in) { VALUE hash, flags; ruby_libvirt_assign_hash_and_flags(in, &hash, &flags); return ruby_libvirt_set_typed_parameters(d, hash, NUM2UINT(flags), NULL, blkio_allowed, ARRAY_SIZE(blkio_allowed), blkio_set); }
Call virDomainBlockCommit to commit changes from a top-level backing file into a lower level base file.
static VALUE libvirt_domain_block_commit(int argc, VALUE *argv, VALUE d) { VALUE disk, base, top, bandwidth, flags; rb_scan_args(argc, argv, "14", &disk, &base, &top, &bandwidth, &flags); ruby_libvirt_generate_call_nil(virDomainBlockCommit, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(disk), ruby_libvirt_get_cstring_or_null(base), ruby_libvirt_get_cstring_or_null(top), ruby_libvirt_value_to_ulong(bandwidth), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetBlockIoTune to retrieve all of the block IO tune parameters for this domain. The keys and values in the hash that is returned are hypervisor specific.
static VALUE libvirt_domain_block_iotune(int argc, VALUE *argv, VALUE d) { VALUE disk, flags; rb_scan_args(argc, argv, "02", &disk, &flags); return ruby_libvirt_get_typed_parameters(d, ruby_libvirt_value_to_uint(flags), (void *)disk, iotune_nparams, iotune_get); }
Call virDomainSetBlockIoTune to set the block IO tune parameters for the supplied disk on this domain. The keys and values in the input hash are hypervisor specific.
static VALUE libvirt_domain_block_iotune_equal(VALUE d, VALUE in) { VALUE disk, hash, flags; Check_Type(in, T_ARRAY); if (RARRAY_LEN(in) == 2) { disk = rb_ary_entry(in, 0); hash = rb_ary_entry(in, 1); flags = INT2NUM(0); } else if (RARRAY_LEN(in) == 3) { disk = rb_ary_entry(in, 0); hash = rb_ary_entry(in, 1); flags = rb_ary_entry(in, 2); } else { rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2 or 3)", RARRAY_LEN(in)); } return ruby_libvirt_set_typed_parameters(d, hash, NUM2UINT(flags), (void *)disk, iotune_allowed, ARRAY_SIZE(iotune_allowed), iotune_set); }
Call virDomainBlockJobAbort to cancel an active block job on the given disk.
static VALUE libvirt_domain_block_job_abort(int argc, VALUE *argv, VALUE d) { VALUE disk, flags = RUBY_Qnil; rb_scan_args(argc, argv, "11", &disk, &flags); ruby_libvirt_generate_call_nil(virDomainBlockJobAbort, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(disk), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetBlockJobInfo to get block job information for a given disk.
static VALUE libvirt_domain_block_job_info(int argc, VALUE *argv, VALUE d) { VALUE disk, flags = RUBY_Qnil, result; virDomainBlockJobInfo info; int r; rb_scan_args(argc, argv, "11", &disk, &flags); memset(&info, 0, sizeof(virDomainBlockJobInfo)); r = virDomainGetBlockJobInfo(ruby_libvirt_domain_get(d), StringValueCStr(disk), &info, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetBlockJobInfo", ruby_libvirt_connect_get(d)); result = rb_class_new_instance(0, NULL, c_domain_block_job_info); rb_iv_set(result, "@type", UINT2NUM(info.type)); rb_iv_set(result, "@bandwidth", ULONG2NUM(info.bandwidth)); rb_iv_set(result, "@cur", ULL2NUM(info.cur)); rb_iv_set(result, "@end", ULL2NUM(info.end)); return result; }
Call virDomainBlockJobSetSpeed to set the maximum allowable bandwidth a block job may consume.
static VALUE libvirt_domain_block_job_speed_equal(VALUE d, VALUE in) { VALUE disk, bandwidth, flags; if (TYPE(in) == T_STRING) { disk = in; bandwidth = INT2NUM(0); flags = INT2NUM(0); } else if (TYPE(in) == T_ARRAY) { if (RARRAY_LEN(in) == 2) { disk = rb_ary_entry(in, 0); bandwidth = rb_ary_entry(in, 1); flags = INT2NUM(0); } else if (RARRAY_LEN(in) == 3) { disk = rb_ary_entry(in, 0); bandwidth = rb_ary_entry(in, 1); flags = rb_ary_entry(in, 2); } else { rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2 or 3)", RARRAY_LEN(in)); } } else { rb_raise(rb_eTypeError, "wrong argument type (expected Number or Array)"); } ruby_libvirt_generate_call_nil(virDomainBlockJobSetSpeed, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(disk), NUM2UINT(bandwidth), NUM2UINT(flags)); }
Call 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_domain_block_peek(int argc, VALUE *argv, VALUE d) { VALUE path, offset, size, flags; char *buffer; int r; rb_scan_args(argc, argv, "31", &path, &offset, &size, &flags); buffer = alloca(sizeof(char) * NUM2UINT(size)); r = virDomainBlockPeek(ruby_libvirt_domain_get(d), StringValueCStr(path), NUM2ULL(offset), NUM2UINT(size), buffer, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainBlockPeek", ruby_libvirt_connect_get(d)); return rb_str_new(buffer, NUM2UINT(size)); }
Call virDomainBlockPull to pull changes from a backing file into a disk image.
static VALUE libvirt_domain_block_pull(int argc, VALUE *argv, VALUE d) { VALUE disk, bandwidth = RUBY_Qnil, flags = RUBY_Qnil; rb_scan_args(argc, argv, "12", &disk, &bandwidth, &flags); ruby_libvirt_generate_call_nil(virDomainBlockPull, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(disk), ruby_libvirt_value_to_ulong(bandwidth), ruby_libvirt_value_to_uint(flags)); }
Call virDomainBlockRebase to populate a disk image with data from its backing image chain.
static VALUE libvirt_domain_block_rebase(int argc, VALUE *argv, VALUE d) { VALUE disk, base, bandwidth, flags; rb_scan_args(argc, argv, "13", &disk, &base, &bandwidth, &flags); ruby_libvirt_generate_call_nil(virDomainBlockRebase, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_get_cstring_or_null(disk), ruby_libvirt_get_cstring_or_null(base), ruby_libvirt_value_to_ulong(bandwidth), ruby_libvirt_value_to_uint(flags)); }
Call virDomainBlockResize to resize a block device of domain.
static VALUE libvirt_domain_block_resize(int argc, VALUE *argv, VALUE d) { VALUE disk, size, flags; rb_scan_args(argc, argv, "21", &disk, &size, &flags); ruby_libvirt_generate_call_nil(virDomainBlockResize, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(disk), NUM2ULL(size), ruby_libvirt_value_to_uint(flags)); }
Call virDomainBlockStats to retrieve statistics about domain block device path.
static VALUE libvirt_domain_block_stats(VALUE d, VALUE path) { virDomainBlockStatsStruct stats; int r; VALUE result; r = virDomainBlockStats(ruby_libvirt_domain_get(d), StringValueCStr(path), &stats, sizeof(stats)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainBlockStats", ruby_libvirt_connect_get(d)); 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; }
Call virDomainGetBlockStatsFlags to retrieve the block statistics for the given disk on this domain. The keys and values in the hash that is returned are hypervisor specific.
static VALUE libvirt_domain_block_stats_flags(int argc, VALUE *argv, VALUE d) { VALUE disk = RUBY_Qnil, flags = RUBY_Qnil; rb_scan_args(argc, argv, "11", &disk, &flags); Check_Type(disk, T_STRING); return ruby_libvirt_get_typed_parameters(d, ruby_libvirt_value_to_uint(flags), (void *)disk, block_stats_nparams, block_stats_get); }
Call virDomainGetBlockInfo to retrieve information about the backing file path for the domain.
static VALUE libvirt_domain_block_info(int argc, VALUE *argv, VALUE d) { virDomainBlockInfo info; int r; VALUE result, flags, path; rb_scan_args(argc, argv, "11", &path, &flags); r = virDomainGetBlockInfo(ruby_libvirt_domain_get(d), StringValueCStr(path), &info, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetBlockInfo", ruby_libvirt_connect_get(d)); 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; }
Call virDomainGetControlInfo to retrieve domain control interface information.
static VALUE libvirt_domain_control_info(int argc, VALUE *argv, VALUE d) { VALUE flags, result; virDomainControlInfo info; int r; rb_scan_args(argc, argv, "01", &flags); r = virDomainGetControlInfo(ruby_libvirt_domain_get(d), &info, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetControlInfo", ruby_libvirt_connect_get(d)); result = rb_class_new_instance(0, NULL, c_domain_control_info); rb_iv_set(result, "@state", ULONG2NUM(info.state)); rb_iv_set(result, "@details", ULONG2NUM(info.details)); rb_iv_set(result, "@stateTime", ULL2NUM(info.stateTime)); return result; }
Call virDomainCoreDump to do a full memory dump of the domain to filename.
static VALUE libvirt_domain_core_dump(int argc, VALUE *argv, VALUE d) { VALUE to, flags; rb_scan_args(argc, argv, "11", &to, &flags); ruby_libvirt_generate_call_nil(virDomainCoreDump, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(to), ruby_libvirt_value_to_uint(flags)); }
Call virDomainCoreDumpWithFormat to do a full memory dump of the domain to filename.
static VALUE libvirt_domain_core_dump_with_format(int argc, VALUE *argv, VALUE d) { VALUE to, dumpformat = RUBY_Qnil, flags = RUBY_Qnil; rb_scan_args(argc, argv, "21", &to, &dumpformat, &flags); ruby_libvirt_generate_call_nil(virDomainCoreDumpWithFormat, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(to), NUM2UINT(dumpformat), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetCPUStats to get statistics about CPU usage attributable to a single domain. If start_cpu is -1, then numcpus must be 1 and statistics attributable to the entire domain is returned. If start_cpu is any positive number, then it represents which CPU to start with and numcpus represents how many consecutive processors to query.
static VALUE libvirt_domain_cpu_stats(int argc, VALUE *argv, VALUE d) { VALUE start_cpu = RUBY_Qnil, numcpus = RUBY_Qnil, flags = RUBY_Qnil, result, tmp; int ret, nparams, j; unsigned int i; virTypedParameterPtr params; rb_scan_args(argc, argv, "03", &start_cpu, &numcpus, &flags); if (NIL_P(start_cpu)) { start_cpu = INT2NUM(-1); } if (NIL_P(numcpus)) { numcpus = INT2NUM(1); } if (NIL_P(flags)) { flags = INT2NUM(0); } if (NUM2INT(start_cpu) == -1) { nparams = virDomainGetCPUStats(ruby_libvirt_domain_get(d), NULL, 0, NUM2INT(start_cpu), NUM2UINT(numcpus), NUM2UINT(flags)); ruby_libvirt_raise_error_if(nparams < 0, e_RetrieveError, "virDomainGetCPUStats", ruby_libvirt_connect_get(d)); params = alloca(nparams * sizeof(virTypedParameter)); ret = virDomainGetCPUStats(ruby_libvirt_domain_get(d), params, nparams, NUM2INT(start_cpu), NUM2UINT(numcpus), NUM2UINT(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virDomainGetCPUStats", ruby_libvirt_connect_get(d)); result = rb_hash_new(); tmp = rb_hash_new(); for (j = 0; j < nparams; j++) { ruby_libvirt_typed_params_to_hash(params, j, tmp); } rb_hash_aset(result, rb_str_new2("all"), tmp); } else { nparams = virDomainGetCPUStats(ruby_libvirt_domain_get(d), NULL, 0, 0, 1, NUM2UINT(flags)); ruby_libvirt_raise_error_if(nparams < 0, e_RetrieveError, "virDomainGetCPUStats", ruby_libvirt_connect_get(d)); params = alloca(nparams * NUM2UINT(numcpus) * sizeof(virTypedParameter)); ret = virDomainGetCPUStats(ruby_libvirt_domain_get(d), params, nparams, NUM2INT(start_cpu), NUM2UINT(numcpus), NUM2UINT(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virDomainGetCPUStats", ruby_libvirt_connect_get(d)); result = rb_hash_new(); for (i = 0; i < NUM2UINT(numcpus); i++) { if (params[i * nparams].type == 0) { /* cpu is not in the map */ continue; } tmp = rb_hash_new(); for (j = 0; j < nparams; j++) { ruby_libvirt_typed_params_to_hash(params, j, tmp); } rb_hash_aset(result, INT2NUM(NUM2UINT(start_cpu) + i), tmp); } } return result; }
Call virDomainCreate to start an already defined domain.
static VALUE libvirt_domain_create(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); if (ruby_libvirt_value_to_uint(flags) != 0) { ruby_libvirt_generate_call_nil(virDomainCreateWithFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); } else { ruby_libvirt_generate_call_nil(virDomainCreate, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); } }
Call virDomainCreateWithFiles to launch a defined domain with a set of open file descriptors.
static VALUE libvirt_domain_create_with_files(int argc, VALUE *argv, VALUE d) { VALUE fds, flags; int *files; unsigned int numfiles, i; rb_scan_args(argc, argv, "02", &fds, &flags); 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)"); } ruby_libvirt_generate_call_nil(virDomainCreateWithFiles, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), numfiles, files, ruby_libvirt_value_to_uint(flags)); }
Call virDomainCurrentSnapshot to retrieve the current snapshot for this domain (if any).
static VALUE libvirt_domain_current_snapshot(int argc, VALUE *argv, VALUE d) { VALUE flags; virDomainSnapshotPtr snap; rb_scan_args(argc, argv, "01", &flags); snap = virDomainSnapshotCurrent(ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(snap == NULL, e_RetrieveError, "virDomainSnapshotCurrent", ruby_libvirt_connect_get(d)); return domain_snapshot_new(snap, d); }
Call virDomainDestroy to do a hard power-off of the domain.
static VALUE libvirt_domain_destroy(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); if (ruby_libvirt_value_to_uint(flags) != 0) { ruby_libvirt_generate_call_nil(virDomainDestroyFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); } else { ruby_libvirt_generate_call_nil(virDomainDestroy, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); } }
Call virDomainDetachDeviceFlags to detach the device described by the device_xml from the domain.
static VALUE libvirt_domain_detach_device(int argc, VALUE *argv, VALUE d) { VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); /* NOTE: can't use virDomainDetachDevice() when flags==0 here * because that function only works on active domains and * VIR_DOMAIN_AFFECT_CURRENT==0. * * See https://gitlab.com/libvirt/libvirt-ruby/-/issues/11 */ ruby_libvirt_generate_call_nil(virDomainDetachDeviceFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetDiskErrors to get errors on disks in the domain.
static VALUE libvirt_domain_disk_errors(int argc, VALUE *argv, VALUE d) { VALUE flags, hash; int maxerr, ret, i; virDomainDiskErrorPtr errors; rb_scan_args(argc, argv, "01", &flags); maxerr = virDomainGetDiskErrors(ruby_libvirt_domain_get(d), NULL, 0, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(maxerr < 0, e_RetrieveError, "virDomainGetDiskErrors", ruby_libvirt_connect_get(d)); errors = alloca(maxerr * sizeof(virDomainDiskError)); ret = virDomainGetDiskErrors(ruby_libvirt_domain_get(d), errors, maxerr, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virDomainGetDiskErrors", ruby_libvirt_connect_get(d)); hash = rb_hash_new(); for (i = 0; i < ret; i++) { rb_hash_aset(hash, rb_str_new2(errors[i].disk), INT2NUM(errors[i].error)); } return hash; }
Call virDomainGetEmulatorPinInfo to an array representing the mapping of emulator threads to physical CPUs. For each physical CPU in the machine, the array offset corresponding to that CPU is 'true' if an emulator thread is running on that CPU, and 'false' otherwise.
static VALUE libvirt_domain_emulator_pin_info(int argc, VALUE *argv, VALUE d) { int maxcpus, ret, j; size_t cpumaplen; unsigned char *cpumap; VALUE emulator2cpumap, flags; rb_scan_args(argc, argv, "01", &flags); maxcpus = ruby_libvirt_get_maxcpus(ruby_libvirt_connect_get(d)); cpumaplen = VIR_CPU_MAPLEN(maxcpus); cpumap = alloca(sizeof(unsigned char) * cpumaplen); ret = virDomainGetEmulatorPinInfo(ruby_libvirt_domain_get(d), cpumap, cpumaplen, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virDomainGetEmulatorPinInfo", ruby_libvirt_connect_get(d)); emulator2cpumap = rb_ary_new(); for (j = 0; j < maxcpus; j++) { rb_ary_push(emulator2cpumap, VIR_CPU_USABLE(cpumap, cpumaplen, 0, j) ? Qtrue : Qfalse); } return emulator2cpumap; }
Call virDomainFree to free a domain object.
static VALUE libvirt_domain_free(VALUE d) { ruby_libvirt_generate_call_free(Domain, d); }
Call virDomainFSFreeze to freeze the specified filesystems within the guest.
static VALUE libvirt_domain_fs_freeze(int argc, VALUE *argv, VALUE d) { VALUE mountpoints = RUBY_Qnil, flags = RUBY_Qnil, entry; const char **mnt; unsigned int nmountpoints; int i; rb_scan_args(argc, argv, "02", &mountpoints, &flags); if (NIL_P(mountpoints)) { mnt = NULL; nmountpoints = 0; } else { Check_Type(mountpoints, T_ARRAY); nmountpoints = RARRAY_LEN(mountpoints); mnt = alloca(nmountpoints * sizeof(char *)); for (i = 0; i < nmountpoints; i++) { entry = rb_ary_entry(mountpoints, i); mnt[i] = StringValueCStr(entry); } } ruby_libvirt_generate_call_int(virDomainFSFreeze, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), mnt, nmountpoints, ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetFSInfo to get information about the guest filesystems.
static VALUE libvirt_domain_fs_info(int argc, VALUE *argv, VALUE d) { VALUE flags = RUBY_Qnil, result; virDomainFSInfoPtr *info; int ret, i = 0, exception; struct fs_info_arg args; rb_scan_args(argc, argv, "01", &flags); ret = virDomainGetFSInfo(ruby_libvirt_domain_get(d), &info, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_Error, "virDomainGetFSInfo", ruby_libvirt_connect_get(d)); args.info = info; args.ninfo = ret; result = rb_protect(fs_info_wrap, (VALUE)&args, &exception); for (i = 0; i < ret; i++) { virDomainFSInfoFree(info[i]); } free(info); if (exception) { rb_jump_tag(exception); } return result; }
Call virDomainFSThaw to thaw the specified filesystems within the guest.
static VALUE libvirt_domain_fs_thaw(int argc, VALUE *argv, VALUE d) { VALUE mountpoints = RUBY_Qnil, flags = RUBY_Qnil, entry; const char **mnt; unsigned int nmountpoints; int i; rb_scan_args(argc, argv, "02", &mountpoints, &flags); if (NIL_P(mountpoints)) { mnt = NULL; nmountpoints = 0; } else { Check_Type(mountpoints, T_ARRAY); nmountpoints = RARRAY_LEN(mountpoints); mnt = alloca(nmountpoints * sizeof(char *)); for (i = 0; i < nmountpoints; i++) { entry = rb_ary_entry(mountpoints, i); mnt[i] = StringValueCStr(entry); } } ruby_libvirt_generate_call_int(virDomainFSThaw, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), mnt, nmountpoints, ruby_libvirt_value_to_uint(flags)); }
Call virDomainFSTrim to call FITRIM within the guest.
static VALUE libvirt_domain_fstrim(int argc, VALUE *argv, VALUE d) { VALUE mountpoint, minimum, flags; rb_scan_args(argc, argv, "03", &mountpoint, &minimum, &flags); ruby_libvirt_generate_call_nil(virDomainFSTrim, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_get_cstring_or_null(mountpoint), ruby_libvirt_value_to_ulonglong(minimum), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetVcpus to retrieve detailed information about the state of a domain's virtual CPUs.
Call virDomainHasCurrentSnapshot to find out if this domain has a snapshot active.
static VALUE libvirt_domain_has_current_snapshot_p(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_truefalse(virDomainHasCurrentSnapshot, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainHasManagedSaveImage to determine if a particular domain has a managed save image.
static VALUE libvirt_domain_has_managed_save(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_truefalse(virDomainHasManagedSaveImage, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetHostname to get the hostname from a domain.
static VALUE libvirt_domain_hostname(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_string(virDomainGetHostname, ruby_libvirt_connect_get(d), 1, ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetID to retrieve the ID of this domain. If the domain isn't running, this will be -1.
static VALUE libvirt_domain_id(VALUE d) { unsigned int id; int out; id = virDomainGetID(ruby_libvirt_domain_get(d)); /* we need to cast the unsigned int id to a signed int out to handle the * -1 case */ out = id; ruby_libvirt_raise_error_if(out == -1, e_RetrieveError, "virDomainGetID", ruby_libvirt_connect_get(d)); return INT2NUM(out); }
Call virDomainInterfaceStats to retrieve statistics about domain interface if.
static VALUE libvirt_domain_if_stats(VALUE d, VALUE sif) { char *ifname = ruby_libvirt_get_cstring_or_null(sif); virDomainInterfaceStatsStruct ifinfo; int r; VALUE result = Qnil; if (ifname) { r = virDomainInterfaceStats(ruby_libvirt_domain_get(d), ifname, &ifinfo, sizeof(virDomainInterfaceStatsStruct)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainInterfaceStats", ruby_libvirt_connect_get(d)); 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; }
Call virDomainGetInfo to retrieve domain information.
static VALUE libvirt_domain_info(VALUE d) { virDomainInfo info; int r; VALUE result; r = virDomainGetInfo(ruby_libvirt_domain_get(d), &info); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetInfo", ruby_libvirt_connect_get(d)); 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; }
Call virDomainInjectNMI to send an NMI to the guest.
static VALUE libvirt_domain_inject_nmi(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virDomainInjectNMI, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetInterfaceParameters to retrieve the interface parameters for the given interface on this domain. The keys and values in the hash that is returned are hypervisor specific.
static VALUE libvirt_domain_interface_parameters(int argc, VALUE *argv, VALUE d) { VALUE device = RUBY_Qnil, flags = RUBY_Qnil; rb_scan_args(argc, argv, "11", &device, &flags); Check_Type(device, T_STRING); return ruby_libvirt_get_typed_parameters(d, ruby_libvirt_value_to_uint(flags), (void *)device, interface_nparams, interface_get); }
Call virDomainSetInterfaceParameters to set the interface parameters for the supplied device on this domain. The keys and values in the input hash are hypervisor specific.
static VALUE libvirt_domain_interface_parameters_equal(VALUE d, VALUE in) { VALUE device, hash, flags; Check_Type(in, T_ARRAY); if (RARRAY_LEN(in) == 2) { device = rb_ary_entry(in, 0); hash = rb_ary_entry(in, 1); flags = INT2NUM(0); } else if (RARRAY_LEN(in) == 3) { device = rb_ary_entry(in, 0); hash = rb_ary_entry(in, 1); flags = rb_ary_entry(in, 2); } else { rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2 or 3)", RARRAY_LEN(in)); } return ruby_libvirt_set_typed_parameters(d, hash, ruby_libvirt_value_to_uint(flags), (void *)device, interface_allowed, ARRAY_SIZE(interface_allowed), interface_set); }
Call virDomainGetJobInfo to retrieve the current state of the running domain job.
static VALUE libvirt_domain_job_info(VALUE d) { int r; virDomainJobInfo info; VALUE result; r = virDomainGetJobInfo(ruby_libvirt_domain_get(d), &info); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetJobInfo", ruby_libvirt_connect_get(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; }
Call virDomainGetJobStats to retrieve information about progress of a background job on a domain.
static VALUE libvirt_domain_job_stats(int argc, VALUE *argv, VALUE d) { VALUE flags, result; int type, exception = 0, nparams = 0, r; virTypedParameterPtr params = NULL; struct params_to_hash_arg args; struct ruby_libvirt_hash_aset_arg asetargs; rb_scan_args(argc, argv, "01", &flags); result = rb_hash_new(); r = virDomainGetJobStats(ruby_libvirt_domain_get(d), &type, ¶ms, &nparams, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetJobStats", ruby_libvirt_connect_get(d)); /* since virDomainGetJobsStats() allocated memory, we need to wrap all * calls below to make sure we don't leak memory */ asetargs.hash = result; asetargs.name = "type"; asetargs.val = INT2NUM(type); rb_protect(ruby_libvirt_hash_aset_wrap, (VALUE)&asetargs, &exception); if (exception) { virTypedParamsFree(params, nparams); rb_jump_tag(exception); } args.params = params; args.nparams = nparams; args.result = result; result = rb_protect(params_to_hash, (VALUE)&args, &exception); if (exception) { virTypedParamsFree(params, nparams); rb_jump_tag(exception); } virTypedParamsFree(params, nparams); return result; }
Call virDomainListAllSnapshots to get an array of snapshot objects for all snapshots.
static VALUE libvirt_domain_list_all_snapshots(int argc, VALUE *argv, VALUE d) { ruby_libvirt_generate_call_list_all(virDomainSnapshotPtr, argc, argv, virDomainListAllSnapshots, ruby_libvirt_domain_get(d), d, domain_snapshot_new, virDomainSnapshotFree); }
Call virDomainSnapshotListNames to retrieve a list of snapshot names available for this domain.
static VALUE libvirt_domain_list_snapshots(int argc, VALUE *argv, VALUE d) { VALUE flags; int r, num; char **names; rb_scan_args(argc, argv, "01", &flags); if (TYPE(flags) != T_NIL && TYPE(flags) != T_FIXNUM) { rb_raise(rb_eTypeError, "wrong argument type (expected Number)"); } num = virDomainSnapshotNum(ruby_libvirt_domain_get(d), 0); ruby_libvirt_raise_error_if(num < 0, e_RetrieveError, "virDomainSnapshotNum", ruby_libvirt_connect_get(d)); if (num == 0) { /* if num is 0, don't call virDomainSnapshotListNames function */ return rb_ary_new2(num); } names = alloca(sizeof(char *) * num); r = virDomainSnapshotListNames(ruby_libvirt_domain_get(d), names, num, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainSnapshotListNames", ruby_libvirt_connect_get(d)); return ruby_libvirt_generate_list(r, names); }
Call virDomainSnapshotLookupByName to retrieve a snapshot object corresponding to snapshot name.
static VALUE libvirt_domain_lookup_snapshot_by_name(int argc, VALUE *argv, VALUE d) { virDomainSnapshotPtr snap; VALUE name, flags; rb_scan_args(argc, argv, "11", &name, &flags); snap = virDomainSnapshotLookupByName(ruby_libvirt_domain_get(d), StringValueCStr(name), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(snap == NULL, e_RetrieveError, "virDomainSnapshotLookupByName", ruby_libvirt_connect_get(d)); return domain_snapshot_new(snap, d); }
Call virDomainLxcEnterNamespace to attach the process to the namespaces associated with the file descriptors in the fds array. Note that this call does not actually enter the namespace; the next call to fork will do that. Also note that this function will return an array of old file descriptors that can be used to switch back to the current namespace later.
static VALUE libvirt_domain_lxc_enter_namespace(int argc, VALUE *argv, VALUE d) { VALUE fds = RUBY_Qnil, flags = RUBY_Qnil, result; int *fdlist; int ret, exception = 0; int *oldfdlist; unsigned int noldfdlist, i; struct ruby_libvirt_ary_store_arg args; rb_scan_args(argc, argv, "11", &fds, &flags); Check_Type(fds, T_ARRAY); fdlist = alloca(sizeof(int) * RARRAY_LEN(fds)); for (i = 0; i < RARRAY_LEN(fds); i++) { fdlist[i] = NUM2INT(rb_ary_entry(fds, i)); } ret = virDomainLxcEnterNamespace(ruby_libvirt_domain_get(d), RARRAY_LEN(fds), fdlist, &noldfdlist, &oldfdlist, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virDomainLxcEnterNamespace", ruby_libvirt_connect_get(d)); result = rb_protect(ruby_libvirt_ary_new2_wrap, (VALUE)&noldfdlist, &exception); if (exception) { free(oldfdlist); rb_jump_tag(exception); } for (i = 0; i < noldfdlist; i++) { args.arr = result; args.index = i; /* from reading the ruby sources, INT2NUM can't possibly throw an * exception, so this can't leak. */ args.elem = INT2NUM(oldfdlist[i]); rb_protect(ruby_libvirt_ary_store_wrap, (VALUE)&args, &exception); if (exception) { free(oldfdlist); rb_jump_tag(exception); } } free(oldfdlist); return result; }
Call virDomainLxcOpenNamespace to open an LXC namespace. Note that this will only work on connections to the LXC driver. The call will return an array of open file descriptors; these should be closed when use of them is finished.
static VALUE libvirt_domain_lxc_open_namespace(int argc, VALUE *argv, VALUE d) { VALUE flags = RUBY_Qnil, result; int *fdlist = NULL; int ret, i, exception = 0; struct ruby_libvirt_ary_store_arg args; rb_scan_args(argc, argv, "01", &flags); ret = virDomainLxcOpenNamespace(ruby_libvirt_domain_get(d), &fdlist, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virDomainLxcOpenNamespace", ruby_libvirt_connect_get(d)); result = rb_protect(ruby_libvirt_ary_new2_wrap, (VALUE)&ret, &exception); if (exception) { goto error; } for (i = 0; i < ret; i++) { args.arr = result; args.index = i; /* from reading the ruby sources, INT2NUM can't possibly throw an * exception, so this can't leak. */ args.elem = INT2NUM(fdlist[i]); rb_protect(ruby_libvirt_ary_store_wrap, (VALUE)&args, &exception); if (exception) { goto error; } } free(fdlist); return result; error: for (i = 0; i < ret; i++) { close(fdlist[i]); } free(fdlist); rb_jump_tag(exception); }
Call virDomainManagedSave to do a managed save of the domain. The domain will be saved to a place of libvirt's choosing.
static VALUE libvirt_domain_managed_save(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virDomainManagedSave, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainManagedSaveRemove to remove the managed save image for a domain.
static VALUE libvirt_domain_managed_save_remove(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virDomainManagedSaveRemove, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call 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_domain_max_memory(VALUE d) { unsigned long max_memory; max_memory = virDomainGetMaxMemory(ruby_libvirt_domain_get(d)); ruby_libvirt_raise_error_if(max_memory == 0, e_RetrieveError, "virDomainGetMaxMemory", ruby_libvirt_connect_get(d)); return ULONG2NUM(max_memory); }
Call virDomainSetMaxMemory to set the maximum amount of memory (in kilobytes) this domain should be allowed to access.
static VALUE libvirt_domain_max_memory_equal(VALUE d, VALUE max_memory) { int r; r = virDomainSetMaxMemory(ruby_libvirt_domain_get(d), NUM2ULONG(max_memory)); ruby_libvirt_raise_error_if(r < 0, e_DefinitionError, "virDomainSetMaxMemory", ruby_libvirt_connect_get(d)); return ULONG2NUM(max_memory); }
Call virDomainGetMaxVcpus to retrieve the maximum number of virtual CPUs this domain can use.
static VALUE libvirt_domain_max_vcpus(VALUE d) { ruby_libvirt_generate_call_int(virDomainGetMaxVcpus, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
Call 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_domain_memory_equal(VALUE d, VALUE in) { VALUE memory, flags; int r; domain_input_to_fixnum_and_flags(in, &memory, &flags); if (ruby_libvirt_value_to_uint(flags) != 0) { r = virDomainSetMemoryFlags(ruby_libvirt_domain_get(d), NUM2ULONG(memory), ruby_libvirt_value_to_uint(flags)); } else { r = virDomainSetMemory(ruby_libvirt_domain_get(d), NUM2ULONG(memory)); } ruby_libvirt_raise_error_if(r < 0, e_DefinitionError, "virDomainSetMemory", ruby_libvirt_connect_get(d)); return ULONG2NUM(memory); }
Call 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_domain_memory_parameters(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); return ruby_libvirt_get_typed_parameters(d, ruby_libvirt_value_to_uint(flags), NULL, memory_nparams, memory_get); }
Call virDomainSetMemoryParameters to set the memory parameters for this domain. The keys and values in the input hash are hypervisor specific.
static VALUE libvirt_domain_memory_parameters_equal(VALUE d, VALUE in) { VALUE hash, flags; ruby_libvirt_assign_hash_and_flags(in, &hash, &flags); return ruby_libvirt_set_typed_parameters(d, hash, NUM2UINT(flags), NULL, domain_memory_allowed, ARRAY_SIZE(domain_memory_allowed), memory_set); }
Call 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_domain_memory_peek(int argc, VALUE *argv, VALUE d) { VALUE start, size, flags; char *buffer; int r; rb_scan_args(argc, argv, "21", &start, &size, &flags); if (NIL_P(flags)) { flags = INT2NUM(VIR_MEMORY_VIRTUAL); } buffer = alloca(sizeof(char) * NUM2UINT(size)); r = virDomainMemoryPeek(ruby_libvirt_domain_get(d), NUM2ULL(start), NUM2UINT(size), buffer, NUM2UINT(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainMemoryPeek", ruby_libvirt_connect_get(d)); return rb_str_new(buffer, NUM2UINT(size)); }
Call virDomainMemoryStats to retrieve statistics about the amount of memory consumed by a domain.
static VALUE libvirt_domain_memory_stats(int argc, VALUE *argv, VALUE d) { virDomainMemoryStatStruct stats[6]; int i, r; VALUE result, flags, tmp; rb_scan_args(argc, argv, "01", &flags); r = virDomainMemoryStats(ruby_libvirt_domain_get(d), stats, 6, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainMemoryStats", ruby_libvirt_connect_get(d)); /* 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_store(result, i, tmp); } return result; }
Call virDomainSetMemoryStatsPeriod to set the memory statistics collection period.
static VALUE libvirt_domain_memory_stats_period(VALUE d, VALUE in) { VALUE period, flags; domain_input_to_fixnum_and_flags(in, &period, &flags); ruby_libvirt_generate_call_nil(virDomainSetMemoryStatsPeriod, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2INT(period), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetMetadata to get the metadata from a domain.
static VALUE libvirt_domain_metadata(int argc, VALUE *argv, VALUE d) { VALUE uri, flags, type; rb_scan_args(argc, argv, "12", &type, &uri, &flags); ruby_libvirt_generate_call_string(virDomainGetMetadata, ruby_libvirt_connect_get(d), 1, ruby_libvirt_domain_get(d), NUM2INT(type), ruby_libvirt_get_cstring_or_null(uri), ruby_libvirt_value_to_uint(flags)); }
Call virDomainSetMetadata to set the metadata for a domain.
static VALUE libvirt_domain_metadata_equal(VALUE d, VALUE in) { VALUE type, metadata, key, uri, flags; Check_Type(in, T_ARRAY); if (RARRAY_LEN(in) < 2 || RARRAY_LEN(in) > 5) { rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2, 3, 4, or 5)", RARRAY_LEN(in)); } type = rb_ary_entry(in, 0); metadata = rb_ary_entry(in, 1); key = Qnil; uri = Qnil; flags = INT2NUM(0); if (RARRAY_LEN(in) >= 3) { key = rb_ary_entry(in, 2); } if (RARRAY_LEN(in) >= 4) { uri = rb_ary_entry(in, 3); } if (RARRAY_LEN(in) == 5) { flags = rb_ary_entry(in, 4); } ruby_libvirt_generate_call_nil(virDomainSetMetadata, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2INT(type), ruby_libvirt_get_cstring_or_null(metadata), ruby_libvirt_get_cstring_or_null(key), ruby_libvirt_get_cstring_or_null(uri), ruby_libvirt_value_to_uint(flags)); }
Call virDomainMigrate to migrate a domain from the host on this connection to the connection referenced in dconn.
static VALUE libvirt_domain_migrate(int argc, VALUE *argv, VALUE d) { VALUE dconn, flags, dname, uri, bandwidth; virDomainPtr ddom = NULL; rb_scan_args(argc, argv, "14", &dconn, &flags, &dname, &uri, &bandwidth); ddom = virDomainMigrate(ruby_libvirt_domain_get(d), ruby_libvirt_connect_get(dconn), ruby_libvirt_value_to_ulong(flags), ruby_libvirt_get_cstring_or_null(dname), ruby_libvirt_get_cstring_or_null(uri), ruby_libvirt_value_to_ulong(bandwidth)); ruby_libvirt_raise_error_if(ddom == NULL, e_Error, "virDomainMigrate", ruby_libvirt_connect_get(d)); return ruby_libvirt_domain_new(ddom, dconn); }
Call virDomainMigrate2 to migrate a domain from the host on this connection to the connection referenced in dconn.
static VALUE libvirt_domain_migrate2(int argc, VALUE *argv, VALUE d) { VALUE dconn, dxml, flags, dname, uri, bandwidth; virDomainPtr ddom = NULL; rb_scan_args(argc, argv, "15", &dconn, &dxml, &flags, &dname, &uri, &bandwidth); ddom = virDomainMigrate2(ruby_libvirt_domain_get(d), ruby_libvirt_connect_get(dconn), ruby_libvirt_get_cstring_or_null(dxml), ruby_libvirt_value_to_ulong(flags), ruby_libvirt_get_cstring_or_null(dname), ruby_libvirt_get_cstring_or_null(uri), ruby_libvirt_value_to_ulong(bandwidth)); ruby_libvirt_raise_error_if(ddom == NULL, e_Error, "virDomainMigrate2", ruby_libvirt_connect_get(d)); return ruby_libvirt_domain_new(ddom, dconn); }
Call virDomainMigrate3 to migrate a domain from the host on this connection to the connection referenced in dconn.
static VALUE libvirt_domain_migrate3(int argc, VALUE *argv, VALUE d) { VALUE dconn = RUBY_Qnil, hash = RUBY_Qnil, flags = RUBY_Qnil; virDomainPtr ddom = NULL; struct ruby_libvirt_parameter_assign_args args; unsigned long hashsize; rb_scan_args(argc, argv, "12", &dconn, &hash, &flags); Check_Type(hash, T_HASH); hashsize = RHASH_SIZE(hash); memset(&args, 0, sizeof(struct ruby_libvirt_parameter_assign_args)); if (hashsize > 0) { args.allowed = migrate3_allowed; args.num_allowed = ARRAY_SIZE(migrate3_allowed); args.params = alloca(sizeof(virTypedParameter) * hashsize); args.i = 0; rb_hash_foreach(hash, ruby_libvirt_typed_parameter_assign, (VALUE)&args); } ddom = virDomainMigrate3(ruby_libvirt_domain_get(d), ruby_libvirt_connect_get(dconn), args.params, args.i, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ddom == NULL, e_Error, "virDomainMigrate3", ruby_libvirt_connect_get(d)); return ruby_libvirt_domain_new(ddom, dconn); }
Call virDomainMigrateGetCompressionCache to get the current size of the migration cache.
static VALUE libvirt_domain_migrate_compression_cache(int argc, VALUE *argv, VALUE d) { VALUE flags; int ret; unsigned long long cachesize; rb_scan_args(argc, argv, "01", &flags); ret = virDomainMigrateGetCompressionCache(ruby_libvirt_domain_get(d), &cachesize, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virDomainMigrateGetCompressionCache", ruby_libvirt_connect_get(d)); return ULL2NUM(cachesize); }
Call virDomainMigrateSetCompressionCache to set the current size of the migration cache.
static VALUE libvirt_domain_migrate_compression_cache_equal(VALUE d, VALUE in) { VALUE cachesize, flags; domain_input_to_fixnum_and_flags(in, &cachesize, &flags); ruby_libvirt_generate_call_nil(virDomainMigrateSetCompressionCache, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2ULL(cachesize), ruby_libvirt_value_to_uint(flags)); }
Call virDomainMigrateSetMaxDowntime to set the maximum downtime desired for live migration.
static VALUE libvirt_domain_migrate_max_downtime_equal(VALUE d, VALUE in) { VALUE downtime, flags; domain_input_to_fixnum_and_flags(in, &downtime, &flags); ruby_libvirt_generate_call_nil(virDomainMigrateSetMaxDowntime, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2ULL(downtime), ruby_libvirt_value_to_uint(flags)); }
Call virDomainMigrateGetMaxSpeed to retrieve the maximum speed a migration can use.
static VALUE libvirt_domain_migrate_max_speed(int argc, VALUE *argv, VALUE d) { VALUE flags; int r; unsigned long bandwidth; rb_scan_args(argc, argv, "01", &flags); r = virDomainMigrateGetMaxSpeed(ruby_libvirt_domain_get(d), &bandwidth, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainMigrateGetMaxSpeed", ruby_libvirt_connect_get(d)); return ULONG2NUM(bandwidth); }
Call virDomainMigrateSetMaxSpeed to set the maximum bandwidth allowed for live migration.
static VALUE libvirt_domain_migrate_max_speed_equal(VALUE d, VALUE in) { VALUE bandwidth, flags; domain_input_to_fixnum_and_flags(in, &bandwidth, &flags); ruby_libvirt_generate_call_nil(virDomainMigrateSetMaxSpeed, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2ULONG(bandwidth), ruby_libvirt_value_to_uint(flags)); }
Call virDomainMigrateSetMaxDowntime to set the maximum downtime desired for live migration. Deprecated; use dom.migrate_max_downtime= instead.
static VALUE libvirt_domain_migrate_set_max_downtime(int argc, VALUE *argv, VALUE d) { VALUE downtime, flags; rb_scan_args(argc, argv, "11", &downtime, &flags); ruby_libvirt_generate_call_nil(virDomainMigrateSetMaxDowntime, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2ULL(downtime), ruby_libvirt_value_to_uint(flags)); }
Call virDomainMigrateSetMaxSpeed to set the maximum bandwidth allowed for live migration. Deprecated; use dom.migrate_max_speed= instead.
static VALUE libvirt_domain_migrate_set_max_speed(int argc, VALUE *argv, VALUE d) { VALUE bandwidth, flags; rb_scan_args(argc, argv, "11", &bandwidth, &flags); ruby_libvirt_generate_call_nil(virDomainMigrateSetMaxSpeed, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2ULONG(bandwidth), ruby_libvirt_value_to_uint(flags)); }
Call virDomainMigrateToURI to migrate a domain from the host on this connection to the host whose libvirt URI is duri.
static VALUE libvirt_domain_migrate_to_uri(int argc, VALUE *argv, VALUE d) { VALUE duri, flags, dname, bandwidth; rb_scan_args(argc, argv, "13", &duri, &flags, &dname, &bandwidth); ruby_libvirt_generate_call_nil(virDomainMigrateToURI, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(duri), NUM2ULONG(flags), ruby_libvirt_get_cstring_or_null(dname), ruby_libvirt_value_to_ulong(bandwidth)); }
Call virDomainMigrateToURI2 to migrate a domain from the host on this connection to the host whose libvirt URI is duri.
static VALUE libvirt_domain_migrate_to_uri2(int argc, VALUE *argv, VALUE d) { VALUE duri, migrate_uri, dxml, flags, dname, bandwidth; rb_scan_args(argc, argv, "06", &duri, &migrate_uri, &dxml, &flags, &dname, &bandwidth); ruby_libvirt_generate_call_nil(virDomainMigrateToURI2, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_get_cstring_or_null(duri), ruby_libvirt_get_cstring_or_null(migrate_uri), ruby_libvirt_get_cstring_or_null(dxml), ruby_libvirt_value_to_ulong(flags), ruby_libvirt_get_cstring_or_null(dname), ruby_libvirt_value_to_ulong(bandwidth)); }
Call virDomainMigrateToURI3 to migrate a domain from the host on this connection to the host whose libvirt URI is duri.
static VALUE libvirt_domain_migrate_to_uri3(int argc, VALUE *argv, VALUE d) { VALUE duri = RUBY_Qnil, hash = RUBY_Qnil, flags = RUBY_Qnil; struct ruby_libvirt_parameter_assign_args args; unsigned long hashsize; rb_scan_args(argc, argv, "03", &duri, &hash, &flags); Check_Type(hash, T_HASH); hashsize = RHASH_SIZE(hash); memset(&args, 0, sizeof(struct ruby_libvirt_parameter_assign_args)); if (hashsize > 0) { args.allowed = migrate3_allowed; args.num_allowed = ARRAY_SIZE(migrate3_allowed); args.params = alloca(sizeof(virTypedParameter) * hashsize); args.i = 0; rb_hash_foreach(hash, ruby_libvirt_typed_parameter_assign, (VALUE)&args); } ruby_libvirt_generate_call_nil(virDomainMigrateToURI3, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_get_cstring_or_null(duri), args.params, args.i, ruby_libvirt_value_to_ulong(flags)); }
Call virDomainGetName to retrieve the name of this domain.
static VALUE libvirt_domain_name(VALUE d) { ruby_libvirt_generate_call_string(virDomainGetName, ruby_libvirt_connect_get(d), 0, ruby_libvirt_domain_get(d)); }
Call virDomainSnapshotNum to retrieve the number of available snapshots for this domain.
static VALUE libvirt_domain_num_of_snapshots(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_int(virDomainSnapshotNum, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetVcpusFlags to retrieve the number of virtual CPUs assigned to this domain.
static VALUE libvirt_domain_num_vcpus(VALUE d, VALUE flags) { ruby_libvirt_generate_call_int(virDomainGetVcpusFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetNumaParameters to retrieve the numa parameters for this domain. The keys and values in the hash that is returned are hypervisor specific.
static VALUE libvirt_domain_numa_parameters(int argc, VALUE *argv, VALUE d) { VALUE flags = RUBY_Qnil; rb_scan_args(argc, argv, "01", &flags); return ruby_libvirt_get_typed_parameters(d, ruby_libvirt_value_to_uint(flags), NULL, numa_nparams, numa_get); }
Call virDomainSetNumaParameters to set the numa parameters for this domain. The keys and values in the input hash are hypervisor specific.
static VALUE libvirt_domain_numa_parameters_equal(VALUE d, VALUE in) { VALUE hash, flags; ruby_libvirt_assign_hash_and_flags(in, &hash, &flags); return ruby_libvirt_set_typed_parameters(d, hash, ruby_libvirt_value_to_uint(flags), NULL, numa_allowed, ARRAY_SIZE(numa_allowed), numa_set); }
Call virDomainOpenChannel to open a channel on a guest. Note that name may be nil, in which case the first channel on the guest is opened.
static VALUE libvirt_domain_open_channel(int argc, VALUE *argv, VALUE d) { VALUE name, st, flags; rb_scan_args(argc, argv, "21", &name, &st, &flags); ruby_libvirt_generate_call_nil(virDomainOpenChannel, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_get_cstring_or_null(name), ruby_libvirt_stream_get(st), ruby_libvirt_value_to_uint(flags)); }
Call virDomainOpenConsole to open up a console to device over stream.
static VALUE libvirt_domain_open_console(int argc, VALUE *argv, VALUE d) { VALUE dev, st, flags; rb_scan_args(argc, argv, "21", &dev, &st, &flags); ruby_libvirt_generate_call_nil(virDomainOpenConsole, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(dev), ruby_libvirt_stream_get(st), NUM2INT(flags)); }
Call virDomainOpenGraphics to connect a file descriptor to the graphics backend of the domain.
static VALUE libvirt_domain_open_graphics(int argc, VALUE *argv, VALUE d) { VALUE fd, idx, flags; rb_scan_args(argc, argv, "12", &fd, &idx, &flags); ruby_libvirt_generate_call_nil(virDomainOpenGraphics, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(idx), NUM2INT(fd), ruby_libvirt_value_to_uint(flags)); }
Call 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_domain_os_type(VALUE d) { ruby_libvirt_generate_call_string(virDomainGetOSType, ruby_libvirt_connect_get(d), 1, ruby_libvirt_domain_get(d)); }
Call virDomainIsPersistent to determine if this is a persistent domain.
static VALUE libvirt_domain_persistent_p(VALUE d) { ruby_libvirt_generate_call_truefalse(virDomainIsPersistent, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
Call virDomainPinVcpu to pin the emulator to a range of physical processors. The cpulist should be an array of Fixnums representing the physical processors this domain's emulator should be allowed to be scheduled on.
static VALUE libvirt_domain_pin_emulator(int argc, VALUE *argv, VALUE d) { VALUE cpulist, flags, e; int i, maxcpus, cpumaplen; unsigned char *cpumap; rb_scan_args(argc, argv, "11", &cpulist, &flags); Check_Type(cpulist, T_ARRAY); maxcpus = ruby_libvirt_get_maxcpus(ruby_libvirt_connect_get(d)); cpumaplen = VIR_CPU_MAPLEN(maxcpus); cpumap = alloca(sizeof(unsigned char) * cpumaplen); MEMZERO(cpumap, unsigned char, cpumaplen); for (i = 0; i < RARRAY_LEN(cpulist); i++) { e = rb_ary_entry(cpulist, i); VIR_USE_CPU(cpumap, NUM2UINT(e)); } ruby_libvirt_generate_call_nil(virDomainPinEmulator, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), cpumap, cpumaplen, ruby_libvirt_value_to_uint(flags)); }
Call 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_domain_pin_vcpu(int argc, VALUE *argv, VALUE d) { VALUE vcpu, cpulist, flags, e; int i, cpumaplen, maxcpus; unsigned char *cpumap; rb_scan_args(argc, argv, "21", &vcpu, &cpulist, &flags); Check_Type(cpulist, T_ARRAY); maxcpus = ruby_libvirt_get_maxcpus(ruby_libvirt_connect_get(d)); cpumaplen = VIR_CPU_MAPLEN(maxcpus); cpumap = alloca(sizeof(unsigned char) * cpumaplen); MEMZERO(cpumap, unsigned char, cpumaplen); for (i = 0; i < RARRAY_LEN(cpulist); i++) { e = rb_ary_entry(cpulist, i); VIR_USE_CPU(cpumap, NUM2UINT(e)); } if (ruby_libvirt_value_to_uint(flags) != 0) { ruby_libvirt_generate_call_nil(virDomainPinVcpuFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2UINT(vcpu), cpumap, cpumaplen, ruby_libvirt_value_to_uint(flags)); } else { ruby_libvirt_generate_call_nil(virDomainPinVcpu, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2UINT(vcpu), cpumap, cpumaplen); } }
Call virDomainPMSuspendForDuration to have the domain enter the target power management suspend level.
static VALUE libvirt_domain_pmsuspend_for_duration(int argc, VALUE *argv, VALUE d) { VALUE target, duration, flags; rb_scan_args(argc, argv, "21", &target, &duration, &flags); ruby_libvirt_generate_call_nil(virDomainPMSuspendForDuration, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2UINT(target), NUM2ULL(duration), ruby_libvirt_value_to_uint(flags)); }
Call virDomainPMWakeup to inject a wakeup into the guest.
static VALUE libvirt_domain_pmwakeup(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virDomainPMWakeup, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainQemuAgentCommand to run an arbitrary command on the Qemu Agent.
static VALUE libvirt_domain_qemu_agent_command(int argc, VALUE *argv, VALUE d) { VALUE command, timeout = RUBY_Qnil, flags = RUBY_Qnil, result; char *ret; int exception = 0; rb_scan_args(argc, argv, "12", &command, &timeout, &flags); if (NIL_P(timeout)) { timeout = INT2NUM(VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT); } ret = virDomainQemuAgentCommand(ruby_libvirt_domain_get(d), StringValueCStr(command), ruby_libvirt_value_to_int(timeout), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret == NULL, e_RetrieveError, "virDomainQemuAgentCommand", ruby_libvirt_connect_get(d)); result = rb_protect(ruby_libvirt_str_new2_wrap, (VALUE)&ret, &exception); free(ret); if (exception) { rb_jump_tag(exception); } return result; }
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_domain_qemu_monitor_command(int argc, VALUE *argv, VALUE d) { VALUE cmd, flags, ret; char *result; int r, exception = 0; const char *type; rb_scan_args(argc, argv, "11", &cmd, &flags); type = virConnectGetType(ruby_libvirt_connect_get(d)); ruby_libvirt_raise_error_if(type == NULL, e_Error, "virConnectGetType", ruby_libvirt_connect_get(d)); /* The type != NULL check is actually redundant, since if type was NULL * we would have raised an exception above. It's here to shut clang, * since clang can't tell that we would never reach this. */ if (type != NULL && strcmp(type, "QEMU") != 0) { rb_raise(rb_eTypeError, "Tried to use virDomainQemuMonitor command on %s connection", type); } r = virDomainQemuMonitorCommand(ruby_libvirt_domain_get(d), StringValueCStr(cmd), &result, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainQemuMonitorCommand", ruby_libvirt_connect_get(d)); ret = rb_protect(ruby_libvirt_str_new2_wrap, (VALUE)&result, &exception); free(result); if (exception) { rb_jump_tag(exception); } return ret; }
Call virDomainReboot to do a reboot of the domain.
static VALUE libvirt_domain_reboot(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virDomainReboot, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainRename to rename a domain.
static VALUE libvirt_domain_rename(int argc, VALUE *argv, VALUE d) { VALUE flags = RUBY_Qnil, name; rb_scan_args(argc, argv, "11", &name, &flags); ruby_libvirt_generate_call_nil(virDomainRename, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(name), ruby_libvirt_value_to_uint(flags)); }
Call virDomainReset to reset a domain immediately.
static VALUE libvirt_domain_reset(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_nil(virDomainReset, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }
Call virDomainResume to resume a suspended domain. After this call the domain will start consuming CPU resources again.
static VALUE libvirt_domain_resume(VALUE d) { ruby_libvirt_generate_call_nil(virDomainResume, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
Call virDomainRevertToSnapshot to restore this domain to a previously saved snapshot.
static VALUE libvirt_domain_revert_to_snapshot(int argc, VALUE *argv, VALUE d) { VALUE snap, flags; rb_scan_args(argc, argv, "11", &snap, &flags); ruby_libvirt_generate_call_nil(virDomainRevertToSnapshot, ruby_libvirt_connect_get(d), domain_snapshot_get(snap), ruby_libvirt_value_to_uint(flags)); }
Call virDomainSave to save the domain state to filename. After this call, the domain will no longer be consuming any resources.
static VALUE libvirt_domain_save(int argc, VALUE *argv, VALUE d) { VALUE flags, to, dxml; rb_scan_args(argc, argv, "12", &to, &dxml, &flags); if (ruby_libvirt_value_to_uint(flags) != 0 || TYPE(dxml) != T_NIL) { ruby_libvirt_generate_call_nil(virDomainSaveFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(to), ruby_libvirt_get_cstring_or_null(dxml), ruby_libvirt_value_to_uint(flags)); } else { ruby_libvirt_generate_call_nil(virDomainSave, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(to)); } }
Call 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_domain_scheduler_parameters(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); return ruby_libvirt_get_typed_parameters(d, ruby_libvirt_value_to_uint(flags), NULL, scheduler_nparams, scheduler_get); }
Call 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_domain_scheduler_parameters_equal(VALUE d, VALUE input) { VALUE hash, flags; ruby_libvirt_assign_hash_and_flags(input, &hash, &flags); return ruby_libvirt_set_typed_parameters(d, hash, NUM2UINT(flags), NULL, domain_scheduler_allowed, ARRAY_SIZE(domain_scheduler_allowed), scheduler_set); }
Call virDomainGetSchedulerType to retrieve the scheduler type used on this domain.
static VALUE libvirt_domain_scheduler_type(VALUE d) { int nparams, exception = 0; char *type; VALUE result; struct create_sched_type_args args; type = virDomainGetSchedulerType(ruby_libvirt_domain_get(d), &nparams); ruby_libvirt_raise_error_if(type == NULL, e_RetrieveError, "virDomainGetSchedulerType", ruby_libvirt_connect_get(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; }
Call virDomainScreenshot to take a screenshot of the domain console as a stream.
static VALUE libvirt_domain_screenshot(int argc, VALUE *argv, VALUE d) { VALUE st, screen, flags; rb_scan_args(argc, argv, "21", &st, &screen, &flags); ruby_libvirt_generate_call_string(virDomainScreenshot, ruby_libvirt_connect_get(d), 1, ruby_libvirt_domain_get(d), ruby_libvirt_stream_get(st), NUM2UINT(screen), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetSecurityLabel to retrieve the security label applied to this domain.
static VALUE libvirt_domain_security_label(VALUE d) { virSecurityLabel seclabel; int r; VALUE result; r = virDomainGetSecurityLabel(ruby_libvirt_domain_get(d), &seclabel); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetSecurityLabel", ruby_libvirt_connect_get(d)); 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; }
Call virDomainGetSecurityLabelList to retrieve the security labels applied to this domain.
static VALUE libvirt_domain_security_label_list(VALUE d) { virSecurityLabelPtr seclabels; int r, i; VALUE result, tmp; r = virDomainGetSecurityLabelList(ruby_libvirt_domain_get(d), &seclabels); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetSecurityLabel", ruby_libvirt_connect_get(d)); result = rb_ary_new2(r); for (i = 0; i < r; i++) { tmp = rb_class_new_instance(0, NULL, c_domain_security_label); rb_iv_set(tmp, "@label", rb_str_new2(seclabels[i].label)); rb_iv_set(tmp, "@enforcing", INT2NUM(seclabels[i].enforcing)); rb_ary_store(result, i, tmp); } return result; }
Call virDomainSendKey to send key(s) to the domain. Keycodes has to be an array of keys to send.
VALUE libvirt_domain_send_key(VALUE d, VALUE codeset, VALUE holdtime, VALUE keycodes) { unsigned int *codes; int i = 0; Check_Type(keycodes, T_ARRAY); codes = alloca(RARRAY_LEN(keycodes) * sizeof(unsigned int)); for (i = 0; i < RARRAY_LEN(keycodes); i++) { codes[i] = NUM2UINT(rb_ary_entry(keycodes,i)); } ruby_libvirt_generate_call_nil(virDomainSendKey, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2UINT(codeset), NUM2UINT(holdtime), codes, RARRAY_LEN(keycodes), 0); }
Call virDomainSendProcessSignal to send a signal to a process inside the domain.
static VALUE libvirt_domain_send_process_signal(int argc, VALUE *argv, VALUE d) { VALUE pid, signum, flags; rb_scan_args(argc, argv, "21", &pid, &signum, &flags); ruby_libvirt_generate_call_nil(virDomainSendProcessSignal, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2LL(pid), NUM2UINT(signum), ruby_libvirt_value_to_uint(flags)); }
Call 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_domain_shutdown(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); if (ruby_libvirt_value_to_uint(flags) != 0) { ruby_libvirt_generate_call_nil(virDomainShutdownFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); } else { ruby_libvirt_generate_call_nil(virDomainShutdown, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); } }
Call virDomainSnapshotCreateXML to create a new snapshot based on snapshot_xml.
static VALUE libvirt_domain_snapshot_create_xml(int argc, VALUE *argv, VALUE d) { VALUE xmlDesc, flags; virDomainSnapshotPtr ret; rb_scan_args(argc, argv, "11", &xmlDesc, &flags); ret = virDomainSnapshotCreateXML(ruby_libvirt_domain_get(d), StringValueCStr(xmlDesc), ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret == NULL, e_Error, "virDomainSnapshotCreateXML", ruby_libvirt_connect_get(d)); return domain_snapshot_new(ret, d); }
Call virDomainGetState to get the current state of the domain.
static VALUE libvirt_domain_state(int argc, VALUE *argv, VALUE d) { VALUE result, flags; int state, reason, retval; rb_scan_args(argc, argv, "01", &flags); retval = virDomainGetState(ruby_libvirt_domain_get(d), &state, &reason, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(retval < 0, e_Error, "virDomainGetState", ruby_libvirt_connect_get(d)); result = rb_ary_new(); rb_ary_push(result, INT2NUM(state)); rb_ary_push(result, INT2NUM(reason)); return result; }
Call 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_domain_suspend(VALUE d) { ruby_libvirt_generate_call_nil(virDomainSuspend, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
static VALUE libvirt_domain_get_time(int argc, VALUE *argv, VALUE d) { VALUE flags = RUBY_Qnil, result; long long seconds; unsigned int nseconds; int ret; rb_scan_args(argc, argv, "01", &flags); ret = virDomainGetTime(ruby_libvirt_domain_get(d), &seconds, &nseconds, ruby_libvirt_value_to_uint(flags)); ruby_libvirt_raise_error_if(ret < 0, e_Error, "virDomainGetTime", ruby_libvirt_connect_get(d)); result = rb_hash_new(); rb_hash_aset(result, rb_str_new2("seconds"), LL2NUM(seconds)); rb_hash_aset(result, rb_str_new2("nseconds"), UINT2NUM(nseconds)); return result; }
static VALUE libvirt_domain_time_equal(VALUE d, VALUE in) { VALUE hash, flags, seconds, nseconds; ruby_libvirt_assign_hash_and_flags(in, &hash, &flags); seconds = rb_hash_aref(hash, rb_str_new2("seconds")); nseconds = rb_hash_aref(hash, rb_str_new2("nseconds")); ruby_libvirt_generate_call_nil(virDomainSetTime, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2LL(seconds), NUM2UINT(nseconds), NUM2UINT(flags)); }
Call virDomainUndefine to undefine the domain. After this call, the domain object is no longer valid.
static VALUE libvirt_domain_undefine(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); if (ruby_libvirt_value_to_uint(flags) != 0) { ruby_libvirt_generate_call_nil(virDomainUndefineFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); } else { ruby_libvirt_generate_call_nil(virDomainUndefine, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); } }
Call virDomainUpdateDeviceFlags to update the device described by the device_xml.
static VALUE libvirt_domain_update_device(int argc, VALUE *argv, VALUE d) { VALUE xml, flags; rb_scan_args(argc, argv, "11", &xml, &flags); ruby_libvirt_generate_call_nil(virDomainUpdateDeviceFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(xml), ruby_libvirt_value_to_uint(flags)); }
Call virDomainIsUpdated to determine whether the definition for this domain has been updated.
static VALUE libvirt_domain_is_updated(VALUE d) { ruby_libvirt_generate_call_truefalse(virDomainIsUpdated, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
Call virDomainSetUserPassword to set the user password on a domain.
static VALUE libvirt_domain_user_password_equal(VALUE d, VALUE in) { VALUE user, password, flags; Check_Type(in, T_ARRAY); if (RARRAY_LEN(in) == 2) { user = rb_ary_entry(in, 0); password = rb_ary_entry(in, 1); flags = INT2NUM(0); } else if (RARRAY_LEN(in) == 3) { user = rb_ary_entry(in, 0); password = rb_ary_entry(in, 1); flags = rb_ary_entry(in, 2); } else { rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2 or 3)", RARRAY_LEN(in)); } ruby_libvirt_generate_call_nil(virDomainSetUserPassword, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), StringValueCStr(user), StringValueCStr(password), ruby_libvirt_value_to_uint(flags)); }
Call virDomainGetUUIDString to retrieve the UUID of this domain.
static VALUE libvirt_domain_uuid(VALUE d) { ruby_libvirt_generate_uuid(virDomainGetUUIDString, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d)); }
Call virDomainGetVcpus to retrieve detailed information about the state of a domain's virtual CPUs.
static VALUE libvirt_domain_vcpus(VALUE d) { virDomainInfo dominfo; virVcpuInfoPtr cpuinfo = NULL; unsigned char *cpumap; int cpumaplen, r, j, maxcpus; VALUE result, vcpuinfo, p2vcpumap; unsigned short i; r = virDomainGetInfo(ruby_libvirt_domain_get(d), &dominfo); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetInfo", ruby_libvirt_connect_get(d)); cpuinfo = alloca(sizeof(virVcpuInfo) * dominfo.nrVirtCpu); maxcpus = ruby_libvirt_get_maxcpus(ruby_libvirt_connect_get(d)); cpumaplen = VIR_CPU_MAPLEN(maxcpus); cpumap = alloca(sizeof(unsigned char) * cpumaplen * dominfo.nrVirtCpu); r = virDomainGetVcpus(ruby_libvirt_domain_get(d), cpuinfo, dominfo.nrVirtCpu, cpumap, cpumaplen); if (r < 0) { /* if the domain is not shutoff, then this is an error */ ruby_libvirt_raise_error_if(dominfo.state != VIR_DOMAIN_SHUTOFF, e_RetrieveError, "virDomainGetVcpus", ruby_libvirt_connect_get(d)); /* otherwise, we can try to call virDomainGetVcpuPinInfo to get the * information instead */ r = virDomainGetVcpuPinInfo(ruby_libvirt_domain_get(d), dominfo.nrVirtCpu, cpumap, cpumaplen, VIR_DOMAIN_AFFECT_CONFIG); ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virDomainGetVcpuPinInfo", ruby_libvirt_connect_get(d)); } result = rb_ary_new(); for (i = 0; i < r; i++) { vcpuinfo = rb_class_new_instance(0, NULL, c_domain_vcpuinfo); if (cpuinfo != NULL) { rb_iv_set(vcpuinfo, "@number", INT2NUM(cpuinfo[i].number)); rb_iv_set(vcpuinfo, "@state", INT2NUM(cpuinfo[i].state)); rb_iv_set(vcpuinfo, "@cpu_time", ULL2NUM(cpuinfo[i].cpuTime)); rb_iv_set(vcpuinfo, "@cpu", INT2NUM(cpuinfo[i].cpu)); } else { rb_iv_set(vcpuinfo, "@number", Qnil); rb_iv_set(vcpuinfo, "@state", Qnil); rb_iv_set(vcpuinfo, "@cpu_time", Qnil); rb_iv_set(vcpuinfo, "@cpu", Qnil); } p2vcpumap = rb_ary_new(); for (j = 0; j < maxcpus; j++) { rb_ary_push(p2vcpumap, (VIR_CPU_USABLE(cpumap, cpumaplen, i, j)) ? Qtrue : Qfalse); } rb_iv_set(vcpuinfo, "@cpumap", p2vcpumap); rb_ary_push(result, vcpuinfo); } return result; }
Call 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_domain_vcpus_equal(VALUE d, VALUE in) { VALUE nvcpus, flags = Qnil; if (TYPE(in) == T_FIXNUM) { nvcpus = in; ruby_libvirt_generate_call_nil(virDomainSetVcpus, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2UINT(nvcpus)); } else if (TYPE(in) == T_ARRAY) { if (RARRAY_LEN(in) != 2) { rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)", RARRAY_LEN(in)); } nvcpus = rb_ary_entry(in, 0); flags = rb_ary_entry(in, 1); ruby_libvirt_generate_call_nil(virDomainSetVcpusFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2UINT(nvcpus), NUM2UINT(flags)); } else { rb_raise(rb_eTypeError, "wrong argument type (expected Number or Array)"); } }
Call 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. Deprecated; use dom.vcpus= instead.
static VALUE libvirt_domain_vcpus_flags_equal(VALUE d, VALUE in) { VALUE nvcpus, flags; domain_input_to_fixnum_and_flags(in, &nvcpus, &flags); ruby_libvirt_generate_call_nil(virDomainSetVcpusFlags, ruby_libvirt_connect_get(d), ruby_libvirt_domain_get(d), NUM2UINT(nvcpus), NUM2UINT(flags)); }
Call virDomainGetXMLDesc to retrieve the XML describing this domain.
static VALUE libvirt_domain_xml_desc(int argc, VALUE *argv, VALUE d) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); ruby_libvirt_generate_call_string(virDomainGetXMLDesc, ruby_libvirt_connect_get(d), 1, ruby_libvirt_domain_get(d), ruby_libvirt_value_to_uint(flags)); }