From: lixianglai <lixianglai(a)loongson.cn>
Implement method for loongarch to get host info, such as
cpu frequency, system info, etc.
Signed-off-by: lixianglai <lixianglai(a)loongson.cn>
---
src/util/virarch.c | 2 ++
src/util/virhostcpu.c | 4 ++--
src/util/virsysinfo.c | 5 +++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/util/virarch.c b/src/util/virarch.c
index 289bd80d90..8107279fb8 100644
--- a/src/util/virarch.c
+++ b/src/util/virarch.c
@@ -224,6 +224,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 4027547e1e..15e97151d6 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -544,7 +544,7 @@ virHostCPUParseFrequency(FILE *cpuinfo,
char line[1024];
/* No sensible way to retrieve CPU frequency */
- if (ARCH_IS_ARM(arch))
+ if (ARCH_IS_ARM(arch) || ARCH_IS_LOONGARCH(arch))
return 0;
if (ARCH_IS_X86(arch))
@@ -579,7 +579,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. */
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 36a861c53f..3a09497725 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -1241,14 +1241,15 @@ virSysinfoRead(void)
{
#if defined(__powerpc__)
return virSysinfoReadPPC();
-#elif defined(__arm__) || defined(__aarch64__)
+#elif defined(__arm__) || defined(__aarch64__) || defined(__loongarch__)
return virSysinfoReadARM();
#elif defined(__s390__) || defined(__s390x__)
return virSysinfoReadS390();
#elif !defined(WIN32) && \
(defined(__x86_64__) || \
defined(__i386__) || \
- defined(__amd64__))
+ defined(__amd64__) || \
+ defined(__loongarch__))
return virSysinfoReadDMI();
#else /* WIN32 || not supported arch */
/*
--
2.27.0