diff --git a/add-error-message-dispaly-while-open-file-failed.patch b/add-error-message-dispaly-while-open-file-failed.patch new file mode 100644 index 0000000000000000000000000000000000000000..a54133c51a1568e49abd726204749cb08afe43b4 --- /dev/null +++ b/add-error-message-dispaly-while-open-file-failed.patch @@ -0,0 +1,53 @@ +From 07b2b5d7f7b2cbe83f33e59633a1232644290e89 Mon Sep 17 00:00:00 2001 +From: wangguochun +Date: Tue, 22 Mar 2022 15:14:12 +0800 +Subject: [PATCH] add error message dispaly while open file failed + +--- + src/domain.c | 2 ++ + src/vcpu_stat.c | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/src/domain.c b/src/domain.c +index 977cabe..694d550 100644 +--- a/src/domain.c ++++ b/src/domain.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include "domain.h" + #include "utils.h" + #include "proc.h" +@@ -105,6 +106,7 @@ static int get_id_from_cgroup(pid_t pid) + } + fp = fopen(path, "r"); + if (fp == NULL) { ++ printf("open file %s fail errno : %d reason : %s \n",path, errno, strerror(errno)); + return id; + } + /* parse id from "cpuset:machine.slice/machine-qemu\x2d$id" */ +diff --git a/src/vcpu_stat.c b/src/vcpu_stat.c +index 1578ec4..84733bd 100644 +--- a/src/vcpu_stat.c ++++ b/src/vcpu_stat.c +@@ -12,6 +12,7 @@ + ********************************************************************************/ + #include + #include ++#include + #include "type.h" + #include "vcpu_stat.h" + #include "domain.h" +@@ -95,6 +96,7 @@ int get_vcpu_list(struct domain_list *list) + + fp = fopen(KVM_VCPU_STAT_PATH, "r"); + if (!fp) { ++ printf("open file %s fail errno : %d reason : %s \n",KVM_VCPU_STAT_PATH, errno, strerror(errno)); + return -1; + } + list->num = 0; +-- +2.27.0 + diff --git a/vmtop.spec b/vmtop.spec index 098461953330ab12ec61dcddc1c6b4fada1967e3..c8603458968bfb3b28292de0deadad5f48e49e07 100644 --- a/vmtop.spec +++ b/vmtop.spec @@ -38,6 +38,7 @@ Patch0027: performance-change-memset-location.patch Patch0028: proc-del-unused-items-getting-from-proc-stat-refresh.patch Patch0029: proc-del-loop-sscanf-for-proc-pid-stat-file.patch Patch0030: utils-del-realpath-from-read_file.patch +Patch0031: add-error-message-dispaly-while-open-file-failed.patch Requires: libvirt, ncurses @@ -78,6 +79,9 @@ install -m 550 vmtop ${RPM_BUILD_ROOT}/usr/bin/%{name} %{_bindir}/vmtop %changelog +* Tue Mar 22 2022 wangguochun +- add error message dispaly while open file failed + * Tue Mar 16 2021 Huawei Technologies Co., Ltd - vcpu_list: pre malloc vcpu list to improve performance - performance: del unnecessary memcpy and memset