Hi,

   {
       res->remapped = mmap(NULL, res->blob_size, PROT_READ,
                            MAP_SHARED, res->dmabuf_fd, 0);
       if (res->remapped == MAP_FAILED) {
+        res->remapped = vfio_dmabuf_mmap(res);
+        if (res->remapped != MAP_FAILED) {
+            return;
+        }
           warn_report("%s: dmabuf mmap failed: %s", __func__,
                       strerror(errno));
           res->remapped = NULL;
@@ -139,8 +236,12 @@ void virtio_gpu_init_dmabuf(struct
virtio_gpu_simple_resource *res)
       } else {
           virtio_gpu_create_udmabuf(res);
           if (res->dmabuf_fd < 0) {

Why test dmabuf_fd ? Can virtio_gpu_init_dmabuf() be called mulmtiple
times ?
Yes, virtio_gpu_init_dmabuf() can be called multiple times as the Guest VM
creates/uses new resources/Guest blobs, which can happen frequently.
Are you suggesting that it is better to make virtio_gpu_create_udmabuf()
return res->dmabuf_fd explicitly as opposed to the current indirect approach?

Yes. Good idea. It would be improve reading.

Thanks,

C.


Reply via email to