在windows下识别更多虚拟机

This commit is contained in:
bin456789 2023-06-23 17:52:41 +08:00
parent 09b3111d2b
commit ef6c5f7aec
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -92,9 +92,12 @@ add_community_repo_for_alpine() {
is_virt() { is_virt() {
if is_in_windows; then if is_in_windows; then
vmstr='VMware|Virtual|BOCHS|QEMU' # https://github.com/systemd/systemd/blob/main/src/basic/virt.c
wmic ComputerSystem | grep -Eiw $vmstr && return 0 # https://sources.debian.org/src/hw-detect/1.159/hw-detect.finish-install.d/08hw-detect/
wmic bios | grep -Eiw $vmstr && return 0 vmstr='VMware|Virtual|Virtualization|VirtualBox|VMW|Hyper-V|Bochs|QEMU|KVM|OpenStack|KubeVirt|innotek|Xen|Parallels|BHYVE'
for name in ComputerSystem BIOS BaseBoard; do
wmic $name | grep -Eiw $vmstr && return 0
done
wmic /namespace:'\\root\cimv2' PATH Win32_Fan | head -1 | grep -q -v Name wmic /namespace:'\\root\cimv2' PATH Win32_Fan | head -1 | grep -q -v Name
else else
if command -v systemd-detect-virt; then if command -v systemd-detect-virt; then