[PATCH 8/8] tests/functional: add GPU blob allocation test

Alex Bennée posted 8 patches 1 month ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
[PATCH 8/8] tests/functional: add GPU blob allocation test
Posted by Alex Bennée 1 month ago
This is a very short microkernel test that initialises and then maps
and unmaps a blob resource.

Without the other fixes in this series it causes QEMU to hang on the
unhandled unmap.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/functional/aarch64/meson.build      |  1 +
 tests/functional/aarch64/test_gpu_blob.py | 73 +++++++++++++++++++++++
 2 files changed, 74 insertions(+)
 create mode 100755 tests/functional/aarch64/test_gpu_blob.py

diff --git a/tests/functional/aarch64/meson.build b/tests/functional/aarch64/meson.build
index 5ad52f93e1d..f6ca33b2be4 100644
--- a/tests/functional/aarch64/meson.build
+++ b/tests/functional/aarch64/meson.build
@@ -26,6 +26,7 @@ tests_aarch64_system_thorough = [
   'aspeed_ast2700',
   'aspeed_ast2700fc',
   'device_passthrough',
+  'gpu_blob',
   'hotplug_pci',
   'imx8mp_evk',
   'kvm',
diff --git a/tests/functional/aarch64/test_gpu_blob.py b/tests/functional/aarch64/test_gpu_blob.py
new file mode 100755
index 00000000000..a913d3b29c8
--- /dev/null
+++ b/tests/functional/aarch64/test_gpu_blob.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python3
+#
+# Functional tests for GPU blob support. This is a directed test to
+# exercise the blob creation and removal features of virtio-gpu. You
+# can find the source code for microkernel test here:
+#   https://gitlab.com/epilys/qemu-880-repro
+#
+# Copyright (c) 2025 Linaro Ltd.
+#
+# Authors:
+#  Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
+#  Alex Bennée <alex.bennee@linaro.org>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu.machine.machine import VMLaunchFailure
+
+from qemu_test import Asset
+from qemu_test import wait_for_console_pattern
+from qemu_test.linuxkernel import LinuxKernelTest
+
+class Aarch64VirtBlobTest(LinuxKernelTest):
+
+    ASSET_BLOB = Asset('https://fileserver.linaro.org/s/kE4nCFLdQcoBF9t/'
+                       'download?path=%2Fblob-test&files=qemu-880.bin',
+                       '2f6ab85d0b156c94fcedd2c4c821c5cbd52925a2de107f8e2d569ea2e34e42eb')
+
+    def test_virtio_gpu_blob(self):
+
+        self.set_machine('virt')
+        self.require_accelerator("tcg")
+
+        blob = self.ASSET_BLOB.fetch()
+
+        self.vm.set_console()
+
+        self.vm.add_args("-machine", "virt,memory-backend=mem0,accel=tcg",
+                         '-m', '4G',
+                         '-cpu', 'max',
+                         '-kernel', blob,
+                         '-object', 'memory-backend-memfd,share=on,id=mem0,size=4G',
+                         '-global', 'virtio-mmio.force-legacy=false',
+                         '-nic', 'none',
+                         '-device',
+                         'virtio-gpu-gl,hostmem=128M,blob=true,venus=true',
+                         '-display', 'egl-headless,gl=on',
+                         '-d', 'guest_errors')
+
+        try:
+            self.vm.launch()
+        except VMLaunchFailure as excp:
+            if "old virglrenderer, blob resources unsupported" in excp.output:
+                self.skipTest("No blob support for virtio-gpu")
+            elif "old virglrenderer, venus unsupported" in excp.output:
+                self.skipTest("No venus support for virtio-gpu")
+            elif "egl: no drm render node available" in excp.output:
+                self.skipTest("Can't access host DRM render node")
+            elif "'type' does not accept value 'egl-headless'" in excp.output:
+                self.skipTest("egl-headless support is not available")
+            elif "'type' does not accept value 'dbus'" in excp.output:
+                self.skipTest("dbus display support is not available")
+            elif "eglInitialize failed: EGL_NOT_INITIALIZED" in excp.output:
+                self.skipTest("EGL failed to initialize on this host")
+            else:
+                self.log.info("unhandled launch failure: %s", excp.output)
+                raise excp
+
+        self.wait_for_console_pattern('[INFO] virtio-gpu test finished')
+        # the test should cleanly exit
+
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
-- 
2.47.3


Re: [PATCH 8/8] tests/functional: add GPU blob allocation test
Posted by Akihiko Odaki 1 month ago
On 2025/10/14 20:12, Alex Bennée wrote:
> This is a very short microkernel test that initialises and then maps
> and unmaps a blob resource.
> 
> Without the other fixes in this series it causes QEMU to hang on the
> unhandled unmap.

Thank you for the reproduction case.

I don't have time to look into it this and the next week due to 
attendance to a conference (MICRO-58), but I'll definitely do so after that.

> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   tests/functional/aarch64/meson.build      |  1 +
>   tests/functional/aarch64/test_gpu_blob.py | 73 +++++++++++++++++++++++
>   2 files changed, 74 insertions(+)
>   create mode 100755 tests/functional/aarch64/test_gpu_blob.py
> 
> diff --git a/tests/functional/aarch64/meson.build b/tests/functional/aarch64/meson.build
> index 5ad52f93e1d..f6ca33b2be4 100644
> --- a/tests/functional/aarch64/meson.build
> +++ b/tests/functional/aarch64/meson.build
> @@ -26,6 +26,7 @@ tests_aarch64_system_thorough = [
>     'aspeed_ast2700',
>     'aspeed_ast2700fc',
>     'device_passthrough',
> +  'gpu_blob',
>     'hotplug_pci',
>     'imx8mp_evk',
>     'kvm',
> diff --git a/tests/functional/aarch64/test_gpu_blob.py b/tests/functional/aarch64/test_gpu_blob.py
> new file mode 100755
> index 00000000000..a913d3b29c8
> --- /dev/null
> +++ b/tests/functional/aarch64/test_gpu_blob.py
> @@ -0,0 +1,73 @@
> +#!/usr/bin/env python3
> +#
> +# Functional tests for GPU blob support. This is a directed test to
> +# exercise the blob creation and removal features of virtio-gpu. You
> +# can find the source code for microkernel test here:
> +#   https://gitlab.com/epilys/qemu-880-repro

Nice. I appreciate the effort to creat the microkernel; hopefully it 
will be useful also to exercise this part of virtio-gpu for debugging in 
the future.

> +#
> +# Copyright (c) 2025 Linaro Ltd.
> +#
> +# Authors:
> +#  Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> +#  Alex Bennée <alex.bennee@linaro.org>
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +from qemu.machine.machine import VMLaunchFailure
> +
> +from qemu_test import Asset
> +from qemu_test import wait_for_console_pattern
> +from qemu_test.linuxkernel import LinuxKernelTest
> +
> +class Aarch64VirtBlobTest(LinuxKernelTest):
> +
> +    ASSET_BLOB = Asset('https://fileserver.linaro.org/s/kE4nCFLdQcoBF9t/'
> +                       'download?path=%2Fblob-test&files=qemu-880.bin',
> +                       '2f6ab85d0b156c94fcedd2c4c821c5cbd52925a2de107f8e2d569ea2e34e42eb')
> +
> +    def test_virtio_gpu_blob(self):
> +
> +        self.set_machine('virt')
> +        self.require_accelerator("tcg")
> +
> +        blob = self.ASSET_BLOB.fetch()
> +
> +        self.vm.set_console()
> +
> +        self.vm.add_args("-machine", "virt,memory-backend=mem0,accel=tcg",
> +                         '-m', '4G',
> +                         '-cpu', 'max',
> +                         '-kernel', blob,
> +                         '-object', 'memory-backend-memfd,share=on,id=mem0,size=4G',
> +                         '-global', 'virtio-mmio.force-legacy=false',
> +                         '-nic', 'none',
> +                         '-device',
> +                         'virtio-gpu-gl,hostmem=128M,blob=true,venus=true',

venus is not exercised with this test case so can be removed.

This test somehow hung on my laptop even with the all other patches in 
this series applied, and removing venus=true fixed the hung.

I suppose the hang is unrelated to the problem fixed in this series and 
but rather is a problem specific to my environment (Asahi Linux). 
Anyway, I think removing venus=true is a safer option to avoid problems 
with the host graphics stack.

Below is a part of build/meson-logs/testlog.txt:

==================================== 1/1 
=====================================
test:         qemu:func-thorough+func-aarch64-thorough+thorough / 
func-aarch64-gpu_blob
start time:   02:25:49
duration:     90.01s
result:       killed by signal 15 SIGTERM
command: 
MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 
MALLOC_PERTURB_=12 RUST_BACKTRACE=1 
QEMU_TEST_QEMU_BINARY=/home/me/q/var/qemu/build/qemu-system-aarch64 
UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 
PYTHONPATH=/home/me/q/var/qemu/python:/home/me/q/var/qemu/tests/functional 
ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 
MESON_TEST_ITERATION=1 QEMU_BUILD_ROOT=/home/me/q/var/qemu/build 
QEMU_TEST_QEMU_IMG=/home/me/q/var/qemu/build/qemu-img 
LD_LIBRARY_PATH=/home/me/q/var/qemu/build/contrib/plugins:/home/me/q/var/qemu/build/tests/tcg/plugins 
/home/me/q/var/qemu/build/pyvenv/bin/python3 
/home/me/q/var/qemu/tests/functional/aarch64/test_gpu_blob.py
----------------------------------- stderr 
-----------------------------------
==31639==WARNING: ASan doesn't fully support makecontext/swapcontext 
functions and may produce false positives in some cases!
==============================================================================


Summary of Failures:

1/1 qemu:func-thorough+func-aarch64-thorough+thorough / 
func-aarch64-gpu_blob TIMEOUT        90.01s   killed by signal 15 SIGTERM

Ok:                 0
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            0
Timeout:            1

> +                         '-display', 'egl-headless,gl=on',
> +                         '-d', 'guest_errors')
> +
> +        try:
> +            self.vm.launch()
> +        except VMLaunchFailure as excp:
> +            if "old virglrenderer, blob resources unsupported" in excp.output:
> +                self.skipTest("No blob support for virtio-gpu")
> +            elif "old virglrenderer, venus unsupported" in excp.output:
> +                self.skipTest("No venus support for virtio-gpu")
> +            elif "egl: no drm render node available" in excp.output:
> +                self.skipTest("Can't access host DRM render node")

This condition is unnecessary as DRM render node is not used.

> +            elif "'type' does not accept value 'egl-headless'" in excp.output:
> +                self.skipTest("egl-headless support is not available")
> +            elif "'type' does not accept value 'dbus'" in excp.output:
> +                self.skipTest("dbus display support is not available")

This can be removed too.

> +            elif "eglInitialize failed: EGL_NOT_INITIALIZED" in excp.output:
> +                self.skipTest("EGL failed to initialize on this host")
> +            else:
> +                self.log.info("unhandled launch failure: %s", excp.output)
> +                raise excp
> +
> +        self.wait_for_console_pattern('[INFO] virtio-gpu test finished')
> +        # the test should cleanly exit
> +
> +
> +if __name__ == '__main__':
> +    LinuxKernelTest.main()


Re: [PATCH 8/8] tests/functional: add GPU blob allocation test
Posted by Akihiko Odaki 1 month ago
On 2025/10/15 11:41, Akihiko Odaki wrote:
> On 2025/10/14 20:12, Alex Bennée wrote:
>> This is a very short microkernel test that initialises and then maps
>> and unmaps a blob resource.
>>
>> Without the other fixes in this series it causes QEMU to hang on the
>> unhandled unmap.
> 
> Thank you for the reproduction case.
> 
> I don't have time to look into it this and the next week due to 
> attendance to a conference (MICRO-58), but I'll definitely do so after 
> that.
> 
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   tests/functional/aarch64/meson.build      |  1 +
>>   tests/functional/aarch64/test_gpu_blob.py | 73 +++++++++++++++++++++++
>>   2 files changed, 74 insertions(+)
>>   create mode 100755 tests/functional/aarch64/test_gpu_blob.py
>>
>> diff --git a/tests/functional/aarch64/meson.build b/tests/functional/ 
>> aarch64/meson.build
>> index 5ad52f93e1d..f6ca33b2be4 100644
>> --- a/tests/functional/aarch64/meson.build
>> +++ b/tests/functional/aarch64/meson.build
>> @@ -26,6 +26,7 @@ tests_aarch64_system_thorough = [
>>     'aspeed_ast2700',
>>     'aspeed_ast2700fc',
>>     'device_passthrough',
>> +  'gpu_blob',
>>     'hotplug_pci',
>>     'imx8mp_evk',
>>     'kvm',
>> diff --git a/tests/functional/aarch64/test_gpu_blob.py b/tests/ 
>> functional/aarch64/test_gpu_blob.py
>> new file mode 100755
>> index 00000000000..a913d3b29c8
>> --- /dev/null
>> +++ b/tests/functional/aarch64/test_gpu_blob.py
>> @@ -0,0 +1,73 @@
>> +#!/usr/bin/env python3
>> +#
>> +# Functional tests for GPU blob support. This is a directed test to
>> +# exercise the blob creation and removal features of virtio-gpu. You
>> +# can find the source code for microkernel test here:
>> +#   https://gitlab.com/epilys/qemu-880-repro
> 
> Nice. I appreciate the effort to creat the microkernel; hopefully it 
> will be useful also to exercise this part of virtio-gpu for debugging in 
> the future.
> 
>> +#
>> +# Copyright (c) 2025 Linaro Ltd.
>> +#
>> +# Authors:
>> +#  Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
>> +#  Alex Bennée <alex.bennee@linaro.org>
>> +#
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +from qemu.machine.machine import VMLaunchFailure
>> +
>> +from qemu_test import Asset
>> +from qemu_test import wait_for_console_pattern

This import of wait_for_console_pattern is unused. There is a call of 
self.wait_for_console_pattern(), but it prefixed with "self." so doesn't 
use this import.

>> +from qemu_test.linuxkernel import LinuxKernelTest
>> +
>> +class Aarch64VirtBlobTest(LinuxKernelTest):
>> +
>> +    ASSET_BLOB = Asset('https://fileserver.linaro.org/s/ 
>> kE4nCFLdQcoBF9t/'
>> +                       'download?path=%2Fblob-test&files=qemu-880.bin',
>> +                       
>> '2f6ab85d0b156c94fcedd2c4c821c5cbd52925a2de107f8e2d569ea2e34e42eb')
>> +
>> +    def test_virtio_gpu_blob(self):
>> +
>> +        self.set_machine('virt')
>> +        self.require_accelerator("tcg")
>> +
>> +        blob = self.ASSET_BLOB.fetch()
>> +
>> +        self.vm.set_console()
>> +
>> +        self.vm.add_args("-machine", "virt,memory- 
>> backend=mem0,accel=tcg",
>> +                         '-m', '4G',
>> +                         '-cpu', 'max',
>> +                         '-kernel', blob,
>> +                         '-object', 'memory-backend- 
>> memfd,share=on,id=mem0,size=4G',
>> +                         '-global', 'virtio-mmio.force-legacy=false',
>> +                         '-nic', 'none',
>> +                         '-device',
>> +                         'virtio-gpu- 
>> gl,hostmem=128M,blob=true,venus=true',
> 
> venus is not exercised with this test case so can be removed.
> 
> This test somehow hung on my laptop even with the all other patches in 
> this series applied, and removing venus=true fixed the hung.
> 
> I suppose the hang is unrelated to the problem fixed in this series and 
> but rather is a problem specific to my environment (Asahi Linux). 
> Anyway, I think removing venus=true is a safer option to avoid problems 
> with the host graphics stack.
> 
> Below is a part of build/meson-logs/testlog.txt:
> 
> ==================================== 1/1 
> =====================================
> test:         qemu:func-thorough+func-aarch64-thorough+thorough / func- 
> aarch64-gpu_blob
> start time:   02:25:49
> duration:     90.01s
> result:       killed by signal 15 SIGTERM
> command: 
> MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 MALLOC_PERTURB_=12 RUST_BACKTRACE=1 QEMU_TEST_QEMU_BINARY=/home/me/q/var/qemu/build/qemu-system-aarch64 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 PYTHONPATH=/home/me/q/var/qemu/python:/home/me/q/var/qemu/tests/functional ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 MESON_TEST_ITERATION=1 QEMU_BUILD_ROOT=/home/me/q/var/qemu/build QEMU_TEST_QEMU_IMG=/home/me/q/var/qemu/build/qemu-img LD_LIBRARY_PATH=/home/me/q/var/qemu/build/contrib/plugins:/home/me/q/var/qemu/build/tests/tcg/plugins /home/me/q/var/qemu/build/pyvenv/bin/python3 /home/me/q/var/qemu/tests/functional/aarch64/test_gpu_blob.py
> ----------------------------------- stderr 
> -----------------------------------
> ==31639==WARNING: ASan doesn't fully support makecontext/swapcontext 
> functions and may produce false positives in some cases!
> ==============================================================================
> 
> 
> Summary of Failures:
> 
> 1/1 qemu:func-thorough+func-aarch64-thorough+thorough / func-aarch64- 
> gpu_blob TIMEOUT        90.01s   killed by signal 15 SIGTERM
> 
> Ok:                 0
> Expected Fail:      0
> Fail:               0
> Unexpected Pass:    0
> Skipped:            0
> Timeout:            1
> 
>> +                         '-display', 'egl-headless,gl=on',
>> +                         '-d', 'guest_errors')
>> +
>> +        try:
>> +            self.vm.launch()
>> +        except VMLaunchFailure as excp:
>> +            if "old virglrenderer, blob resources unsupported" in 
>> excp.output:
>> +                self.skipTest("No blob support for virtio-gpu")
>> +            elif "old virglrenderer, venus unsupported" in excp.output:
>> +                self.skipTest("No venus support for virtio-gpu")
>> +            elif "egl: no drm render node available" in excp.output:
>> +                self.skipTest("Can't access host DRM render node")
> 
> This condition is unnecessary as DRM render node is not used.
> 
>> +            elif "'type' does not accept value 'egl-headless'" in 
>> excp.output:
>> +                self.skipTest("egl-headless support is not available")
>> +            elif "'type' does not accept value 'dbus'" in excp.output:
>> +                self.skipTest("dbus display support is not available")
> 
> This can be removed too.
> 
>> +            elif "eglInitialize failed: EGL_NOT_INITIALIZED" in 
>> excp.output:
>> +                self.skipTest("EGL failed to initialize on this host")
>> +            else:
>> +                self.log.info("unhandled launch failure: %s", 
>> excp.output)
>> +                raise excp
>> +
>> +        self.wait_for_console_pattern('[INFO] virtio-gpu test finished')
>> +        # the test should cleanly exit
>> +
>> +
>> +if __name__ == '__main__':
>> +    LinuxKernelTest.main()
>