diff --git a/add-loongarch64-libvirt-support.patch b/add-loongarch64-libvirt-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..89659900f219b836a47d4fa4d871c5b70c6f3a88 --- /dev/null +++ b/add-loongarch64-libvirt-support.patch @@ -0,0 +1,128 @@ +diff --git a/nova/objects/fields.py b/nova/objects/fields.py +index 960fcc8..bee0acf 100644 +--- a/nova/objects/fields.py ++++ b/nova/objects/fields.py +@@ -137,6 +137,7 @@ class Architecture(BaseNovaEnum): + I686 = arch.I686 + IA64 = arch.IA64 + LM32 = arch.LM32 ++ LOONGARCH64 = arch.LOONGARCH64 + + M68K = arch.M68K + MICROBLAZE = arch.MICROBLAZE +diff --git a/nova/virt/arch.py b/nova/virt/arch.py +index 7518ab9..f73d2b2 100644 +--- a/nova/virt/arch.py ++++ b/nova/virt/arch.py +@@ -23,6 +23,7 @@ CRIS = 'cris' + I686 = 'i686' + IA64 = 'ia64' + LM32 = 'lm32' ++LOONGARCH64 = 'loongarch64' + + M68K = 'm68k' + MICROBLAZE = 'microblaze' +@@ -56,7 +57,7 @@ XTENSAEB = 'xtensaeb' + + ALL = ( + ALPHA, ARMV6, ARMV7, ARMV7B, +- AARCH64, CRIS, I686, IA64, LM32, ++ AARCH64, CRIS, I686, IA64, LM32, LOONGARCH64, + M68K, MICROBLAZE, MICROBLAZEEL, MIPS, MIPSEL, + MIPS64, MIPS64EL, OPENRISC, PARISC, PARISC64, + PPC, PPCLE, PPC64, PPC64LE, PPCEMB, +diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py +index db255a5..48e036c 100644 +--- a/nova/virt/libvirt/driver.py ++++ b/nova/virt/libvirt/driver.py +@@ -5053,8 +5053,7 @@ class LibvirtDriver(driver.ComputeDriver): + 'migration can break unless all compute nodes ' + 'have identical cpus. AArch64 does not support ' + 'other modes.') +- elif caps.host.cpu.arch == fields.Architecture.LOONGARCH64: +- mode = "custom" ++ elif arch == fields.Architecture.LOONGARCH64: + model = "la464" + else: + mode = "host-model" +@@ -5066,7 +5065,7 @@ class LibvirtDriver(driver.ComputeDriver): + if arch == fields.Architecture.AARCH64: + if not models: + models = ['max'] +- if caps.host.cpu.arch == fields.Architecture.LOONGARCH64: ++ if arch == fields.Architecture.LOONGARCH64: + if not models: + models = ["la464"] + +@@ -5951,6 +5950,8 @@ class LibvirtDriver(driver.ComputeDriver): + # NOTE(kevinz): Only virtio device type is supported by AARCH64 + # so use 'virtio' instead when running on AArch64 hardware. + video.type = 'virtio' ++ elif guestarch == fields.Architecture.LOONGARCH64: ++ video.type = 'virtio' + elif CONF.spice.enabled: + video.type = 'qxl' + if image_meta.properties.get('hw_video_model'): +@@ -6147,7 +6148,8 @@ class LibvirtDriver(driver.ComputeDriver): + caps = self._host.get_capabilities() + return self._host.supports_uefi and ( + hw_firmware_type == fields.FirmwareType.UEFI or +- caps.host.cpu.arch == fields.Architecture.AARCH64 ++ caps.host.cpu.arch == fields.Architecture.AARCH64 or ++ caps.host.cpu.arch == fields.Architecture.LOONGARCH64 + ) + + def _check_secure_boot_support( +@@ -6215,7 +6217,7 @@ class LibvirtDriver(driver.ComputeDriver): + + hw_firmware_type = image_meta.properties.get('hw_firmware_type') + +- if arch == fields.Architecture.AARCH64: ++ if arch == fields.Architecture.AARCH64 or arch == fields.Architecture.LOONGARCH64: + if not hw_firmware_type: + hw_firmware_type = fields.FirmwareType.UEFI + +@@ -6585,6 +6587,9 @@ class LibvirtDriver(driver.ComputeDriver): + guest.os_mach_type is not None and + 'q35' in guest.os_mach_type): + return True ++ if (caps.host.cpu.arch == fields.Architecture.LOONGARCH64 and ++ guest.os_mach_type.startswith('virt')): ++ return True + return False + + def _get_guest_config(self, instance, network_info, image_meta, +@@ -7010,7 +7015,7 @@ class LibvirtDriver(driver.ComputeDriver): + # TODO(stephenfin): We might want to do this for other non-x86 + # architectures + arch = libvirt_utils.get_arch(image_meta) +- if arch != fields.Architecture.AARCH64: ++ if arch != fields.Architecture.AARCH64 and arch != fields.Architecture.LOONGARCH64: + return None + + bus = 'usb' +@@ -9360,9 +9365,9 @@ class LibvirtDriver(driver.ComputeDriver): + LOG.debug("cpu compare xml: %s", cpu_xml, instance=instance) + ret = self._host.compare_cpu(cpu_xml) + except libvirt.libvirtError as e: +- if cpu.arch == fields.Architecture.AARCH64: ++ if cpu.arch == fields.Architecture.AARCH64 or cpu.arch == fields.Architecture.LOONGARCH64: + LOG.debug("Host CPU compatibility check does not make " +- "sense on AArch64; skip CPU comparison") ++ "sense on AArch64 or LoongArch64; skip CPU comparison") + return + error_code = e.get_error_code() + if error_code == libvirt.VIR_ERR_NO_SUPPORT: +diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py +index 8708f3c..04d063f 100644 +--- a/nova/virt/libvirt/utils.py ++++ b/nova/virt/libvirt/utils.py +@@ -530,6 +530,8 @@ def get_cpu_model_from_arch(arch: str) -> str: + # that all the stuff it can currently emulate, both for "TCG" and "KVM" + elif arch == obj_fields.Architecture.AARCH64: + mode = 'max' ++ elif arch == obj_fields.Architecture.LOONGARCH64: ++ mode = 'la464' + return mode + + diff --git a/openstack-nova.spec b/openstack-nova.spec index 063a1378dd36bf87682e7bc9c229323859976bcb..446d2b89b9ef3ff8c96ce1caa0ef58a22ed1a2a3 100644 --- a/openstack-nova.spec +++ b/openstack-nova.spec @@ -17,7 +17,7 @@ Name: openstack-nova # Liberty semver reset # https://review.openstack.org/#/q/I6a35fa0dda798fad93b804d00a46af80f08d475c,n,z Version: 23.2.2 -Release: 2 +Release: 3 Summary: OpenStack Compute (nova) License: ASL 2.0 @@ -51,6 +51,7 @@ Source40: nova_migration-rootwrap.conf Source41: nova_migration-rootwrap_cold_migration Patch01: add-loongarch64-support.patch +Patch02: add-loongarch64-libvirt-support.patch BuildArch: noarch @@ -726,6 +727,9 @@ exit 0 %endif %changelog +* Tue Jun 11 2024 zhaixiaojuan - 23.2.2-3 +- Add loongarch64 libvirt support + * Tue Jun 11 2024 zhaixiaojuan - 23.2.2-2 - Add loongarch64 support