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

David Dillow
2008-09-08T00:37:22Z

On Mon, 2008-09-08 at 07:45 +0800, Yan Li wrote:
> +int is_vmware_guest(void)
> +{
> + u32 version[3];
> +
> + getVersion(&version[0]);
> +
> + if (version[1] != BDOOR_MAGIC) {
> + /* Incorrect virtual machine version */
> + return 0;
> + }
> +
> + if (version[0] != VERSION_MAGIC) {
> + /* Incorrect version magic */
> + return 0;
> + }
> +
> + /* Yes, we are running as VMware Guest */
> + printk(KERN_INFO "vmware detected\n");
> + return 1;
> +}

If you want this to be used by more callsites, it probably doesn't make
sense to have it print out a message each time.

In fact would it make more sense to have a framework (cpu feature flag?)
to detect that we're in any virtualized environment and make this one of
the detection routines, and perhaps cache the result. Especially if this
detection would be used to manage anything near a hot-path in the page
cache as you suggested.

But maybe that's overkill.