class Hypervisor::VCPU

Public Class Methods

new(flags = VCPU_DEFAULT) click to toggle source
# File lib/hypervisor/vcpu.rb, line 3
def initialize(flags = VCPU_DEFAULT)
  FFI::MemoryPointer.new(:uint, 1) do |vcpu|
    Framework.return_t(Framework.hv_vcpu_create(vcpu, flags))

    @vcpu = vcpu.get_uint(0)
  end
end

Public Instance Methods

destroy!() click to toggle source
# File lib/hypervisor/vcpu.rb, line 11
def destroy!
  Framework.return_t(Framework.hv_vcpu_destroy(@vcpu))
end
flags() click to toggle source
# File lib/hypervisor/vcpu.rb, line 113
def flags
  read_register(Hypervisor::X86_RFLAGS)
end
flags=(value) click to toggle source
# File lib/hypervisor/vcpu.rb, line 117
def flags=(value)
  write_register(Hypervisor::X86_RFLAGS, value)
end
flush() click to toggle source
# File lib/hypervisor/vcpu.rb, line 15
def flush
  Framework.return_t(Framework.hv_vcpu_flush(@vcpu))
end
invalidate_tlb() click to toggle source
# File lib/hypervisor/vcpu.rb, line 19
def invalidate_tlb
  Framework.return_t(Framework.hv_vcpu_invalidate_tlb(@vcpu))
end
read_register(register) click to toggle source
# File lib/hypervisor/vcpu.rb, line 27
def read_register(register)
  FFI::MemoryPointer.new(:uint64_t, 1) do |value|
    Framework.return_t(Framework.hv_vcpu_read_register(@vcpu, register, value))

    return value.get_uint64(0)
  end
end
read_vmcs(field) click to toggle source
# File lib/hypervisor/vcpu.rb, line 39
def read_vmcs(field)
  FFI::MemoryPointer.new(:uint64_t, 1) do |value|
    Framework.return_t(Framework.hv_vmx_vcpu_read_vmcs(@vcpu, field, value))

    return value.get_uint64(0)
  end
end
run() click to toggle source
# File lib/hypervisor/vcpu.rb, line 23
def run
  Framework.return_t(Framework.hv_vcpu_run(@vcpu))
end
write_register(register, value) click to toggle source
# File lib/hypervisor/vcpu.rb, line 35
def write_register(register, value)
  Framework.return_t(Framework.hv_vcpu_write_register(@vcpu, register, value))
end
write_vmcs(field, value) click to toggle source
# File lib/hypervisor/vcpu.rb, line 47
def write_vmcs(field, value)
  Framework.return_t(Framework.hv_vmx_vcpu_write_vmcs(@vcpu, field, value))
end