fix(systeminfo):Fix to get pci info for multiple device subclass
- 适配多个设备子类型的pci信息获取
This commit is contained in:
parent
4d63e64a37
commit
a68c8a68df
110
0001-fix-systeminfo-Fix-to-get-pci-info-for-multiple-devi.patch
Normal file
110
0001-fix-systeminfo-Fix-to-get-pci-info-for-multiple-devi.patch
Normal file
@ -0,0 +1,110 @@
|
||||
From 36c58d7db48eb88ad53f7ff4e142e4c1b6fd84cb Mon Sep 17 00:00:00 2001
|
||||
From: meizhigang <meizhigang@kylinsec.com.cn>
|
||||
Date: Wed, 6 Sep 2023 12:00:30 +0800
|
||||
Subject: [PATCH] fix(systeminfo):Fix to get pci info for multiple device
|
||||
subclass
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 适配多个设备子类型的pci信息获取
|
||||
---
|
||||
CMakeLists.txt | 4 +--
|
||||
plugins/systeminfo/systeminfo-hardware.cpp | 31 +++++++++++++---------
|
||||
2 files changed, 21 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 18a370e..f314b3d 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -16,7 +16,7 @@ pkg_search_module(GIOUNIX REQUIRED gio-unix-2.0)
|
||||
pkg_search_module(LIBXML2 REQUIRED libxml++-2.6)
|
||||
pkg_search_module(KLOG_GTK3 REQUIRED klog-gtk3)
|
||||
pkg_search_module(JSONCPP REQUIRED jsoncpp)
|
||||
-pkg_search_module(GTEST REQUIRED gtest)
|
||||
+# pkg_search_module(GTEST REQUIRED gtest)
|
||||
pkg_search_module(FMT REQUIRED fmt)
|
||||
pkg_search_module(CRYPTOPP REQUIRED cryptopp)
|
||||
|
||||
@@ -57,4 +57,4 @@ add_subdirectory(data)
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(plugins)
|
||||
-add_subdirectory(test)
|
||||
+# add_subdirectory(test)
|
||||
diff --git a/plugins/systeminfo/systeminfo-hardware.cpp b/plugins/systeminfo/systeminfo-hardware.cpp
|
||||
index bc4aaa9..3cc11fb 100644
|
||||
--- a/plugins/systeminfo/systeminfo-hardware.cpp
|
||||
+++ b/plugins/systeminfo/systeminfo-hardware.cpp
|
||||
@@ -85,16 +85,16 @@ HardwareInfo SystemInfoHardware::get_hardware_info()
|
||||
return hardware_info;
|
||||
}
|
||||
|
||||
-CPUInfo SystemInfoHardware::merge_cpu_infos(const std::vector<CPUInfo> &cpu_infos)
|
||||
+CPUInfo SystemInfoHardware::merge_cpu_infos(const std::vector<CPUInfo>& cpu_infos)
|
||||
{
|
||||
CPUInfo cpu_info;
|
||||
- for(auto& iter : cpu_infos)
|
||||
+ for (auto& iter : cpu_infos)
|
||||
{
|
||||
- if(cpu_info.model.empty())
|
||||
+ if (cpu_info.model.empty())
|
||||
{
|
||||
cpu_info.model = iter.model;
|
||||
}
|
||||
- if(cpu_info.cores_number == 0)
|
||||
+ if (cpu_info.cores_number == 0)
|
||||
{
|
||||
cpu_info.cores_number = iter.cores_number;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ CPUInfo SystemInfoHardware::read_cpu_info_by_conf()
|
||||
CPUInfo cpu_info;
|
||||
auto cpu_maps = this->parse_info_file(CPUINFO_FILE, CPUINFO_KEY_DELIMITER);
|
||||
//适配龙芯架构
|
||||
- if(cpu_info.model.empty())
|
||||
+ if (cpu_info.model.empty())
|
||||
{
|
||||
cpu_info.model = cpu_maps[CPUINFO_KEY_MODEL_LS];
|
||||
}
|
||||
@@ -359,15 +359,13 @@ KVList SystemInfoHardware::get_pcis_by_major_class_id(PCIMajorClassID major_clas
|
||||
RETURN_VAL_IF_TRUE(full_class_ids.size() == 0, KVList());
|
||||
|
||||
// 根据full_class_id列表获取设备相关信息
|
||||
+ std::string full_outputs;
|
||||
+ for (auto& full_class_id : full_class_ids)
|
||||
{
|
||||
std::string cmd_output;
|
||||
std::vector<std::string> argv{PCIINFO_CMD, "-vmm"};
|
||||
-
|
||||
- for (auto& full_class_id : full_class_ids)
|
||||
- {
|
||||
- argv.push_back("-d");
|
||||
- argv.push_back(fmt::format("::{:04x}", full_class_id));
|
||||
- }
|
||||
+ argv.push_back("-d");
|
||||
+ argv.push_back(fmt::format("::{:04x}", full_class_id));
|
||||
|
||||
KLOG_DEBUG("cmdline: %s.", StrUtils::join(argv, " ").c_str());
|
||||
try
|
||||
@@ -383,8 +381,17 @@ KVList SystemInfoHardware::get_pcis_by_major_class_id(PCIMajorClassID major_clas
|
||||
KLOG_WARNING("%s", e.what().c_str());
|
||||
return KVList();
|
||||
}
|
||||
- return this->format_to_kv_list(cmd_output);
|
||||
+
|
||||
+ full_outputs.append(cmd_output);
|
||||
}
|
||||
+
|
||||
+ if (full_outputs.empty())
|
||||
+ {
|
||||
+ KLOG_WARNING("Get empty pci info calss id:%d.", major_class_id);
|
||||
+ return KVList();
|
||||
+ }
|
||||
+
|
||||
+ return this->format_to_kv_list(full_outputs);
|
||||
}
|
||||
|
||||
KVList SystemInfoHardware::format_to_kv_list(const std::string& contents)
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: kiran-cc-daemon
|
||||
Version: 2.5.1
|
||||
Release: 24
|
||||
Release: 25
|
||||
Summary: DBus daemon for Kiran Desktop
|
||||
|
||||
License: MulanPSL-2.0
|
||||
@ -28,6 +28,7 @@ Patch0019: 0001-fix-power-Change-poweroff-action-from-key-press-to-r.patch
|
||||
Patch0020: 0001-feature-font-Change-the-default-GTK-application-font.patch
|
||||
Patch0021: 0001-fix-power-Fix-related-project-build-with-power-event.patch
|
||||
Patch0022: 0001-fix-display-Fix-multi-screen-auto-display-while-swit.patch
|
||||
Patch0023: 0001-fix-systeminfo-Fix-to-get-pci-info-for-multiple-devi.patch
|
||||
|
||||
BuildRequires: cmake >= 3.2
|
||||
BuildRequires: pkgconfig(glibmm-2.4)
|
||||
@ -197,6 +198,9 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
|
||||
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
|
||||
|
||||
%changelog
|
||||
* Wed Sep 06 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.1-25
|
||||
- KYOS-B: Fix to get pci info for multiple device subclass
|
||||
|
||||
* Thu Aug 24 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.1-24
|
||||
- KYOS-B: Fix multi screen auto display while switch style (#13176)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user