From: Dongwon Kim <dongwon....@intel.com> Signed-off-by: Dongwon Kim <dongwon....@intel.com> Message-Id: <20240320034229.3347130-1-dongwon....@intel.com> [PMD: Split patch in 3, part 2/3] Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- include/ui/console.h | 1 + hw/vfio/display.c | 8 +++++++- ui/console.c | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/ui/console.h b/include/ui/console.h index a7f6cef26d..1f3d025548 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -360,6 +360,7 @@ void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y); uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf); uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf); +int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf); void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con, diff --git a/hw/vfio/display.c b/hw/vfio/display.c index c962e5f88f..676b2fc5f3 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -259,9 +259,15 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDevice *vdev, static void vfio_display_free_one_dmabuf(VFIODisplay *dpy, VFIODMABuf *dmabuf) { + int fd; + QTAILQ_REMOVE(&dpy->dmabuf.bufs, dmabuf, next); + fd = dpy_gl_dmabuf_get_fd(&dmabuf->buf); + if (fd > -1) { + close(fd); + } + dpy_gl_release_dmabuf(dpy->con, &dmabuf->buf); - close(dmabuf->buf.fd); g_free(dmabuf); } diff --git a/ui/console.c b/ui/console.c index edabad64c0..10abeb9780 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1208,6 +1208,15 @@ uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf) return 0; } +int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf) +{ + if (dmabuf) { + return dmabuf->fd; + } + + return -1; +} + void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf) { -- 2.41.0