[PATCH v1] virtio-gpu-virgl: Correct virgl_cmd_context_create()

liweishi@kylinos.cn posted 1 patch 1 month ago
hw/display/virtio-gpu-virgl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v1] virtio-gpu-virgl: Correct virgl_cmd_context_create()
Posted by liweishi@kylinos.cn 1 month ago
From: Weishi Li <liweishi@kylinos.cn>

Due to the fact that g->parent_obj.conf only adds
VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED setting when
VIRGL_VERSION_MAJOR >= 1, virgl_cmd_comtext_create()
will always return by error=VIRTIO_GPU_RESP_ERR_UNSPEC
when VIRGL_VERSION_MAJOR < 1, resulting in gl context
initialization failure.

Signed-off-by: Weishi Li <liweishi@kylinos.cn>
---
 hw/display/virtio-gpu-virgl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 145a0b3879..48f6121e16 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -338,6 +338,7 @@ static void virgl_cmd_context_create(VirtIOGPU *g,
                                     cc.debug_name);
 
     if (cc.context_init) {
+#if VIRGL_VERSION_MAJOR >= 1
         if (!virtio_gpu_context_init_enabled(g->parent_obj.conf)) {
             qemu_log_mask(LOG_GUEST_ERROR, "%s: context_init disabled",
                           __func__);
@@ -345,7 +346,6 @@ static void virgl_cmd_context_create(VirtIOGPU *g,
             return;
         }
 
-#if VIRGL_VERSION_MAJOR >= 1
         virgl_renderer_context_create_with_flags(cc.hdr.ctx_id,
                                                  cc.context_init,
                                                  cc.nlen,
-- 
2.25.1