[PATCH 1/3] hw/display/virtio-gpu: Improve "opengl is not available" error message

Peter Maydell posted 3 patches 3 months, 3 weeks ago
[PATCH 1/3] hw/display/virtio-gpu: Improve "opengl is not available" error message
Posted by Peter Maydell 3 months, 3 weeks ago
If the user tries to use the virtio-gpu-gl device but the display
backend doesn't have OpenGL support enabled, we currently print a
rather uninformative error message:

$ qemu-system-aarch64 -M virt -device virtio-gpu-gl
qemu-system-aarch64: -device virtio-gpu-gl: opengl is not available

Since OpenGL is not enabled on display frontends by default, users
are quite likely to run into this. Improve the error message to
be more specific and to suggest to the user a path forward.

Note that the case of "user tried to enable OpenGL but the display
backend doesn't handle it" is caught elsewhere first, so we can
assume that isn't the problem:

$ qemu-system-aarch64 -M virt -device virtio-gpu-gl -display curses,gl=on
qemu-system-aarch64: OpenGL is not supported by the display

(Use of error_append_hint() requires us to add an ERRP_GUARD() to
the function, as noted in include/qapi/error.h.)

With this commit we now produce the hopefully more helpful error:
$ ./build/x86/qemu-system-aarch64 -M virt -device virtio-gpu-gl
qemu-system-aarch64: -device virtio-gpu-gl: The display backend does not have OpenGL support enabled
It can be enabled with '-display BACKEND,gl=on' where BACKEND is the name of the display backend to use.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2443
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/display/virtio-gpu-gl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 952820a4256..49cb61edd23 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -107,6 +107,7 @@ static void virtio_gpu_gl_reset(VirtIODevice *vdev)
 static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
 {
     VirtIOGPU *g = VIRTIO_GPU(qdev);
+    ERRP_GUARD();
 
 #if HOST_BIG_ENDIAN
     error_setg(errp, "virgl is not supported on bigendian platforms");
@@ -119,7 +120,12 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
     }
 
     if (!display_opengl) {
-        error_setg(errp, "opengl is not available");
+        error_setg(errp,
+                   "The display backend does not have OpenGL support enabled");
+        error_append_hint(errp,
+                          "It can be enabled with '-display BACKEND,gl=on' "
+                          "where BACKEND is the name of the display backend "
+                          "to use.\n");
         return;
     }
 
-- 
2.34.1
Re: [PATCH 1/3] hw/display/virtio-gpu: Improve "opengl is not available" error message
Posted by Alex Bennée 3 months, 2 weeks ago
Peter Maydell <peter.maydell@linaro.org> writes:

> If the user tries to use the virtio-gpu-gl device but the display
> backend doesn't have OpenGL support enabled, we currently print a
> rather uninformative error message:
>
> $ qemu-system-aarch64 -M virt -device virtio-gpu-gl
> qemu-system-aarch64: -device virtio-gpu-gl: opengl is not available
>
> Since OpenGL is not enabled on display frontends by default, users
> are quite likely to run into this. Improve the error message to
> be more specific and to suggest to the user a path forward.
>
> Note that the case of "user tried to enable OpenGL but the display
> backend doesn't handle it" is caught elsewhere first, so we can
> assume that isn't the problem:
>
> $ qemu-system-aarch64 -M virt -device virtio-gpu-gl -display curses,gl=on
> qemu-system-aarch64: OpenGL is not supported by the display
>
> (Use of error_append_hint() requires us to add an ERRP_GUARD() to
> the function, as noted in include/qapi/error.h.)
>
> With this commit we now produce the hopefully more helpful error:
> $ ./build/x86/qemu-system-aarch64 -M virt -device virtio-gpu-gl
> qemu-system-aarch64: -device virtio-gpu-gl: The display backend does not have OpenGL support enabled
> It can be enabled with '-display BACKEND,gl=on' where BACKEND is the name of the display backend to use.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2443
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH 1/3] hw/display/virtio-gpu: Improve "opengl is not available" error message
Posted by Philippe Mathieu-Daudé 3 months, 2 weeks ago
On 31/7/24 17:41, Peter Maydell wrote:
> If the user tries to use the virtio-gpu-gl device but the display
> backend doesn't have OpenGL support enabled, we currently print a
> rather uninformative error message:
> 
> $ qemu-system-aarch64 -M virt -device virtio-gpu-gl
> qemu-system-aarch64: -device virtio-gpu-gl: opengl is not available
> 
> Since OpenGL is not enabled on display frontends by default, users
> are quite likely to run into this. Improve the error message to
> be more specific and to suggest to the user a path forward.
> 
> Note that the case of "user tried to enable OpenGL but the display
> backend doesn't handle it" is caught elsewhere first, so we can
> assume that isn't the problem:
> 
> $ qemu-system-aarch64 -M virt -device virtio-gpu-gl -display curses,gl=on
> qemu-system-aarch64: OpenGL is not supported by the display
> 
> (Use of error_append_hint() requires us to add an ERRP_GUARD() to
> the function, as noted in include/qapi/error.h.)
> 
> With this commit we now produce the hopefully more helpful error:
> $ ./build/x86/qemu-system-aarch64 -M virt -device virtio-gpu-gl
> qemu-system-aarch64: -device virtio-gpu-gl: The display backend does not have OpenGL support enabled
> It can be enabled with '-display BACKEND,gl=on' where BACKEND is the name of the display backend to use.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2443
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/display/virtio-gpu-gl.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>