Additional QEMU specifications

By default, the options for the following qemu-system-x86_64 commands are set for the QNX Developer Desktop:

sudo qemu-system-x86_64 \
--enable-kvm \
-drive file=output/disk-qemu.vmdk,if=ide,id=drv0 \
-netdev bridge,br=virbr0,id=net0 \
-device virtio-net-pci,netdev=net0,mac=52:54:00:91:01:ea \
-pidfile output/qemu.pid \
-nographic \
-kernel output/ifs.bin \
-serial mon:stdio \
-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-pci,rng=rng0 \
-vga none \
-display sdl,gl=on \

These options specify the networking, file system, kernel, and serial console.

CPU specification

You can adjust the number of CPUs with the -smp command. For example, to set the number of CPUs to 8, use the following command:

-smp 8 \

RAM specification

You can adjust the amount of RAM with the -m command. For example, to set the amount of RAM to 16, use the following command:

-m 16G \
Warning:

Increasing this above 16 GB may result in unexpected behavior.

Physical bit specification

You can make the QEMU CPU use physical bits with the --cpu host command. If you choose to use physical bit, it's also recommended to specify the maximum limit with host-phys-bits-limit.

For AMD architectures, set the limit to 40:

--cpu host,host-phys-bits-limit=40

For Intel architectures, set the limit to 39:

--cpu host,host-phys-bits-limit=39

GPU specification

The -device command alters the GPU, particularly if QEMU uses OpenGL host offloading.

You can use the following options with this command:

virtio-vga-gl

Implements the standard Virtio GPU driver without OpenGL host offloading. For example:

-device virtio-vga-gl
virtio-gpu-gl-pci

Implements the Virtio GPU driver on top of virgl, enabling OpenGL offloading. It's recommended to update QEMU to version 10 for best performance with this option.

Additionally, you can add the following options to the virtio-gpu-gl-pci option:

  • blob — Helps QEMU define the resolution and memory for the virtual GPU.
  • venus — Enables Vulkan support through Venus, if your host is capable of it.

For example:

-device virtio-gpu-gl-pci,hostmem=8G,blob=true,venus=true

To set the resolution, set xres and yres to the desired resolution values. You can use these options with the virtio-vga-gl option, although it isn't fully supported on all architectures. Ensure that QEMU is also aware of the updated resolution by altering the /usr/lib/graphics/drm-virtio/graphics-virtio-virgl.conf file. Refer to the section below for more information on increasing the QEMU screen resolution.

To set a GPU without OpenGL host offloading and with a specified resolution, use the following command:

-device virtio-vga-gl,xres=1920,yres=1080

To set a GPU with OpenGL host offloading and with a specified resolution, use the following command:

-device virtio-gpu-gl-pci,xres=1920,yres=1080,hostmem=8G,blob=true,venus=true

Sample commands

Here are some examples of specifications that you can set:

Start QEMU on an Intel CPU without OpenGL host offloading:

sudo qemu-system-x86_64 \
  --enable-kvm \
  -drive file=output/disk-qemu.vmdk,if=ide,id=drv0 \
  -netdev bridge,br=virbr0,id=net0 \
  -device virtio-net-pci,netdev=net0,mac=52:54:00:91:01:ea \
  -pidfile output/qemu.pid \
  -nographic \
  -kernel output/ifs.bin \
  -serial mon:stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0 \
  -vga none \
  -display sdl,gl=on \
  -smp 8 \
  -m 16G \
  --cpu host,host-phys-bits-limit=39 \
  -device virtio-vga-gl

Start QEMU on an Intel CPU with OpenGL host offloading but without Vulkan support:

sudo qemu-system-x86_64 \
  --enable-kvm \
  -drive file=output/disk-qemu.vmdk,if=ide,id=drv0 \
  -netdev bridge,br=virbr0,id=net0 \
  -device virtio-net-pci,netdev=net0,mac=52:54:00:91:01:ea \
  -pidfile output/qemu.pid \
  -nographic \
  -kernel output/ifs.bin \
  -serial mon:stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0 \
  -vga none \
  -display sdl,gl=on \
  -smp 8 \
  -m 16G \
  --cpu host,host-phys-bits-limit=39 \
  -device virtio-gpu-gl-pci,hostmem=8G

