@@ -357,9 +357,7 @@ impl VcpuFd {
357
357
pub fn get_fpu ( & self ) -> Result < kvm_fpu > {
358
358
let mut fpu = kvm_fpu:: default ( ) ;
359
359
// SAFETY: Here we trust the kernel not to read past the end of the kvm_fpu struct.
360
- let ret = unsafe {
361
- ioctl_with_mut_ref ( self , KVM_GET_FPU ( ) , & mut fpu)
362
- } ;
360
+ let ret = unsafe { ioctl_with_mut_ref ( self , KVM_GET_FPU ( ) , & mut fpu) } ;
363
361
if ret != 0 {
364
362
return Err ( errno:: Error :: last ( ) ) ;
365
363
}
@@ -396,9 +394,7 @@ impl VcpuFd {
396
394
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
397
395
pub fn set_fpu ( & self , fpu : & kvm_fpu ) -> Result < ( ) > {
398
396
// SAFETY: Here we trust the kernel not to read past the end of the kvm_fpu struct.
399
- let ret = unsafe {
400
- ioctl_with_ref ( self , KVM_SET_FPU ( ) , fpu)
401
- } ;
397
+ let ret = unsafe { ioctl_with_ref ( self , KVM_SET_FPU ( ) , fpu) } ;
402
398
if ret < 0 {
403
399
return Err ( errno:: Error :: last ( ) ) ;
404
400
}
@@ -443,9 +439,7 @@ impl VcpuFd {
443
439
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
444
440
pub fn set_cpuid2 ( & self , cpuid : & CpuId ) -> Result < ( ) > {
445
441
// SAFETY: Here we trust the kernel not to read past the end of the kvm_cpuid2 struct.
446
- let ret = unsafe {
447
- ioctl_with_ptr ( self , KVM_SET_CPUID2 ( ) , cpuid. as_fam_struct_ptr ( ) )
448
- } ;
442
+ let ret = unsafe { ioctl_with_ptr ( self , KVM_SET_CPUID2 ( ) , cpuid. as_fam_struct_ptr ( ) ) } ;
449
443
if ret < 0 {
450
444
return Err ( errno:: Error :: last ( ) ) ;
451
445
}
@@ -484,9 +478,8 @@ impl VcpuFd {
484
478
485
479
let mut cpuid = CpuId :: new ( num_entries) . map_err ( |_| errno:: Error :: new ( libc:: ENOMEM ) ) ?;
486
480
// SAFETY: Here we trust the kernel not to read past the end of the kvm_cpuid2 struct.
487
- let ret = unsafe {
488
- ioctl_with_mut_ptr ( self , KVM_GET_CPUID2 ( ) , cpuid. as_mut_fam_struct_ptr ( ) )
489
- } ;
481
+ let ret =
482
+ unsafe { ioctl_with_mut_ptr ( self , KVM_GET_CPUID2 ( ) , cpuid. as_mut_fam_struct_ptr ( ) ) } ;
490
483
if ret != 0 {
491
484
return Err ( errno:: Error :: last ( ) ) ;
492
485
}
@@ -563,9 +556,7 @@ impl VcpuFd {
563
556
564
557
// SAFETY: The ioctl is unsafe unless you trust the kernel not to write past the end of the
565
558
// local_apic struct.
566
- let ret = unsafe {
567
- ioctl_with_mut_ref ( self , KVM_GET_LAPIC ( ) , & mut klapic)
568
- } ;
559
+ let ret = unsafe { ioctl_with_mut_ref ( self , KVM_GET_LAPIC ( ) , & mut klapic) } ;
569
560
if ret < 0 {
570
561
return Err ( errno:: Error :: last ( ) ) ;
571
562
}
@@ -607,9 +598,7 @@ impl VcpuFd {
607
598
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
608
599
pub fn set_lapic ( & self , klapic : & kvm_lapic_state ) -> Result < ( ) > {
609
600
// SAFETY: The ioctl is safe because the kernel will only read from the klapic struct.
610
- let ret = unsafe {
611
- ioctl_with_ref ( self , KVM_SET_LAPIC ( ) , klapic)
612
- } ;
601
+ let ret = unsafe { ioctl_with_ref ( self , KVM_SET_LAPIC ( ) , klapic) } ;
613
602
if ret < 0 {
614
603
return Err ( errno:: Error :: last ( ) ) ;
615
604
}
@@ -655,9 +644,7 @@ impl VcpuFd {
655
644
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
656
645
pub fn get_msrs ( & self , msrs : & mut Msrs ) -> Result < usize > {
657
646
// SAFETY: Here we trust the kernel not to read past the end of the kvm_msrs struct.
658
- let ret = unsafe {
659
- ioctl_with_mut_ptr ( self , KVM_GET_MSRS ( ) , msrs. as_mut_fam_struct_ptr ( ) )
660
- } ;
647
+ let ret = unsafe { ioctl_with_mut_ptr ( self , KVM_GET_MSRS ( ) , msrs. as_mut_fam_struct_ptr ( ) ) } ;
661
648
if ret < 0 {
662
649
return Err ( errno:: Error :: last ( ) ) ;
663
650
}
@@ -696,9 +683,7 @@ impl VcpuFd {
696
683
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
697
684
pub fn set_msrs ( & self , msrs : & Msrs ) -> Result < usize > {
698
685
// SAFETY: Here we trust the kernel not to read past the end of the kvm_msrs struct.
699
- let ret = unsafe {
700
- ioctl_with_ptr ( self , KVM_SET_MSRS ( ) , msrs. as_fam_struct_ptr ( ) )
701
- } ;
686
+ let ret = unsafe { ioctl_with_ptr ( self , KVM_SET_MSRS ( ) , msrs. as_fam_struct_ptr ( ) ) } ;
702
687
// KVM_SET_MSRS actually returns the number of msr entries written.
703
688
if ret < 0 {
704
689
return Err ( errno:: Error :: last ( ) ) ;
@@ -735,9 +720,7 @@ impl VcpuFd {
735
720
pub fn get_mp_state ( & self ) -> Result < kvm_mp_state > {
736
721
let mut mp_state = Default :: default ( ) ;
737
722
// SAFETY: Here we trust the kernel not to read past the end of the kvm_mp_state struct.
738
- let ret = unsafe {
739
- ioctl_with_mut_ref ( self , KVM_GET_MP_STATE ( ) , & mut mp_state)
740
- } ;
723
+ let ret = unsafe { ioctl_with_mut_ref ( self , KVM_GET_MP_STATE ( ) , & mut mp_state) } ;
741
724
if ret != 0 {
742
725
return Err ( errno:: Error :: last ( ) ) ;
743
726
}
@@ -774,9 +757,7 @@ impl VcpuFd {
774
757
) ) ]
775
758
pub fn set_mp_state ( & self , mp_state : kvm_mp_state ) -> Result < ( ) > {
776
759
// SAFETY: Here we trust the kernel not to read past the end of the kvm_mp_state struct.
777
- let ret = unsafe {
778
- ioctl_with_ref ( self , KVM_SET_MP_STATE ( ) , & mp_state)
779
- } ;
760
+ let ret = unsafe { ioctl_with_ref ( self , KVM_SET_MP_STATE ( ) , & mp_state) } ;
780
761
if ret != 0 {
781
762
return Err ( errno:: Error :: last ( ) ) ;
782
763
}
@@ -806,9 +787,7 @@ impl VcpuFd {
806
787
pub fn get_xsave ( & self ) -> Result < kvm_xsave > {
807
788
let mut xsave = Default :: default ( ) ;
808
789
// SAFETY: Here we trust the kernel not to read past the end of the kvm_xsave struct.
809
- let ret = unsafe {
810
- ioctl_with_mut_ref ( self , KVM_GET_XSAVE ( ) , & mut xsave)
811
- } ;
790
+ let ret = unsafe { ioctl_with_mut_ref ( self , KVM_GET_XSAVE ( ) , & mut xsave) } ;
812
791
if ret != 0 {
813
792
return Err ( errno:: Error :: last ( ) ) ;
814
793
}
@@ -839,9 +818,7 @@ impl VcpuFd {
839
818
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
840
819
pub fn set_xsave ( & self , xsave : & kvm_xsave ) -> Result < ( ) > {
841
820
// SAFETY: Here we trust the kernel not to read past the end of the kvm_xsave struct.
842
- let ret = unsafe {
843
- ioctl_with_ref ( self , KVM_SET_XSAVE ( ) , xsave)
844
- } ;
821
+ let ret = unsafe { ioctl_with_ref ( self , KVM_SET_XSAVE ( ) , xsave) } ;
845
822
if ret != 0 {
846
823
return Err ( errno:: Error :: last ( ) ) ;
847
824
}
@@ -871,9 +848,7 @@ impl VcpuFd {
871
848
pub fn get_xcrs ( & self ) -> Result < kvm_xcrs > {
872
849
let mut xcrs = Default :: default ( ) ;
873
850
// SAFETY: Here we trust the kernel not to read past the end of the kvm_xcrs struct.
874
- let ret = unsafe {
875
- ioctl_with_mut_ref ( self , KVM_GET_XCRS ( ) , & mut xcrs)
876
- } ;
851
+ let ret = unsafe { ioctl_with_mut_ref ( self , KVM_GET_XCRS ( ) , & mut xcrs) } ;
877
852
if ret != 0 {
878
853
return Err ( errno:: Error :: last ( ) ) ;
879
854
}
@@ -904,9 +879,7 @@ impl VcpuFd {
904
879
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
905
880
pub fn set_xcrs ( & self , xcrs : & kvm_xcrs ) -> Result < ( ) > {
906
881
// SAFETY: Here we trust the kernel not to read past the end of the kvm_xcrs struct.
907
- let ret = unsafe {
908
- ioctl_with_ref ( self , KVM_SET_XCRS ( ) , xcrs)
909
- } ;
882
+ let ret = unsafe { ioctl_with_ref ( self , KVM_SET_XCRS ( ) , xcrs) } ;
910
883
if ret != 0 {
911
884
return Err ( errno:: Error :: last ( ) ) ;
912
885
}
@@ -936,9 +909,7 @@ impl VcpuFd {
936
909
pub fn get_debug_regs ( & self ) -> Result < kvm_debugregs > {
937
910
let mut debug_regs = Default :: default ( ) ;
938
911
// SAFETY: Here we trust the kernel not to read past the end of the kvm_debugregs struct.
939
- let ret = unsafe {
940
- ioctl_with_mut_ref ( self , KVM_GET_DEBUGREGS ( ) , & mut debug_regs)
941
- } ;
912
+ let ret = unsafe { ioctl_with_mut_ref ( self , KVM_GET_DEBUGREGS ( ) , & mut debug_regs) } ;
942
913
if ret != 0 {
943
914
return Err ( errno:: Error :: last ( ) ) ;
944
915
}
@@ -969,9 +940,7 @@ impl VcpuFd {
969
940
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
970
941
pub fn set_debug_regs ( & self , debug_regs : & kvm_debugregs ) -> Result < ( ) > {
971
942
// SAFETY: Here we trust the kernel not to read past the end of the kvm_debugregs struct.
972
- let ret = unsafe {
973
- ioctl_with_ref ( self , KVM_SET_DEBUGREGS ( ) , debug_regs)
974
- } ;
943
+ let ret = unsafe { ioctl_with_ref ( self , KVM_SET_DEBUGREGS ( ) , debug_regs) } ;
975
944
if ret != 0 {
976
945
return Err ( errno:: Error :: last ( ) ) ;
977
946
}
@@ -1009,9 +978,7 @@ impl VcpuFd {
1009
978
pub fn get_vcpu_events ( & self ) -> Result < kvm_vcpu_events > {
1010
979
let mut vcpu_events = Default :: default ( ) ;
1011
980
// SAFETY: Here we trust the kernel not to read past the end of the kvm_vcpu_events struct.
1012
- let ret = unsafe {
1013
- ioctl_with_mut_ref ( self , KVM_GET_VCPU_EVENTS ( ) , & mut vcpu_events)
1014
- } ;
981
+ let ret = unsafe { ioctl_with_mut_ref ( self , KVM_GET_VCPU_EVENTS ( ) , & mut vcpu_events) } ;
1015
982
if ret != 0 {
1016
983
return Err ( errno:: Error :: last ( ) ) ;
1017
984
}
@@ -1050,9 +1017,7 @@ impl VcpuFd {
1050
1017
1051
1018
pub fn set_vcpu_events ( & self , vcpu_events : & kvm_vcpu_events ) -> Result < ( ) > {
1052
1019
// SAFETY: Here we trust the kernel not to read past the end of the kvm_vcpu_events struct.
1053
- let ret = unsafe {
1054
- ioctl_with_ref ( self , KVM_SET_VCPU_EVENTS ( ) , vcpu_events)
1055
- } ;
1020
+ let ret = unsafe { ioctl_with_ref ( self , KVM_SET_VCPU_EVENTS ( ) , vcpu_events) } ;
1056
1021
if ret != 0 {
1057
1022
return Err ( errno:: Error :: last ( ) ) ;
1058
1023
}
0 commit comments