firecracker-microvm / firecracker

Secure and fast microVMs for serverless computing.
http://firecracker-microvm.io
Apache License 2.0
25.03k stars 1.75k forks source link

[Feature Request] Different guest architecture #2812

Closed denysvitali closed 2 years ago

denysvitali commented 2 years ago

Feature Request

According to this FAQ entry it is currently not possible to emulate another architecture.

An example of a use case would be to be able to run an Alpine aarch64 image on an x86_64 host.

Can I emulate a different architecture in the guest than the one on the host?

Guest operating systems must be built for the same CPU architecture as the host on which it will run. Firecracker does not support running microVMs on any architecture other than the one the host is running on. In other words, running an OS built for a x86_64 on an aarch64 system will not work, and vice versa.

I haven't found anywhere in the repo whether this is on purpose or it's just a feature that is lacking, and I would like to know if:

The FAQ don't mention exactly what's the scope of this project, and its relationship with QEMU is vaguely worded:

Firecracker is an alternative to QEMU that is purpose-built for running serverless functions and containers safely and efficiently, and nothing more.

Describe the desired solution

Starting a VM with firecracker-ctl on a x86_64 host should work:

#!/bin/bash
FC_SOCK="/tmp/firecracker.sock"
export FC_SOCK

firecracker-ctl boot-source \
  --boot-args "console=ttyS0 reboot=k panic=1 pci=off" \
  "$PWD/vmlinux-aarch64"

firecracker-ctl drive \
  --id rootfs \
  -r=false \
  -R=true \
  -p "$PWD/alpine.rootfs-aarch64.ext4"

firecracker-ctl action start

Currently, the CLI fails with:

FATA[0000] action failed: unexpected 400 : {"fault_message":"Cannot load kernel due to invalid memory configuration or invalid kernel image. Invalid ELF magic number"}

and the firecrackerd daemon fails with:

2021-12-10T14:43:56.451798605 [anonymous-instance:fc_api:ERROR:src/api_server/src/parsed_request.rs:128] Received Error. Status code: 400 Bad Request. Message: Cannot load kernel due to invalid memory configuration or invalid kernel image. Invalid ELF magic number

Describe possible alternatives

Additional context

N/A

Checks

raduiliescu commented 2 years ago

Hi @denysvitali,

We don't plan to add CPU emulation support in Firecracker.

Firecracker is minimalist in features and offers a lightweight virtualization model. This enable us to maintain a low attack surface, and utilize the resources efficiently, making Firecracker well suited for serverless workloads. Adding CPU emulation capabilities will complicate the device model, without bringing considerable benefits for our targeted workloads.

Thanks!