Start QEMU on an Intel CPU with Vulkan support through Venus:

sudo qemu-system-x86_64 \
  --enable-kvm \
  -drive file=output/disk-qemu.vmdk,if=ide,id=drv0 \
  -netdev bridge,br=virbr0,id=net0 \
  -device virtio-net-pci,netdev=net0,mac=52:54:00:91:01:ea \
  -pidfile output/qemu.pid \
  -nographic \
  -kernel output/ifs.bin \
  -serial mon:stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0 \
  -vga none \
  -display sdl,gl=on \
  -smp 8 \
  -m 16G \
  --cpu host,host-phys-bits-limit=39 \
  -device virtio-gpu-gl-pci,hostmem=8G,blob=true,venus=true

Start QEMU on an AMD CPU with Vulkan support through Venus and with a 1920x1080 resolution:

sudo qemu-system-x86_64 \
  --enable-kvm \
  -drive file=output/disk-qemu.vmdk,if=ide,id=drv0 \
  -netdev bridge,br=virbr0,id=net0 \
  -device virtio-net-pci,netdev=net0,mac=52:54:00:91:01:ea \
  -pidfile output/qemu.pid \
  -nographic \
  -kernel output/ifs.bin \
  -serial mon:stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0 \
  -vga none \
  -display sdl,gl=on \
  -smp 8 \
  -m 16G \
  --cpu host,host-phys-bits-limit=40 \
  -device virtio-gpu-gl-pci,xres=1920,yres=1080,hostmem=8G,blob=true,venus=true

Increasing the QEMU screen resolution

To run QEMU with a different resolution, it's recommended to update QEMU to version 10. It's also recommended to enable OpenGL host offloading and Vulkan support; otherwise, performance can be unstable.

To run the newer version of QEMU, and work with a desktop with 1080p resolution and Vulkan support:

  1. Ensure that you're using QEMU 10.

  2. Run the VM with one of the sample commands above and wait for the apk updates to complete. It's recommended to perform the first boot without OpenGL host offloading.

  3. Log in as root on the console. The password is also root.

  4. Modify the display resolution to 1920 x 1280 in /usr/lib/graphics/drm-virtio/graphics-virtio-virgl.conf. For example:

    @@ -23,7 +23,7 @@ begin winmgr
     end globals
    
       begin display 1
    -    video-mode = 1280 x 768 @ 60
    +    video-mode = 1920 x 1080 @ 60
         defer-framebuffer-creation = false
         force-composition = true
         allow-bypass = false

    For more information on the graphics configuration file, refer to "Configuring Screen" in the QNX SDP 8.0 documentation.

  5. Close the screen window to shut down the VM.

  6. Put together a command to start the VM based on your hardware specifications. Ensure that the xres= and yres= values are set to 1920 and 1080, respectively.

  7. Run the command in the VM folder to relaunch the VM. View the "Sample commands" section above for examples.

Note:

If you decide to try a larger resolution, such as 4K (3840 x 2160), then set the graphics configuration and the resolution (specified in the virtio-gpu-gl-pci device option in the command) to matching values.

Vulkan support

QEMU 10 enables Vulkan support. Once you've launched the VM, you can run the following command in a terminal to check for available GPUs:

[root@qnxqemu ~]# vulkaninfo | grep "GPU id"
MESA: error: Use of VkSurfacePresentModeCompatibilityEXT without a VkSurfacePresentModeEXT set. This is an application bug.
GPU id : 0 (Virtio-GPU Venus (Intel(R) UHD Graphics 630 (CFL GT2))):
GPU id : 1 (Virtio-GPU Venus (Quadro T1000)):
GPU id : 2 (Virtio-GPU Venus (llvmpipe (LLVM 15.0.7, 256 bits))):
MESA-VIRTIO: debug: failed to dup sync fd

Vulkan currently only works with the Intel driver, so you should invoke a Vulkan app and target GPU 0. For example:

vkcubepp --gpu_number 0

If you see a spinning cube, Vulkan is working as expected in the VM.

Page updated: