diff mbox series

[RFC,QEMU,16/18] virtio-gpu: fix hw-display-virtio-gpu.so undefined symbol virtio_gpu_virgl_resource_unmap

Message ID 20230312092244.451465-17-ray.huang@amd.com (mailing list archive)
State New, archived
Headers show
Series Add VirtIO GPU and Passthrough GPU support on Xen | expand

Commit Message

Huang Rui March 12, 2023, 9:22 a.m. UTC
From: Honglei Huang <honglei1.huang@amd.com>

Move virtio_gpu_virgl_resource_unmap to virtio-gpu.c cause virtio-gpu.so
call this function but this function in virtio-gpu-gl.so before.

Add virgl dependency  into virtio-gpu-gl.so.

Suggested-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Honglei Huang <honglei1.huang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
---
 hw/display/meson.build        |  2 +-
 hw/display/virtio-gpu-virgl.c | 17 -----------------
 hw/display/virtio-gpu.c       | 19 +++++++++++++++++++
 3 files changed, 20 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/hw/display/meson.build b/hw/display/meson.build
index 7a725ed80e..21999dfbe0 100644
--- a/hw/display/meson.build
+++ b/hw/display/meson.build
@@ -67,7 +67,7 @@  softmmu_ss.add(when: [pixman, 'CONFIG_ATI_VGA'], if_true: files('ati.c', 'ati_2d
 if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
   virtio_gpu_ss = ss.source_set()
   virtio_gpu_ss.add(when: 'CONFIG_VIRTIO_GPU',
-                    if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman])
+                    if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman, virgl])
   virtio_gpu_ss.add(when: 'CONFIG_LINUX', if_true: files('virtio-gpu-udmabuf.c'),
                                           if_false: files('virtio-gpu-udmabuf-stubs.c'))
   virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 69083d15a9..d5214e0f43 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -636,23 +636,6 @@  static void virgl_cmd_resource_map_blob(VirtIOGPU *g,
     virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp));
 }
 
-int virtio_gpu_virgl_resource_unmap(VirtIOGPU *g,
-                                    struct virtio_gpu_simple_resource *res)
-{
-    if (!res->mapped) {
-        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already unmapped %d\n",
-                      __func__, res->resource_id);
-        return VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
-    }
-
-    memory_region_set_enabled(&res->region, false);
-    memory_region_del_subregion(&g->parent_obj.hostmem, &res->region);
-    object_unparent(OBJECT(&res->region));
-
-    res->mapped = NULL;
-    return virgl_renderer_resource_unmap(res->resource_id);
-}
-
 static void virgl_cmd_resource_unmap_blob(VirtIOGPU *g,
                                         struct virtio_gpu_ctrl_command *cmd)
 {
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 95e421a525..95eaed61b3 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -31,6 +31,8 @@ 
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 
+#include <virglrenderer.h>
+
 #define VIRTIO_GPU_VM_VERSION 1
 
 static struct virtio_gpu_simple_resource *
@@ -873,6 +875,23 @@  void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
     g_free(iov);
 }
 
+int virtio_gpu_virgl_resource_unmap(VirtIOGPU *g,
+                                    struct virtio_gpu_simple_resource *res)
+{
+    if (!res->mapped) {
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already unmapped %d\n",
+                      __func__, res->resource_id);
+        return VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
+    }
+
+    memory_region_set_enabled(&res->region, false);
+    memory_region_del_subregion(&g->parent_obj.hostmem, &res->region);
+    object_unparent(OBJECT(&res->region));
+
+    res->mapped = NULL;
+    return virgl_renderer_resource_unmap(res->resource_id);
+}
+
 static void virtio_gpu_cleanup_mapping(VirtIOGPU *g,
                                        struct virtio_gpu_simple_resource *res)
 {