* AWS Firecracker microVMs expose /dev/vsock and report sys_vendor='Amazon EC2' * with product_name containing 'Firecracker'. Full EC2 reports a real instance * type like 't3.large', so the product_name check distinguishes them.
()
| 285 | * type like 't3.large', so the product_name check distinguishes them. |
| 286 | */ |
| 287 | function isFirecracker(): boolean { |
| 288 | if (platform() !== "linux") return false; |
| 289 | if (!existsSync("/dev/vsock")) return false; |
| 290 | try { |
| 291 | const sysVendor = readFileSync("/sys/class/dmi/id/sys_vendor", "utf-8").trim(); |
| 292 | if (sysVendor !== "Amazon EC2") return false; |
| 293 | const productName = readFileSync("/sys/class/dmi/id/product_name", "utf-8").trim(); |
| 294 | return productName.toLowerCase().includes("firecracker"); |
| 295 | } catch { |
| 296 | return false; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | function isKVM(): boolean { |
| 301 | if (platform() !== "linux") return false; |
no outgoing calls
no test coverage detected