121 Commits
Author SHA1 Message Date
Chia-I Wu f8000f0986 vtest: add VCMD_CONTEXT_INIT
It gives clients access to virgl_renderer_context_create_with_flags.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Isaac Bosompem <[email protected]>
2021-01-16 08:05:29 +00:00
Chia-I Wu 0b3e195268 vtest: add VCMD_GET_CAPSET
Comparing to VCMD_GET_{CAPS,CAPS2}, it allows any capset id/version
to be queried.

This is similar to linux's DRM_IOCTL_VIRTGPU_GET_CAPS.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Isaac Bosompem <[email protected]>
2021-01-16 08:05:29 +00:00
Chia-I Wu 53aedf637f vtest: add VCMD_GET_PARAM
There is no parameter defined yet, but the command can be used to query
optional features.  It also allows new features to be introduced without
bumping up the protocol version.

This is similar to linux's DRM_IOCTL_VIRTGPU_GETPARAM.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Isaac Bosompem <[email protected]>
2021-01-16 08:05:29 +00:00
Chia-I Wu 48b67e83a1 vtest: defer virgl_renderer_context_create further
The goal is to allow clients to negoticate protocol versions, capsets,
and in the future, parameters and context types before
virgl_renderer_context_create is called.

Specifically, these commands should not trigger
virgl_renderer_context_create

  VCMD_PING_PROTOCOL_VERSION
  VCMD_PROTOCOL_VERSION
  VCMD_GET_CAPS
  VCMD_GET_CAPS2
  VCMD_RESOURCE_BUSY_WAIT when res_id==0 (for legacy reasons)

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Isaac Bosompem <[email protected]>
2021-01-16 08:05:29 +00:00
Chia-I Wu 3802f56a3b vtest: defer virgl_renderer_context_create
Move virgl_renderer_context_create call from vtest_create_context to
the new vtest_lazy_init_context.  This defers context initialization
until the first command after VCMD_CREATE_RENDERER.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Isaac Bosompem <[email protected]>
2021-01-16 08:05:29 +00:00
Chia-I Wu 654771bca1 vtest: use vtest_destroy_context to cleanup
struct vtest_context is about to get more complex.  Use
vtest_destroy_context so that we have a single point that does context
destruction.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Isaac Bosompem <[email protected]>
2021-01-16 08:05:29 +00:00
Chia-I Wu a06a0b0a9e vtest: fix a NULL deref in fuzzer
Passing NULL for args to indicate nop is too tricky to get right.
Add a bool for that.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: David Riley <[email protected]>
2020-07-20 12:16:43 -07:00
Chia-I Wu cf1e5ba972 vtest: use per-context resource table
We want to destroy all resources owned by a context after a client
dies unexpectedly.  This is needed for --multi-clients.  See commit
6c44b4a79 (vtest: add experimental multi-client support) for more
details.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:59 -07:00
Chia-I Wu ad1b7b15dd vtest: properly clean up resources
Call virgl_renderer_resource_unref from resource_destroy_func.  Do
not rely on virgl_renderer_cleanup to clean up for us.  This is
needed for proper multiple client support, where we need to clean up
client resources when a client dies.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:57 -07:00
Chia-I Wu eca6ebc2ef vtest: add vtest_resource::res_id
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:56 -07:00
Chia-I Wu 75e7efc826 vtest: add vtest_create_resource_internal
Move the common code of vtest_create_{resource,resource2} to the new
function.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:55 -07:00
Chia-I Wu 7dea0da5fd vtest: manage v1 resources with vtest_resource
Manage both v1 and v2 resources the same way.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:54 -07:00
Chia-I Wu be02caf74b vtest: add vtest_resource
Add vtest_resource and embed iovec in it.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:53 -07:00
Chia-I Wu dbeb8e7aff vtest: add vtest_create_resource_setup_shm
This helper sets up shm and iov.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:51 -07:00
Chia-I Wu 55f570cd2c vtest: add vtest_create_resource_decode_args2
This helper decodes VCMD_RESOURCE_CREATE2 args.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:50 -07:00
Chia-I Wu 046d008358 vtest: add vtest_create_resource_decode_args
This helper decodes VCMD_RESOURCE_CREATE args.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:49 -07:00
Chia-I Wu b1ed555f89 vtest: add vtest_transfer_put_internal
Move the common code of vtest_transfer_{put,put_nop,put2,put2_nop}
to the new function.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:48 -07:00
Chia-I Wu c8d3e8ff21 vtest: add vtest_transfer_get_internal
Move the common code of vtest_transfer_{get,get_nop,get2,get2_nop}
to the new function.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:47 -07:00
Chia-I Wu 5d71e4a32b vtest: add vtest_transfer_decode_args2
Replace DECODE_TRANSFER2 macro by the new helper.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:46 -07:00
Chia-I Wu e1ccc59b5b vtest: add vtest_transfer_decode_args
Replace DECODE_TRANSFER macro by the new helper.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
2020-07-16 16:23:42 -07:00
Elie Tournier 70019da650 build: Drop autotools
Autotools is deprecated since debb6e6ac4
It's now time to drop it definitively.

