From 4123437e633f05af0ae8091d5db440597394ba36 Mon Sep 17 00:00:00 2001 From: zhaotianrui Date: Wed, 11 Jan 2023 14:09:41 -0500 Subject: [PATCH 4/4] 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: zhaotianrui --- src/util/virarch.c | 2 ++ src/util/virhostcpu.c | 2 +- src/util/virsysinfo.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/virarch.c b/src/util/virarch.c index decdbdd7ac..0520a1c80b 100644 --- a/src/util/virarch.c +++ b/src/util/virarch.c @@ -227,6 +227,8 @@ virArch virArchFromHost(void) arch = VIR_ARCH_X86_64; } else if (STREQ(ut.machine, "sw_64")) { arch = VIR_ARCH_SW_64; + } 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 5ec98d6016..ce3da7e6ec 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -577,7 +577,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)) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 8a53702224..6d4778fed7 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1190,7 +1190,7 @@ 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(); @@ -1198,6 +1198,7 @@ virSysinfoRead(void) (defined(__x86_64__) || \ defined(__i386__) || \ defined(__amd64__) || \ + defined(__loongarch__) || \ defined(__sw_64__)) return virSysinfoReadDMI(); #else /* WIN32 || not supported arch */ -- 2.25.1