Re: [PATCH 1/2] VMware detection support for x86 and x86-64
From: David Dillow
Date: Sun Sep 07 2008 - 20:37:23 EST
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/