summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorHeiko Carstens2011-09-06 02:53:02 +0200
committerKarel Zak2011-09-09 23:54:01 +0200
commit10829cd73c0f0e226d10d75c8b8e00260a7708e8 (patch)
tree1d5e04f393cce525d42e6684e2519a038f8ab799 /sys-utils/lscpu.c
parentlscpu: add s390 test case (diff)
downloadkernel-qcow2-util-linux-10829cd73c0f0e226d10d75c8b8e00260a7708e8.tar.gz
kernel-qcow2-util-linux-10829cd73c0f0e226d10d75c8b8e00260a7708e8.tar.xz
kernel-qcow2-util-linux-10829cd73c0f0e226d10d75c8b8e00260a7708e8.zip
lscpu: add Hypervisor to output
Some vendors have several hypervisors. Therefore it makes sense to not only print out the hypervisor vendor but also the name of the hypervisor. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 69e80eb3c..601c8729c 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -137,6 +137,7 @@ struct lscpu_desc {
char *family;
char *model;
char *virtflag; /* virtualization flag (vmx, svm) */
+ char *hypervisor; /* hypervisor software */
int hyper; /* hypervisor vendor ID */
int virtype; /* VIRT_PARA|FULL|NONE ? */
char *mhz;
@@ -672,14 +673,31 @@ read_hypervisor(struct lscpu_desc *desc)
char buf[BUFSIZ];
desc->hyper = HYPER_IBM;
+ desc->hypervisor = "PR/SM";
desc->virtype = VIRT_FULL;
while (fgets(buf, sizeof(buf), fd) != NULL) {
+ char *str;
+
if (!strstr(buf, "Control Program:"))
continue;
if (!strstr(buf, "KVM"))
desc->hyper = HYPER_IBM;
else
desc->hyper = HYPER_KVM;
+ str = strchr(buf, ':');
+ if (!str)
+ continue;
+ if (asprintf(&str, str + 1) == -1)
+ errx(EXIT_FAILURE, _("failed to allocate memory"));
+ /* remove leading, trailing and repeating whitespace */
+ while (*str == ' ')
+ str++;
+ desc->hypervisor = str;
+ str += strlen(str) - 1;
+ while ((*str == '\n') || (*str == ' '))
+ *(str--) = '\0';
+ while ((str = strstr(desc->hypervisor, " ")))
+ memmove(str, str + 1, strlen(str));
}
fclose(fd);
}
@@ -1276,6 +1294,8 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
else if (!strcmp(desc->virtflag, "vmx"))
print_s(_("Virtualization:"), "VT-x");
}
+ if (desc->hypervisor)
+ print_s(_("Hypervisor:"), desc->hypervisor);
if (desc->hyper) {
print_s(_("Hypervisor vendor:"), hv_vendors[desc->hyper]);
print_s(_("Virtualization type:"), virt_types[desc->virtype]);