Implement method for loongarch to get host info, such as
cpu frequency, system info, etc.
Signed-off-by: Xianglai Li <lixianglai(a)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