Signed-off-by: Elie Tournier <[email protected]>
Reviewed-by: Gert Wollny <[email protected]>
2020-06-02 18:58:02 +00:00
Tomeu Vizoso 70b18e56d5 vtest: Handle errors coming out of virgl_renderer_submit_cmd
Previously, Mesa would remain forever blocked in read() after an error
such as failing to compile a shader.

Signed-off-by: Tomeu Vizoso <[email protected]>
Reviewed-by: Gert Wollny <[email protected]>
2020-04-21 12:46:27 +00:00
Tomeu Vizoso 469b65b9cb vtest: Initialize sendmsg iovec contents
To keep Valgrind happy:

==3628== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
==3628==    at 0x48DB431: sendmsg (sendmsg.c:28)
==3628==    by 0x10C00E: vtest_create_resource2 (in /virglrenderer/build/vtest/virgl_test_server)
==3628==    by 0x10AC2B: vtest_server_run (in /virglrenderer/build/vtest/virgl_test_server)
==3628==    by 0x10A5B3: main (in /virglrenderer/build/vtest/virgl_test_server)
==3628==  Address 0x1fff0004ef is on thread 1's stack
==3628==  in frame #1, created by vtest_create_resource2 (???:)

Signed-off-by: Tomeu Vizoso <[email protected]>
Reviewed-by: Gert Wollny <[email protected]>
2020-04-21 12:46:27 +00:00
Chia-I Wu 6c44b4a798 vtest: add experimental multi-client support
Add --multi-clients to enable experimental multi-client support.

Note that multi-client should be enabled only when the clients know
and trust each other.  This is because resources are global among
the clients.  Two clients trying to create two resources with the
same id will result in an id conflict for example.

Proper multi-client support requires changes to the protocol.  The
main change will be for the server to generate globally unique
resource ids and enforce access controls.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:24 -07:00
Chia-I Wu b6aa008177 vtest: add enum vtest_client_error
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:22 -07:00
Chia-I Wu 4150a90ca3 vtest: overhaul vtest_server_run_renderer
Add vtest_server_run to replace vtest_server_run_renderer.  The new
function is the main loop of the server, which

 - accepts new client connections
 - dispatches client commands
 - removes inactive clients
 - lazily initi/cleanup the renderer
 - optionally forks for each connection

in a single loop.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:18 -07:00
Chia-I Wu 97c2225912 vtest: make vtest_client a list
In preparation for multi-client support.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:16 -07:00
Chia-I Wu 861ba2a6cb vtest: replace gotos by a loop in main
Get rid of gotos so that it will be easier when we turn
vtest_server_run_renderer into the main loop.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:13 -07:00
Chia-I Wu 134dcfb658 vtest: move do_fork logic into vtest_server_run_renderer
We want to make vtest_server_run_renderer the main loop when we add
multi-client support.  Forking for new clients will be done in the
main loop.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:11 -07:00
Chia-I Wu 4d234f9f17 vtest: initialize renderer when the client connects
Call vtest_init_renderer when the client connects, instead of before
the first command.  We want to make vtest_server_run_renderer the
main loop when we add multi-client support, and this makes things
simpler.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:08 -07:00
Chia-I Wu b88a34d5d3 vtest: refactor vtest_server_run_renderer
Refactor command dispatching to a separate function,
vtest_client_dispatch_commands.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:05 -07:00
Chia-I Wu 3b8bf6b3eb vtest: move ctx_flags into vtest_server
In preparation for multi-client support.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:03 -07:00
Chia-I Wu 5670ebd0ec vtest: add vtest_client
In preparation for multi-client support.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:22:00 -07:00
Chia-I Wu ead1006c87 vtest: rename vtest_program to vtest_server
In preparation for multi-client support.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:21:58 -07:00
Chia-I Wu c6771ac666 vtest: move to multi-client support in vtest_renderer
This commit moves input/out_fd into vtest_context to allow multiple
clients, where each client is represented by a vtest_context and has
its own vtest_input.

