Provisioning with qemu and libvirt

First, use the bootc-image-builder project to make a .raw or .qcow2 disk image from your container image.

The default base images do not have any default credentials to log in. If you have not configured any, and you are directly passing the default base image into the below command, you will not be able to log into the virtual machine. See Authentication as well as Building containers for more information.

Example bootc-image-builder invocation

Particularly when using container images that require a pull secret, you will need to ensure the image is pulled into your container storage before invoking the below command via e.g. podman pull <target container image>. The issue of authentication and image pulling is being discussed in this PR.
Run bootc-image-builder to turn a container image into a disk image
podman run \
    --rm \
    -it \
    --privileged \
    --pull=newer \
    --security-opt label=type:unconfined_t \
    -v $(pwd)/output:/output \
    -v /var/lib/containers/storage:/var/lib/containers/storage \
    quay.io/centos-bootc/bootc-image-builder:stream9 \
    --local \
    --type qcow2 \
    

There is no default root filesystem type configured for the Fedora base images; you can specify one via the --rootfs option, for example:

  • --rootfs xfs

  • --rootfs btrfs

etc.

For supported filesystem types in the base images, see Storage.

(Note that there are more options, such as including a config.json which can inject users and SSH keys)

libvirt

The libvirt project is supported on several platforms but is very common on Linux environments.

Here is a very simplified example virt-install invocation:

virt-install \
    --name fedora-bootc \
    --cpu host \
    --vcpus 4 \
    --memory 4096 \
    --import --disk ./output/qcow2/disk.qcow2,format=qcow2 \
    --os-variant fedora-eln

More information about virt-install is available in its man page, as well as other places such as Red Hat Enterprise Linux documentation.

qemu

Using "raw" qemu in some cases gives more control than higher level tools such as libvirt, but introduces architecture and platform specifics.

qemu-system-x86_64 (Linux)

qemu-system-x86_64 \
    -M accel=kvm \
    -cpu host \
    -smp 2 \
    -m 4096 \
    -bios /usr/share/OVMF/OVMF_CODE.fd \
    -serial stdio \
    -snapshot output/qcow2/disk.qcow2

qemu (macOS, ARM/aarch64)

qemu-system-aarch64 \
    -M accel=hvf \
    -cpu host \
    -smp 2 \
    -m 4096 \
    -bios /opt/homebrew/Cellar/qemu/8.1.3_2/share/qemu/edk2-aarch64-code.fd \
    -serial stdio \
    -machine virt \
    -snapshot output/qcow2/disk.qcow2