From nobody Tue Apr 30 07:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513876303436382.0357820113726; Thu, 21 Dec 2017 09:11:43 -0800 (PST) Received: from localhost ([::1]:59918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4NP-00068o-J5 for importer@patchew.org; Thu, 21 Dec 2017 12:11:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4Jp-0003HB-Cl for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS4Jm-000176-I4 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53536) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS4Jm-00016Q-Cc for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:38 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 986FD5D697 for ; Thu, 21 Dec 2017 17:07:37 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 010165C6D4; Thu, 21 Dec 2017 17:07:35 +0000 (UTC) From: Maxime Coquelin To: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com Date: Thu, 21 Dec 2017 18:07:12 +0100 Message-Id: <20171221170716.10709-2-maxime.coquelin@redhat.com> In-Reply-To: <20171221170716.10709-1-maxime.coquelin@redhat.com> References: <20171221170716.10709-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 21 Dec 2017 17:07:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/5] vhost-user-test: extract read-guest-mem test from main loop X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Coquelin , mlureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch makes read-guest-test consistent with other tests, i.e. create the test server in the test thread. Signed-off-by: Maxime Coquelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/vhost-user-test.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index e2c89ed376..11796e6562 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -617,6 +617,28 @@ GSourceFuncs test_migrate_source_funcs =3D { .check =3D test_migrate_source_check, }; =20 +static void test_read_guest_mem(void) +{ + TestServer *server =3D NULL; + char *qemu_cmd =3D NULL; + QTestState *s =3D NULL; + + server =3D test_server_new("test"); + test_server_listen(server); + + qemu_cmd =3D GET_QEMU_CMD(server); + + s =3D qtest_start(qemu_cmd); + g_free(qemu_cmd); + + init_virtio_dev(server); + + read_guest_mem(server); + + qtest_quit(s); + test_server_free(server); +} + static void test_migrate(void) { TestServer *s =3D test_server_new("src"); @@ -919,10 +941,7 @@ static void test_multiqueue(void) =20 int main(int argc, char **argv) { - QTestState *s =3D NULL; - TestServer *server =3D NULL; const char *hugefs; - char *qemu_cmd =3D NULL; int ret; char template[] =3D "/tmp/vhost-test-XXXXXX"; GMainLoop *loop; @@ -947,20 +966,11 @@ int main(int argc, char **argv) root =3D tmpfs; } =20 - server =3D test_server_new("test"); - test_server_listen(server); - loop =3D g_main_loop_new(NULL, FALSE); /* run the main loop thread so the chardev may operate */ thread =3D g_thread_new(NULL, thread_function, loop); =20 - qemu_cmd =3D GET_QEMU_CMD(server); - - s =3D qtest_start(qemu_cmd); - g_free(qemu_cmd); - init_virtio_dev(server); - - qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_m= em); + qtest_add_func("/vhost-user/read-guest-mem", test_read_guest_mem); qtest_add_func("/vhost-user/migrate", test_migrate); qtest_add_func("/vhost-user/multiqueue", test_multiqueue); =20 @@ -978,12 +988,7 @@ int main(int argc, char **argv) =20 ret =3D g_test_run(); =20 - if (s) { - qtest_quit(s); - } - /* cleanup */ - test_server_free(server); =20 /* finish the helper thread and dispatch pending sources */ g_main_loop_quit(loop); --=20 2.14.3 From nobody Tue Apr 30 07:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513876169076846.1437659452442; Thu, 21 Dec 2017 09:09:29 -0800 (PST) Received: from localhost ([::1]:59839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4LN-0004FR-Nm for importer@patchew.org; Thu, 21 Dec 2017 12:09:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4Jp-0003HD-NV for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS4Jo-00018T-L1 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS4Jo-00017y-C9 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:40 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0C9E806BA for ; Thu, 21 Dec 2017 17:07:39 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1CD73819B; Thu, 21 Dec 2017 17:07:37 +0000 (UTC) From: Maxime Coquelin To: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com Date: Thu, 21 Dec 2017 18:07:13 +0100 Message-Id: <20171221170716.10709-3-maxime.coquelin@redhat.com> In-Reply-To: <20171221170716.10709-1-maxime.coquelin@redhat.com> References: <20171221170716.10709-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Dec 2017 17:07:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/5] vhost-user-test: setup virtqueues in all tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Coquelin , mlureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Only the multiqueue test setups the virtqueues. This patch generalizes the setup of virtqueues for all tests. Signed-off-by: Maxime Coquelin --- tests/vhost-user-test.c | 53 +++++++++++++++++++++++++++++++++++++++------= ---- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 11796e6562..be463fe7f2 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -55,6 +55,7 @@ /*********** FROM hw/virtio/vhost-user.c *********************************= ****/ =20 #define VHOST_MEMORY_MAX_NREGIONS 8 +#define VHOST_MAX_VIRTQUEUES 0x100 =20 #define VHOST_USER_F_PROTOCOL_FEATURES 30 #define VHOST_USER_PROTOCOL_F_MQ 0 @@ -141,6 +142,8 @@ enum { =20 typedef struct TestServer { QPCIBus *bus; + QVirtioPCIDevice *dev; + QVirtQueue *vq[VHOST_MAX_VIRTQUEUES]; gchar *socket_path; gchar *mig_path; gchar *chr_name; @@ -155,6 +158,7 @@ typedef struct TestServer { bool test_fail; int test_flags; int queues; + QGuestAllocator *alloc; } TestServer; =20 static const char *tmpfs; @@ -162,26 +166,43 @@ static const char *root; =20 static void init_virtio_dev(TestServer *s) { - QVirtioPCIDevice *dev; uint32_t features; + int i; =20 s->bus =3D qpci_init_pc(NULL); g_assert_nonnull(s->bus); =20 - dev =3D qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET); - g_assert_nonnull(dev); + s->dev =3D qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET); + g_assert_nonnull(s->dev); =20 - qvirtio_pci_device_enable(dev); - qvirtio_reset(&dev->vdev); - qvirtio_set_acknowledge(&dev->vdev); - qvirtio_set_driver(&dev->vdev); + qvirtio_pci_device_enable(s->dev); + qvirtio_reset(&s->dev->vdev); + qvirtio_set_acknowledge(&s->dev->vdev); + qvirtio_set_driver(&s->dev->vdev); + + s->alloc =3D pc_alloc_init(); =20 - features =3D qvirtio_get_features(&dev->vdev); + for (i =3D 0; i < s->queues * 2; i++) { + s->vq[i] =3D qvirtqueue_setup(&s->dev->vdev, s->alloc, i); + } + + features =3D qvirtio_get_features(&s->dev->vdev); features =3D features & VIRTIO_NET_F_MAC; - qvirtio_set_features(&dev->vdev, features); + qvirtio_set_features(&s->dev->vdev, features); =20 - qvirtio_set_driver_ok(&dev->vdev); - qvirtio_pci_device_free(dev); + qvirtio_set_driver_ok(&s->dev->vdev); +} + +static void uninit_virtio_dev(TestServer *s) +{ + int i; + + for (i =3D 0; i < s->queues * 2; i++) { + qvirtqueue_cleanup(s->dev->vdev.bus, s->vq[i], s->alloc); + } + pc_alloc_uninit(s->alloc); + + qvirtio_pci_device_free(s->dev); } =20 static void wait_for_fds(TestServer *s) @@ -635,6 +656,8 @@ static void test_read_guest_mem(void) =20 read_guest_mem(server); =20 + uninit_virtio_dev(server); + qtest_quit(s); test_server_free(server); } @@ -711,6 +734,8 @@ static void test_migrate(void) =20 read_guest_mem(dest); =20 + uninit_virtio_dev(s); + g_source_destroy(source); g_source_unref(source); =20 @@ -789,6 +814,8 @@ static void test_reconnect_subprocess(void) wait_for_fds(s); wait_for_rings_started(s, 2); =20 + uninit_virtio_dev(s); + qtest_end(); test_server_free(s); return; @@ -818,6 +845,8 @@ static void test_connect_fail_subprocess(void) wait_for_fds(s); wait_for_rings_started(s, 2); =20 + uninit_virtio_dev(s); + qtest_end(); test_server_free(s); } @@ -846,6 +875,8 @@ static void test_flags_mismatch_subprocess(void) wait_for_fds(s); wait_for_rings_started(s, 2); =20 + uninit_virtio_dev(s); + qtest_end(); test_server_free(s); } --=20 2.14.3 From nobody Tue Apr 30 07:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513876299565514.7708311196685; Thu, 21 Dec 2017 09:11:39 -0800 (PST) Received: from localhost ([::1]:59913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4NO-00067E-9A for importer@patchew.org; Thu, 21 Dec 2017 12:11:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4Jt-0003JF-B8 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS4Js-0001AV-Dj for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS4Js-0001A5-7H for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:44 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E7F8624BE for ; Thu, 21 Dec 2017 17:07:43 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05BE53819B; Thu, 21 Dec 2017 17:07:39 +0000 (UTC) From: Maxime Coquelin To: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com Date: Thu, 21 Dec 2017 18:07:14 +0100 Message-Id: <20171221170716.10709-4-maxime.coquelin@redhat.com> In-Reply-To: <20171221170716.10709-1-maxime.coquelin@redhat.com> References: <20171221170716.10709-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 21 Dec 2017 17:07:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/5] vhost-user-test: make features mask an init_virtio_dev() argument X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Coquelin , mlureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The goal is to generalize the use of [un]init_virtio_dev() to all tests, which does not necessarily expose the same features set. Signed-off-by: Maxime Coquelin --- tests/vhost-user-test.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index be463fe7f2..be7a401789 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -164,7 +164,7 @@ typedef struct TestServer { static const char *tmpfs; static const char *root; =20 -static void init_virtio_dev(TestServer *s) +static void init_virtio_dev(TestServer *s, uint32_t features_mask) { uint32_t features; int i; @@ -187,7 +187,7 @@ static void init_virtio_dev(TestServer *s) } =20 features =3D qvirtio_get_features(&s->dev->vdev); - features =3D features & VIRTIO_NET_F_MAC; + features =3D features & features_mask; qvirtio_set_features(&s->dev->vdev, features); =20 qvirtio_set_driver_ok(&s->dev->vdev); @@ -652,7 +652,7 @@ static void test_read_guest_mem(void) s =3D qtest_start(qemu_cmd); g_free(qemu_cmd); =20 - init_virtio_dev(server); + init_virtio_dev(server, VIRTIO_NET_F_MAC); =20 read_guest_mem(server); =20 @@ -681,7 +681,7 @@ static void test_migrate(void) from =3D qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s); + init_virtio_dev(s, VIRTIO_NET_F_MAC); wait_for_fds(s); size =3D get_log_size(s); g_assert_cmpint(size, =3D=3D, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)= ); @@ -803,7 +803,7 @@ static void test_reconnect_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s); + init_virtio_dev(s, VIRTIO_NET_F_MAC); wait_for_fds(s); wait_for_rings_started(s, 2); =20 @@ -841,7 +841,7 @@ static void test_connect_fail_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s); + init_virtio_dev(s, VIRTIO_NET_F_MAC); wait_for_fds(s); wait_for_rings_started(s, 2); =20 @@ -871,7 +871,7 @@ static void test_flags_mismatch_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s); + init_virtio_dev(s, VIRTIO_NET_F_MAC); wait_for_fds(s); wait_for_rings_started(s, 2); =20 --=20 2.14.3 From nobody Tue Apr 30 07:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513876182504477.00131109828646; Thu, 21 Dec 2017 09:09:42 -0800 (PST) Received: from localhost ([::1]:59848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4Ld-0004Uy-Eb for importer@patchew.org; Thu, 21 Dec 2017 12:09:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4Jv-0003Kn-Dj for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS4Ju-0001Bx-HC for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS4Ju-0001BE-B6 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96BA2C058ED7 for ; Thu, 21 Dec 2017 17:07:45 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id D76045C6D4; Thu, 21 Dec 2017 17:07:43 +0000 (UTC) From: Maxime Coquelin To: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com Date: Thu, 21 Dec 2017 18:07:15 +0100 Message-Id: <20171221170716.10709-5-maxime.coquelin@redhat.com> In-Reply-To: <20171221170716.10709-1-maxime.coquelin@redhat.com> References: <20171221170716.10709-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 21 Dec 2017 17:07:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/5] vhost-user-test: fix features mask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Coquelin , mlureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" VIRTIO_NET_F_MAC is a bit position, not a bit mask. Signed-off-by: Maxime Coquelin --- tests/vhost-user-test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index be7a401789..6a144e8d7e 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -652,7 +652,7 @@ static void test_read_guest_mem(void) s =3D qtest_start(qemu_cmd); g_free(qemu_cmd); =20 - init_virtio_dev(server, VIRTIO_NET_F_MAC); + init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC); =20 read_guest_mem(server); =20 @@ -681,7 +681,7 @@ static void test_migrate(void) from =3D qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, VIRTIO_NET_F_MAC); + init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); wait_for_fds(s); size =3D get_log_size(s); g_assert_cmpint(size, =3D=3D, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)= ); @@ -803,7 +803,7 @@ static void test_reconnect_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, VIRTIO_NET_F_MAC); + init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); wait_for_fds(s); wait_for_rings_started(s, 2); =20 @@ -841,7 +841,7 @@ static void test_connect_fail_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, VIRTIO_NET_F_MAC); + init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); wait_for_fds(s); wait_for_rings_started(s, 2); =20 @@ -871,7 +871,7 @@ static void test_flags_mismatch_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, VIRTIO_NET_F_MAC); + init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); wait_for_fds(s); wait_for_rings_started(s, 2); =20 --=20 2.14.3 From nobody Tue Apr 30 07:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513876377990718.1129978561978; Thu, 21 Dec 2017 09:12:57 -0800 (PST) Received: from localhost ([::1]:59993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4Oo-0007Nt-VZ for importer@patchew.org; Thu, 21 Dec 2017 12:12:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4K4-0003TJ-Vj for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS4K4-0001Ji-15 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS4K3-0001In-PB for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:07:55 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03CDFC0587F6 for ; Thu, 21 Dec 2017 17:07:55 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC3E419F1E; Thu, 21 Dec 2017 17:07:45 +0000 (UTC) From: Maxime Coquelin To: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com Date: Thu, 21 Dec 2017 18:07:16 +0100 Message-Id: <20171221170716.10709-6-maxime.coquelin@redhat.com> In-Reply-To: <20171221170716.10709-1-maxime.coquelin@redhat.com> References: <20171221170716.10709-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 21 Dec 2017 17:07:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/5] vhost-user-test: use init_virtio_dev in multiqueue test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Coquelin , mlureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that init_virtio_dev() has been generalized to all cases, use it in test_multiqueue() to avoid code duplication. Signed-off-by: Maxime Coquelin --- tests/vhost-user-test.c | 65 ++++++---------------------------------------= ---- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 6a144e8d7e..ec6ac9dc9e 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -892,79 +892,30 @@ static void test_flags_mismatch(void) =20 #endif =20 -static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot) -{ - QVirtioPCIDevice *dev; - - dev =3D qvirtio_pci_device_find(bus, VIRTIO_ID_NET); - g_assert(dev !=3D NULL); - g_assert_cmphex(dev->vdev.device_type, =3D=3D, VIRTIO_ID_NET); - - qvirtio_pci_device_enable(dev); - qvirtio_reset(&dev->vdev); - qvirtio_set_acknowledge(&dev->vdev); - qvirtio_set_driver(&dev->vdev); - - return dev; -} - -static void driver_init(QVirtioDevice *dev) -{ - uint32_t features; - - features =3D qvirtio_get_features(dev); - features =3D features & ~(QVIRTIO_F_BAD_FEATURE | - (1u << VIRTIO_RING_F_INDIRECT_DESC) | - (1u << VIRTIO_RING_F_EVENT_IDX)); - qvirtio_set_features(dev, features); - - qvirtio_set_driver_ok(dev); -} - -#define PCI_SLOT 0x04 - static void test_multiqueue(void) { - const int queues =3D 2; TestServer *s =3D test_server_new("mq"); - QVirtioPCIDevice *dev; - QPCIBus *bus; - QVirtQueuePCI *vq[queues * 2]; - QGuestAllocator *alloc; char *cmd; - int i; - - s->queues =3D queues; + uint32_t features_mask =3D ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_RING_F_EVENT_IDX)); + s->queues =3D 2; test_server_listen(s); =20 cmd =3D g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",qu= eues=3D%d " "-device virtio-net-pci,netdev=3Dnet0,mq=3Don,ve= ctors=3D%d", 512, 512, root, s->chr_name, s->socket_path, "", s->chr_name, - queues, queues * 2 + 2); + s->queues, s->queues * 2 + 2); qtest_start(cmd); g_free(cmd); =20 - bus =3D qpci_init_pc(NULL); - dev =3D virtio_net_pci_init(bus, PCI_SLOT); + init_virtio_dev(s, features_mask); =20 - alloc =3D pc_alloc_init(); - for (i =3D 0; i < queues * 2; i++) { - vq[i] =3D (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, i); - } + wait_for_rings_started(s, s->queues * 2); =20 - driver_init(&dev->vdev); - wait_for_rings_started(s, queues * 2); + uninit_virtio_dev(s); =20 - /* End test */ - for (i =3D 0; i < queues * 2; i++) { - qvirtqueue_cleanup(dev->vdev.bus, &vq[i]->vq, alloc); - } - pc_alloc_uninit(alloc); - qvirtio_pci_device_disable(dev); - g_free(dev->pdev); - g_free(dev); - qpci_free_pc(bus); qtest_end(); =20 test_server_free(s); --=20 2.14.3