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;
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")
}
/* 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;
}