# Create a secondary virtual machine

This section provides the steps for creating virtual machine (VM)
images using the Qualcomm Linux build system.

To use a virtual machine with Qualcomm Linux, ensure that the image recipes include the
virtual machine manager (VMM) tools, and generate the Guest VM kernel and root file system images.

The procedure provides the following:

> 
> 
> - Include essential VMM tools, such as `crosvm` and `qemu`
> in the image recipes already defined in Qualcomm Linux.
> - Use commands to build Guest VM kernel and root file system images.
> - Use commands to launch the Guest VM.

## Set up the development machine

1. Install `clang` on the host development machine:

sudo apt install clang-11
        Copy to clipboard
2. Enable the `meta-rust` layer in the Qualcomm Linux environment. The `meta-rust` layer provides Rust compiler (rustc) and package
manager (cargo) to compile crosvm, which is implemented in the Rust language.
3. Add the `meta-rust` layer to `EXTRALAYERS` in the `meta-qcom-distro/conf/bblayers.conf` file and then
open the `conf/bblayers.conf` file and add the layer path to `EXTRALAYERS` variable as follows:

EXTRALAYERS ?= " \
        ${WORKSPACE}/layers/meta-rust \
        "
        Copy to clipboard
4. Create the `meta-qcom-distro/conf/distro/include/rust_version.inc` file with the following content:

# include this in your distribution to easily switch between versions
        # just by changing RUST_VERSION variable
        
        RUST_VERSION ?= "1.73.0"
        
        PREFERRED_VERSION_cargo ?= "${RUST_VERSION}"
        PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}"
        PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}"
        PREFERRED_VERSION_rust ?= "${RUST_VERSION}"
        PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}"
        PREFERRED_VERSION_rust-llvm ?= "${RUST_VERSION}"
        PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}"
        PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}"
        Copy to clipboard
5. Include the `rust_version.inc` file in the `meta-qcom-distro/conf/distro/qcom-wayland.conf` file as follows:

require conf/distro/include/rust_version.inc
        Copy to clipboard

## Add the `crosvm` tool to Qualcomm Linux images

To add the `crosvm` tool to the images built by Qualcomm Linux, edit the `meta-qcom-distro/recipes-products/packagegroups/packagegroup-qcom-vm-host.bb` package group recipe file and add the following code block:

RDEPENDS:packagegroup-qcom-vm-host:append:qcom-custom-bsp = "\
       crosvm \
       "
    Copy to clipboard

## Build the image recipe and the Guest VM images

1. To build an existing Qualcomm Linux image recipe, run the `bitbake <image>` command. This includes the `crosvm` tool in the image generated.
For example, for `qcom-console-image` run the following command:

bitbake qcom-console-image
        Copy to clipboard
2. To build a Guest VM image, run the following command:

bitbake multiconfig:qcom-guestvm:qcom-guestvm-image
        Copy to clipboard

    After the Guest VM image is successfully created, you can find the following artifacts:

    - The Guest VM build command creates a folder named `tmp-qcom-guestvm-glibc` for the Guest VM image.
    - The Guest VM kernel and rootfs images are generated in the `tmp-qcom-guestvm-glibc/deploy/images/<machine-name>` directory.
    - The `tmp-qcom-guestvm-glibc/deploy/images/<machine-name>/Image` file is the Guest VM kernel image.
    - The `tmp-qcom-guestvm-glibc/deploy/images/<machine-name>/qcom-guestvm-image-<machine-name>.ext4` file is the Guest VM root file system image.
    - After flashing the images created by the `bitbake <image>` command and booting up the device, copy the Guest VM kernel and root file system images to the device, for example, under the `/var/gunyah` directory.

## Launch Guest VM

1. To launch Guest VM, use the crosvm tool.
2. In the following command, the Guest VM kernel and the root file system images are from the `/var/gunyah` directory on the device.

crosvm --log-level=debug --no-syslog run --disable-sandbox --hypervisor gunyah --protected-vm-without-firmware \
        --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 --serial=type=stdout,hardware=serial,earlycon,num=1 \
        --root /var/gunyah/qcom-guestvm-image-qcs9100-ride-sx.ext4 --no-balloon --no-rng --params \
        "earlyprintk=serial panic=0" /var/gunyah/Image
        Copy to clipboard

    - The `--root /var/gunyah/qcom-guestvm-image-qcs9100-ride-sx.ext4` option specifies the path to the root file system for the Guest VM.
    - The last parameter `/var/gunyah/Image` is passed to the `crosvm` tool that specifies the path to the kernel image.

For more information, see [Enable virtualization](https://docs.qualcomm.com/bundle/publicresource/topics/80-70029-3/virtualization.html).

Last Published: Mar 16, 2026

[Previous Topic
Configure property-vault properties](https://docs.qualcomm.com/bundle/publicresource/80-70029-27/topics/configure_properties.md) [Next Topic
Update firmware and OS on Qualcomm Linux using capsule and OSTree mechanisms](https://docs.qualcomm.com/bundle/publicresource/80-70029-27/topics/update_fw_and_os_qualcomm_linux_using_capsule_and_ostree_mechanisms.md)