libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/aarch64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

Hello to everyone.

I’m trying to virtualize Android on my jetson nano using qemu / kvm on ubuntu 18.04. This is the tutorial that I’ve read to build the Android images :

and this is the command that I give to start Android :

#!/bin/sh -e

qemu-system-aarch64 \
    -machine virt,gic-version=host -cpu host -smp 4 -enable-kvm \
    -append "console=ttyAMA0,38400 vt.global_cursor_default=0 androidboot.selinux=permissive debug drm.debug=0 androidboot.lcd_density=160" \
    -m 3048 \
    -kernel /root/Scrivania/Work/I9/aosp_kernel/out/android-4.14-q/common/arch/arm64/boot/Image \
    -initrd /root/Scrivania/Work/I9/aosp/out/target/product/generic_arm64/ramdisk.img \
    -drive index=0,if=virtio,format=raw,id=system,file=/root/Scrivania/Work/I9/aosp/out/target/product/generic_arm64/system.img \
    -drive index=1,if=virtio,format=raw,id=cache,file=/root/Scrivania/Work/I9/aosp/out/target/product/generic_arm64/cache.img \
    -drive index=2,if=virtio,format=raw,id=userdata,file=/root/Scrivania/Work/I9/aosp/out/target/product/generic_arm64/userdata.img \
    -netdev user,id=mynet,hostfwd=tcp::5401-:5555 -device virtio-net-pci,netdev=mynet \
    -device qemu-xhci \
    -device virtio-mouse-pci -device virtio-keyboard-pci \
    -d guest_errors \
    -serial mon:stdio \
    -device virtio-gpu-pci,virgl=on,xres=1280,yres=720 -display sdl,gl=on

it gives this error :

qemu-system-aarch64: warning: gic-version=host not relevant with kernel-irqchip=off as only userspace GICv2 is
supported. Using v2 ...

libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/aarch64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  95
  Current serial number in output stream:  94

root@ziomario-desktop:# find / -name swrast_dri.so

/usr/lib/aarch64-linux-gnu/dri/swrast_dri.so
/usr/lib/arm-linux-gnueabihf/dri/swrast_dri.so

I tried also with :

    -device virtio-gpu-pci,virgl=on,xres=1280,yres=720 -display sdl

removing gl=on,but I’ve got the same error. how can I fix it ?

Hi,
Please try on r32.4.2. Looks like it is based on r32.4.2:
kvm-aosp-jetson-nano/README_Jetson_Nano_BSP.md at master · antmicro/kvm-aosp-jetson-nano · GitHub

Suggest you confirm it works on the release first. And then can try to move to production release r32.4.3 or r32.4.4.

this error does not depend about the kvm aosp jetson nano github. Infact I get the same error trying to virtualize windows 10 arm64 with this command :

root@ziomario-desktop:# qemu-system-aarch64 -M virt-2.12 -enable-kvm -cpu host -smp 2 -m 2048 -device qemu-xhci -device usb-kbd -device usb-mouse -drive file=/root/Scrivania/Work/isoarm/win10arm.qcow2,if=virtio -nic user,model=virtio -device usb-storage,drive=install -device usb-storage,drive=drivers -drive file="/root/Scrivania/Work/isoarm/$isoname1",if=none,id=install,media=cdrom,readonly=on -drive file="$virtio",if=none,media=cdrom,readonly=on,id=drivers -bios /root/Scrivania/Work/I9/win10arm/QEMU_EFI.fd -device virtio-gpu-pci,virgl=on,xres=1280,yres=720 -display sdl,gl=on

libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/aarch64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  95
  Current serial number in output stream:  94

as u can see in this case I’m not using the kvm aosp jetson nano github at all. So,the problem is not related to it. Take in consideration that I have installed the Kernel Version: 4.9.201+ recompiled with the patches gotten from here :

necessary to enable correctly KVM and these packages on ubuntu 18.04 :

apt install libepoxy-dev libdrm-dev libgbm-dev libpulse-dev mesa-common-dev libgbm-dev libsdl2-dev libsdl2-2.0-0 libvirglrenderer-dev libsdl2-dev

maybe I need to install some additional package ? this is the Jetpack version that I’m using :

root@ziomario-desktop:# ./jetsonInfo.py

NVIDIA Jetson Nano (Developer Kit Version)
L4T 32.5.1 [ JetPack UNKNOWN ]
Ubuntu 18.04.5 LTS
Kernel Version: 4.9.201+
Xlib: extension “NV-GLX” missing on display “:1003.0”.
Xlib: extension “NV-GLX” missing on display “:1003.0”.
Xlib: extension “NV-GLX” missing on display “:1003.0”.
CUDA 10.2.89
CUDA Architecture: 5.3
OpenCV version: 4.5.0
OpenCV Cuda: YES
CUDNN: 8.0.0.180
TensorRT: 7.1.3.0
Vision Works: 1.6.0.501
VPI: ii libnvvpi1 1.0.15 arm64 NVIDIA Vision Programming Interface library

Not sure if this can help

I have issued these commands :

sudo rm /usr/lib/aarch64-linux-gnu/libdrm_nvdc.so
sudo ldconfig

and I have added these parameters to qemu / kvm command line :

-device virtio-gpu-pci,virgl=on,xres=1280,yres=720 -display sdl,gl=on

instead of this one :

-device ramfb

unfortunately it seems that it does not work.

I have also issued these commands :

sudo ln -sf libdrm.so.2.4.0 libdrm.so.2
sudo ldconfig

in this case the error is still there.