@@ -57,8 +57,8 @@ pub enum KvmVcpuError {
57
57
VcpuGetLapic ( kvm_ioctls:: Error ) ,
58
58
/// Failed to get KVM vcpu mp state: {0}
59
59
VcpuGetMpState ( kvm_ioctls:: Error ) ,
60
- /// Unexpected number of MSRS reported by the kernel
61
- VcpuGetMsrsIncomplete ,
60
+ /// Failed to get KVM vcpu msr: 0x{0:x}
61
+ VcpuGetMsr ( u32 ) ,
62
62
/// Failed to get KVM vcpu msrs: {0}
63
63
VcpuGetMsrs ( kvm_ioctls:: Error ) ,
64
64
/// Failed to get KVM vcpu regs: {0}
@@ -321,7 +321,7 @@ impl KvmVcpu {
321
321
. get_msrs ( & mut msrs)
322
322
. map_err ( KvmVcpuError :: VcpuGetMsrs ) ?;
323
323
if nmsrs != expected_nmsrs {
324
- return Err ( KvmVcpuError :: VcpuGetMsrsIncomplete ) ;
324
+ return Err ( KvmVcpuError :: VcpuGetMsr ( msr_index_chunk [ nmsrs ] ) ) ;
325
325
}
326
326
327
327
msr_chunks. push ( msrs) ;
@@ -928,18 +928,17 @@ mod tests {
928
928
929
929
#[ test]
930
930
fn test_get_msrs_with_invalid_msr_index ( ) {
931
- // Test `get_msrs()` with unsupported MSR indices. This should return
932
- // `VcpuGetMsrsIncomplete` error that happens when `KVM_GET_MSRS` fails to populdate
933
- // MSR value in the middle and exits. Currently, MSR indices 2..=4 are not listed as
934
- // supported MSRs.
931
+ // Test `get_msrs()` with unsupported MSR indices. This should return `VcpuGetMsr` error
932
+ // that happens when `KVM_GET_MSRS` fails to populate MSR values in the middle and exits.
933
+ // Currently, MSR indices 2..=4 are not listed as supported MSRs.
935
934
let ( _, vcpu, _) = setup_vcpu ( 0x1000 ) ;
936
935
let msr_index_list: Vec < u32 > = vec ! [ 2 , 3 , 4 ] ;
937
936
match vcpu. get_msrs ( & msr_index_list) {
938
- Err ( KvmVcpuError :: VcpuGetMsrsIncomplete ) => ( ) ,
937
+ Err ( KvmVcpuError :: VcpuGetMsr ( _ ) ) => ( ) ,
939
938
Err ( err) => panic ! ( "Unexpected error: {err}" ) ,
940
- Ok ( _) => panic ! (
941
- "KvmVcpu::get_msrs() for unsupported MSRs should fail with VcpuGetMsrsIncomplete."
942
- ) ,
939
+ Ok ( _) => {
940
+ panic ! ( "KvmVcpu::get_msrs() for unsupported MSRs should fail with VcpuGetMsr." )
941
+ }
943
942
}
944
943
}
945
944
}
0 commit comments