From: lixianglai <lixianglai@loongson.cn>
Implement method for loongarch to get host info, such as
cpu frequency, system info, etc.
Signed-off-by: lixianglai <lixianglai@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
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
On Thu, Dec 14, 2023 at 02:08:48PM +0800, xianglai li wrote:
> +++ b/src/util/virhostcpu.c
> @@ -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;
So is the case different on loongarch than it is on other
architectures? Weird.
> +++ 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();
This is definitely not right: we shouldn't be calling the
Arm-specific function on loongarch.
> #elif defined(__s390__) || defined(__s390x__)
> return virSysinfoReadS390();
> #elif !defined(WIN32) && \
> (defined(__x86_64__) || \
> defined(__i386__) || \
> - defined(__amd64__))
> + defined(__amd64__) || \
> + defined(__loongarch__))
> return virSysinfoReadDMI();
Does loongarch actually have DMI support?
--
Andrea Bolognani / Red Hat / Virtualization
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Hi Andrea:
> On Thu, Dec 14, 2023 at 02:08:48PM +0800, xianglai li wrote:
>> +++ b/src/util/virhostcpu.c
>> @@ -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;
> So is the case different on loongarch than it is on other
> architectures? Weird.
Yes, loongarch and x86 do have some similarities and differences in the
cpu Address space string, loongarch is "Address Sizes" under X86 is
"address sizes",
arm and other architectures should not have this identifier, At present,
only x86 architecture and sh architecture can enter the process,
other architectures will directly return, and the superior call also
needs to allow the loongarch architecture. I will correct it in the next
version
>
>> +++ 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();
> This is definitely not right: we shouldn't be calling the
> Arm-specific function on loongarch.
Ok, I'll correct that in the next version.
>> #elif defined(__s390__) || defined(__s390x__)
>> return virSysinfoReadS390();
>> #elif !defined(WIN32) && \
>> (defined(__x86_64__) || \
>> defined(__i386__) || \
>> - defined(__amd64__))
>> + defined(__amd64__) || \
>> + defined(__loongarch__))
>> return virSysinfoReadDMI();
> Does loongarch actually have DMI support?
Yes, loongarch does support dmi.
Thanks,
Xianglai.
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
On Tue, Dec 19, 2023 at 05:23:36PM +0800, lixianglai wrote: > > On Thu, Dec 14, 2023 at 02:08:48PM +0800, xianglai li wrote: > > > +++ b/src/util/virhostcpu.c > > > @@ -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; > > > > So is the case different on loongarch than it is on other > > architectures? Weird. > > Yes, loongarch and x86 do have some similarities and differences in the cpu > Address space string, loongarch is "Address Sizes" under X86 is "address > sizes", Unfortunate choice on the kernel's part, but not much we can do about that I guess. The way you handled it is perfectly fine. > arm and other architectures should not have this identifier, At present, > only x86 architecture and sh architecture can enter the process, > > other architectures will directly return, and the superior call also needs > to allow the loongarch architecture. I will correct it in the next version Good catch! I hadn't even noticed that but it definitely needs to be addressed. > > > #elif !defined(WIN32) && \ > > > (defined(__x86_64__) || \ > > > defined(__i386__) || \ > > > - defined(__amd64__)) > > > + defined(__amd64__) || \ > > > + defined(__loongarch__)) > > > return virSysinfoReadDMI(); > > > > Does loongarch actually have DMI support? > > Yes, loongarch does support dmi. Excellent, just making sure :) -- Andrea Bolognani / Red Hat / Virtualization _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org
© 2016 - 2026 Red Hat, Inc.