From: Marc-André Lureau Date: Mon, 5 Jul 2021 10:42:18 +0000 (+0400) Subject: hw/display: fail early when multiple virgl devices are requested X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=02f9725f3df8a0e8f0a209d7436fad04e1ac190e;p=qemu.git hw/display: fail early when multiple virgl devices are requested This avoids failing to initialize virgl and crashing later on, and clear the user expectations. Signed-off-by: Marc-André Lureau Reviewed-by: Mark Cave-Ayland Message-Id: <20210705104218.1161101-1-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 7ab93bf8c8..b1035e119c 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)) { + 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;