summary refs log tree commit diff stats
path: root/contrib/vhost-user-gpu/virgl.c
diff options
context:
space:
mode:
authorLi Qiang <liq3ea@163.com>2021-05-15 20:04:03 -0700
committerGerd Hoffmann <kraxel@redhat.com>2021-05-27 11:55:59 +0200
commit3ea32d1355d446057c17458238db2749c52ee8f0 (patch)
tree9165fd0daa7b6cf4dd0b84da96b2f485fb5555a4 /contrib/vhost-user-gpu/virgl.c
parent9f22893adcb02580aee5968f32baa2cd109b3ec2 (diff)
downloadfocaccia-qemu-3ea32d1355d446057c17458238db2749c52ee8f0.tar.gz
focaccia-qemu-3ea32d1355d446057c17458238db2749c52ee8f0.zip
vhost-user-gpu: abstract vg_cleanup_mapping_iov
Currently in vhost-user-gpu, we free resource directly in
the cleanup case of resource. If we change the cleanup logic
we need to change several places, also abstruct a
'vg_create_mapping_iov' can be symmetry with the
'vg_create_mapping_iov'. This is like what virtio-gpu does,
no function changed.

Signed-off-by: Li Qiang <liq3ea@163.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210516030403.107723-9-liq3ea@163.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'contrib/vhost-user-gpu/virgl.c')
-rw-r--r--contrib/vhost-user-gpu/virgl.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c
index 7172104b19..3e45e1bd33 100644
--- a/contrib/vhost-user-gpu/virgl.c
+++ b/contrib/vhost-user-gpu/virgl.c
@@ -116,8 +116,9 @@ virgl_cmd_resource_unref(VuGpu *g,
     virgl_renderer_resource_detach_iov(unref.resource_id,
                                        &res_iovs,
                                        &num_iovs);
-    g_free(res_iovs);
-
+    if (res_iovs != NULL && num_iovs != 0) {
+        vg_cleanup_mapping_iov(g, res_iovs, num_iovs);
+    }
     virgl_renderer_resource_unref(unref.resource_id);
 }
 
@@ -294,7 +295,7 @@ virgl_resource_attach_backing(VuGpu *g,
     ret = virgl_renderer_resource_attach_iov(att_rb.resource_id,
                                        res_iovs, att_rb.nr_entries);
     if (ret != 0) {
-        g_free(res_iovs);
+        vg_cleanup_mapping_iov(g, res_iovs, att_rb.nr_entries);
     }
 }
 
@@ -314,7 +315,7 @@ virgl_resource_detach_backing(VuGpu *g,
     if (res_iovs == NULL || num_iovs == 0) {
         return;
     }
-    g_free(res_iovs);
+    vg_cleanup_mapping_iov(g, res_iovs, num_iovs);
 }
 
 static void