Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 2 | |
| 3 | ******************************* |
| 4 | Using the Quick EMUlator (QEMU) |
| 5 | ******************************* |
| 6 | |
| 7 | The Yocto Project uses an implementation of the Quick EMUlator (QEMU) |
| 8 | Open Source project as part of the Yocto Project development "tool set". |
| 9 | This chapter provides both procedures that show you how to use the Quick |
| 10 | EMUlator (QEMU) and other QEMU information helpful for development |
| 11 | purposes. |
| 12 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 13 | Overview |
| 14 | ======== |
| 15 | |
| 16 | Within the context of the Yocto Project, QEMU is an emulator and |
| 17 | virtualization machine that allows you to run a complete image you have |
| 18 | built using the Yocto Project as just another task on your build system. |
| 19 | QEMU is useful for running and testing images and applications on |
| 20 | supported Yocto Project architectures without having actual hardware. |
| 21 | Among other things, the Yocto Project uses QEMU to run automated Quality |
| 22 | Assurance (QA) tests on final images shipped with each release. |
| 23 | |
| 24 | .. note:: |
| 25 | |
| 26 | This implementation is not the same as QEMU in general. |
| 27 | |
| 28 | This section provides a brief reference for the Yocto Project |
| 29 | implementation of QEMU. |
| 30 | |
| 31 | For official information and documentation on QEMU in general, see the |
| 32 | following references: |
| 33 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 34 | - `QEMU Website <https://wiki.qemu.org/Main_Page>`__\ *:* The official |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 35 | website for the QEMU Open Source project. |
| 36 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 37 | - `Documentation <https://wiki.qemu.org/Manual>`__\ *:* The QEMU user |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 38 | manual. |
| 39 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 40 | Running QEMU |
| 41 | ============ |
| 42 | |
| 43 | To use QEMU, you need to have QEMU installed and initialized as well as |
| 44 | have the proper artifacts (i.e. image files and root filesystems) |
| 45 | available. Follow these general steps to run QEMU: |
| 46 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 47 | #. *Install QEMU:* QEMU is made available with the Yocto Project a |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 48 | number of ways. One method is to install a Software Development Kit |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 49 | (SDK). See ":ref:`sdk-manual/intro:the qemu emulator`" section in the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 50 | Yocto Project Application Development and the Extensible Software |
| 51 | Development Kit (eSDK) manual for information on how to install QEMU. |
| 52 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 53 | #. *Setting Up the Environment:* How you set up the QEMU environment |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 54 | depends on how you installed QEMU: |
| 55 | |
| 56 | - If you cloned the ``poky`` repository or you downloaded and |
| 57 | unpacked a Yocto Project release tarball, you can source the build |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 58 | environment script (i.e. :ref:`structure-core-script`):: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 59 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 60 | $ cd poky |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 61 | $ source oe-init-build-env |
| 62 | |
| 63 | - If you installed a cross-toolchain, you can run the script that |
| 64 | initializes the toolchain. For example, the following commands run |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 65 | the initialization script from the default ``poky_sdk`` directory:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 66 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 67 | . poky_sdk/environment-setup-core2-64-poky-linux |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 68 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 69 | #. *Ensure the Artifacts are in Place:* You need to be sure you have a |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 70 | pre-built kernel that will boot in QEMU. You also need the target |
| 71 | root filesystem for your target machine's architecture: |
| 72 | |
| 73 | - If you have previously built an image for QEMU (e.g. ``qemux86``, |
| 74 | ``qemuarm``, and so forth), then the artifacts are in place in |
| 75 | your :term:`Build Directory`. |
| 76 | |
| 77 | - If you have not built an image, you can go to the |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 78 | :yocto_dl:`machines/qemu </releases/yocto/yocto-&DISTRO;/machines/qemu/>` area and download a |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 79 | pre-built image that matches your architecture and can be run on |
| 80 | QEMU. |
| 81 | |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 82 | See the ":ref:`sdk-manual/appendix-obtain:extracting the root filesystem`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 83 | section in the Yocto Project Application Development and the |
| 84 | Extensible Software Development Kit (eSDK) manual for information on |
| 85 | how to extract a root filesystem. |
| 86 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 87 | #. *Run QEMU:* The basic ``runqemu`` command syntax is as follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 88 | |
| 89 | $ runqemu [option ] [...] |
| 90 | |
| 91 | Based on what you provide on the command |
| 92 | line, ``runqemu`` does a good job of figuring out what you are trying |
| 93 | to do. For example, by default, QEMU looks for the most recently |
| 94 | built image according to the timestamp when it needs to look for an |
| 95 | image. Minimally, through the use of options, you must provide either |
| 96 | a machine name, a virtual machine image (``*wic.vmdk``), or a kernel |
| 97 | image (``*.bin``). |
| 98 | |
| 99 | Here are some additional examples to help illustrate further QEMU: |
| 100 | |
| 101 | - This example starts QEMU with MACHINE set to "qemux86-64". |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 102 | Assuming a standard :term:`Build Directory`, ``runqemu`` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 103 | automatically finds the ``bzImage-qemux86-64.bin`` image file and |
| 104 | the ``core-image-minimal-qemux86-64-20200218002850.rootfs.ext4`` |
| 105 | (assuming the current build created a ``core-image-minimal`` |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 106 | image):: |
| 107 | |
| 108 | $ runqemu qemux86-64 |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 109 | |
| 110 | .. note:: |
| 111 | |
| 112 | When more than one image with the same name exists, QEMU finds |
| 113 | and uses the most recently built image according to the |
| 114 | timestamp. |
| 115 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 116 | - This example produces the exact same results as the previous |
| 117 | example. This command, however, specifically provides the image |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 118 | and root filesystem type:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 119 | |
| 120 | $ runqemu qemux86-64 core-image-minimal ext4 |
| 121 | |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 122 | - This example specifies to boot an :term:`Initramfs` image and to |
| 123 | enable audio in QEMU. For this case, ``runqemu`` sets the internal |
| 124 | variable ``FSTYPE`` to ``cpio.gz``. Also, for audio to be enabled, |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 125 | an appropriate driver must be installed (see the ``audio`` option |
| 126 | in :ref:`dev-manual/qemu:\`\`runqemu\`\` command-line options` |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 127 | for more information):: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 128 | |
| 129 | $ runqemu qemux86-64 ramfs audio |
| 130 | |
| 131 | - This example does not provide enough information for QEMU to |
| 132 | launch. While the command does provide a root filesystem type, it |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 133 | must also minimally provide a `MACHINE`, `KERNEL`, or `VM` option:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 134 | |
| 135 | $ runqemu ext4 |
| 136 | |
| 137 | - This example specifies to boot a virtual machine image |
| 138 | (``.wic.vmdk`` file). From the ``.wic.vmdk``, ``runqemu`` |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 139 | determines the QEMU architecture (`MACHINE`) to be "qemux86-64" and |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 140 | the root filesystem type to be "vmdk":: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 141 | |
| 142 | $ runqemu /home/scott-lenovo/vm/core-image-minimal-qemux86-64.wic.vmdk |
| 143 | |
| 144 | Switching Between Consoles |
| 145 | ========================== |
| 146 | |
| 147 | When booting or running QEMU, you can switch between supported consoles |
| 148 | by using Ctrl+Alt+number. For example, Ctrl+Alt+3 switches you to the |
| 149 | serial console as long as that console is enabled. Being able to switch |
| 150 | consoles is helpful, for example, if the main QEMU console breaks for |
| 151 | some reason. |
| 152 | |
| 153 | .. note:: |
| 154 | |
| 155 | Usually, "2" gets you to the main console and "3" gets you to the |
| 156 | serial console. |
| 157 | |
| 158 | Removing the Splash Screen |
| 159 | ========================== |
| 160 | |
| 161 | You can remove the splash screen when QEMU is booting by using Alt+left. |
| 162 | Removing the splash screen allows you to see what is happening in the |
| 163 | background. |
| 164 | |
| 165 | Disabling the Cursor Grab |
| 166 | ========================= |
| 167 | |
| 168 | The default QEMU integration captures the cursor within the main window. |
| 169 | It does this since standard mouse devices only provide relative input |
| 170 | and not absolute coordinates. You then have to break out of the grab |
| 171 | using the "Ctrl+Alt" key combination. However, the Yocto Project's |
| 172 | integration of QEMU enables the wacom USB touch pad driver by default to |
| 173 | allow input of absolute coordinates. This default means that the mouse |
| 174 | can enter and leave the main window without the grab taking effect |
| 175 | leading to a better user experience. |
| 176 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 177 | Running Under a Network File System (NFS) Server |
| 178 | ================================================ |
| 179 | |
| 180 | One method for running QEMU is to run it on an NFS server. This is |
| 181 | useful when you need to access the same file system from both the build |
| 182 | and the emulated system at the same time. It is also worth noting that |
| 183 | the system does not need root privileges to run. It uses a user space |
| 184 | NFS server to avoid that. Follow these steps to set up for running QEMU |
| 185 | using an NFS server. |
| 186 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 187 | #. *Extract a Root Filesystem:* Once you are able to run QEMU in your |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 188 | environment, you can use the ``runqemu-extract-sdk`` script, which is |
| 189 | located in the ``scripts`` directory along with the ``runqemu`` |
| 190 | script. |
| 191 | |
| 192 | The ``runqemu-extract-sdk`` takes a root filesystem tarball and |
| 193 | extracts it into a location that you specify. Here is an example that |
| 194 | takes a file system and extracts it to a directory named |
| 195 | ``test-nfs``: |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 196 | |
| 197 | .. code-block:: none |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 198 | |
| 199 | runqemu-extract-sdk ./tmp/deploy/images/qemux86-64/core-image-sato-qemux86-64.tar.bz2 test-nfs |
| 200 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 201 | #. *Start QEMU:* Once you have extracted the file system, you can run |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 202 | ``runqemu`` normally with the additional location of the file system. |
| 203 | You can then also make changes to the files within ``./test-nfs`` and |
| 204 | see those changes appear in the image in real time. Here is an |
| 205 | example using the ``qemux86`` image: |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 206 | |
| 207 | .. code-block:: none |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 208 | |
| 209 | runqemu qemux86-64 ./test-nfs |
| 210 | |
| 211 | .. note:: |
| 212 | |
| 213 | Should you need to start, stop, or restart the NFS share, you can use |
| 214 | the following commands: |
| 215 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 216 | - To start the NFS share:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 217 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 218 | runqemu-export-rootfs start file-system-location |
| 219 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 220 | - To stop the NFS share:: |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 221 | |
| 222 | runqemu-export-rootfs stop file-system-location |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 223 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 224 | - To restart the NFS share:: |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 225 | |
| 226 | runqemu-export-rootfs restart file-system-location |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 227 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 228 | QEMU CPU Compatibility Under KVM |
| 229 | ================================ |
| 230 | |
| 231 | By default, the QEMU build compiles for and targets 64-bit and x86 Intel |
| 232 | Core2 Duo processors and 32-bit x86 Intel Pentium II processors. QEMU |
| 233 | builds for and targets these CPU types because they display a broad |
| 234 | range of CPU feature compatibility with many commonly used CPUs. |
| 235 | |
| 236 | Despite this broad range of compatibility, the CPUs could support a |
| 237 | feature that your host CPU does not support. Although this situation is |
| 238 | not a problem when QEMU uses software emulation of the feature, it can |
| 239 | be a problem when QEMU is running with KVM enabled. Specifically, |
| 240 | software compiled with a certain CPU feature crashes when run on a CPU |
| 241 | under KVM that does not support that feature. To work around this |
| 242 | problem, you can override QEMU's runtime CPU setting by changing the |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 243 | ``QB_CPU_KVM`` variable in ``qemuboot.conf`` in the :term:`Build Directory` |
| 244 | ``deploy/image`` directory. This setting specifies a ``-cpu`` option passed |
| 245 | into QEMU in the ``runqemu`` script. Running ``qemu -cpu help`` returns a |
| 246 | list of available supported CPU types. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 247 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 248 | QEMU Performance |
| 249 | ================ |
| 250 | |
| 251 | Using QEMU to emulate your hardware can result in speed issues depending |
| 252 | on the target and host architecture mix. For example, using the |
| 253 | ``qemux86`` image in the emulator on an Intel-based 32-bit (x86) host |
| 254 | machine is fast because the target and host architectures match. On the |
| 255 | other hand, using the ``qemuarm`` image on the same Intel-based host can |
| 256 | be slower. But, you still achieve faithful emulation of ARM-specific |
| 257 | issues. |
| 258 | |
| 259 | To speed things up, the QEMU images support using ``distcc`` to call a |
| 260 | cross-compiler outside the emulated system. If you used ``runqemu`` to |
| 261 | start QEMU, and the ``distccd`` application is present on the host |
| 262 | system, any BitBake cross-compiling toolchain available from the build |
| 263 | system is automatically used from within QEMU simply by calling |
| 264 | ``distcc``. You can accomplish this by defining the cross-compiler |
| 265 | variable (e.g. ``export CC="distcc"``). Alternatively, if you are using |
| 266 | a suitable SDK image or the appropriate stand-alone toolchain is |
| 267 | present, the toolchain is also automatically used. |
| 268 | |
| 269 | .. note:: |
| 270 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 271 | There are several mechanisms to connect to the system running |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 272 | on the QEMU emulator: |
| 273 | |
| 274 | - QEMU provides a framebuffer interface that makes standard consoles |
| 275 | available. |
| 276 | |
| 277 | - Generally, headless embedded devices have a serial port. If so, |
| 278 | you can configure the operating system of the running image to use |
| 279 | that port to run a console. The connection uses standard IP |
| 280 | networking. |
| 281 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 282 | - SSH servers are available in some QEMU images. The ``core-image-sato`` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 283 | QEMU image has a Dropbear secure shell (SSH) server that runs with |
| 284 | the root password disabled. The ``core-image-full-cmdline`` and |
| 285 | ``core-image-lsb`` QEMU images have OpenSSH instead of Dropbear. |
| 286 | Including these SSH servers allow you to use standard ``ssh`` and |
| 287 | ``scp`` commands. The ``core-image-minimal`` QEMU image, however, |
| 288 | contains no SSH server. |
| 289 | |
| 290 | - You can use a provided, user-space NFS server to boot the QEMU |
| 291 | session using a local copy of the root filesystem on the host. In |
| 292 | order to make this connection, you must extract a root filesystem |
| 293 | tarball by using the ``runqemu-extract-sdk`` command. After |
| 294 | running the command, you must then point the ``runqemu`` script to |
| 295 | the extracted directory instead of a root filesystem image file. |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 296 | See the |
| 297 | ":ref:`dev-manual/qemu:running under a network file system (nfs) server`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 298 | section for more information. |
| 299 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 300 | QEMU Command-Line Syntax |
| 301 | ======================== |
| 302 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 303 | The basic ``runqemu`` command syntax is as follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 304 | |
| 305 | $ runqemu [option ] [...] |
| 306 | |
| 307 | Based on what you provide on the command line, ``runqemu`` does a |
| 308 | good job of figuring out what you are trying to do. For example, by |
| 309 | default, QEMU looks for the most recently built image according to the |
| 310 | timestamp when it needs to look for an image. Minimally, through the use |
| 311 | of options, you must provide either a machine name, a virtual machine |
| 312 | image (``*wic.vmdk``), or a kernel image (``*.bin``). |
| 313 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 314 | Following is the command-line help output for the ``runqemu`` command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 315 | |
| 316 | $ runqemu --help |
| 317 | |
| 318 | Usage: you can run this script with any valid combination |
| 319 | of the following environment variables (in any order): |
| 320 | KERNEL - the kernel image file to use |
| 321 | ROOTFS - the rootfs image file or nfsroot directory to use |
| 322 | MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified) |
| 323 | Simplified QEMU command-line options can be passed with: |
| 324 | nographic - disable video console |
| 325 | serial - enable a serial console on /dev/ttyS0 |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 326 | slirp - enable user networking, no root privileges required |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 327 | kvm - enable KVM when running x86/x86_64 (VT-capable CPU required) |
| 328 | kvm-vhost - enable KVM with vhost when running x86/x86_64 (VT-capable CPU required) |
| 329 | publicvnc - enable a VNC server open to all hosts |
| 330 | audio - enable audio |
| 331 | [*/]ovmf* - OVMF firmware file or base name for booting with UEFI |
| 332 | tcpserial=<port> - specify tcp serial port number |
| 333 | biosdir=<dir> - specify custom bios dir |
| 334 | biosfilename=<filename> - specify bios filename |
| 335 | qemuparams=<xyz> - specify custom parameters to QEMU |
| 336 | bootparams=<xyz> - specify custom kernel parameters during boot |
| 337 | help, -h, --help: print this text |
| 338 | |
| 339 | Examples: |
| 340 | runqemu |
| 341 | runqemu qemuarm |
| 342 | runqemu tmp/deploy/images/qemuarm |
| 343 | runqemu tmp/deploy/images/qemux86/<qemuboot.conf> |
| 344 | runqemu qemux86-64 core-image-sato ext4 |
| 345 | runqemu qemux86-64 wic-image-minimal wic |
| 346 | runqemu path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial |
| 347 | runqemu qemux86 iso/hddimg/wic.vmdk/wic.qcow2/wic.vdi/ramfs/cpio.gz... |
| 348 | runqemu qemux86 qemuparams="-m 256" |
| 349 | runqemu qemux86 bootparams="psplash=false" |
| 350 | runqemu path/to/<image>-<machine>.wic |
| 351 | runqemu path/to/<image>-<machine>.wic.vmdk |
| 352 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 353 | ``runqemu`` Command-Line Options |
| 354 | ================================ |
| 355 | |
| 356 | Following is a description of ``runqemu`` options you can provide on the |
| 357 | command line: |
| 358 | |
| 359 | .. note:: |
| 360 | |
| 361 | If you do provide some "illegal" option combination or perhaps you do |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 362 | not provide enough in the way of options, ``runqemu`` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 363 | provides appropriate error messaging to help you correct the problem. |
| 364 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 365 | - `QEMUARCH`: The QEMU machine architecture, which must be "qemuarm", |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 366 | "qemuarm64", "qemumips", "qemumips64", "qemuppc", "qemux86", or |
| 367 | "qemux86-64". |
| 368 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 369 | - `VM`: The virtual machine image, which must be a ``.wic.vmdk`` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 370 | file. Use this option when you want to boot a ``.wic.vmdk`` image. |
| 371 | The image filename you provide must contain one of the following |
| 372 | strings: "qemux86-64", "qemux86", "qemuarm", "qemumips64", |
| 373 | "qemumips", "qemuppc", or "qemush4". |
| 374 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 375 | - `ROOTFS`: A root filesystem that has one of the following filetype |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 376 | extensions: "ext2", "ext3", "ext4", "jffs2", "nfs", or "btrfs". If |
| 377 | the filename you provide for this option uses "nfs", it must provide |
| 378 | an explicit root filesystem path. |
| 379 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 380 | - `KERNEL`: A kernel image, which is a ``.bin`` file. When you provide a |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 381 | ``.bin`` file, ``runqemu`` detects it and assumes the file is a |
| 382 | kernel image. |
| 383 | |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 384 | - `MACHINE`: The architecture of the QEMU machine, which must be one of |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 385 | the following: "qemux86", "qemux86-64", "qemuarm", "qemuarm64", |
| 386 | "qemumips", "qemumips64", or "qemuppc". The MACHINE and QEMUARCH |
| 387 | options are basically identical. If you do not provide a MACHINE |
| 388 | option, ``runqemu`` tries to determine it based on other options. |
| 389 | |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 390 | - ``ramfs``: Indicates you are booting an :term:`Initramfs` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 391 | image, which means the ``FSTYPE`` is ``cpio.gz``. |
| 392 | |
| 393 | - ``iso``: Indicates you are booting an ISO image, which means the |
| 394 | ``FSTYPE`` is ``.iso``. |
| 395 | |
| 396 | - ``nographic``: Disables the video console, which sets the console to |
| 397 | "ttys0". This option is useful when you have logged into a server and |
| 398 | you do not want to disable forwarding from the X Window System (X11) |
| 399 | to your workstation or laptop. |
| 400 | |
| 401 | - ``serial``: Enables a serial console on ``/dev/ttyS0``. |
| 402 | |
| 403 | - ``biosdir``: Establishes a custom directory for BIOS, VGA BIOS and |
| 404 | keymaps. |
| 405 | |
| 406 | - ``biosfilename``: Establishes a custom BIOS name. |
| 407 | |
| 408 | - ``qemuparams=\"xyz\"``: Specifies custom QEMU parameters. Use this |
| 409 | option to pass options other than the simple "kvm" and "serial" |
| 410 | options. |
| 411 | |
| 412 | - ``bootparams=\"xyz\"``: Specifies custom boot parameters for the |
| 413 | kernel. |
| 414 | |
| 415 | - ``audio``: Enables audio in QEMU. The MACHINE option must be either |
| 416 | "qemux86" or "qemux86-64" in order for audio to be enabled. |
| 417 | Additionally, the ``snd_intel8x0`` or ``snd_ens1370`` driver must be |
| 418 | installed in linux guest. |
| 419 | |
| 420 | - ``slirp``: Enables "slirp" networking, which is a different way of |
| 421 | networking that does not need root access but also is not as easy to |
| 422 | use or comprehensive as the default. |
| 423 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 424 | Using ``slirp`` by default will forward the guest machine's |
| 425 | 22 and 23 TCP ports to host machine's 2222 and 2323 ports |
| 426 | (or the next free ports). Specific forwarding rules can be configured |
| 427 | by setting ``QB_SLIRP_OPT`` as environment variable or in ``qemuboot.conf`` |
| 428 | in the :term:`Build Directory` ``deploy/image`` directory. |
| 429 | Examples:: |
| 430 | |
| 431 | QB_SLIRP_OPT="-netdev user,id=net0,hostfwd=tcp::8080-:80" |
| 432 | |
| 433 | QB_SLIRP_OPT="-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22" |
| 434 | |
| 435 | The first example forwards TCP port 80 from the emulated system to |
| 436 | port 8080 (or the next free port) on the host system, |
| 437 | allowing access to an http server running in QEMU from |
| 438 | ``http://<host ip>:8080/``. |
| 439 | |
| 440 | The second example does the same, but also forwards TCP port 22 on the |
| 441 | guest system to 2222 (or the next free port) on the host system, |
| 442 | allowing ssh access to the emulated system using |
| 443 | ``ssh -P 2222 <user>@<host ip>``. |
| 444 | |
| 445 | Keep in mind that proper configuration of firewall software is required. |
| 446 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 447 | - ``kvm``: Enables KVM when running "qemux86" or "qemux86-64" QEMU |
| 448 | architectures. For KVM to work, all the following conditions must be |
| 449 | met: |
| 450 | |
| 451 | - Your MACHINE must be either qemux86" or "qemux86-64". |
| 452 | |
| 453 | - Your build host has to have the KVM modules installed, which are |
| 454 | ``/dev/kvm``. |
| 455 | |
| 456 | - The build host ``/dev/kvm`` directory has to be both writable and |
| 457 | readable. |
| 458 | |
| 459 | - ``kvm-vhost``: Enables KVM with VHOST support when running "qemux86" |
| 460 | or "qemux86-64" QEMU architectures. For KVM with VHOST to work, the |
| 461 | following conditions must be met: |
| 462 | |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 463 | - ``kvm`` option conditions defined above must be met. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 464 | |
| 465 | - Your build host has to have virtio net device, which are |
| 466 | ``/dev/vhost-net``. |
| 467 | |
| 468 | - The build host ``/dev/vhost-net`` directory has to be either |
| 469 | readable or writable and "slirp-enabled". |
| 470 | |
| 471 | - ``publicvnc``: Enables a VNC server open to all hosts. |