virgl_cmd_resource_unref() destroys the virgl renderer resource without first disabling any scanouts that reference it. The QEMU frontend then holds a stale DMA-BUF until another DMABUF_SCANOUT message arrives.
Send a DMABUF_SCANOUT disable message (fd=-1) for each affected scanout before destroying the resource. Reviewed-by: Akihiko Odaki <[email protected]> Fixes: d52c454aadcd ("contrib: add vhost-user-gpu") Signed-off-by: Marc-André Lureau <[email protected]> --- contrib/vhost-user-gpu/virgl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 20bae57d0fe4..5a5f9f14c80c 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -113,6 +113,18 @@ virgl_cmd_resource_unref(VuGpu *g, VUGPU_FILL_CMD(unref); + for (int i = 0; i < VIRTIO_GPU_MAX_SCANOUTS; i++) { + if (g->scanout[i].resource_id == unref.resource_id) { + VhostUserGpuMsg msg = { + .request = VHOST_USER_GPU_DMABUF_SCANOUT, + .size = sizeof(VhostUserGpuDMABUFScanout), + .payload.dmabuf_scanout.scanout_id = i, + }; + vg_send_msg(g, &msg, -1); + g->scanout[i].resource_id = 0; + } + } + virgl_renderer_resource_detach_iov(unref.resource_id, &res_iovs, &num_iovs); -- 2.55.0.543.g5ebe2ebe4ea8
