Skip to contentSkip to conversation

eal/x86: get hypervisor name

PATCH Superseded Thomas Monjalon 4 participants 16 messages Nov 30, 2017 – Jan 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal/x86: get hypervisor name

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

---
warning: to be tested

---
 lib/librte_eal/common/arch/arm/rte_cpuflags.c      |  6 +++++
 lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c   |  6 +++++
 lib/librte_eal/common/arch/x86/rte_cpuflags.c      | 30 ++++++++++++++++++++++
 .../common/include/arch/x86/rte_cpuflags.h         |  1 +
 .../common/include/generic/rte_cpuflags.h          | 14 ++++++++++
 lib/librte_eal/rte_eal_version.map                 |  9 ++++++-
 6 files changed, 65 insertions(+), 1 deletion(-)
lib/librte_eal/common/arch/arm/rte_cpuflags.c +6 -0
index 88f1cbe37..f1f0cb51d 100644
@@ -178,3 +178,9 @@ rte_cpu_get_flag_name(enum rte_cpu_flag_t feature)
 		return NULL;
 	return rte_cpu_feature_table[feature].name;
 }
+
+enum rte_hypervisor
+rte_hypervisor_get_name(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +6 -0
index 970a61c5e..b905cbd2c 100644
@@ -146,3 +146,9 @@ rte_cpu_get_flag_name(enum rte_cpu_flag_t feature)
 		return NULL;
 	return rte_cpu_feature_table[feature].name;
 }
+
+enum rte_hypervisor
+rte_hypervisor_get_name(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/arch/x86/rte_cpuflags.c +30 -0
index 7d4a0fefb..76893b8f1 100644
@@ -34,6 +34,7 @@
 #include "rte_cpuflags.h"
 
 #include <stdio.h>
+#include <string.h>
 #include <errno.h>
 #include <stdint.h>
 #include <cpuid.h>
@@ -92,6 +93,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(AVX, 0x00000001, 0, RTE_REG_ECX, 28)
 	FEAT_DEF(F16C, 0x00000001, 0, RTE_REG_ECX, 29)
 	FEAT_DEF(RDRAND, 0x00000001, 0, RTE_REG_ECX, 30)
+	FEAT_DEF(HYPERVISOR, 0x00000001, 0, RTE_REG_ECX, 31)
 
 	FEAT_DEF(FPU, 0x00000001, 0, RTE_REG_EDX,  0)
 	FEAT_DEF(VME, 0x00000001, 0, RTE_REG_EDX,  1)
@@ -194,3 +196,31 @@ rte_cpu_get_flag_name(enum rte_cpu_flag_t feature)
 		return NULL;
 	return rte_cpu_feature_table[feature].name;
 }
+
+/* See http://lwn.net/Articles/301888/ */
+#define HYPERVISOR_INFO_LEAF 0x40000000
+
+enum rte_hypervisor
+rte_hypervisor_get_name(void)
+{
+	cpuid_registers_t regs;
+	char name[13];
+
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_HYPERVISOR))
+		return RTE_HYPERVISOR_NONE;
+
+	__cpuid(HYPERVISOR_INFO_LEAF,
+			regs[RTE_REG_EAX], regs[RTE_REG_EBX],
+			regs[RTE_REG_ECX], regs[RTE_REG_EDX]);
+	for (int reg = 1; reg < 4; reg++)
+		memcpy(name + (reg - 1) * 4, &regs[reg], 4);
+	name[12] = '\0';
+
+	if (strcmp("KVMKVMKVM", name) == 0)
+		return RTE_HYPERVISOR_KVM;
+	if (strcmp("Microsoft Hv", name) == 0)
+		return RTE_HYPERVISOR_HYPERV;
+	if (strcmp("VMwareVMware", name) == 0)
+		return RTE_HYPERVISOR_VMWARE;
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/include/arch/x86/rte_cpuflags.h +1 -0
index 26204fabb..686ac07f3 100644
@@ -69,6 +69,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_AVX,                    /**< AVX */
 	RTE_CPUFLAG_F16C,                   /**< F16C */
 	RTE_CPUFLAG_RDRAND,                 /**< RDRAND */
+	RTE_CPUFLAG_HYPERVISOR,             /**< Running on a hypervisor */
 
 	/* (EAX 01h) EDX features */
 	RTE_CPUFLAG_FPU,                    /**< FPU */
lib/librte_eal/common/include/generic/rte_cpuflags.h +14 -0
index c1c5551fc..3832fb851 100644
@@ -93,4 +93,18 @@ rte_cpu_check_supported(void);
 int
 rte_cpu_is_supported(void);
 
+enum rte_hypervisor {
+	RTE_HYPERVISOR_NONE,
+	RTE_HYPERVISOR_KVM,
+	RTE_HYPERVISOR_HYPERV,
+	RTE_HYPERVISOR_VMWARE,
+	RTE_HYPERVISOR_UNKNOWN
+};
+
+/**
+ * Get the type of hypervisor it is running on.
+ */
+enum rte_hypervisor
+rte_hypervisor_get_name(void);
+
 #endif /* _RTE_CPUFLAGS_H_ */
