Add some default device support for loongarch

Add adaptations for loongarch with the following features:
Default video Support
UEFI prefer
Usb tablet and usb keyboard
rng and memballoon
sound device
Usb controller

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
This commit is contained in:
Xianglai Li 2023-12-13 04:43:51 -05:00 committed by Pavel Hrdina
parent d2cf01b3eb
commit ea3cae4dc9
2 changed files with 19 additions and 6 deletions

View File

@ -31,6 +31,8 @@ class DeviceVideo(Device):
return None return None
if guest.os.is_pseries(): if guest.os.is_pseries():
return "vga" return "vga"
if guest.os.is_loongarch64():
return "virtio"
if guest.os.is_arm_machvirt(): if guest.os.is_arm_machvirt():
# For all cases here the hv and guest are new enough for virtio # For all cases here the hv and guest are new enough for virtio
return "virtio" return "virtio"

View File

@ -353,7 +353,8 @@ class Guest(XMLBuilder):
if (self.os.is_arm_machvirt() or if (self.os.is_arm_machvirt() or
self.os.is_riscv_virt() or self.os.is_riscv_virt() or
self.os.is_s390x() or self.os.is_s390x() or
self.os.is_pseries()): self.os.is_pseries() or
self.os.is_loongarch64()):
return True return True
if not os_support: if not os_support:
@ -544,6 +545,7 @@ class Guest(XMLBuilder):
else: else:
prefer_efi = (self.os.is_arm_machvirt() or prefer_efi = (self.os.is_arm_machvirt() or
self.os.is_riscv_virt() or self.os.is_riscv_virt() or
self.os.is_loongarch64() or
self.conn.is_bhyve()) self.conn.is_bhyve())
log.debug("Prefer EFI => %s", prefer_efi) log.debug("Prefer EFI => %s", prefer_efi)
@ -910,7 +912,8 @@ class Guest(XMLBuilder):
usb_tablet = True usb_tablet = True
if (self.os.is_arm_machvirt() or if (self.os.is_arm_machvirt() or
self.os.is_riscv_virt() or self.os.is_riscv_virt() or
self.os.is_pseries()): self.os.is_pseries() or
self.os.is_loongarch64()):
usb_tablet = True usb_tablet = True
usb_keyboard = True usb_keyboard = True
@ -992,7 +995,10 @@ class Guest(XMLBuilder):
# For pseries, we always assume OS supports usb3 # For pseries, we always assume OS supports usb3
if qemu_usb3: if qemu_usb3:
usb3 = True usb3 = True
elif self.os.is_loongarch64():
# For loongarch64, we always assume OS supports usb3
if qemu_usb3:
usb3 = True
if usb2: if usb2:
for dev in DeviceController.get_usb2_controllers(self.conn): for dev in DeviceController.get_usb2_controllers(self.conn):
@ -1024,7 +1030,8 @@ class Guest(XMLBuilder):
if self.os.is_container() and not self.conn.is_vz(): if self.os.is_container() and not self.conn.is_vz():
return return
if (not self.os.is_x86() and if (not self.os.is_x86() and
not self.os.is_pseries()): not self.os.is_pseries() and
not self.os.is_loongarch64()):
return return
self.add_device(DeviceGraphics(self.conn)) self.add_device(DeviceGraphics(self.conn))
@ -1037,7 +1044,8 @@ class Guest(XMLBuilder):
self.os.is_arm_machvirt() or self.os.is_arm_machvirt() or
self.os.is_riscv_virt() or self.os.is_riscv_virt() or
self.os.is_s390x() or self.os.is_s390x() or
self.os.is_pseries()): self.os.is_pseries() or
self.os.is_loongarch64()):
return return
if (self.conn.is_qemu() and if (self.conn.is_qemu() and
@ -1083,7 +1091,8 @@ class Guest(XMLBuilder):
self.os.is_arm_machvirt() or self.os.is_arm_machvirt() or
self.os.is_riscv_virt() or self.os.is_riscv_virt() or
self.os.is_s390x() or self.os.is_s390x() or
self.os.is_pseries()): self.os.is_pseries() or
self.os.is_loongarch64()):
return return
if self.osinfo.supports_virtioballoon(self._extra_drivers): if self.osinfo.supports_virtioballoon(self._extra_drivers):
@ -1110,6 +1119,8 @@ class Guest(XMLBuilder):
return True return True
if self.os.is_riscv_virt(): if self.os.is_riscv_virt():
return True return True
if self.os.is_loongarch64():
return True
return False return False
def _add_q35_pcie_controllers(self): def _add_q35_pcie_controllers(self):