[RFC PATCH 2/8] tests: vhost-vdpa: parameterize VDUSE operations

Eugenio Pérez posted 8 patches 1 month, 1 week ago
Maintainers: Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
[RFC PATCH 2/8] tests: vhost-vdpa: parameterize VDUSE operations
Posted by Eugenio Pérez 1 month, 1 week ago
Make the VduseOps callbacks a parameter to test_server_new() instead
of hardcoding vduse_read_guest_mem_ops.

This allows different test cases to provide custom queue enable/disable
handlers for testing various vhost-vdpa scenarios.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 tests/qtest/vhost-vdpa-test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/qtest/vhost-vdpa-test.c b/tests/qtest/vhost-vdpa-test.c
index 1fc5acacfed3..1c7d8540bd19 100644
--- a/tests/qtest/vhost-vdpa-test.c
+++ b/tests/qtest/vhost-vdpa-test.c
@@ -277,7 +277,7 @@ static bool test_setup_reconnect_log(VduseDev *vdev, const char *tmpfs)
     return ok;
 }
 
-static TestServer *test_server_new(const gchar *name)
+static TestServer *test_server_new(const gchar *name, const VduseOps *ops)
 {
     TestServer *server = g_new0(TestServer, 1);
     g_autoptr(GError) err = NULL;
@@ -302,7 +302,7 @@ static TestServer *test_server_new(const gchar *name)
                                     2, /* num_queues */
                                     sizeof(config),
                                     config,
-                                    &vduse_read_guest_mem_ops,
+                                    ops,
                                     server);
 
     if (!server->vdev) {
@@ -387,7 +387,7 @@ static void vhost_vdpa_test_cleanup(void *s)
 
 static void *vhost_vdpa_test_setup_memfile(GString *cmd_line, void *arg)
 {
-    TestServer *server = test_server_new("vdpa-memfile");
+    TestServer *server = test_server_new("vdpa-memfile", &vduse_read_guest_mem_ops);
 
     if (!server->ready) {
         g_test_skip("Failed to create VDUSE device");
-- 
2.53.0