From 568965c0c852d882028d0777c1fa311da62ef6cb Mon Sep 17 00:00:00 2001
From: Xianglai Li <lixianglai@loongson.cn>
Date: Wed, 28 Feb 2024 02:11:16 -0500
Subject: [PATCH 3/4] Add some default device support for loongarch

Add adaptations for loongarch with the following features:
scsi support
default video Support
cpu modeul support

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
---
 virtinst/devices/disk.py  | 2 ++
 virtinst/devices/video.py | 2 ++
 virtinst/domain/cpu.py    | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py
index dc59fd1..cfb1387 100644
--- a/virtinst/devices/disk.py
+++ b/virtinst/devices/disk.py
@@ -974,6 +974,8 @@ class DeviceDisk(Device):
             return "sd"
         if guest.os.is_q35():
             return "sata"
+        if self.is_cdrom() and guest.os.is_loongarch64():
+            return "scsi"
         if self.conn.is_bhyve():
             # IDE bus is not supported by bhyve
             return "sata"
diff --git a/virtinst/devices/video.py b/virtinst/devices/video.py
index 70067a7..97adf7d 100644
--- a/virtinst/devices/video.py
+++ b/virtinst/devices/video.py
@@ -31,6 +31,8 @@ class DeviceVideo(Device):
             return None
         if guest.os.is_pseries():
             return "vga"
+        if guest.os.is_loongarch64():
+            return "virtio"
         if guest.os.is_arm_machvirt():
             # For all cases here the hv and guest are new enough for virtio
             return "virtio"
diff --git a/virtinst/domain/cpu.py b/virtinst/domain/cpu.py
index 5de42b4..c93a43b 100644
--- a/virtinst/domain/cpu.py
+++ b/virtinst/domain/cpu.py
@@ -449,5 +449,8 @@ class DomainCpu(XMLBuilder):
             # -M virt defaults to a 32bit CPU, even if using aarch64
             self.set_model(guest, "cortex-a57")
 
+        elif guest.os.is_loongarch64():
+            self.set_model(guest, "la464")
+
         elif guest.os.is_x86() and guest.type == "kvm":
             self._set_cpu_x86_kvm_default(guest)
-- 
2.27.0

