@@ -51,28 +51,39 @@ static bool getHostVendor(FFstrbuf* vendor) {
5151
5252const char * ffDetectHost (FFHostResult * host ) {
5353 // This is a hack for Asahi Linux, whose product_family is empty
54- if (ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/product_family" , "/sys/class/dmi/id/product_family" , & host -> family )) {
55- ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/product_name" , "/sys/class/dmi/id/product_name" , & host -> name );
54+ bool productName = ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/product_name" , "/sys/class/dmi/id/product_name" , & host -> name );
55+ bool productFamily = ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/product_family" , "/sys/class/dmi/id/product_family" , & host -> family );
56+ if (productName || productFamily ) {
5657 ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/product_version" , "/sys/class/dmi/id/product_version" , & host -> version );
5758 ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/product_sku" , "/sys/class/dmi/id/product_sku" , & host -> sku );
5859 ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/product_serial" , "/sys/class/dmi/id/product_serial" , & host -> serial );
5960 ffGetSmbiosValue ("/sys/devices/virtual/dmi/id/sys_vendor" , "/sys/class/dmi/id/sys_vendor" , & host -> vendor );
61+
62+ #if __x86_64__
63+ ffHostDetectMac (host );
64+ #endif
65+
66+ // KVM/Qemu virtual machine
67+ if (ffStrbufStartsWithS (& host -> name , "Standard PC" )) {
68+ ffStrbufPrependS (& host -> name , "KVM/QEMU " );
69+ }
70+
71+ #if __aarch64__
72+ else if (host -> family .length == 0 && ffStrbufEqualS (& host -> vendor , "Apple Inc .") && ffStrbufStartsWithS (& host -> name , "Mac ")) {
73+ // Hack for Asahi Linux
74+ ffStrbufDestroy (& host -> family );
75+ ffStrbufInitMove (& host -> family , & host -> name );
76+ getHostProductName (& host -> name );
77+ getHostSerialNumber (& host -> serial );
78+ }
79+ #endif
6080 } else {
6181 getHostProductFamily (& host -> family );
6282 getHostProductName (& host -> name );
6383 getHostSerialNumber (& host -> serial );
6484 getHostVendor (& host -> vendor );
6585 }
6686
67- #ifdef __x86_64__
68- ffHostDetectMac (host );
69- #endif
70-
71- // KVM/Qemu virtual machine
72- if (ffStrbufStartsWithS (& host -> name , "Standard PC" )) {
73- ffStrbufPrependS (& host -> name , "KVM/QEMU " );
74- }
75-
7687 if (host -> family .length == 0 && host -> name .length == 0 ) {
7788 const char * wslDistroName = getenv ("WSL_DISTRO_NAME" );
7889 // On WSL, the real host can't be detected. Instead use WSL as host.
0 commit comments