lib/librte_eal/rte_eal_version.map +8 -1
index f4f46c1be..3f8d81577 100644
@@ -200,6 +200,13 @@ DPDK_17.11 {
 
 } DPDK_17.08;
 
+DPDK_18.02 {
+	global:
+
+	rte_hypervisor_get_name;
+
+} DPDK_17.11;
+
 EXPERIMENTAL {
 	global:
 
@@ -235,4 +242,4 @@ EXPERIMENTAL {
 	rte_service_set_stats_enable;
 	rte_service_start_with_defaults;
 
-} DPDK_17.11;
+} DPDK_18.02;
Signature · 1 line
2.15.0
#1 lore raw

lib/librte_eal/common/arch/x86/rte_cpuflags.c rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) · line 217

Quoted 3 lines · On Thu, 30 Nov 2017 22:47:20 +0100 Thomas Monjalon <[email protected]> wrote:
lib/librte_eal/common/arch/x86/rte_cpuflags.c +3 -0
+	for (int reg = 1; reg < 4; reg++)
+		memcpy(name + (reg - 1) * 4, &regs[reg], 4);
+	name[12] = '\0';

C99 style declarations are not generally used in DPDK.

#2 lore raw

30/11/2017 22:55, Stephen Hemminger:

Quoted 8 lines

lib/librte_eal/common/arch/x86/rte_cpuflags.c rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) · line 217

Quoted 3 lines · On Thu, 30 Nov 2017 22:47:20 +0100 Thomas Monjalon <[email protected]> wrote:
lib/librte_eal/common/arch/x86/rte_cpuflags.c +3 -0
+	for (int reg = 1; reg < 4; reg++)
+		memcpy(name + (reg - 1) * 4, &regs[reg], 4);
+	name[12] = '\0';

C99 style declarations are not generally used in DPDK.

True :)
It will be fixed in v2.

I think I should add a log somewhere at initialization in order to test this function.
Do you think it deserves a table of name strings in the .h?

#3 lore raw
Quoted 10 lines · On Thu, 30 Nov 2017 23:03:57 +0100 Thomas Monjalon <[email protected]> wrote:

30/11/2017 22:55, Stephen Hemminger:

Quoted 8 lines

lib/librte_eal/common/arch/x86/rte_cpuflags.c rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) · line 217

Quoted 3 lines · On Thu, 30 Nov 2017 22:47:20 +0100 Thomas Monjalon <[email protected]> wrote:
lib/librte_eal/common/arch/x86/rte_cpuflags.c +3 -0
+	for (int reg = 1; reg < 4; reg++)
+		memcpy(name + (reg - 1) * 4, &regs[reg], 4);
+	name[12] = '\0';  

C99 style declarations are not generally used in DPDK.

Quoted 6 lines

True :)
It will be fixed in v2.

I think I should add a log somewhere at initialization in order to test this function.
Do you think it deserves a table of name strings in the .h?

Same table is short-listed in util-linux (lscpu). You might also want to handle Xen, Xen PV, VirtualBox, Windows and WSL at some point.

#4 lore raw
In reply to Thomas Monjalon

-----Original Message-----

Quoted 33 lines

Date: Thu, 30 Nov 2017 22:47:20 +0100
From: Thomas Monjalon <[email protected]>
To: [email protected]
Subject: [dpdk-dev] [PATCH] eal/x86: get hypervisor name
X-Mailer: git-send-email 2.15.0

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

---
warning: to be tested

---
 lib/librte_eal/common/arch/arm/rte_cpuflags.c      |  6 +++++
 lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c   |  6 +++++
 lib/librte_eal/common/arch/x86/rte_cpuflags.c      | 30 ++++++++++++++++++++++
 .../common/include/arch/x86/rte_cpuflags.h         |  1 +
 .../common/include/generic/rte_cpuflags.h          | 14 ++++++++++
 lib/librte_eal/rte_eal_version.map                 |  9 ++++++-
 6 files changed, 65 insertions(+), 1 deletion(-)
lib/librte_eal/common/include/arch/x86/rte_cpuflags.h +0 -0
 	RTE_CPUFLAG_FPU,                    /**< FPU */
lib/librte_eal/common/include/generic/rte_cpuflags.h +3 -0
index c1c5551fc..3832fb851 100644
@@ -93,4 +93,18 @@ rte_cpu_check_supported(void);
 int
 rte_cpu_is_supported(void);
 
+enum rte_hypervisor {
+	RTE_HYPERVISOR_NONE,
+	RTE_HYPERVISOR_KVM,

lib/librte_eal/common/include/generic/rte_cpuflags.h rte_cpu_check_supported(void); · line 108

Quoted 10 lines
lib/librte_eal/common/include/generic/rte_cpuflags.h +10 -0
+	RTE_HYPERVISOR_HYPERV,
+	RTE_HYPERVISOR_VMWARE,
+	RTE_HYPERVISOR_UNKNOWN
+};
+
+/**
+ * Get the type of hypervisor it is running on.
+ */
+enum rte_hypervisor
+rte_hypervisor_get_name(void);

