public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Ruediger Meier <sweet_f_a@gmx.de>
To: util-linux@vger.kernel.org
Cc: Stanislav Brabec <sbrabec@suse.cz>, Petr Uzel <petr.uzel@suse.cz>
Subject: [PATCH 1/5] lscpu: minor cleanup and improve hypervisor detection
Date: Tue, 20 May 2014 15:42:27 +0000	[thread overview]
Message-ID: <1400600551-7227-2-git-send-email-sweet_f_a@gmx.de> (raw)
In-Reply-To: <1400600551-7227-1-git-send-email-sweet_f_a@gmx.de>

From: Ruediger Meier <ruediger.meier@ga-group.nl>

- add HYPER_VBOX
- improve HYPER_VMWARE

This patch comes from openSUSE / SLE. Original author was probably
Petr Uzel.
Internal SUSE references: fate310255, sr226509

CC: Stanislav Brabec <sbrabec@suse.cz>
CC: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 sys-utils/lscpu.c | 29 +++++++++++++++++++++++++++--
 sys-utils/lscpu.h |  3 ++-
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index ad1a6b3..0203916 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -87,7 +87,26 @@ const char *hv_vendors[] = {
 	[HYPER_UML]	= "User-mode Linux",
 	[HYPER_INNOTEK]	= "Innotek GmbH",
 	[HYPER_HITACHI]	= "Hitachi",
-	[HYPER_PARALLELS] = "Parallels"
+	[HYPER_PARALLELS] = "Parallels",
+	[HYPER_VBOX]	= "Oracle"
+};
+
+const int hv_vendor_pci[] = {
+	[HYPER_NONE]	= 0x0000,
+	[HYPER_XEN]	= 0x5853,
+	[HYPER_KVM]	= 0x0000,
+	[HYPER_MSHV]	= 0x1414,
+	[HYPER_VMWARE]	= 0x15ad,
+	[HYPER_VBOX]	= 0x80ee
+};
+
+const int hv_graphics_pci[] = {
+	[HYPER_NONE]	= 0x0000,
+	[HYPER_XEN]	= 0x0001,
+	[HYPER_KVM]	= 0x0000,
+	[HYPER_MSHV]	= 0x5353,
+	[HYPER_VMWARE]	= 0x0710,
+	[HYPER_VBOX]	= 0xbeef
 };
 
 /* CPU modes */
@@ -589,9 +608,15 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 		desc->hyper = HYPER_XEN;
 
 	/* Xen full-virt on non-x86_64 */
-	} else if (has_pci_device(0x5853, 0x0001)) {
+	} else if (has_pci_device( hv_vendor_pci[HYPER_XEN], hv_graphics_pci[HYPER_XEN])) {
 		desc->hyper = HYPER_XEN;
 		desc->virtype = VIRT_FULL;
+	} else if (has_pci_device( hv_vendor_pci[HYPER_VMWARE], hv_graphics_pci[HYPER_VMWARE])) {
+		desc->hyper = HYPER_VMWARE;
+		desc->virtype = VIRT_FULL;
+	} else if (has_pci_device( hv_vendor_pci[HYPER_VBOX], hv_graphics_pci[HYPER_VBOX])) {
+		desc->hyper = HYPER_VBOX;
+		desc->virtype = VIRT_FULL;
 
 	/* IBM PR/SM */
 	} else if (path_exist(_PATH_PROC_SYSINFO)) {
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 312038f..7bb538d 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -13,7 +13,8 @@ enum {
 	HYPER_UML,
 	HYPER_INNOTEK,		/* VBOX */
 	HYPER_HITACHI,
-	HYPER_PARALLELS		/* OpenVZ/VIrtuozzo */
+	HYPER_PARALLELS,	/* OpenVZ/VIrtuozzo */
+	HYPER_VBOX
 };
 
 extern int read_hypervisor_dmi(void);
-- 
1.8.4.5


  reply	other threads:[~2014-05-20 15:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 15:42 [PATCH 0/5] lscpu: improve hypervisor detection Ruediger Meier
2014-05-20 15:42 ` Ruediger Meier [this message]
2014-05-20 15:42 ` [PATCH 2/5] tests: add vbox lscpu dump Ruediger Meier
2014-05-20 15:42 ` [PATCH 3/5] lscpu: detect OS/400 and pHyp hypervisors Ruediger Meier
2014-05-21  7:37   ` Karel Zak
2014-05-21  9:43     ` Ruediger Meier
2014-05-21 12:41       ` Karel Zak
2014-05-21 23:03   ` Ruediger Meier
2014-05-22  8:48     ` Karel Zak
2014-05-22  9:08       ` Heiko Carstens
2014-05-22  9:30         ` Alexander Graf
2014-05-28 21:54           ` Ruediger Meier
2014-05-28 22:29             ` Alexander Graf
2014-05-20 15:42 ` [PATCH 4/5] lscpu: improve vmware detection Ruediger Meier
2014-05-20 18:40   ` Ruediger Meier
2014-05-20 15:42 ` [PATCH 5/5] lscpu: avoid compiler warnings Ruediger Meier
2014-05-21  8:10   ` Karel Zak
2014-05-20 16:34 ` [PATCH 0/5] lscpu: improve hypervisor detection Stanislav Brabec
2014-05-20 18:13   ` Ruediger Meier
2014-05-21  8:24   ` Karel Zak
2014-05-21 22:29 ` Ruediger Meier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400600551-7227-2-git-send-email-sweet_f_a@gmx.de \
    --to=sweet_f_a@gmx.de \
    --cc=petr.uzel@suse.cz \
    --cc=sbrabec@suse.cz \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox