Class: Hypervisor::VCPU
- Inherits:
-
Object
- Object
- Hypervisor::VCPU
- Defined in:
- lib/hypervisor/vcpu.rb
Instance Method Summary collapse
- #destroy! ⇒ Object
- #flags ⇒ Object
- #flags=(value) ⇒ Object
- #flush ⇒ Object
-
#initialize(flags = VCPU_DEFAULT) ⇒ VCPU
constructor
A new instance of VCPU.
- #invalidate_tlb ⇒ Object
- #read_register(register) ⇒ Object
- #read_vmcs(field) ⇒ Object
- #run ⇒ Object
- #write_register(register, value) ⇒ Object
- #write_vmcs(field, value) ⇒ Object
Constructor Details
#initialize(flags = VCPU_DEFAULT) ⇒ VCPU
Returns a new instance of VCPU.
3 4 5 6 7 8 9 |
# 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 |
Instance Method Details
#destroy! ⇒ Object
11 12 13 |
# File 'lib/hypervisor/vcpu.rb', line 11 def destroy! Framework.return_t(Framework.hv_vcpu_destroy(@vcpu)) end |
#flags ⇒ Object
113 114 115 |
# File 'lib/hypervisor/vcpu.rb', line 113 def flags read_register(Hypervisor::X86_RFLAGS) end |
#flags=(value) ⇒ Object
117 118 119 |
# File 'lib/hypervisor/vcpu.rb', line 117 def flags=(value) write_register(Hypervisor::X86_RFLAGS, value) end |
#flush ⇒ Object
15 16 17 |
# File 'lib/hypervisor/vcpu.rb', line 15 def flush Framework.return_t(Framework.hv_vcpu_flush(@vcpu)) end |
#invalidate_tlb ⇒ Object
19 20 21 |
# File 'lib/hypervisor/vcpu.rb', line 19 def invalidate_tlb Framework.return_t(Framework.hv_vcpu_invalidate_tlb(@vcpu)) end |
#read_register(register) ⇒ Object
27 28 29 30 31 32 33 |
# 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) ⇒ Object
39 40 41 42 43 44 45 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/hypervisor/vcpu.rb', line 23 def run Framework.return_t(Framework.hv_vcpu_run(@vcpu)) end |
#write_register(register, value) ⇒ Object
35 36 37 |
# 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) ⇒ Object
47 48 49 |
# 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 |