Emulator Installation
Not supported yet The emulator is currently not supported. Support is planned for a future release.
XCENA Emulator runs a Linux guest and a simulated XCENA CXL device, allowing you to develop and test SDK applications without physical XCENA hardware. Use the emulator to check program behavior. Measure device performance on hardware because emulator timing includes software execution overhead.
XCENA Emulator is distributed as part of the XCENA Docker image.
Prerequisites
- Docker Engine installed on the Linux host.
- For KVM acceleration (recommended): hardware virtualization enabled,
/dev/kvmavailable, and permission for the container process to access it. - If KVM is unavailable, use QEMU software emulation (TCG) with
--no-kvm; this is slower. - Free disk space for the SDK image and the guest disk. For SDK v1.5.0, allow about 18 GB of additional space per container initially, plus room for guest writes. Disk usage varies by SDK image.
- The default launch gives the guest 48 GiB of RAM (
-m 48G).
Physical CXL hardware, CXL device passthrough, and XCENA drivers on the host are not required for this emulator workflow. The guest image provides the guest-side drivers. X11 and Wayland forwarding are optional for GUI applications; the terminal-based emulator does not require them or FUSE passthrough.
Check KVM on the host
Run these checks in the host terminal, before starting the container:
ls -l /dev/kvm
kvm-ok
On Ubuntu, kvm-ok is provided by the cpu-checker package; install that package if the command is unavailable. See the Ubuntu KVM instructions.
If /dev/kvm is missing or the check reports that KVM cannot be used, check CPU virtualization support, BIOS/UEFI virtualization settings, and host KVM module availability. When the host is itself a VM, nested virtualization must be available. If the device exists but access is denied, check its ownership and permissions for the user running the emulator. KVM availability on the host does not by itself guarantee access inside a container.
1. Prepare Docker Environment
For Docker installation and XCENA Docker image setup, refer to Docker Installation.
In the host terminal, enter the image tag from the release notes when prompted. Tags from v1.4.4 onward include the v prefix (for example, v1.4.11).
printf 'SDK image tag from the release notes: '
read -r SDK_TAG
Then start the container. The variable check prevents running without a tag. This example names the container xcena_sdk; use the same name when reconnecting later.
docker run -it --name xcena_sdk --device=/dev/kvm --cap-add=SYS_ADMIN -e USER="$USER" "xcenadev/sdk:${SDK_TAG:?Enter an SDK image tag}" /bin/bash
--device=/dev/kvm makes KVM available to the container. The command retains the SDK’s documented SYS_ADMIN capability and passes the host username through USER. It does not pass through a physical CXL device.
If KVM is unavailable, including in a VM without nested virtualization, omit the device option when creating the container:
docker run -it --name xcena_sdk --cap-add=SYS_ADMIN -e USER="$USER" "xcenadev/sdk:${SDK_TAG:?Enter an SDK image tag}" /bin/bash
Then use ./run.sh --no-kvm instead of ./run.sh in the launch step below. Choose the command that matches the host KVM check above.
Keep the terminal running docker run -it open while you use the emulator: closing it stops the container and any QEMU running in it. To leave it with the container still running, press Ctrl-P then Ctrl-Q. See If the original terminal was closed for recovery.
If the KVM command fails because /dev/kvm cannot be added, Docker can still leave an xcena_sdk container that never started. Before running the command without KVM, check its status in the host terminal:
docker ps -a --filter name='^xcena_sdk$'
Remove it only if its STATUS is Created:
docker rm xcena_sdk
To reuse a stopped container, run docker start -ai xcena_sdk on the host. To enter a running container, use docker exec -it xcena_sdk /bin/bash. Do not remove and recreate a container just to reconnect: removing it deletes guest disk changes stored in its writable layer unless that disk is kept in an external volume.
For Podman, use a fully qualified image name so that the registry is not chosen through short-name resolution:
podman run -it --name xcena_sdk --device=/dev/kvm --cap-add=SYS_ADMIN -e USER="$USER" "docker.io/xcenadev/sdk:${SDK_TAG:?Enter an SDK image tag}" /bin/bash
For rootless containers, device access also depends on user/group mapping and the host security policy. If /dev/kvm is accessible only through a supplementary group such as kvm, add --group-add keep-groups to this command; it requires the crun OCI runtime and cannot be combined with other --group-add values. Without KVM, omit --device=/dev/kvm and use ./run.sh --no-kvm. See the Podman device and group options.
2. Verify Installation
2.1 Launch QEMU
In the container shell, run:
cd /work/emulator
./run.sh
The terminal now displays the Linux guest’s boot output and console. The supplied Ubuntu image automatically logs in as xcena; wait for the guest shell prompt, then check initialization as described below. For a separate guest shell, follow Additional Terminal Access.
The first emulator launch in a new container may take several minutes without output. Wait for the guest shell prompt before running commands.
If you copy or move rootfs.qcow2, keep any matching rootfs.base.*.qcow2 file beside it; images using a base disk and an overlay need both files.
Warnings that the trace events cxl_type3_config_read and cxl_type3_config_write do not exist are harmless.
The guest console prompt appears only after the XCENA initialization service finishes, so the console can stay quiet for a while after the kernel messages; the first boot also updates SDK file ownership. If no prompt appears, press Enter, as described in Switching Consoles.
See the Emulator Guide for console switching and normal shutdown. You do not need to start another QEMU instance to open another terminal.
2.2 Verify SDK in QEMU
A working SSH connection does not mean device initialization has finished. In the guest shell, wait up to five minutes for the initialization service to finish and its marker to appear:
if timeout 300 bash -c 'until systemctl is-active --quiet xcena_init.service && test -f /opt/xcena/init_done; do systemctl is-failed --quiet xcena_init.service && exit 1; sleep 2; done'; then
echo "Initialization service completed; verify device detection below."
elif systemctl is-failed --quiet xcena_init.service; then
echo "Initialization service failed. Inspect the service logs."
else
echo "Initialization did not finish within this wait period. Inspect the service logs."
fi
On the serial console, the prompt appears only after the initialization service finishes, so this check returns immediately there. It waits only when you connect through ssh.sh before initialization ends.
This is a bounded check, not an expected startup duration. It stops early if the service fails. If it fails or times out, inspect the initialization service before running SDK workloads:
systemctl status xcena_init.service --no-pager
sudo journalctl -b -u xcena_init.service --no-pager -n 100
The marker records progress through the initialization script; it does not prove that every setup command succeeded. Once the check succeeds, check the SDK directory and device detection:
cd ~/sdk
ls
Next, confirm that the virtual XCENA device is detected correctly:
xcena_cli num-device
Expected output excerpt for the default single-device configuration (device details follow):
Number of devices : 1
If the device count is zero or differs from your configuration, inspect the service logs above before continuing. After a guest reboot, the device count can stay zero until QEMU is restarted; see Normal guest shutdown. The steps in xcena_cli Execution Errors are for physical hardware. Do not stop or remove the emulator container: stopping it kills QEMU, and removing it deletes guest disk changes stored in the container.
After confirming device detection, proceed with the Tutorials in QEMU.
With KVM, accessing CXL memory through SIMD instructions or float/double pointers can fail with an illegal instruction error. Applications that do this require ./run.sh --no-kvm. See Illegal Instruction Error with SIMD Access in QEMU.