IMO, cpu_flag area is the not the correct abstraction to get the hypervisor name. It is x86 specific. I think, correct usage will be to call hypervisor specific APIs like KVM_GET_API_VERSION
https://lwn.net/Articles/658511/

BTW, What is the need for an DPDK application to know the hypervisor name? What action an DPDK application should take based on hypervisor name? if is not interest of data plane application why it needs to be abstracted in DPDK?

#5 lore raw

01/12/2017 09:12, Jerin Jacob:

Quoted 47 lines

-----Original Message-----

Quoted 33 lines

Date: Thu, 30 Nov 2017 22:47:20 +0100
From: Thomas Monjalon <[email protected]>
To: [email protected]
Subject: [dpdk-dev] [PATCH] eal/x86: get hypervisor name
X-Mailer: git-send-email 2.15.0

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

---
warning: to be tested

---
 lib/librte_eal/common/arch/arm/rte_cpuflags.c      |  6 +++++
 lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c   |  6 +++++
 lib/librte_eal/common/arch/x86/rte_cpuflags.c      | 30 ++++++++++++++++++++++
 .../common/include/arch/x86/rte_cpuflags.h         |  1 +
 .../common/include/generic/rte_cpuflags.h          | 14 ++++++++++
 lib/librte_eal/rte_eal_version.map                 |  9 ++++++-
 6 files changed, 65 insertions(+), 1 deletion(-)
lib/librte_eal/common/include/arch/x86/rte_cpuflags.h +0 -0
 	RTE_CPUFLAG_FPU,                    /**< FPU */
lib/librte_eal/common/include/generic/rte_cpuflags.h +3 -0
index c1c5551fc..3832fb851 100644
@@ -93,4 +93,18 @@ rte_cpu_check_supported(void);
 int
 rte_cpu_is_supported(void);
 
+enum rte_hypervisor {
+	RTE_HYPERVISOR_NONE,
+	RTE_HYPERVISOR_KVM,

lib/librte_eal/common/include/generic/rte_cpuflags.h rte_cpu_check_supported(void); · line 108

Quoted 10 lines
lib/librte_eal/common/include/generic/rte_cpuflags.h +10 -0
+	RTE_HYPERVISOR_HYPERV,
+	RTE_HYPERVISOR_VMWARE,
+	RTE_HYPERVISOR_UNKNOWN
+};
+
+/**
+ * Get the type of hypervisor it is running on.
+ */
+enum rte_hypervisor
+rte_hypervisor_get_name(void);
Quoted 4 lines

IMO, cpu_flag area is the not the correct abstraction to get the hypervisor name. It is x86 specific. I think, correct usage will be to call hypervisor specific APIs like KVM_GET_API_VERSION
https://lwn.net/Articles/658511/

I think it is quite logical because the CPU is virtualized by the hypervisor. It is similar to get the CPU model, but for a different ring level.

Quoted 4 lines

BTW, What is the need for an DPDK application to know the hypervisor name? What action an DPDK application should take based on hypervisor name? if is not interest of data plane application why it needs to be abstracted in DPDK?

I see two usages for now.
We can automate the use of the specific VMware TSC (it is an option currently). We can adapt the device management policy on Hyper-V without waiting a device scan.

#6 lore raw

-----Original Message-----

Quoted 54 lines

Date: Fri, 01 Dec 2017 09:52:26 +0100
From: Thomas Monjalon <[email protected]>
To: Jerin Jacob <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [dpdk-dev] [PATCH] eal/x86: get hypervisor name

01/12/2017 09:12, Jerin Jacob:

Quoted 47 lines

-----Original Message-----

Quoted 33 lines

Date: Thu, 30 Nov 2017 22:47:20 +0100
From: Thomas Monjalon <[email protected]>
To: [email protected]
Subject: [dpdk-dev] [PATCH] eal/x86: get hypervisor name
X-Mailer: git-send-email 2.15.0

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

---
warning: to be tested

---
 lib/librte_eal/common/arch/arm/rte_cpuflags.c      |  6 +++++
 lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c   |  6 +++++
 lib/librte_eal/common/arch/x86/rte_cpuflags.c      | 30 ++++++++++++++++++++++
 .../common/include/arch/x86/rte_cpuflags.h         |  1 +
 .../common/include/generic/rte_cpuflags.h          | 14 ++++++++++
 lib/librte_eal/rte_eal_version.map                 |  9 ++++++-
 6 files changed, 65 insertions(+), 1 deletion(-)
lib/librte_eal/common/include/arch/x86/rte_cpuflags.h +0 -0
 	RTE_CPUFLAG_FPU,                    /**< FPU */
