qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] hw/display: fail early when multiple virgl devices are re


From: Marc-André Lureau
Subject: Re: [PATCH v2] hw/display: fail early when multiple virgl devices are requested
Date: Mon, 5 Jul 2021 15:08:28 +0400

Hi

On Mon, Jul 5, 2021 at 3:03 PM Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
On 7/5/21 12:42 PM, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> This avoids failing to initialize virgl and crashing later on, and clear
> the user expectations.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/display/virtio-gpu-gl.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
> index aea9700d5c..bc55c4767e 100644
> --- a/hw/display/virtio-gpu-gl.c
> +++ b/hw/display/virtio-gpu-gl.c
> @@ -113,6 +113,11 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
>      return;
>  #endif

> +    if (!object_resolve_path_type("", TYPE_VIRTIO_GPU_GL, NULL)) {

Isn't the condition inverted?

No, it's easy to misread though. It returns NULL if there are no or multiple instances.

When realize() is reached the first time, we should have only one instance, and thus !NULL.


> +        error_setg(errp, "at most one %s device is permitted", TYPE_VIRTIO_GPU_GL);
> +        return;
> +    }
> +
>      if (!display_opengl) {
>          error_setg(errp, "opengl is not available");
>          return;
>




--
Marc-André Lureau

reply via email to

[Prev in Thread] Current Thread [Next in Thread]