@@ -1764,7 +1764,7 @@ impl VcpuFd {
1764
1764
/// ```
1765
1765
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
1766
1766
pub fn sync_regs ( & self ) -> kvm_sync_regs {
1767
- let kvm_run: & mut kvm_run = self . kvm_run_ptr . as_mut_ref ( ) ;
1767
+ let kvm_run = self . kvm_run_ptr . as_ref ( ) ;
1768
1768
1769
1769
// SAFETY: Accessing this union field could be out of bounds if the `kvm_run`
1770
1770
// allocation isn't large enough. The `kvm_run` region is set using
@@ -2689,9 +2689,9 @@ mod tests {
2689
2689
let kvm = Kvm :: new ( ) . unwrap ( ) ;
2690
2690
let vm = kvm. create_vm ( ) . unwrap ( ) ;
2691
2691
let vcpu = vm. create_vcpu ( 0 ) . unwrap ( ) ;
2692
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . immediate_exit, 0 ) ;
2692
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . immediate_exit, 0 ) ;
2693
2693
vcpu. set_kvm_immediate_exit ( 1 ) ;
2694
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . immediate_exit, 1 ) ;
2694
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . immediate_exit, 1 ) ;
2695
2695
}
2696
2696
2697
2697
#[ test]
@@ -2763,17 +2763,17 @@ mod tests {
2763
2763
] ;
2764
2764
for reg in & sync_regs {
2765
2765
vcpu. set_sync_valid_reg ( * reg) ;
2766
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_valid_regs, * reg as u64 ) ;
2766
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_valid_regs, * reg as u64 ) ;
2767
2767
vcpu. clear_sync_valid_reg ( * reg) ;
2768
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_valid_regs, 0 ) ;
2768
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_valid_regs, 0 ) ;
2769
2769
}
2770
2770
2771
2771
// Test that multiple valid SyncRegs can be set at the same time
2772
2772
vcpu. set_sync_valid_reg ( SyncReg :: Register ) ;
2773
2773
vcpu. set_sync_valid_reg ( SyncReg :: SystemRegister ) ;
2774
2774
vcpu. set_sync_valid_reg ( SyncReg :: VcpuEvents ) ;
2775
2775
assert_eq ! (
2776
- vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_valid_regs,
2776
+ vcpu. kvm_run_ptr. as_ref ( ) . kvm_valid_regs,
2777
2777
SyncReg :: Register as u64 | SyncReg :: SystemRegister as u64 | SyncReg :: VcpuEvents as u64
2778
2778
) ;
2779
2779
@@ -2786,17 +2786,17 @@ mod tests {
2786
2786
2787
2787
for reg in & sync_regs {
2788
2788
vcpu. set_sync_dirty_reg ( * reg) ;
2789
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_dirty_regs, * reg as u64 ) ;
2789
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_dirty_regs, * reg as u64 ) ;
2790
2790
vcpu. clear_sync_dirty_reg ( * reg) ;
2791
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_dirty_regs, 0 ) ;
2791
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_dirty_regs, 0 ) ;
2792
2792
}
2793
2793
2794
2794
// Test that multiple dirty SyncRegs can be set at the same time
2795
2795
vcpu. set_sync_dirty_reg ( SyncReg :: Register ) ;
2796
2796
vcpu. set_sync_dirty_reg ( SyncReg :: SystemRegister ) ;
2797
2797
vcpu. set_sync_dirty_reg ( SyncReg :: VcpuEvents ) ;
2798
2798
assert_eq ! (
2799
- vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_dirty_regs,
2799
+ vcpu. kvm_run_ptr. as_ref ( ) . kvm_dirty_regs,
2800
2800
SyncReg :: Register as u64 | SyncReg :: SystemRegister as u64 | SyncReg :: VcpuEvents as u64
2801
2801
) ;
2802
2802
}
0 commit comments