[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 14/17] target-i386: Add vmare as a known name to
From: |
Don Slutz |
Subject: |
[Qemu-devel] [PATCH v7 14/17] target-i386: Add vmare as a known name to Hypervisor vendor. |
Date: |
Fri, 12 Oct 2012 15:56:19 -0400 |
Part of "target-i386: Add way to expose VMWare CPUID"
Also adds some other known names (kvm, hyperv) to Hypervisor vendor.
This allows "hypervisor-vendor=vmware3" instead of
"hypervisor-vendor=VMwareVMware,hypervisor-level=2,hypervisor-features=0".
And "hypervisor-vendor=vmware" instead of
"hypervisor-vendor=VMwareVMware,hypervisor-level=0x10,hypervisor-features=0".
This is based on:
VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
Signed-off-by: Don Slutz <address@hidden>
---
target-i386/cpu.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
target-i386/cpu.h | 9 ++++++++
2 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f058add..c8466ec 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1203,6 +1203,23 @@ static char *x86_cpuid_get_hv_vendor(Object *obj, Error
**errp)
}
value[CPUID_VENDOR_SZ] = '\0';
+ /* Convert known names */
+ if (!strcmp(value, CPUID_HV_VENDOR_HYPERV) &&
+ env->cpuid_hv_level == CPUID_HV_LEVEL_HYPERV_CPUID_MIN &&
+ env->cpuid_hv_features_set == CPUID_HV_FEATURES_HYPERV) {
+ pstrcpy(value, sizeof(value), "hyperv");
+ } else if (!strcmp(value, CPUID_HV_VENDOR_VMWARE) &&
+ env->cpuid_hv_features_set == CPUID_HV_FEATURES_VMWARE) {
+ if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_4) {
+ pstrcpy(value, sizeof(value), "vmware4");
+ } else if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_3) {
+ pstrcpy(value, sizeof(value), "vmware3");
+ }
+ } else if (!strcmp(value, CPUID_HV_VENDOR_KVM) &&
+ (env->cpuid_hv_level == CPUID_HV_LEVEL_KVM_0 ||
+ env->cpuid_hv_level == CPUID_HV_LEVEL_KVM_1)) {
+ pstrcpy(value, sizeof(value), "kvm");
+ }
return value;
}
@@ -1216,7 +1233,46 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const
char *value,
memset(adj_value, 0, sizeof(adj_value));
- pstrcpy(adj_value, sizeof(adj_value), value);
+ /* Convert known names */
+ if (!strcmp(value, "hyperv")) {
+ if (!env->cpuid_hv_level_set) {
+ object_property_set_int(obj, CPUID_HV_LEVEL_HYPERV_CPUID_MIN,
+ "hypervisor-level", errp);
+ }
+ if (!env->cpuid_hv_features_set) {
+ object_property_set_int(obj, CPUID_HV_FEATURES_HYPERV,
+ "hypervisor-features", errp);
+ }
+ pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_HYPERV);
+ } else if (!strcmp(value, "vmware") || !strcmp(value, "vmware4")) {
+ if (!env->cpuid_hv_level_set) {
+ object_property_set_int(obj, CPUID_HV_LEVEL_VMWARE_4,
+ "hypervisor-level", errp);
+ }
+ if (!env->cpuid_hv_features_set) {
+ object_property_set_int(obj, CPUID_HV_FEATURES_VMWARE,
+ "hypervisor-features", errp);
+ }
+ pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE);
+ } else if (!strcmp(value, "vmware3")) {
+ if (!env->cpuid_hv_level_set) {
+ object_property_set_int(obj, CPUID_HV_LEVEL_VMWARE_3,
+ "hypervisor-level", errp);
+ }
+ if (!env->cpuid_hv_features_set) {
+ object_property_set_int(obj, CPUID_HV_FEATURES_VMWARE,
+ "hypervisor-features", errp);
+ }
+ pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE);
+ } else if (!strcmp(value, "kvm")) {
+ if (!env->cpuid_hv_level_set) {
+ object_property_set_int(obj, CPUID_HV_LEVEL_KVM_1,
+ "hypervisor-level", errp);
+ }
+ pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_KVM);
+ } else {
+ pstrcpy(adj_value, sizeof(adj_value), value);
+ }
env->cpuid_hv_vendor1 = 0;
env->cpuid_hv_vendor2 = 0;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 6ceef05..a387d82 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -498,6 +498,15 @@
#define CPUID_HV_VENDOR_HYPERV "Microsoft Hv"
#define CPUID_HV_FEATURES_HYPERV 0x31237648 /* "Hv#1" */
+#define CPUID_HV_LEVEL_VMWARE_3 0x40000002
+#define CPUID_HV_LEVEL_VMWARE_4 0x40000010
+#define CPUID_HV_VENDOR_VMWARE "VMwareVMware"
+#define CPUID_HV_FEATURES_VMWARE 0
+
+#define CPUID_HV_LEVEL_KVM_0 0
+#define CPUID_HV_LEVEL_KVM_1 0x40000001
+#define CPUID_HV_VENDOR_KVM "KVMKVMKVM"
+
#define CPUID_MWAIT_IBE (1 << 1) /* Interrupts can exit capability */
#define CPUID_MWAIT_EMX (1 << 0) /* enumeration supported */
--
1.7.1
- [Qemu-devel] [PATCH v7 07/17] target-i386: Add x86_set_hyperv., (continued)
- [Qemu-devel] [PATCH v7 07/17] target-i386: Add x86_set_hyperv., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 08/17] target-i386: Use x86_set_hyperv to set hypervisor vendor., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 09/17] target-i386: Use x86_set_hyperv to set hypervisor features., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 10/17] target-i386: Use Hypervisor level in -machine pc, accel=kvm., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 11/17] target-i386: Use Hypervisor vendor in -machine pc, accel=kvm., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 15/17] target-i386: Use Hypervisor level in -machine pc, accel=tcg., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 17/17] target-i386: target-i386: Add VMWare CPUID Timing information in -machine pc, accel=tcg, Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 12/17] target-i386: Use Hypervisor features in -machine pc, accel=kvm., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 13/17] target-i386: Add VMWare CPUID Timing information in -machine pc, accel=kvm., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 16/17] target-i386: Use Hypervisor vendor in -machine pc, accel=tcg., Don Slutz, 2012/10/12
- [Qemu-devel] [PATCH v7 14/17] target-i386: Add vmare as a known name to Hypervisor vendor.,
Don Slutz <=
- Re: [Qemu-devel] [PATCH v7 00/17] target-i386: Add way to expose VMWare CPUID, Marcelo Tosatti, 2012/10/29