lib/librte_eal/common/include/generic/rte_cpuflags.h +3 -0
index c1c5551fc..3832fb851 100644
@@ -93,4 +93,18 @@ rte_cpu_check_supported(void);
 int
 rte_cpu_is_supported(void);
 
+enum rte_hypervisor {
+	RTE_HYPERVISOR_NONE,
+	RTE_HYPERVISOR_KVM,

lib/librte_eal/common/include/generic/rte_cpuflags.h rte_cpu_check_supported(void); · line 108

Quoted 10 lines
lib/librte_eal/common/include/generic/rte_cpuflags.h +10 -0
+	RTE_HYPERVISOR_HYPERV,
+	RTE_HYPERVISOR_VMWARE,
+	RTE_HYPERVISOR_UNKNOWN
+};
+
+/**
+ * Get the type of hypervisor it is running on.
+ */
+enum rte_hypervisor
+rte_hypervisor_get_name(void);
Quoted 7 lines
Quoted 4 lines

IMO, cpu_flag area is the not the correct abstraction to get the hypervisor name. It is x86 specific. I think, correct usage will be to call hypervisor specific APIs like KVM_GET_API_VERSION
https://lwn.net/Articles/658511/

I think it is quite logical because the CPU is virtualized by the hypervisor. It is similar to get the CPU model, but for a different ring level.

At least on non x86, it is not exposed as CPU flags. IMO, *hypervisor*.h file makes more sense rather than rte_cpuflags.h.

Quoted 8 lines
Quoted 5 lines

BTW, What is the need for an DPDK application to know the hypervisor name? What action an DPDK application should take based on hypervisor name? if is not interest of data plane application why it needs to be abstracted in DPDK?

I see two usages for now.
We can automate the use of the specific VMware TSC (it is an option currently).

In my view this use case needed by the DPDK "implementation" not the "application". So internal API makes more sense to me.

Quoted 1 line

We can adapt the device management policy on Hyper-V without waiting a device scan.

I am not sure about this? Looks like a candidate for library implementation not for the "application"

#7 lore raw

PATCH v2 1/1 eal/x86: get hypervisor name

In reply to Thomas Monjalon

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

---
v2 changes:
- remove C99 style declaration
- move code in rte_hypervisor.* files
- add a function to get the name string

---
 lib/librte_eal/bsdapp/eal/Makefile                 |  2 ++
 lib/librte_eal/common/Makefile                     |  2 +-
 lib/librte_eal/common/arch/arm/rte_hypervisor.c    | 11 ++++++
 lib/librte_eal/common/arch/ppc_64/rte_hypervisor.c | 11 ++++++
 lib/librte_eal/common/arch/x86/rte_cpuflags.c      | 11 ++----
 lib/librte_eal/common/arch/x86/rte_cpuid.h         | 19 ++++++++++
 lib/librte_eal/common/arch/x86/rte_hypervisor.c    | 40 ++++++++++++++++++++++
 lib/librte_eal/common/eal_common_hypervisor.c      | 22 ++++++++++++
 .../common/include/arch/x86/rte_cpuflags.h         |  1 +
 lib/librte_eal/common/include/rte_hypervisor.h     | 33 ++++++++++++++++++
 lib/librte_eal/linuxapp/eal/Makefile               |  2 ++
 lib/librte_eal/rte_eal_version.map                 | 10 +++++-
 12 files changed, 153 insertions(+), 11 deletions(-)
 create mode 100644 lib/librte_eal/common/arch/arm/rte_hypervisor.c
 create mode 100644 lib/librte_eal/common/arch/ppc_64/rte_hypervisor.c
 create mode 100644 lib/librte_eal/common/arch/x86/rte_cpuid.h
 create mode 100644 lib/librte_eal/common/arch/x86/rte_hypervisor.c
 create mode 100644 lib/librte_eal/common/eal_common_hypervisor.c
 create mode 100644 lib/librte_eal/common/include/rte_hypervisor.h
lib/librte_eal/bsdapp/eal/Makefile +2 -0
index afa117de4..d0c943d4e 100644
@@ -71,6 +71,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_tailqs.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_errno.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_hypervisor.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_string_fns.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_devargs.c
@@ -87,6 +88,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_service.c
 
 # from arch dir
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_hypervisor.c
 SRCS-$(CONFIG_RTE_ARCH_X86) += rte_spinlock.c
 SRCS-y += rte_cycles.c
 
lib/librte_eal/common/Makefile +1 -1
index 9effd0d45..f7c9ed952 100644
@@ -43,7 +43,7 @@ INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h
 INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h
 INC += rte_malloc.h rte_keepalive.h rte_time.h
 INC += rte_service.h rte_service_component.h
-INC += rte_bitmap.h rte_vfio.h
+INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h
 
 GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h
 GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +11 -0
new file mode 100644
index 000000000..3792fe2ce
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/arch/ppc_64/rte_hypervisor.c new file +11 -0
new file mode 100644
index 000000000..3792fe2ce
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/arch/x86/rte_cpuflags.c +2 -9
index 7d4a0fefb..c33cd8779 100644
@@ -36,16 +36,8 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
-#include <cpuid.h>
 
-enum cpu_register_t {
-	RTE_REG_EAX = 0,
-	RTE_REG_EBX,
-	RTE_REG_ECX,
-	RTE_REG_EDX,
-};
-
-typedef uint32_t cpuid_registers_t[4];
+#include "rte_cpuid.h"
 
 /**
  * Struct to hold a processor feature entry
@@ -92,6 +84,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(AVX, 0x00000001, 0, RTE_REG_ECX, 28)
 	FEAT_DEF(F16C, 0x00000001, 0, RTE_REG_ECX, 29)
 	FEAT_DEF(RDRAND, 0x00000001, 0, RTE_REG_ECX, 30)
+	FEAT_DEF(HYPERVISOR, 0x00000001, 0, RTE_REG_ECX, 31)
 
 	FEAT_DEF(FPU, 0x00000001, 0, RTE_REG_EDX,  0)
 	FEAT_DEF(VME, 0x00000001, 0, RTE_REG_EDX,  1)
lib/librte_eal/common/arch/x86/rte_cpuid.h new file +19 -0
new file mode 100644
index 000000000..b773ad931
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation
+ */
+
+#ifndef RTE_CPUID_H
+#define RTE_CPUID_H
+
+#include <cpuid.h>
+
+enum cpu_register_t {
+	RTE_REG_EAX = 0,
+	RTE_REG_EBX,
+	RTE_REG_ECX,
+	RTE_REG_EDX,
+};
+
+typedef uint32_t cpuid_registers_t[4];
+
+#endif /* RTE_CPUID_H */
lib/librte_eal/common/arch/x86/rte_hypervisor.c new file +40 -0
new file mode 100644
index 000000000..edf07be18
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "rte_cpuflags.h"
+#include "rte_cpuid.h"
+
+/* See http://lwn.net/Articles/301888/ */
+#define HYPERVISOR_INFO_LEAF 0x40000000
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	cpuid_registers_t regs;
+	int reg;
+	char name[13];
+
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_HYPERVISOR))
+		return RTE_HYPERVISOR_NONE;
+
+	__cpuid(HYPERVISOR_INFO_LEAF,
+			regs[RTE_REG_EAX], regs[RTE_REG_EBX],
+			regs[RTE_REG_ECX], regs[RTE_REG_EDX]);
+	for (reg = 1; reg < 4; reg++)
+		memcpy(name + (reg - 1) * 4, &regs[reg], 4);
+	name[12] = '\0';
+
+	if (strcmp("KVMKVMKVM", name) == 0)
+		return RTE_HYPERVISOR_KVM;
+	if (strcmp("Microsoft Hv", name) == 0)
+		return RTE_HYPERVISOR_HYPERV;
+	if (strcmp("VMwareVMware", name) == 0)
+		return RTE_HYPERVISOR_VMWARE;
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/eal_common_hypervisor.c new file +22 -0
new file mode 100644
index 000000000..c3b4c621b
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+const char *
+rte_hypervisor_get_name(enum rte_hypervisor id)
+{
+	switch (id) {
+	case RTE_HYPERVISOR_NONE:
+		return "none";
+	case RTE_HYPERVISOR_KVM:
+		return "KVM";
+	case RTE_HYPERVISOR_HYPERV:
+		return "Hyper-V";
+	case RTE_HYPERVISOR_VMWARE:
+		return "VMware";
+	default:
+		return "unknown";
+	}
+}
lib/librte_eal/common/include/arch/x86/rte_cpuflags.h +1 -0
index 26204fabb..686ac07f3 100644
@@ -69,6 +69,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_AVX,                    /**< AVX */
 	RTE_CPUFLAG_F16C,                   /**< F16C */
 	RTE_CPUFLAG_RDRAND,                 /**< RDRAND */
+	RTE_CPUFLAG_HYPERVISOR,             /**< Running on a hypervisor */
 
 	/* (EAX 01h) EDX features */
 	RTE_CPUFLAG_FPU,                    /**< FPU */
lib/librte_eal/common/include/rte_hypervisor.h new file +33 -0
new file mode 100644
index 000000000..8d8aac744
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#ifndef RTE_HYPERVISOR_H
+#define RTE_HYPERVISOR_H
+
+/**
+ * @file
+ * Hypervisor awareness.
+ */
+
+enum rte_hypervisor {
+	RTE_HYPERVISOR_NONE,
+	RTE_HYPERVISOR_KVM,
+	RTE_HYPERVISOR_HYPERV,
+	RTE_HYPERVISOR_VMWARE,
+	RTE_HYPERVISOR_UNKNOWN
+};
+
+/**
+ * Get the id of hypervisor it is running on.
+ */
+enum rte_hypervisor
+rte_hypervisor_get(void);
+
+/**
+ * Get the name of a given hypervisor id.
+ */
+const char *
+rte_hypervisor_get_name(enum rte_hypervisor id);
+
+#endif /* RTE_HYPERVISOR_H */
lib/librte_eal/linuxapp/eal/Makefile +2 -0
index 5a7b8b2ac..257b10d5e 100644
@@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_tailqs.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_errno.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_hypervisor.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_string_fns.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_devargs.c
@@ -94,6 +95,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_service.c
 
 # from arch dir
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_hypervisor.c
 SRCS-$(CONFIG_RTE_ARCH_X86) += rte_spinlock.c
 SRCS-y += rte_cycles.c
 
