diff options
author | Heiko Carstens | 2011-08-10 10:34:30 +0200 |
---|---|---|
committer | Heiko Carstens | 2011-08-14 17:34:21 +0200 |
commit | b8ec7bdfeb75cff8a4374e87d06783b121e0ecd5 (patch) | |
tree | d9104ca50a05bbce95f8a08317224cfdb362d63b /sys-utils/lscpu.c | |
parent | lscpu: fix fallback nthreads calculation (diff) | |
download | kernel-qcow2-util-linux-b8ec7bdfeb75cff8a4374e87d06783b121e0ecd5.tar.gz kernel-qcow2-util-linux-b8ec7bdfeb75cff8a4374e87d06783b121e0ecd5.tar.xz kernel-qcow2-util-linux-b8ec7bdfeb75cff8a4374e87d06783b121e0ecd5.zip |
lscpu: detect IBM hypervisor
Detect if the hypervisor on s390 is from KVM or IBM.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r-- | sys-utils/lscpu.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index c5e5f2d30..22e680b3e 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -50,6 +50,7 @@ #define _PATH_PROC_XENCAP _PATH_PROC_XEN "/capabilities" #define _PATH_PROC_CPUINFO "/proc/cpuinfo" #define _PATH_PROC_PCIDEVS "/proc/bus/pci/devices" +#define _PATH_PROC_SYSINFO "/proc/sysinfo" /* virtualization types */ enum { @@ -69,14 +70,16 @@ enum { HYPER_XEN, HYPER_KVM, HYPER_MSHV, - HYPER_VMWARE + HYPER_VMWARE, + HYPER_IBM }; const char *hv_vendors[] = { [HYPER_NONE] = NULL, [HYPER_XEN] = "Xen", [HYPER_KVM] = "KVM", [HYPER_MSHV] = "Microsoft", - [HYPER_VMWARE] = "VMware" + [HYPER_VMWARE] = "VMware", + [HYPER_IBM] = "IBM" }; /* CPU modes */ @@ -598,6 +601,21 @@ read_hypervisor(struct lscpu_desc *desc) /* Xen full-virt on non-x86_64 */ desc->hyper = HYPER_XEN; desc->virtype = VIRT_FULL; + } else if (path_exist(_PATH_PROC_SYSINFO)) { + FILE *fd = path_fopen("r", 0, _PATH_PROC_SYSINFO); + char buf[BUFSIZ]; + + desc->hyper = HYPER_IBM; + desc->virtype = VIRT_FULL; + while (fgets(buf, sizeof(buf), fd) != NULL) { + if (!strstr(buf, "Control Program:")) + continue; + if (!strstr(buf, "KVM")) + desc->hyper = HYPER_IBM; + else + desc->hyper = HYPER_KVM; + } + fclose(fd); } } |