Re: [PATCH 1/2] VMware guest detection for x86 and x86-64

H. Peter Anvin
2008-09-24T16:19:53Z

Yan Li wrote:
> Detects whether we are running as a VMware guest or not. Detection is
> based upon DMI vendor string.
>
> It provides a function:
> int is_vmware_guest(void)
> that can be used easily to detect if we are running as a VMware guest
> or not.
>
> I haven't used PCI vendor Id since that requires copying a trunk of
> codes from early_quirks() and I think copying code is not good. And
> reusing codes from early_quirks() needs intrivial change to present
> codes structure. Comparatively, checking "VMware" string against DMI
> manufacturer is a lot more simpler (one-line code). Also there's no
> evidence indicating that VMware will change their vendor string in
> near future. Therefore I choose to use simpler way.
>
> Tested on x86 and x86-64 VMs and machines.

I'd like to make this a general VM platform detection subsystem. We
have similar issues with Virtual PC, and again, DMI appears to be the
sanest way to detect it -- at least to a primary screen.

-hpa