lib/librte_eal/rte_eal_version.map +9 -1
index f4f46c1be..b3dc5a746 100644
@@ -200,6 +200,14 @@ DPDK_17.11 {
 
 } DPDK_17.08;
 
+DPDK_18.02 {
+	global:
+
+	rte_hypervisor_get;
+	rte_hypervisor_get_name;
+
+} DPDK_17.11;
+
 EXPERIMENTAL {
 	global:
 
@@ -235,4 +243,4 @@ EXPERIMENTAL {
 	rte_service_set_stats_enable;
 	rte_service_start_with_defaults;
 
-} DPDK_17.11;
+} DPDK_18.02;
Signature · 1 line
2.15.1
Acked-by on v2 1/1
#8 lore raw

-----Original Message-----

Quoted 13 lines

Date: Sat, 30 Dec 2017 23:47:23 +0100
From: Thomas Monjalon <[email protected]>
To: [email protected]
Cc: Stephen Hemminger <[email protected]>, Jerin Jacob
<[email protected]>
Subject: [PATCH v2] eal/x86: get hypervisor name
X-Mailer: git-send-email 2.15.1

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

Quoted 7 lines

---
v2 changes:
- remove C99 style declaration
- move code in rte_hypervisor.* files
- add a function to get the name string

From the new API change perspective,

#9 lore raw
In reply to Thomas Monjalon
Quoted 10 lines · On Sat, 30 Dec 2017 23:47:23 +0100 Thomas Monjalon <[email protected]> wrote:

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

---
v2 changes:
- remove C99 style declaration
- move code in rte_hypervisor.* files
- add a function to get the name string

Looks good to me.
What about Xen?

#10 lore raw

02/01/2018 17:34, Stephen Hemminger:

Quoted 14 lines
Quoted 10 lines · On Sat, 30 Dec 2017 23:47:23 +0100 Thomas Monjalon <[email protected]> wrote:

The CPUID instruction is catched by hypervisor which can return a flag indicating one is running, and its name.

---
v2 changes:
- remove C99 style declaration
- move code in rte_hypervisor.* files
- add a function to get the name string

Quoted 2 lines

Looks good to me.
What about Xen?

Xen is not supported in DPDK currently.
So it will be handled as "unknown".
Xen awareness can be added later with some driver support.

#11 lore raw

PATCH v3 1/1 eal/x86: get hypervisor name

In reply to Thomas Monjalon

The CPUID instruction is caught by hypervisor which can return a flag indicating one is running, and its name.

---
v3 changes:
- better CPUID flag description
v2 changes:
- remove C99 style declaration
- move code in rte_hypervisor.* files
- add a function to get the name string

---
 lib/librte_eal/bsdapp/eal/Makefile                 |  2 ++
 lib/librte_eal/common/Makefile                     |  2 +-
 lib/librte_eal/common/arch/arm/rte_hypervisor.c    | 11 ++++++
 lib/librte_eal/common/arch/ppc_64/rte_hypervisor.c | 11 ++++++
 lib/librte_eal/common/arch/x86/rte_cpuflags.c      | 11 ++----
 lib/librte_eal/common/arch/x86/rte_cpuid.h         | 19 ++++++++++
 lib/librte_eal/common/arch/x86/rte_hypervisor.c    | 40 ++++++++++++++++++++++
 lib/librte_eal/common/eal_common_hypervisor.c      | 22 ++++++++++++
 .../common/include/arch/x86/rte_cpuflags.h         |  1 +
 lib/librte_eal/common/include/rte_hypervisor.h     | 33 ++++++++++++++++++
 lib/librte_eal/linuxapp/eal/Makefile               |  2 ++
 lib/librte_eal/rte_eal_version.map                 | 10 +++++-
 12 files changed, 153 insertions(+), 11 deletions(-)
 create mode 100644 lib/librte_eal/common/arch/arm/rte_hypervisor.c
 create mode 100644 lib/librte_eal/common/arch/ppc_64/rte_hypervisor.c
 create mode 100644 lib/librte_eal/common/arch/x86/rte_cpuid.h
 create mode 100644 lib/librte_eal/common/arch/x86/rte_hypervisor.c
 create mode 100644 lib/librte_eal/common/eal_common_hypervisor.c
 create mode 100644 lib/librte_eal/common/include/rte_hypervisor.h