Note that clients must know and trust each other, especially when it
comes to resources.  There is no conflict or ownership check in
vtest_create_resource or vtest_resource_unref respectively yet.
There is also no resource sharing support yet.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:21:55 -07:00
Chia-I Wu 1a01bdbefb vtest: move protocol_version into vtest_context
In preparation for multi-client support.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:21:51 -07:00
Chia-I Wu d1672f6401 vtest: add multi-context support to vtest_renderer
A vtest_renderer is still global, but it can now have multiple
vtest_contexts.  vtest_create_renderer is replaced by

  vtest_init_renderer
  vtest_create_context
  vtest_set_current_context

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:21:48 -07:00
Chia-I Wu 7fbd96a672 vtest: make renderer/renderer_cbs static
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:21:47 -07:00
Chia-I Wu 1cb1a86145 vtest: move fence_id/last_fence into vtest_renderer
In preparation for multi-context support.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:21:45 -07:00
Chia-I Wu 4e11244e54 vtest: move max_length into vtest_renderer
In preparation for multi-context support.

Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Gurchetan Singh <[email protected]>
2020-03-18 17:20:59 -07:00
David Riley 10854be913 Remove hardcoded "-fsanitize=address"
"-fsanitize=address" which pulls in asan does not work with other
sanitizers like msan/tsan etc.

Based on original change by [email protected].

Signed-off-by: David Riley <[email protected]>
Reviewed-by: Lepton Wu <[email protected]>
2020-02-05 21:09:50 -08:00
Woody Chow 08820cb0fb Fix vtest build by depending on libvirglrenderer_dep
Build was broken by https://gitlab.freedesktop.org/virgl/virglrenderer/merge_requests/335

Reviewed-by: Gert Wollny <[email protected]>
2020-01-16 08:56:52 +00:00
Nathan Owens 9c3b8f4acc Add sys/select.h for musl
Reviewed-by: Nathan Owens [email protected]
2020-01-02 21:13:55 -06:00
Gert Wollny 1e581b6b49 meson: set visibility flag when compiler supports it
Since vtest_server and the tests make use of private interfaces we must
mirror the autotoosl build that keeps the private interfaces in a static
library so that these functions can be called by the test code. The main
library that get installed then uses this static library and adds the
exported interface.

Closes #152

Signed-off-by: Gert Wollny <[email protected]>
Reviewed-by: Gurchetan Singh <[email protected]>
2019-12-27 10:00:56 +01:00
Marc-André Lureau c7f7d76b47 Fix -Wpointer-arith warnings
Fixes:
warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Gert Wollny <[email protected]>
2019-12-06 13:43:51 +04:00
Marc-André Lureau d93f600983 Fix some -Wpedantic warning
Fixes
ISO C does not support ‘__FUNCTION__’ predefined identifier

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Gert Wollny <[email protected]>
2019-12-06 13:43:51 +04:00
Gert Wollny 17c2368f97 build: Add meson build
This patch adds the meson build system as alternative to the
autotools build system.

v2: Thanks to Alexandros for his comments that lead to the following changes:
    - Fix logic for platforms so that the ones selected by 'auto' don't
      fail if the dependencies are missing, but fail when explicitely
      requested
    - declare project version differently
    - set a minimun meson version
    - clean up some braces
    - reformat some code
    - squesh remaining separate patches

v3: require meson 0.46 (Gurchetan)

v4: set minimum gbm version to 18.0.0

v5: - fix gbm version requirement (Gurchetan)
    - don't duplicate glx files (Gurchetan)

Fixes: #129

Signed-off-by: Gert Wollny <[email protected]>
Tested-by: Gurchetan Singh <[email protected]>
Reviewed-by: Gurchetan Singh <[email protected]>
2019-09-26 11:16:08 +00:00
Gert Wollny ecba12cdac vtest: Add option and environment variable to select the rendernode
In systems with more then one graphics card the rendernode is currently
picked based on the order in which they are listed in /dev/dri. Add an
command line option and a environment variable to make it possible to
specify the render node explicitely.

Fixes #135

Signed-off-by: Gert Wollny <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
2019-09-26 11:15:40 +00:00
Gert Wollny a07a3f6f96 vrend: Fix newly introduced warnings
The fuzzer series added a few warnings that need to be silenced.

Signed-off-by: Gert Wollny <[email protected]>
Reviewed-by: David Riley <[email protected]>
2019-06-13 18:36:55 +02:00
David Riley 1fdc471e29 vtest: set a maximum cmd length to avoid fuzzer memory errors
Signed-off-by: David Riley <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
2019-06-12 11:53:44 -07:00