@@ -41,25 +41,18 @@ pub enum VcpuArchError {
4141 SetMp ( kvm_ioctls:: Error ) ,
4242 /// Failed FamStructWrapper operation: {0}
4343 Fam ( vmm_sys_util:: fam:: Error ) ,
44- /// {0}
45- GetMidrEl1 ( String ) ,
4644 /// Failed to set/get device attributes for vCPU: {0}
4745 DeviceAttribute ( kvm_ioctls:: Error ) ,
4846}
4947
5048/// Extract the Manufacturer ID from the host.
5149/// The ID is found between bits 24-31 of MIDR_EL1 register.
52- pub fn get_manufacturer_id_from_host ( ) -> Result < u32 , VcpuArchError > {
50+ pub fn get_manufacturer_id_from_host ( ) -> Option < u32 > {
5351 let midr_el1_path = "/sys/devices/system/cpu/cpu0/regs/identification/midr_el1" ;
54- let midr_el1 = std:: fs:: read_to_string ( midr_el1_path) . map_err ( |err| {
55- VcpuArchError :: GetMidrEl1 ( format ! ( "Failed to get MIDR_EL1 from host path: {err}" ) )
56- } ) ?;
52+ let midr_el1 = std:: fs:: read_to_string ( midr_el1_path) . ok ( ) ?;
5753 let midr_el1_trimmed = midr_el1. trim_end ( ) . trim_start_matches ( "0x" ) ;
58- let manufacturer_id = u32:: from_str_radix ( midr_el1_trimmed, 16 ) . map_err ( |err| {
59- VcpuArchError :: GetMidrEl1 ( format ! ( "Invalid MIDR_EL1 found on host: {err}" , ) )
60- } ) ?;
61-
62- Ok ( manufacturer_id >> 24 )
54+ let manufacturer_id = u32:: from_str_radix ( midr_el1_trimmed, 16 ) . ok ( ) ?;
55+ Some ( manufacturer_id >> 24 )
6356}
6457
6558/// Saves states of registers into `state`.
0 commit comments