lib/librte_eal/bsdapp/eal/Makefile +2 -0
index 3c3407b78..c6940760f 100644
@@ -43,6 +43,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_tailqs.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_errno.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_hypervisor.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_string_fns.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_devargs.c
@@ -59,6 +60,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_service.c
 
 # from arch dir
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_hypervisor.c
 SRCS-$(CONFIG_RTE_ARCH_X86) += rte_spinlock.c
 SRCS-y += rte_cycles.c
 
lib/librte_eal/common/Makefile +1 -1
index f37b9d866..a0eaeed78 100644
@@ -15,7 +15,7 @@ INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h
 INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h
 INC += rte_malloc.h rte_keepalive.h rte_time.h
 INC += rte_service.h rte_service_component.h
-INC += rte_bitmap.h rte_vfio.h
+INC += rte_bitmap.h rte_vfio.h rte_hypervisor.h
 
 GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h
 GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +11 -0
new file mode 100644
index 000000000..3792fe2ce
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/arch/ppc_64/rte_hypervisor.c new file +11 -0
new file mode 100644
index 000000000..3792fe2ce
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/arch/x86/rte_cpuflags.c +2 -9
index 2df58a917..053612d6f 100644
@@ -7,16 +7,8 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
-#include <cpuid.h>
 
-enum cpu_register_t {
-	RTE_REG_EAX = 0,
-	RTE_REG_EBX,
-	RTE_REG_ECX,
-	RTE_REG_EDX,
-};
-
-typedef uint32_t cpuid_registers_t[4];
+#include "rte_cpuid.h"
 
 /**
  * Struct to hold a processor feature entry
@@ -63,6 +55,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(AVX, 0x00000001, 0, RTE_REG_ECX, 28)
 	FEAT_DEF(F16C, 0x00000001, 0, RTE_REG_ECX, 29)
 	FEAT_DEF(RDRAND, 0x00000001, 0, RTE_REG_ECX, 30)
+	FEAT_DEF(HYPERVISOR, 0x00000001, 0, RTE_REG_ECX, 31)
 
 	FEAT_DEF(FPU, 0x00000001, 0, RTE_REG_EDX,  0)
 	FEAT_DEF(VME, 0x00000001, 0, RTE_REG_EDX,  1)
lib/librte_eal/common/arch/x86/rte_cpuid.h new file +19 -0
new file mode 100644
index 000000000..b773ad931
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation
+ */
+
+#ifndef RTE_CPUID_H
+#define RTE_CPUID_H
+
+#include <cpuid.h>
+
+enum cpu_register_t {
+	RTE_REG_EAX = 0,
+	RTE_REG_EBX,
+	RTE_REG_ECX,
+	RTE_REG_EDX,
+};
+
+typedef uint32_t cpuid_registers_t[4];
+
+#endif /* RTE_CPUID_H */
lib/librte_eal/common/arch/x86/rte_hypervisor.c new file +40 -0
new file mode 100644
index 000000000..edf07be18
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "rte_cpuflags.h"
+#include "rte_cpuid.h"
+
+/* See http://lwn.net/Articles/301888/ */
+#define HYPERVISOR_INFO_LEAF 0x40000000
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	cpuid_registers_t regs;
+	int reg;
+	char name[13];
+
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_HYPERVISOR))
+		return RTE_HYPERVISOR_NONE;
+
+	__cpuid(HYPERVISOR_INFO_LEAF,
+			regs[RTE_REG_EAX], regs[RTE_REG_EBX],
+			regs[RTE_REG_ECX], regs[RTE_REG_EDX]);
+	for (reg = 1; reg < 4; reg++)
+		memcpy(name + (reg - 1) * 4, &regs[reg], 4);
+	name[12] = '\0';
+
+	if (strcmp("KVMKVMKVM", name) == 0)
+		return RTE_HYPERVISOR_KVM;
+	if (strcmp("Microsoft Hv", name) == 0)
+		return RTE_HYPERVISOR_HYPERV;
+	if (strcmp("VMwareVMware", name) == 0)
+		return RTE_HYPERVISOR_VMWARE;
+	return RTE_HYPERVISOR_UNKNOWN;
+}
lib/librte_eal/common/eal_common_hypervisor.c new file +22 -0
new file mode 100644
index 000000000..c3b4c621b
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+const char *
+rte_hypervisor_get_name(enum rte_hypervisor id)
+{
+	switch (id) {
+	case RTE_HYPERVISOR_NONE:
+		return "none";
+	case RTE_HYPERVISOR_KVM:
+		return "KVM";
+	case RTE_HYPERVISOR_HYPERV:
+		return "Hyper-V";
+	case RTE_HYPERVISOR_VMWARE:
+		return "VMware";
+	default:
+		return "unknown";
+	}
+}
lib/librte_eal/common/include/arch/x86/rte_cpuflags.h +1 -0
index eb0bdf480..8315f6b69 100644
@@ -40,6 +40,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_AVX,                    /**< AVX */
 	RTE_CPUFLAG_F16C,                   /**< F16C */
 	RTE_CPUFLAG_RDRAND,                 /**< RDRAND */
