File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
bin/propolis-utils/src/bin Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,35 @@ fn print_json(results: &BTreeMap<CpuidKey, Cpuid>) {
267267 Cpuid , CpuidEntry ,
268268 } ;
269269
270+ let vendor = {
271+ use propolis_api_types:: instance_spec:: { CpuidValues , CpuidVendor } ;
272+ match results. get ( & CpuidKey :: Leaf ( 0 ) ) {
273+ None => {
274+ eprintln ! ( "no result for leaf 0, selecting default vendor" ) ;
275+ CpuidVendor :: Amd
276+ }
277+ Some ( values) => {
278+ let values = CpuidValues {
279+ eax : values. eax ,
280+ ebx : values. ebx ,
281+ ecx : values. ecx ,
282+ edx : values. edx ,
283+ } ;
284+
285+ match CpuidVendor :: try_from ( values) {
286+ Err ( _) => {
287+ eprintln ! (
288+ "vendor in leaf 0 values ({values:?}) \
289+ not recognized, selecting default vendor"
290+ ) ;
291+ CpuidVendor :: Amd
292+ }
293+ Ok ( v) => v,
294+ }
295+ }
296+ }
297+ } ;
298+
270299 // Returns `true` if `key` has subleaf data and its leaf index is `leaf`.
271300 fn key_matches_leaf_and_has_subleaves ( key : & CpuidKey , leaf : u32 ) -> bool {
272301 let CpuidKey :: SubLeaf ( l, _) = key else {
@@ -307,7 +336,7 @@ fn print_json(results: &BTreeMap<CpuidKey, Cpuid>) {
307336 } )
308337 } )
309338 . collect ( ) ,
310- vendor : propolis_api_types :: instance_spec :: CpuidVendor :: Amd ,
339+ vendor,
311340 } ;
312341
313342 println ! ( "{}" , serde_json:: to_string_pretty( & cpuid) . unwrap( ) ) ;
You can’t perform that action at this time.
0 commit comments