summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys-utils/lscpu.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 1f8f5f198..47f690d88 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -603,9 +603,8 @@ read_hypervisor_cpuid(struct lscpu_desc *desc __attribute__((__unused__)))
static int is_compatible(const char *path, const char *str)
{
- FILE *fd;
+ FILE *fd = path_fopen("r", 0, "%s", path);
- fd = path_fopen("r", 0, "%s", path);
if (fd) {
char buf[256];
size_t i, len;
@@ -636,11 +635,9 @@ read_hypervisor_powerpc(struct lscpu_desc *desc)
desc->virtype = VIRT_PARA;
/* PowerNV (POWER Non-Virtualized, bare-metal) */
- } else if (path_exist(_PATH_PROC_DEVICETREE "/compatible")) {
- if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "ibm,powernv")) {
- desc->hyper = HYPER_NONE;
- desc->virtype = VIRT_NONE;
- }
+ } else if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "ibm,powernv")) {
+ desc->hyper = HYPER_NONE;
+ desc->virtype = VIRT_NONE;
/* PowerVM (IBM's proprietary hypervisor, aka pHyp) */
} else if (path_exist(_PATH_PROC_DEVICETREE "/ibm,partition-name")
@@ -658,11 +655,9 @@ read_hypervisor_powerpc(struct lscpu_desc *desc)
}
/* Qemu */
- } else if (path_exist(_PATH_PROC_DEVICETREE "/compatible")) {
- if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "qemu,pseries")) {
- desc->hyper = HYPER_KVM;
- desc->virtype = VIRT_PARA;
- }
+ } else if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "qemu,pseries")) {
+ desc->hyper = HYPER_KVM;
+ desc->virtype = VIRT_PARA;
}
return desc->hyper;
}