[PATCH] virtio-gpu-virgl: fix a bug in context create

liweishi@kylinos.cn posted 1 patch 10 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250320072834.173759-1-liweishi@kylinos.cn
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
hw/display/virtio-gpu-virgl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] virtio-gpu-virgl: fix a bug in context create
Posted by liweishi@kylinos.cn 10 months, 3 weeks ago
From: Weishi Li <liweishi@kylinos.cn>

When VIRGL_VERSION_MAJOR<1, virtio_gpu_context_init_enabled
will always return false, causing virgl_cmd_context_create
to always return error. Therefore, it is necessary to also
include the virtio_gpu_context_init_enabled segment in the
VIRGL_VERSION_MAJOR judgment to ensure that context create
can also succeed when VIRGL_VERSION-MAJOR<1

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