Opengl can not be used with libvirt


A virtual system “win10LTSC” was created, and I can use is normally. All virtio driver were installed, but when I change the video module to virtio, and turn on the 3D acceleration, the virtual system can not work.

启动域时出错: internal error: QEMU unexpectedly closed the monitor (vm='win10LTSC'): 2024-04-19T07:08:43.068983Z qemu-system-x86_64: -device {"driver":"virtio-vga-gl","id":"video0","max_outputs":1,"bus":"pcie.0","addr":"0x1"}: opengl is not available

Traceback (most recent call last):
  File "/nix/store/kg0k9xb64dziq1zbbjiyxd81nbqs9j7p-virt-manager-4.1.0/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/nix/store/kg0k9xb64dziq1zbbjiyxd81nbqs9j7p-virt-manager-4.1.0/share/virt-manager/virtManager/asyncjob.py", line 108, in tmpcb
    callback(*args, **kwargs)
  File "/nix/store/kg0k9xb64dziq1zbbjiyxd81nbqs9j7p-virt-manager-4.1.0/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
    ret = fn(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/kg0k9xb64dziq1zbbjiyxd81nbqs9j7p-virt-manager-4.1.0/share/virt-manager/virtManager/object/domain.py", line 1402, in startup
    self._backend.create()
  File "/nix/store/lwln0g2amirg6xjclcfvkq4kbbip9kz1-python3.11-libvirt-9.9.0/lib/python3.11/site-packages/libvirt.py", line 1373, in create
    raise libvirtError('virDomainCreate() failed')
libvirt.libvirtError: internal error: QEMU unexpectedly closed the monitor (vm='win10LTSC'): 2024-04-19T07:08:43.068983Z qemu-system-x86_64: -device {"driver":"virtio-vga-gl","id":"video0","max_outputs":1,"bus":"pcie.0","addr":"0x1"}: opengl is not available

But I had install it

...
        hardware = {
                bluetooth = {
                        enable = true;
                        powerOnBoot = true;
                };
                opengl.enable = true;
        };
...
        virtualisation  =  { 
                docker = {
                        enable = true;
                        storageDriver = "btrfs";
                };
                libvirtd.enable = true;
# waydroid.enable = true;
        };

and I can find opengl module in

/run/opengl-driver » tree                                                    sukipai@SUKIPAI
.
├── lib -> /nix/store/zwsvcpspvdykjz1i1rpjz7f3msvhpdca-mesa-23.1.9-drivers/lib
└── share -> /nix/store/zwsvcpspvdykjz1i1rpjz7f3msvhpdca-mesa-23.1.9-drivers/share

3 directories, 0 files

I want to know why?And I can only use the QXL model now. :sob:

Running into the same issue at the moment, @SongguokunSgg have you opened an issue on GitHub for this ?
I didn’t find any about this but I’ve seen Nvidia GPUs have bugs with QEMU/libvirt 3D acceleration upstream see : libvirt: openGL does not work with Nvidia GPUs · Issue #164436 · NixOS/nixpkgs · GitHub

I had solved this problem. You should turn on the OpenGL in spice label, and turn the 3d accelerat in virtue.

In space label (channel ?) I don’t see OpenGL :
image

I found this I think it’s probably this checkbox :
image
I also had to change Listen type from address to none

1 Like

Yes, AkechiShiro is correct.

  1. Video: set model to Virtio, and 3D acceleration needs to be enabled.
  2. Spice server: set “Listen type” to None, enable OpenGL, and then select a non-NVIDIA GPU.
1 Like