From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>, kraxel@redhat.com
Subject: [PATCH 2/2] hw/display: fail early when multiple virgl devices are requested
Date: Thu, 1 Jul 2021 11:18:37 +0400 [thread overview]
Message-ID: <20210701071837.738897-2-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20210701071837.738897-1-marcandre.lureau@redhat.com>
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 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index d971b48080..c973d4824b 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -25,6 +25,8 @@
#include <virglrenderer.h>
+static int virgl_count = 0;
+
static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,
struct virtio_gpu_scanout *s,
uint32_t resource_id)
@@ -113,6 +115,11 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
return;
#endif
+ if (virgl_count++ > 0) {
+ error_setg(errp, "multiple virgl devices aren't supported yet");
+ return;
+ }
+
if (!display_opengl) {
error_setg(errp, "opengl is not available");
return;
@@ -124,6 +131,10 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
virtio_gpu_device_realize(qdev, errp);
}
+static void virtio_gpu_gl_device_unrealize(DeviceState *dev)
+{
+ virgl_count--;
+}
static Property virtio_gpu_gl_properties[] = {
DEFINE_PROP_BIT("stats", VirtIOGPU, parent_obj.conf.flags,
@@ -144,6 +155,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
vgc->update_cursor_data = virtio_gpu_gl_update_cursor_data;
vdc->realize = virtio_gpu_gl_device_realize;
+ vdc->unrealize = virtio_gpu_gl_device_unrealize;
vdc->reset = virtio_gpu_gl_reset;
device_class_set_props(dc, virtio_gpu_gl_properties);
}
--
2.29.0
next prev parent reply other threads:[~2021-07-01 7:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-01 7:18 [PATCH 1/2] hw/display: report an error if virgl initialization failed marcandre.lureau
2021-07-01 7:18 ` marcandre.lureau [this message]
2021-07-03 5:14 ` [PATCH 2/2] hw/display: fail early when multiple virgl devices are requested Mark Cave-Ayland
2021-07-05 10:42 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210701071837.738897-2-marcandre.lureau@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).