@@ -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
@@ -2663,9 +2663,9 @@ mod tests {
2663
2663
let kvm = Kvm :: new ( ) . unwrap ( ) ;
2664
2664
let vm = kvm. create_vm ( ) . unwrap ( ) ;
2665
2665
let vcpu = vm. create_vcpu ( 0 ) . unwrap ( ) ;
2666
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . immediate_exit, 0 ) ;
2666
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . immediate_exit, 0 ) ;
2667
2667
vcpu. set_kvm_immediate_exit ( 1 ) ;
2668
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . immediate_exit, 1 ) ;
2668
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . immediate_exit, 1 ) ;
2669
2669
}
2670
2670
2671
2671
#[ test]
@@ -2737,17 +2737,17 @@ mod tests {
2737
2737
] ;
2738
2738
for reg in & sync_regs {
2739
2739
vcpu. set_sync_valid_reg ( * reg) ;
2740
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_valid_regs, * reg as u64 ) ;
2740
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_valid_regs, * reg as u64 ) ;
2741
2741
vcpu. clear_sync_valid_reg ( * reg) ;
2742
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_valid_regs, 0 ) ;
2742
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_valid_regs, 0 ) ;
2743
2743
}
2744
2744
2745
2745
// Test that multiple valid SyncRegs can be set at the same time
2746
2746
vcpu. set_sync_valid_reg ( SyncReg :: Register ) ;
2747
2747
vcpu. set_sync_valid_reg ( SyncReg :: SystemRegister ) ;
2748
2748
vcpu. set_sync_valid_reg ( SyncReg :: VcpuEvents ) ;
2749
2749
assert_eq ! (
2750
- vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_valid_regs,
2750
+ vcpu. kvm_run_ptr. as_ref ( ) . kvm_valid_regs,
2751
2751
SyncReg :: Register as u64 | SyncReg :: SystemRegister as u64 | SyncReg :: VcpuEvents as u64
2752
2752
) ;
2753
2753
@@ -2760,17 +2760,17 @@ mod tests {
2760
2760
2761
2761
for reg in & sync_regs {
2762
2762
vcpu. set_sync_dirty_reg ( * reg) ;
2763
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_dirty_regs, * reg as u64 ) ;
2763
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_dirty_regs, * reg as u64 ) ;
2764
2764
vcpu. clear_sync_dirty_reg ( * reg) ;
2765
- assert_eq ! ( vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_dirty_regs, 0 ) ;
2765
+ assert_eq ! ( vcpu. kvm_run_ptr. as_ref ( ) . kvm_dirty_regs, 0 ) ;
2766
2766
}
2767
2767
2768
2768
// Test that multiple dirty SyncRegs can be set at the same time
2769
2769
vcpu. set_sync_dirty_reg ( SyncReg :: Register ) ;
2770
2770
vcpu. set_sync_dirty_reg ( SyncReg :: SystemRegister ) ;
2771
2771
vcpu. set_sync_dirty_reg ( SyncReg :: VcpuEvents ) ;
2772
2772
assert_eq ! (
2773
- vcpu. kvm_run_ptr. as_mut_ref ( ) . kvm_dirty_regs,
2773
+ vcpu. kvm_run_ptr. as_ref ( ) . kvm_dirty_regs,
2774
2774
SyncReg :: Register as u64 | SyncReg :: SystemRegister as u64 | SyncReg :: VcpuEvents as u64
2775
2775
) ;
2776
2776
}
0 commit comments