Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions testcloud/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
peeweep marked this conversation as resolved.
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"
Expand Down
2 changes: 1 addition & 1 deletion testcloud/distro_utils/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Comment thread
peeweep marked this conversation as resolved.

if arch not in arch_map:
log.error("Requested architecture is not supported by testcloud for Debian.")
Expand Down
16 changes: 16 additions & 0 deletions testcloud/distro_utils/fedora.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ def get_fedora_image_url(version: str, arch: str) -> str:
raise exceptions.TestcloudImageError
return str(url)

# RISC-V image not released
if arch == "riscv64":
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()
except (ConnectionError, requests.exceptions.JSONDecodeError):
Expand Down
33 changes: 33 additions & 0 deletions testcloud/domain_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
<os>
<type arch='{arch}' machine='{model}'>hvm</type>
{uefi_loader}
<boot dev='hd'/>
</os>
{cpu}
<memballoon model='virtio'></memballoon>
""".format(
arch=self.arch,
model=self.model,
uefi_loader="<loader readonly='yes' type='pflash'>/usr/share/edk2/riscv/RISCV_VIRT_CODE.qcow2</loader>",
cpu=(
"<cpu mode='host-passthrough' check='none'/>"
if self.kvm
else "<cpu mode='custom' match='exact'><model>rva23s64</model></cpu>"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to be more conservative here? e.g. use rather rv64 ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'd prefer to keep rva23s64 for now. My primary use case is testing openruyi RISC-V images, which need at least RVA23. Since rva23s64 is a superset of rv64, it should remain backwards compatible so it won't cause issues for other use cases.

),
)


def storage_device_name_generator():
prefix = "vd"
for i in range(26):
Expand Down Expand Up @@ -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")

Expand Down