File tree Expand file tree Collapse file tree 5 files changed +285
-26
lines changed
tests/integration_tests/build Expand file tree Collapse file tree 5 files changed +285
-26
lines changed Original file line number Diff line number Diff line change 55use std:: result;
66
77use arch_gen:: x86:: msr_index:: * ;
8- use kvm_bindings:: { kvm_msr_entry, Msrs } ;
9- use kvm_ioctls:: VcpuFd ;
8+ use kvm_bindings:: { kvm_msr_entry, MsrList , Msrs } ;
9+ use kvm_ioctls:: { Kvm , VcpuFd } ;
1010
1111#[ derive( Debug ) ]
1212/// MSR related errors.
1313pub enum Error {
14+ /// Getting supported MSRs failed.
15+ GetSupportedModelSpecificRegisters ( kvm_ioctls:: Error ) ,
1416 /// Setting up MSRs failed.
1517 SetModelSpecificRegisters ( kvm_ioctls:: Error ) ,
1618 /// Failed to set all MSRs.
@@ -227,6 +229,21 @@ pub fn setup_msrs(vcpu: &VcpuFd) -> Result<()> {
227229 } )
228230}
229231
232+ /// Returns the list of supported, serializable MSRs.
233+ ///
234+ /// # Arguments
235+ ///
236+ /// * `kvm_fd` - Structure that holds the KVM's fd.
237+ pub fn supported_guest_msrs ( kvm_fd : & Kvm ) -> Result < MsrList > {
238+ let mut msr_list = kvm_fd
239+ . get_msr_index_list ( )
240+ . map_err ( Error :: GetSupportedModelSpecificRegisters ) ?;
241+
242+ msr_list. retain ( |msr_index| msr_should_serialize ( * msr_index) ) ;
243+
244+ Ok ( msr_list)
245+ }
246+
230247#[ cfg( test) ]
231248mod tests {
232249 use super :: * ;
Original file line number Diff line number Diff line change @@ -816,9 +816,9 @@ mod tests {
816816 ErrorKind :: Internal
817817 ) ;
818818 assert_eq ! (
819- error_kind( StartMicrovmError :: VcpuConfigure (
820- vstate :: Error :: SetSupportedCpusFailed ( utils:: errno:: Error :: new( 0 ) )
821- ) ) ,
819+ error_kind( StartMicrovmError :: VcpuConfigure ( vstate :: Error :: VcpuFd (
820+ utils:: errno:: Error :: new( 0 )
821+ ) ) ) ,
822822 ErrorKind :: Internal
823823 ) ;
824824 assert_eq ! (
Original file line number Diff line number Diff line change @@ -885,6 +885,7 @@ impl Vmm {
885885 cpu_index,
886886 self . vm . fd ( ) ,
887887 self . vm . supported_cpuid ( ) . clone ( ) ,
888+ self . vm . supported_msrs ( ) . clone ( ) ,
888889 self . pio_device_manager . io_bus . clone ( ) ,
889890 vcpu_exit_evt,
890891 request_ts. clone ( ) ,
You can’t perform that action at this time.
0 commit comments