[libvirt PATCH V2 3/4] Implement the method of getting host info for loongarch

Xianglai Li posted 4 patches 11 months, 2 weeks ago
There is a newer version of this series
[libvirt PATCH V2 3/4] Implement the method of getting host info for loongarch
Posted by Xianglai Li 11 months, 2 weeks ago
From: xianglai li <lixianglai@loongson.cn>

Implement method for loongarch to get host info, such as
cpu frequency, system info, etc.

Signed-off-by: "Xianglai Li" <lixianglai@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 74b7ec6f1b..20f54a6040 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..c809fc0d7a 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -553,6 +553,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",
@@ -579,7 +581,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. */
@@ -1650,7 +1652,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
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [libvirt PATCH V2 3/4] Implement the method of getting host info for loongarch
Posted by Andrea Bolognani 11 months, 1 week ago
On Wed, Jan 10, 2024 at 11:07:48AM +0800, Xianglai Li wrote:
> diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
> index 4027547e1e..c809fc0d7a 100644
> --- a/src/util/virhostcpu.c
> +++ b/src/util/virhostcpu.c
> @@ -1650,7 +1652,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;

Alignment is slightly off here.

-- 
Andrea Bolognani / Red Hat / Virtualization
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [libvirt PATCH V2 3/4] Implement the method of getting host info for loongarch
Posted by lixianglai 10 months, 3 weeks ago
Hi Andrea :

> On Wed, Jan 10, 2024 at 11:07:48AM +0800, Xianglai Li wrote:
>> diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
>> index 4027547e1e..c809fc0d7a 100644
>> --- a/src/util/virhostcpu.c
>> +++ b/src/util/virhostcpu.c
>> @@ -1650,7 +1652,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;
> Alignment is slightly off here.
>
OK!

Thanks!

Xianglai.



_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org