1 Star 0 Fork 70

周正亮/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Implement-the-method-of-getting-host-info-for-loonga.patch 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
Xianglai Li 提交于 2024-05-20 03:36 . Add loongarch support for libvirt
From 918a7e7601cf7fc5d8619ff7214e7d43cdee2e08 Mon Sep 17 00:00:00 2001
From: Xianglai Li <lixianglai@loongson.cn>
Date: Fri, 28 Jul 2023 03:27:41 -0400
Subject: [PATCH 3/3] Implement the method of getting host info for loongarch
Implement method for loongarch to get host info, such as
cpu frequency, system info, etc.
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
---
src/util/virarch.c | 2 ++
src/util/virhostcpu.c | 7 +++++--
src/util/virsysinfo.c | 3 ++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/util/virarch.c b/src/util/virarch.c
index 8545f993ea..a94318da0d 100644
--- a/src/util/virarch.c
+++ b/src/util/virarch.c
@@ -223,6 +223,8 @@ virArch virArchFromHost(void)
arch = VIR_ARCH_X86_64;
} else if (STREQ(ut.machine, "arm64")) {
arch = VIR_ARCH_AARCH64;
+ } else if (STREQ(ut.machine, "loongarch64")) {
+ arch = VIR_ARCH_LOONGARCH64;
} else {
/* Otherwise assume the canonical name */
if ((arch = virArchFromString(ut.machine)) == VIR_ARCH_NONE) {
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index a3781ca870..01de69c0d1 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -575,6 +575,8 @@ virHostCPUParseFrequency(FILE *cpuinfo,
prefix = "clock";
else if (ARCH_IS_S390(arch))
prefix = "cpu MHz dynamic";
+ else if (ARCH_IS_LOONGARCH(arch))
+ prefix = "CPU MHz";
if (!prefix) {
VIR_WARN("%s is not supported by the %s parser",
@@ -601,7 +603,7 @@ virHostCPUParsePhysAddrSize(FILE *cpuinfo, unsigned int *addrsz)
char *str;
char *endptr;
- if (!(str = STRSKIP(line, "address sizes")))
+ if (!(str = STRCASESKIP(line, "address sizes")))
continue;
/* Skip the colon. */
@@ -1672,7 +1674,8 @@ virHostCPUGetPhysAddrSize(const virArch hostArch,
{
g_autoptr(FILE) cpuinfo = NULL;
- if (!(ARCH_IS_X86(hostArch) || ARCH_IS_SH4(hostArch))) {
+ if (!(ARCH_IS_X86(hostArch) || ARCH_IS_SH4(hostArch) ||
+ ARCH_IS_LOONGARCH(hostArch))) {
/* Ensure size is set to 0 as physical address size is unknown */
*size = 0;
return 0;
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 36a861c53f..4a03fc3246 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -1248,7 +1248,8 @@ virSysinfoRead(void)
#elif !defined(WIN32) && \
(defined(__x86_64__) || \
defined(__i386__) || \
- defined(__amd64__))
+ defined(__amd64__) || \
+ defined(__loongarch__))
return virSysinfoReadDMI();
#else /* WIN32 || not supported arch */
/*
--
2.39.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhou-zhengliang/libvirt.git
git@gitee.com:zhou-zhengliang/libvirt.git
zhou-zhengliang
libvirt
libvirt
master

搜索帮助