@@ -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,
@@ -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);
}
@@ -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)
{