Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-vmm/mshv
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 04731d9734c5d8974b37763844514bca8229efdd
Choose a base ref
..
head repository: rust-vmm/mshv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2c3696df9b1a01011850c302ef06f410464879b4
Choose a head ref
Showing with 30 additions and 16 deletions.
  1. +30 −16 mshv-ioctls/src/ioctls/vcpu.rs
46 changes: 30 additions & 16 deletions mshv-ioctls/src/ioctls/vcpu.rs
Original file line number Diff line number Diff line change
@@ -1257,11 +1257,7 @@ mod tests {

#[test]
fn test_set_get_regs() {
let hv = Mshv::new().unwrap();
let vm = hv.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();

vcpu.set_reg(&[
let set_reg_assocs: [hv_register_assoc; 2] = [
hv_register_assoc {
name: hv_register_name_HV_X64_REGISTER_RIP,
value: hv_register_value { reg64: 0x1000 },
@@ -1272,10 +1268,8 @@ mod tests {
value: hv_register_value { reg64: 0x2 },
..Default::default()
},
])
.unwrap();

let mut get_regs: [hv_register_assoc; 2] = [
];
let get_reg_assocs: [hv_register_assoc; 2] = [
hv_register_assoc {
name: hv_register_name_HV_X64_REGISTER_RIP,
..Default::default()
@@ -1286,12 +1280,30 @@ mod tests {
},
];

vcpu.get_reg(&mut get_regs).unwrap();
for i in [0, 1] {
let hv = Mshv::new().unwrap();
let vm = hv.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();

// SAFETY: access union fields
unsafe {
assert!(get_regs[0].value.reg64 == 0x1000);
assert!(get_regs[1].value.reg64 == 0x2);
if i == 0 {
vcpu.set_reg(&set_reg_assocs).unwrap();
} else {
vcpu.hvcall_set_reg(&set_reg_assocs).unwrap();
}

let mut get_regs: [hv_register_assoc; 2] = get_reg_assocs;

if i == 0 {
vcpu.get_reg(&mut get_regs).unwrap();
} else {
vcpu.hvcall_get_reg(&mut get_regs).unwrap();
}

// SAFETY: access union fields
unsafe {
assert!(get_regs[0].value.reg64 == 0x1000);
assert!(get_regs[1].value.reg64 == 0x2);
}
}
}

@@ -1661,9 +1673,11 @@ mod tests {
let hv = Mshv::new().unwrap();
let vm = hv.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();
let res = vcpu.get_cpuid_values(0, 0, 0, 0).unwrap();
let max_function = res[0];
let res_0 = vcpu.get_cpuid_values(0, 0, 0, 0).unwrap();
let max_function = res_0[0];
assert!(max_function >= 1);
let res_1 = vcpu.hvcall_get_cpuid_values(0, 0, 0, 0).unwrap();
assert!(res_1[0] >= 1);
}

#[test]