* [PATCH] virtio-gpu: create drm fd based on specified render node path
@ 2025-12-05 18:49 Luqmaan Irshad
2025-12-08 0:49 ` Dmitry Osipenko
0 siblings, 1 reply; 7+ messages in thread
From: Luqmaan Irshad @ 2025-12-05 18:49 UTC (permalink / raw)
To: qemu-devel
Cc: mst, alex.bennee, odaki, dmitry.osipenko,
pierre-eric.pelloux-prayer, luckmaan21, Luqmaan Irshad
Added a special callback function called virtio_get_drm_fd to create
a render node based on the path specified by the user via QEMU command
line. This function is called during the virglrenderer callback sequence
where we specify the get_drm_fd function pointer to call back our
new function, allowing us to pass the fd of our created render node.
Based-on: 20251116125641.2255794-1-dmitry.osipenko@collabora.com
Signed-off-by: Luqmaan Irshad <luirshad@amd.com>
---
hw/display/virtio-gpu-gl.c | 4 ++++
hw/display/virtio-gpu-virgl.c | 17 ++++++++++++++++-
include/hw/virtio/virtio-gpu.h | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index b640900fc6..c0587929e4 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -161,6 +161,10 @@ static const Property virtio_gpu_gl_properties[] = {
VIRTIO_GPU_FLAG_VENUS_ENABLED, false),
DEFINE_PROP_BIT("drm_native_context", VirtIOGPU, parent_obj.conf.flags,
VIRTIO_GPU_FLAG_DRM_ENABLED, false),
+#if VIRGL_RENDERER_CALLBACKS_VERSION >= 2s
+ DEFINE_PROP_STRING("drm_render_node", VirtIOGPU,
+ parent_obj.drm_render_node),
+#endif
};
static void virtio_gpu_gl_device_unrealize(DeviceState *qdev)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 6ad3b46066..c271194260 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -1016,6 +1016,15 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
}
}
+#if VIRGL_RENDERER_CALLBACKS_VERSION >= 2
+static int virtio_get_drm_fd(void *opaque)
+{
+ VirtIOGPU *g = opaque;
+ int fd = open(g->parent_obj.drm_render_node, O_RDWR);
+ return fd;
+}
+#endif
+
static void virgl_write_fence(void *opaque, uint32_t fence)
{
VirtIOGPU *g = opaque;
@@ -1300,7 +1309,13 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
}
if (virtio_gpu_drm_enabled(g->parent_obj.conf)) {
flags |= VIRGL_RENDERER_DRM;
-
+#if VIRGL_RENDERER_CALLBACKS_VERSION >= 2
+ if (g->parent_obj.drm_render_node) {
+ if (virtio_gpu_3d_cbs.version < 2)
+ virtio_gpu_3d_cbs.version = 2;
+ virtio_gpu_3d_cbs.get_drm_fd = virtio_get_drm_fd;
+ }
+#endif
if (!(flags & VIRGL_RENDERER_ASYNC_FENCE_CB)) {
/*
* Virglrenderer skips enabling DRM context support without
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index a4963508a4..aba8343848 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -152,6 +152,7 @@ struct VirtIOGPUBase {
struct virtio_gpu_base_conf conf;
struct virtio_gpu_config virtio_config;
const GraphicHwOps *hw_ops;
+ char *drm_render_node;
int renderer_blocked;
int enable;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
2025-12-05 18:49 [PATCH] virtio-gpu: create drm fd based on specified render node path Luqmaan Irshad
@ 2025-12-08 0:49 ` Dmitry Osipenko
2025-12-09 18:57 ` Irshad, Luqmaan
2025-12-11 14:18 ` Akihiko Odaki
0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Osipenko @ 2025-12-08 0:49 UTC (permalink / raw)
To: Luqmaan Irshad, qemu-devel
Cc: mst, alex.bennee, odaki, pierre-eric.pelloux-prayer, luckmaan21
Hi,
On 12/5/25 21:49, Luqmaan Irshad wrote:
> Added a special callback function called virtio_get_drm_fd to create
> a render node based on the path specified by the user via QEMU command
> line. This function is called during the virglrenderer callback sequence
> where we specify the get_drm_fd function pointer to call back our
> new function, allowing us to pass the fd of our created render node.
>
> Based-on: 20251116125641.2255794-1-dmitry.osipenko@collabora.com
>
> Signed-off-by: Luqmaan Irshad <luirshad@amd.com>
> ---
> hw/display/virtio-gpu-gl.c | 4 ++++
> hw/display/virtio-gpu-virgl.c | 17 ++++++++++++++++-
> include/hw/virtio/virtio-gpu.h | 1 +
> 3 files changed, 21 insertions(+), 1 deletion(-)
Do you think it could be possible and worthwhile to make QEMU's EGL
display to use same GPU as virgl automatically? I.e. we tell QEMU/EGL
which GPU to use and then virgl will use same DRM device that backs EGL.
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
2025-12-08 0:49 ` Dmitry Osipenko
@ 2025-12-09 18:57 ` Irshad, Luqmaan
2025-12-10 15:26 ` Dmitry Osipenko
2025-12-11 14:18 ` Akihiko Odaki
1 sibling, 1 reply; 7+ messages in thread
From: Irshad, Luqmaan @ 2025-12-09 18:57 UTC (permalink / raw)
To: Dmitry Osipenko, qemu-devel@nongnu.org
Cc: mst@redhat.com, alex.bennee@linaro.org,
odaki@rsg.ci.i.u-tokyo.ac.jp, Pelloux-Prayer, Pierre-Eric,
luckmaan21@gmail.com
[-- Attachment #1: Type: text/plain, Size: 2211 bytes --]
[AMD Official Use Only - AMD Internal Distribution Only]
Hello Dmitry,
Thats an interesting idea! I would be curious to look into that further, however my ability to do so may be limited since my contract ends at the end of this week.
After my contract ends, I won't have access to a multi-GPU system I can test this on. I may be able to work out some way to borrow the system, but at the moment this is uncertain.
If this patch looks good, my suggestion would be to merge this change, and we can look into adding this as a separate patch on top of this if I can get access to a system. Let me know how this sounds 🙂
Sincerely,
Luq
________________________________
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Sent: Sunday, December 7, 2025 7:49 PM
To: Irshad, Luqmaan <Luqmaan.Irshad@amd.com>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>
Cc: mst@redhat.com <mst@redhat.com>; alex.bennee@linaro.org <alex.bennee@linaro.org>; odaki@rsg.ci.i.u-tokyo.ac.jp <odaki@rsg.ci.i.u-tokyo.ac.jp>; Pelloux-Prayer, Pierre-Eric <Pierre-eric.Pelloux-prayer@amd.com>; luckmaan21@gmail.com <luckmaan21@gmail.com>
Subject: Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
Hi,
On 12/5/25 21:49, Luqmaan Irshad wrote:
> Added a special callback function called virtio_get_drm_fd to create
> a render node based on the path specified by the user via QEMU command
> line. This function is called during the virglrenderer callback sequence
> where we specify the get_drm_fd function pointer to call back our
> new function, allowing us to pass the fd of our created render node.
>
> Based-on: 20251116125641.2255794-1-dmitry.osipenko@collabora.com
>
> Signed-off-by: Luqmaan Irshad <luirshad@amd.com>
> ---
> hw/display/virtio-gpu-gl.c | 4 ++++
> hw/display/virtio-gpu-virgl.c | 17 ++++++++++++++++-
> include/hw/virtio/virtio-gpu.h | 1 +
> 3 files changed, 21 insertions(+), 1 deletion(-)
Do you think it could be possible and worthwhile to make QEMU's EGL
display to use same GPU as virgl automatically? I.e. we tell QEMU/EGL
which GPU to use and then virgl will use same DRM device that backs EGL.
--
Best regards,
Dmitry
[-- Attachment #2: Type: text/html, Size: 5209 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
2025-12-09 18:57 ` Irshad, Luqmaan
@ 2025-12-10 15:26 ` Dmitry Osipenko
0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Osipenko @ 2025-12-10 15:26 UTC (permalink / raw)
To: Irshad, Luqmaan, qemu-devel@nongnu.org
Cc: mst@redhat.com, alex.bennee@linaro.org,
odaki@rsg.ci.i.u-tokyo.ac.jp, Pelloux-Prayer, Pierre-Eric,
luckmaan21@gmail.com
On 12/9/25 21:57, Irshad, Luqmaan wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> Hello Dmitry,
>
> Thats an interesting idea! I would be curious to look into that further, however my ability to do so may be limited since my contract ends at the end of this week.
>
> After my contract ends, I won't have access to a multi-GPU system I can test this on. I may be able to work out some way to borrow the system, but at the moment this is uncertain.
>
> If this patch looks good, my suggestion would be to merge this change, and we can look into adding this as a separate patch on top of this if I can get access to a system. Let me know how this sounds 🙂
>
> Sincerely,
Thanks for notifying that you won't work on the patch further. It will
be merged or amended.
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
2025-12-08 0:49 ` Dmitry Osipenko
2025-12-09 18:57 ` Irshad, Luqmaan
@ 2025-12-11 14:18 ` Akihiko Odaki
2025-12-11 16:30 ` Irshad, Luqmaan
1 sibling, 1 reply; 7+ messages in thread
From: Akihiko Odaki @ 2025-12-11 14:18 UTC (permalink / raw)
To: Dmitry Osipenko, Luqmaan Irshad, qemu-devel
Cc: mst, alex.bennee, pierre-eric.pelloux-prayer, luckmaan21
On 2025/12/08 9:49, Dmitry Osipenko wrote:
> Hi,
>
> On 12/5/25 21:49, Luqmaan Irshad wrote:
>> Added a special callback function called virtio_get_drm_fd to create
>> a render node based on the path specified by the user via QEMU command
>> line. This function is called during the virglrenderer callback sequence
>> where we specify the get_drm_fd function pointer to call back our
>> new function, allowing us to pass the fd of our created render node.
I guess what you need can be achieved by specifying a render node for
the display. Headless displays (egl-headless and dbus) has the
rendernode property for this. For the other displays, Mesa should choose
an appropriate render node, and it can be overridden with the DRI_PRIME
environment variable:
https://docs.mesa3d.org/envvars.html#envvar-DRI_PRIME
>>
>> Based-on: 20251116125641.2255794-1-dmitry.osipenko@collabora.com
>>
>> Signed-off-by: Luqmaan Irshad <luirshad@amd.com>
>> ---
>> hw/display/virtio-gpu-gl.c | 4 ++++
>> hw/display/virtio-gpu-virgl.c | 17 ++++++++++++++++-
>> include/hw/virtio/virtio-gpu.h | 1 +
>> 3 files changed, 21 insertions(+), 1 deletion(-)
>
> Do you think it could be possible and worthwhile to make QEMU's EGL
> display to use same GPU as virgl automatically? I.e. we tell QEMU/EGL
> which GPU to use and then virgl will use same DRM device that backs EGL.
As far as I understand, it is already ensured that virgl uses the EGL
display QEMU uses, and I think that what you want. Opening a different
render node and passing the node to virglrenderer breaks it.
Regards,
Akihiko Odaki
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
2025-12-11 14:18 ` Akihiko Odaki
@ 2025-12-11 16:30 ` Irshad, Luqmaan
2025-12-12 3:24 ` Akihiko Odaki
0 siblings, 1 reply; 7+ messages in thread
From: Irshad, Luqmaan @ 2025-12-11 16:30 UTC (permalink / raw)
To: Akihiko Odaki, Dmitry Osipenko, qemu-devel@nongnu.org
Cc: mst@redhat.com, alex.bennee@linaro.org,
Pelloux-Prayer, Pierre-Eric, luckmaan21@gmail.com
[-- Attachment #1: Type: text/plain, Size: 2729 bytes --]
[AMD Official Use Only - AMD Internal Distribution Only]
Hello Akihiko,
I just had a brief conversation with Pierre-Eric, and I believe the use case is slightly different than the one described. For virgl, selecting using DRI_PRIME only would suffice because QEMU and VirGL (both using OpenGL), both rely on the driver to pickup the GPU.
For Native context however (this case) there is no GL driver use from virglrenderer side, which is why we inform virglrenderer using the callback functions instead.
Sincerely,
Luq
________________________________
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Sent: Thursday, December 11, 2025 9:19:22 a.m.
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>; Irshad, Luqmaan <Luqmaan.Irshad@amd.com>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>
Cc: mst@redhat.com <mst@redhat.com>; alex.bennee@linaro.org <alex.bennee@linaro.org>; Pelloux-Prayer, Pierre-Eric <Pierre-eric.Pelloux-prayer@amd.com>; luckmaan21@gmail.com <luckmaan21@gmail.com>
Subject: Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
On 2025/12/08 9:49, Dmitry Osipenko wrote:
> Hi,
>
> On 12/5/25 21:49, Luqmaan Irshad wrote:
>> Added a special callback function called virtio_get_drm_fd to create
>> a render node based on the path specified by the user via QEMU command
>> line. This function is called during the virglrenderer callback sequence
>> where we specify the get_drm_fd function pointer to call back our
>> new function, allowing us to pass the fd of our created render node.
I guess what you need can be achieved by specifying a render node for
the display. Headless displays (egl-headless and dbus) has the
rendernode property for this. For the other displays, Mesa should choose
an appropriate render node, and it can be overridden with the DRI_PRIME
environment variable:
https://docs.mesa3d.org/envvars.html#envvar-DRI_PRIME
>>
>> Based-on: 20251116125641.2255794-1-dmitry.osipenko@collabora.com
>>
>> Signed-off-by: Luqmaan Irshad <luirshad@amd.com>
>> ---
>> hw/display/virtio-gpu-gl.c | 4 ++++
>> hw/display/virtio-gpu-virgl.c | 17 ++++++++++++++++-
>> include/hw/virtio/virtio-gpu.h | 1 +
>> 3 files changed, 21 insertions(+), 1 deletion(-)
>
> Do you think it could be possible and worthwhile to make QEMU's EGL
> display to use same GPU as virgl automatically? I.e. we tell QEMU/EGL
> which GPU to use and then virgl will use same DRM device that backs EGL.
As far as I understand, it is already ensured that virgl uses the EGL
display QEMU uses, and I think that what you want. Opening a different
render node and passing the node to virglrenderer breaks it.
Regards,
Akihiko Odaki
[-- Attachment #2: Type: text/html, Size: 5387 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
2025-12-11 16:30 ` Irshad, Luqmaan
@ 2025-12-12 3:24 ` Akihiko Odaki
0 siblings, 0 replies; 7+ messages in thread
From: Akihiko Odaki @ 2025-12-12 3:24 UTC (permalink / raw)
To: Irshad, Luqmaan, Dmitry Osipenko, qemu-devel@nongnu.org,
Honglei Huang
Cc: mst@redhat.com, alex.bennee@linaro.org,
Pelloux-Prayer, Pierre-Eric, luckmaan21@gmail.com
On 2025/12/12 1:30, Irshad, Luqmaan wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
Your keep sending message with this "Internal Distribution Only" mark.
Can you remove it? Perhaps you may ask Honglei Huang, who is also from
AMD and work on virtio-gpu/QEMU.
>
> Hello Akihiko,
>
> I just had a brief conversation with Pierre-Eric, and I believe the use case is slightly different than the one described. For virgl, selecting using DRI_PRIME only would suffice because QEMU and VirGL (both using OpenGL), both rely on the driver to pickup the GPU.
DRI_PRIME is used for EGL, not OpenGL. EGL is agnostic to rendering APIs
so it works for Vulkan too.
>
> For Native context however (this case) there is no GL driver use from virglrenderer side, which is why we inform virglrenderer using the callback functions instead.
Now I understand the problem you are facing; virglrenderer does not
respect the EGL display for DRM native context, which is the problem
that needs to be fixed; adding another callback function only works
around it.
Fortunately, there is EXT_device_drm_render_node, an EGL extension that
allows virglrenderer to query the underlying render node from the EGL
display, which can be used for DRM native context:
https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_device_drm_render_node.txt
Consuming the EGL display, you can exploit the render-API-agnostic
nature of EGL and ensure DRM native context will work consistently with
VirGL and Venus. virglrenderer will be able to use the appropriate
render node chosen by Mesa, and if you want to choose a render node by
your own, you will be able to use the rendernode property of headless
displays or DRI_PRIME for the other displays; no need to set another
property for virtio-gpu.
Using EXT_device_drm_render_node on the virglrenderer side may also
benefit other VMMs that use virglrenderer.
Regards,
Akihiko Odaki
>
> Sincerely,
>
> Luq
>
> ________________________________
> From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> Sent: Thursday, December 11, 2025 9:19:22 a.m.
> To: Dmitry Osipenko <dmitry.osipenko@collabora.com>; Irshad, Luqmaan <Luqmaan.Irshad@amd.com>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>
> Cc: mst@redhat.com <mst@redhat.com>; alex.bennee@linaro.org <alex.bennee@linaro.org>; Pelloux-Prayer, Pierre-Eric <Pierre-eric.Pelloux-prayer@amd.com>; luckmaan21@gmail.com <luckmaan21@gmail.com>
> Subject: Re: [PATCH] virtio-gpu: create drm fd based on specified render node path
>
> On 2025/12/08 9:49, Dmitry Osipenko wrote:
>> Hi,
>>
>> On 12/5/25 21:49, Luqmaan Irshad wrote:
>>> Added a special callback function called virtio_get_drm_fd to create
>>> a render node based on the path specified by the user via QEMU command
>>> line. This function is called during the virglrenderer callback sequence
>>> where we specify the get_drm_fd function pointer to call back our
>>> new function, allowing us to pass the fd of our created render node.
>
> I guess what you need can be achieved by specifying a render node for
> the display. Headless displays (egl-headless and dbus) has the
> rendernode property for this. For the other displays, Mesa should choose
> an appropriate render node, and it can be overridden with the DRI_PRIME
> environment variable:
> https://docs.mesa3d.org/envvars.html#envvar-DRI_PRIME
>
>>>
>>> Based-on: 20251116125641.2255794-1-dmitry.osipenko@collabora.com
>>>
>>> Signed-off-by: Luqmaan Irshad <luirshad@amd.com>
>>> ---
>>> hw/display/virtio-gpu-gl.c | 4 ++++
>>> hw/display/virtio-gpu-virgl.c | 17 ++++++++++++++++-
>>> include/hw/virtio/virtio-gpu.h | 1 +
>>> 3 files changed, 21 insertions(+), 1 deletion(-)
>>
>> Do you think it could be possible and worthwhile to make QEMU's EGL
>> display to use same GPU as virgl automatically? I.e. we tell QEMU/EGL
>> which GPU to use and then virgl will use same DRM device that backs EGL.
>
> As far as I understand, it is already ensured that virgl uses the EGL
> display QEMU uses, and I think that what you want. Opening a different
> render node and passing the node to virglrenderer breaks it.
>
> Regards,
> Akihiko Odaki
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-12-12 3:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 18:49 [PATCH] virtio-gpu: create drm fd based on specified render node path Luqmaan Irshad
2025-12-08 0:49 ` Dmitry Osipenko
2025-12-09 18:57 ` Irshad, Luqmaan
2025-12-10 15:26 ` Dmitry Osipenko
2025-12-11 14:18 ` Akihiko Odaki
2025-12-11 16:30 ` Irshad, Luqmaan
2025-12-12 3:24 ` Akihiko Odaki
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).