Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xhypervisor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
os
xhypervisor
Commits
e1416807
Commit
e1416807
authored
5 years ago
by
Stefan Lankes
Browse files
Options
Downloads
Patches
Plain Diff
revise code, increasing the readability
parent
09db0885
Branches
Topic/1163-adminApi
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Cargo.toml
+1
-1
1 addition, 1 deletion
Cargo.toml
src/lib.rs
+13
-13
13 additions, 13 deletions
src/lib.rs
with
14 additions
and
14 deletions
Cargo.toml
+
1
−
1
View file @
e1416807
[package]
name
=
"xhypervisor"
version
=
"0.0.1
1
"
version
=
"0.0.1
2
"
authors
=
[
"Stefan Lankes"
,
"Saurav Sachidanand"
]
license
=
"MIT"
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
13
−
13
View file @
e1416807
...
...
@@ -166,7 +166,7 @@ pub fn protect_mem(gpa: u64, size: usize, mem_perm: &MemPerm) -> Result<(), Erro
///
/// * `tsc` Guest TSC value
pub
fn
sync_tsc
(
tsc
:
u64
)
->
Result
<
(),
Error
>
{
match_error_code
(
unsafe
{
hv_vm_sync_tsc
(
tsc
as
u64
)
})
match_error_code
(
unsafe
{
hv_vm_sync_tsc
(
tsc
)
})
}
/// Forces an immediate VMEXIT of a set of vCPUs
...
...
@@ -273,7 +273,7 @@ impl vCPU {
let
_error
=
match_error_code
(
unsafe
{
hv_vcpu_get_exec_time
(
self
.id
,
&
mut
exec_time
)
})
?
;
Ok
(
exec_time
as
u64
)
Ok
(
exec_time
)
}
/// Forces flushing of cached vCPU state
...
...
@@ -289,7 +289,7 @@ impl vCPU {
/// Enables an MSR to be used natively by the VM
pub
fn
enable_native_msr
(
&
self
,
msr
:
u32
,
enable
:
bool
)
->
Result
<
(),
Error
>
{
match_error_code
(
unsafe
{
hv_vcpu_enable_native_msr
(
self
.id
as
hv_vcpuid_t
,
msr
as
u32
,
enable
)
hv_vcpu_enable_native_msr
(
self
.id
as
hv_vcpuid_t
,
msr
,
enable
)
})
}
...
...
@@ -298,16 +298,16 @@ impl vCPU {
let
mut
value
:
u64
=
0
;
let
_error
=
match_error_code
(
unsafe
{
hv_vcpu_read_msr
(
self
.id
as
hv_vcpuid_t
,
msr
as
u32
,
&
mut
value
)
hv_vcpu_read_msr
(
self
.id
as
hv_vcpuid_t
,
msr
,
&
mut
value
)
})
?
;
Ok
(
value
as
u64
)
Ok
(
value
)
}
/// Set the value of an MSR of the vCPU
pub
fn
write_msr
(
&
self
,
msr
:
u32
,
value
:
u64
)
->
Result
<
(),
Error
>
{
match_error_code
(
unsafe
{
hv_vcpu_write_msr
(
self
.id
as
hv_vcpuid_t
,
msr
as
u32
,
&
(
value
as
u64
))
hv_vcpu_write_msr
(
self
.id
as
hv_vcpuid_t
,
msr
,
&
(
value
))
})
}
...
...
@@ -320,13 +320,13 @@ impl vCPU {
hv_vcpu_read_register
(
self
.id
as
hv_vcpuid_t
,
(
*
reg
)
.clone
(),
&
mut
value
)
})
?
;
Ok
(
value
as
u64
)
Ok
(
value
)
}
/// Sets the value of an architectural x86 register of the vCPU
pub
fn
write_register
(
&
self
,
reg
:
&
x86Reg
,
value
:
u64
)
->
Result
<
(),
Error
>
{
match_error_code
(
unsafe
{
hv_vcpu_write_register
(
self
.id
as
hv_vcpuid_t
,
(
*
reg
)
.clone
(),
value
as
u64
)
hv_vcpu_write_register
(
self
.id
as
hv_vcpuid_t
,
(
*
reg
)
.clone
(),
value
)
})
}
...
...
@@ -335,16 +335,16 @@ impl vCPU {
let
mut
value
:
u64
=
0
;
match_error_code
(
unsafe
{
hv_vmx_vcpu_read_vmcs
(
self
.id
as
hv_vcpuid_t
,
field
as
u32
,
&
mut
value
)
hv_vmx_vcpu_read_vmcs
(
self
.id
as
hv_vcpuid_t
,
field
,
&
mut
value
)
})
?
;
Ok
(
value
as
u64
)
Ok
(
value
)
}
/// Sets the value of a VMCS field of the vCPU
pub
fn
write_vmcs
(
&
self
,
field
:
u32
,
value
:
u64
)
->
Result
<
(),
Error
>
{
match_error_code
(
unsafe
{
hv_vmx_vcpu_write_vmcs
(
self
.id
as
hv_vcpuid_t
,
field
as
u32
,
value
as
u64
)
hv_vmx_vcpu_write_vmcs
(
self
.id
as
hv_vcpuid_t
,
field
,
value
)
})
}
...
...
@@ -352,7 +352,7 @@ impl vCPU {
/// guest physical address space of the VM
pub
fn
set_apic_addr
(
&
self
,
gpa
:
u64
)
->
Result
<
(),
Error
>
{
match_error_code
(
unsafe
{
hv_vmx_vcpu_set_apic_address
(
self
.id
as
hv_vcpuid_t
,
gpa
as
u64
)
hv_vmx_vcpu_set_apic_address
(
self
.id
as
hv_vcpuid_t
,
gpa
)
})
}
...
...
@@ -410,7 +410,7 @@ pub fn read_vmx_cap(vmx_cap: &VMXCap) -> Result<u64, Error> {
match_error_code
(
unsafe
{
hv_vmx_read_capability
((
*
vmx_cap
)
.clone
(),
&
mut
value
)
})
?
;
Ok
(
value
as
u64
)
Ok
(
value
)
}
impl
fmt
::
Display
for
VMXCap
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment