From a16501281a517d8d4ce6df4092944eb231ad13d5 Mon Sep 17 00:00:00 2001 From: jinqiang zhang Date: Mon, 8 Jun 2026 02:56:39 +0800 Subject: [PATCH 1/3] Add RISC-V support --- testcloud/config.py | 4 ++-- testcloud/distro_utils/debian.py | 2 +- testcloud/distro_utils/fedora.py | 4 ++++ testcloud/domain_configuration.py | 33 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/testcloud/config.py b/testcloud/config.py index 16a2d63..e2dc12e 100644 --- a/testcloud/config.py +++ b/testcloud/config.py @@ -273,8 +273,8 @@ def DATA_DIR(self, value): "latest": "9", } - DEBIAN_RELEASE_MAP = {"10": "buster", "11": "bullseye", "12": "bookworm"} - DEBIAN_LATEST = "12" + DEBIAN_RELEASE_MAP = {"10": "buster", "11": "bullseye", "12": "bookworm", "13": "trixie"} + DEBIAN_LATEST = "13" DEBIAN_IMG_URL = "https://cloud.debian.org/images/cloud/%s/daily/latest/debian-%s-genericcloud-%s-daily.qcow2" UBUNTU_RELEASES_API = "https://api.launchpad.net/devel/ubuntu/series" diff --git a/testcloud/distro_utils/debian.py b/testcloud/distro_utils/debian.py index 171f176..90b5c35 100644 --- a/testcloud/distro_utils/debian.py +++ b/testcloud/distro_utils/debian.py @@ -13,7 +13,7 @@ def get_debian_image_url(version: str, arch: str) -> str: - arch_map = {"x86_64": "amd64", "aarch64": "arm64", "ppc64le": "ppc64el"} + arch_map = {"x86_64": "amd64", "aarch64": "arm64", "ppc64le": "ppc64el", "riscv64": "riscv64"} if arch not in arch_map: log.error("Requested architecture is not supported by testcloud for Debian.") diff --git a/testcloud/distro_utils/fedora.py b/testcloud/distro_utils/fedora.py index 7c3d6c9..f664a52 100644 --- a/testcloud/distro_utils/fedora.py +++ b/testcloud/distro_utils/fedora.py @@ -152,6 +152,10 @@ def get_fedora_image_url(version: str, arch: str) -> str: raise exceptions.TestcloudImageError return str(url) + # RISC-V image not released + if arch == "riscv64": + return "https://dl.fedoraproject.org/pub/alt/risc-v/release/42/Cloud/riscv64/images/Fedora-Cloud-Base-Generic-42.20250911-2251ba41cdd3.riscv64.qcow2" + try: releases = session.get("https://getfedora.org/releases.json").json() except (ConnectionError, requests.exceptions.JSONDecodeError): diff --git a/testcloud/domain_configuration.py b/testcloud/domain_configuration.py index e73b680..3194ebf 100644 --- a/testcloud/domain_configuration.py +++ b/testcloud/domain_configuration.py @@ -155,6 +155,37 @@ def generate(self) -> str: ) +class RISCV64ArchitectureConfiguration(ArchitectureConfiguration): + qemu = "qemu-system-riscv64" + arch = "riscv64" + model = "virt" + + def __init__(self, kvm=True, uefi=True, model="virt") -> None: + self.kvm = kvm + self.uefi = uefi + self.model = model + + def generate(self) -> str: + return """ + + hvm + {uefi_loader} + + + {cpu} + + """.format( + arch=self.arch, + model=self.model, + uefi_loader="/usr/share/edk2/riscv/RISCV_VIRT_CODE.qcow2", + cpu=( + "" + if self.kvm + else "rva23s64" + ), + ) + + def storage_device_name_generator(): prefix = "vd" for i in range(26): @@ -529,6 +560,8 @@ def _get_default_domain_conf( domain_configuration.system_architecture = Ppc64leArchitectureConfiguration(kvm=kvm, uefi=False, model="pseries") elif desired_arch == "s390x": domain_configuration.system_architecture = S390xArchitectureConfiguration(kvm=kvm, uefi=False, model="s390-ccw-virtio") + elif desired_arch == "riscv64": + domain_configuration.system_architecture = RISCV64ArchitectureConfiguration(kvm=kvm, uefi=True, model="virt") else: raise TestcloudInstanceError("Unsupported arch") From bf29ed4f360be20de645778bad415c9f1f7a2239 Mon Sep 17 00:00:00 2001 From: jinqiang zhang Date: Tue, 30 Jun 2026 20:47:16 +0800 Subject: [PATCH 2/3] fedora: dynamically discover latest RISC-V Cloud Base image Instead of hardcoding a specific image URL, scrape the directory listing at dl.fedoraproject.org/pub/alt/risc-v/release/{version}/Cloud/riscv64/images/ to find the latest Fedora-Cloud-Base-Generic qcow2 for the requested version. --- testcloud/distro_utils/fedora.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/testcloud/distro_utils/fedora.py b/testcloud/distro_utils/fedora.py index f664a52..20e0cbd 100644 --- a/testcloud/distro_utils/fedora.py +++ b/testcloud/distro_utils/fedora.py @@ -154,7 +154,19 @@ def get_fedora_image_url(version: str, arch: str) -> str: # RISC-V image not released if arch == "riscv64": - return "https://dl.fedoraproject.org/pub/alt/risc-v/release/42/Cloud/riscv64/images/Fedora-Cloud-Base-Generic-42.20250911-2251ba41cdd3.riscv64.qcow2" + images_url = "https://dl.fedoraproject.org/pub/alt/risc-v/release/%s/Cloud/riscv64/images/" % version + try: + response = session.get(images_url) + response.raise_for_status() + except Exception: + log.error("Couldn't fetch RISC-V image listing for Fedora %s" % version) + raise exceptions.TestcloudImageError + matches = re.findall(r'href="(Fedora-Cloud-Base-Generic-[^"]+\.riscv64\.qcow2)"', response.text) + if not matches: + log.error("No RISC-V Cloud Base image found for Fedora %s" % version) + raise exceptions.TestcloudImageError + matches.sort(reverse=True) + return images_url + matches[0] try: releases = session.get("https://getfedora.org/releases.json").json() From 6355447532c0b1b8266e081810346f7ba57192bd Mon Sep 17 00:00:00 2001 From: jinqiang zhang Date: Tue, 30 Jun 2026 20:48:17 +0800 Subject: [PATCH 3/3] README: add riscv64 support Add riscv64 to the list of supported architectures and add a usage example for Debian 13 on riscv64. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a5c159..404031c 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ the **virt-manager** tool. Instances can be created with a different architecture than the host architecture. You'll need to have a proper qemu binary installed for this to work (eg. qemu-system-aarch64-core for aarch64 on x86_64 on Fedora). Supported -architectures in testcloud are: x86_64, aarch64, ppc64le, and s390x. Any combinations of these are supported. +architectures in testcloud are: x86_64, aarch64, ppc64le, s390x, and riscv64. Any combinations of these are supported. Some examples: @@ -131,6 +131,11 @@ $ testcloud create centos-stream --arch x86_64 $ testcloud create fedora:rawhide --arch ppc64le ``` +``` +# Debian riscv64 on x86_64 (or any other) +$ testcloud create debian:13 --arch riscv64 +``` + ### Starting, stopping, and removing an instance Instances can be started and stopped using the `instance` interface of