+	RTE_CPUFLAG_HYPERVISOR,             /**< Running in a VM */
 
 	/* (EAX 01h) EDX features */
 	RTE_CPUFLAG_FPU,                    /**< FPU */
lib/librte_eal/common/include/rte_hypervisor.h new file +33 -0
new file mode 100644
index 000000000..8d8aac744
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#ifndef RTE_HYPERVISOR_H
+#define RTE_HYPERVISOR_H
+
+/**
+ * @file
+ * Hypervisor awareness.
+ */
+
+enum rte_hypervisor {
+	RTE_HYPERVISOR_NONE,
+	RTE_HYPERVISOR_KVM,
+	RTE_HYPERVISOR_HYPERV,
+	RTE_HYPERVISOR_VMWARE,
+	RTE_HYPERVISOR_UNKNOWN
+};
+
+/**
+ * Get the id of hypervisor it is running on.
+ */
+enum rte_hypervisor
+rte_hypervisor_get(void);
+
+/**
+ * Get the name of a given hypervisor id.
+ */
+const char *
+rte_hypervisor_get_name(enum rte_hypervisor id);
+
+#endif /* RTE_HYPERVISOR_H */
lib/librte_eal/linuxapp/eal/Makefile +2 -0
index 588c0bdfb..7bf278f3b 100644
@@ -50,6 +50,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_tailqs.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_errno.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_hypervisor.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_string_fns.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_devargs.c
@@ -66,6 +67,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_service.c
 
 # from arch dir
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_cpuflags.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_hypervisor.c
 SRCS-$(CONFIG_RTE_ARCH_X86) += rte_spinlock.c
 SRCS-y += rte_cycles.c
 
lib/librte_eal/rte_eal_version.map +9 -1
index f4f46c1be..b3dc5a746 100644
@@ -200,6 +200,14 @@ DPDK_17.11 {
 
 } DPDK_17.08;
 
+DPDK_18.02 {
+	global:
+
+	rte_hypervisor_get;
+	rte_hypervisor_get_name;
+
+} DPDK_17.11;
+
 EXPERIMENTAL {
 	global:
 
@@ -235,4 +243,4 @@ EXPERIMENTAL {
 	rte_service_set_stats_enable;
 	rte_service_start_with_defaults;
 
-} DPDK_17.11;
+} DPDK_18.02;
Signature · 1 line
2.15.1
#12 lore raw
Quoted 7 lines · On Sun, 7 Jan 2018 23:20:42 +0100 Thomas Monjalon <[email protected]> wrote:
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +1 -0
new file mode 100644
index 000000000..3792fe2ce
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause

lib/librte_eal/common/arch/arm/rte_hypervisor.c line 11

Quoted 10 lines
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +10 -0
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}

Looking at util-linux for inspiration.

Xen is "XenVMMXenVMM"

On PowerPC, the hypervisor type can be deduced from /proc via devicetree.

OpenVz/Virtuzzo can be detected by /proc/vz and /proc/bc

#13 lore raw

08/01/2018 17:54, Stephen Hemminger:

Quoted 23 lines
Quoted 7 lines · On Sun, 7 Jan 2018 23:20:42 +0100 Thomas Monjalon <[email protected]> wrote:
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +1 -0
new file mode 100644
index 000000000..3792fe2ce
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause

lib/librte_eal/common/arch/arm/rte_hypervisor.c line 11

Quoted 10 lines
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +10 -0
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}

Looking at util-linux for inspiration.

Quoted 5 lines

Xen is "XenVMMXenVMM"

On PowerPC, the hypervisor type can be deduced from /proc via devicetree.

OpenVz/Virtuzzo can be detected by /proc/vz and /proc/bc

I really don't see any benefit of detecting Xen or OpenVz in DPDK.

#14 lore raw

My comment was intended as an FYI for future usage.

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, January 8, 2018 10:46 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; Stephen Hemminger <[email protected]>; Jerin Jacob <[email protected]>; Adrien Mazarguil <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3] eal/x86: get hypervisor name

08/01/2018 17:54, Stephen Hemminger:

Quoted 23 lines
Quoted 7 lines · On Sun, 7 Jan 2018 23:20:42 +0100 Thomas Monjalon <[email protected]> wrote:
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +1 -0
new file mode 100644
index 000000000..3792fe2ce
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause

lib/librte_eal/common/arch/arm/rte_hypervisor.c line 11

Quoted 10 lines
lib/librte_eal/common/arch/arm/rte_hypervisor.c new file +10 -0
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include "rte_hypervisor.h"
+
+enum rte_hypervisor
+rte_hypervisor_get(void)
+{
+	return RTE_HYPERVISOR_UNKNOWN;
+}

Looking at util-linux for inspiration.

Quoted 5 lines

Xen is "XenVMMXenVMM"

On PowerPC, the hypervisor type can be deduced from /proc via devicetree.

OpenVz/Virtuzzo can be detected by /proc/vz and /proc/bc

I really don't see any benefit of detecting Xen or OpenVz in DPDK.