Hi, > - pixman_image_unref(res->image); > + if (res->image) { > + pixman_image_unref(res->image); > + }
There is qemu_pixman_image_unref(). Like pixman_image_unref except that it also accepts (and ignores) NULL pointers. > virtio_gpu_cleanup_mapping(g, res); > QTAILQ_REMOVE(&g->reslist, res, next); > g->hostmem -= res->hostmem; > @@ -494,6 +496,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, > { > struct virtio_gpu_simple_resource *res; > struct virtio_gpu_resource_flush rf; > + struct virtio_gpu_scanout *scanout; > pixman_region16_t flush_region; > int i; > > @@ -504,16 +507,28 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, > > res = virtio_gpu_find_check_resource(g, rf.resource_id, false, > __func__, &cmd->error); > - if (!res || res->blob) { > + if (!res) { > return; > } > > - if (rf.r.x > res->width || > + if (res->blob && display_opengl) { console_has_gl(scanout->con) > + if (!res->blob && > + (rf.r.x > res->width || > rf.r.y > res->height || > rf.r.width > res->width || > rf.r.height > res->height || > rf.r.x + rf.r.width > res->width || > - rf.r.y + rf.r.height > res->height) { > + rf.r.y + rf.r.height > res->height)) { > qemu_log_mask(LOG_GUEST_ERROR, "%s: flush bounds outside resource" > " bounds for resource %d: %d %d %d %d vs %d %d\n", > __func__, rf.resource_id, rf.r.x, rf.r.y, Indent needs fixing. Do we need sanity checks for the res->blob == true case? I think so ... > g->parent_obj.enable = 1; > - data = (uint8_t *)pixman_image_get_data(res->image); > + > + if (res->blob) { > + if (display_opengl) { Again console_has_gl(scanout->con) > + if (!virtio_gpu_update_dmabuf(g, scanout_id, res, fb)) { > + virtio_gpu_update_scanout(g, scanout_id, res, r); > + return; > + } > + } > + > + data = res->blob; > + } else { > + data = (uint8_t *)pixman_image_get_data(res->image); > + } > > /* create a surface for this scanout */ > - if (!scanout->ds || > + if ((res->blob && !display_opengl) || And again. take care, Gerd