From d10f3f9bc65b7832db98ef00973bf22f38dd86a6 Mon Sep 17 00:00:00 2001
From: Xianglai Li <lixianglai@loongson.cn>
Date: Wed, 28 Feb 2024 02:03:21 -0500
Subject: [PATCH 1/4] Add loongarch support

Set loongarch installable,And Define the judgment function of
loongarch architecture.

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
---
 virtManager/createvm.py | 6 +++++-
 virtinst/domain/os.py   | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/virtManager/createvm.py b/virtManager/createvm.py
index 7e5ded6..f5d678d 100644
--- a/virtManager/createvm.py
+++ b/virtManager/createvm.py
@@ -476,7 +476,8 @@ class vmmCreateVM(vmmGObjectUI):
 
         installable_arch = bool(guest.os.is_x86() or
                 guest.os.is_ppc64() or
-                guest.os.is_s390x())
+                guest.os.is_s390x() or
+                guest.os.is_loongarch64())
 
         default_efi = (
             self.config.get_default_firmware_setting() == "uefi" and
@@ -864,6 +865,9 @@ class vmmCreateVM(vmmGObjectUI):
             defmachine = recommended_machine
             prios = [defmachine]
 
+        if self._capsinfo.arch in ["loongarch64"]:
+            defmachine = "virt"
+
         for p in prios[:]:
             if p not in machines:
                 prios.remove(p)  # pragma: no cover
diff --git a/virtinst/domain/os.py b/virtinst/domain/os.py
index e2cea75..e783c85 100644
--- a/virtinst/domain/os.py
+++ b/virtinst/domain/os.py
@@ -77,6 +77,8 @@ class DomainOs(XMLBuilder):
         return self.arch == "riscv64" or self.arch == "riscv32"
     def is_riscv_virt(self):
         return self.is_riscv() and str(self.machine).startswith("virt")
+    def is_loongarch64(self):
+        return self.arch == "loongarch64"
 
     ##################
     # XML properties #
-- 
2.27.0

