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>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Xianglai Li 2024-03-21 11:30:28 +08:00 committed by Andrea Bolognani
parent 3243783c32
commit 0038b155ec
3 changed files with 9 additions and 3 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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 */
/*