> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a secondary virtual machine

This section provides the steps for creating virtual machine (VM) images using the Qualcomm Linux build system. The Guest VM rootfs and Guest VM kernel are same as that of the host.

Qualcomm Linux supports virtual machine monitors, with or without KVM. Currently, Qualcomm Linux supports only [QEMU](https://www.qemu.org/) as VM monitor.

The procedure provides the following:

> * Command to setup KVM.
> * Commands to launch the Guest VM using QEMU.

## **Set up the development machine**

To set up the development machine, follow the steps:

1. To set up the build, see [Build Qualcomm Linux](https://dragonwingdocs.qualcomm.com/Key-Documents/Yocto-Guide/build-qualcomm-linux#build-qualcomm-linux).
   <Note>
     `kvm` is enabled by default in `DISTRO_FEATURES` for all Qualcomm Linux distributions. No separate KVM distro configuration is required. KVM hardware acceleration is available on machines that include `kvm` in `MACHINE_FEATURES`, currently: `iq-9075-evk` and `iq-8275-evk`. On other machines, QEMU runs without KVM acceleration.
   </Note>
2. Append `virtualization` to `DISTRO_FEATURES` in build directory: `conf/local.conf`.
   ```text theme={null}
   DISTRO_FEATURES:append = " virtualization"
   ```
3. Build `qcom-console-image` or `qcom-multimedia-image`:
   ```text theme={null}
   bitbake qcom-console-image
   ```

## **Launch Guest VM**

This section describes how to launch a Guest VM on a Qualcomm Linux machine using QEMU, with and without Kernel‑based virtual machine (KVM) acceleration.

Prerequisites

* QEMU is available on the machine.
* The Guest VM uses the host root file system image.
* The Guest VM kernel image is available at `/boot/Image`.

1. Copy the host root file system image to the device and use it as the root file system for the Guest VM.
   **Note**
   If `qcom-console-image` is built for the `qcs9100-ride-sx` platform, the root file system image for the Guest VM is available at: `<build dir>/tmp/deploy/images/qcs9100-ride-sx/qcom-console-image-qcs9100-ride-sx.rootfs.qcomflash/rootfs.img`.
2. Launch the Guest VM.
   * Launching the Guest VM without KVM acceleration:
     Run the following command to launch the Guest VM using QEMU without KVM acceleration:
     > ```text theme={null}
     > qemu-system-aarch64 -M virt  \
     >                     -cpu cortex-a76  \
     >                     -m 4G \
     >                     -kernel /boot/Image \
     >                     -drive file=rootfs.img,if=virtio,format=raw \
     >                     -append "root=/dev/vda" \
     >                     -accel tcg \
     >                     -smp 4 \
     >                     -nographic
     > ```
   * Launching the Guest VM with KVM:
     <Note>
       * KVM is enabled by default in `DISTRO_FEATURES`. The machine must include `kvm` in `MACHINE_FEATURES` (e.g., `iq-9075-evk`, `iq-8275-evk`).
     </Note>
     * The `/dev/kvm` device node must be present on the machine.
     * Verify that KVM is available:
       ```text theme={null}
       ls /dev/kvm
       ```
     * Run the following command to launch Guest VM in QEMU with KVM acceleration.
       ```text theme={null}
       qemu-system-aarch64 -M virt \
                           -m 4G \
                           -kernel /boot/Image \
                           -drive file=rootfs.img,if=virtio,format=raw \
                           -append "root=/dev/vda" \
                           -enable-kvm \
                           -cpu host \
                           --enable-kvm \
                           -smp 4 \
                           -nographic
       ```
   **Note**
   * The `rootfs.img` file is located in the current working directory. To use a different location, update the `-drive` option accordingly. For example: `-drivefile=/mydir/rootfs.img,if=virtio,format=raw`
   * The Guest VM kernel is provided using the `-kernel /boot/Image` option.

For more information, see [Enable virtualization](https://dragonwingdocs.qualcomm.com/System/Kernel/enable-virtualization).

## **Next steps**

* For Docker container support, see [Run Docker containers](./run-docker-containers).
* For Kubernetes enablement, see [Set up Kubernetes with Qualcomm Linux](./set-up-kubernetes-with-qualcomm-linux).
  `kvm` is enabled by default in `DISTRO_FEATURES` for all Qualcomm Linux distributions. No separate KVM distro configuration is required. KVM hardware acceleration is available on machines that include `kvm` in `MACHINE_FEATURES`, currently: `iq-9075-evk` and `iq-8275-evk`. On other machines, QEMU runs without KVM acceleration.
