From nobody Thu Nov 6 18:20:04 2025 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542293018291569.4600599329476; Thu, 15 Nov 2018 06:43:38 -0800 (PST) Received: from localhost ([::1]:39252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNIro-0003DL-8O for importer@patchew.org; Thu, 15 Nov 2018 09:43:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNIga-0002UV-Ng for qemu-devel@nongnu.org; Thu, 15 Nov 2018 09:32:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNIgZ-00048F-3n for qemu-devel@nongnu.org; Thu, 15 Nov 2018 09:32:00 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55141) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNIgY-0003w6-OA for qemu-devel@nongnu.org; Thu, 15 Nov 2018 09:31:58 -0500 Received: by mail-wm1-x343.google.com with SMTP id r63-v6so19120773wma.4 for ; Thu, 15 Nov 2018 06:31:35 -0800 (PST) Received: from localhost.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id x194-v6sm55262620wmd.41.2018.11.15.06.31.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 06:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ppXImhltsxcdhzpFhgx+Canp1HXjcIszeLgMMZbyMc0=; b=NSrCY3komSOZmnPbyI58mDHNAYXiIBfPrKJLY3RyKMu3yhHyzC1Rz/K01I5lDPW1/l 5cwY83MEoGeS+wvorWbp1oEHtUDXT3pjNnJgYJjHVrDtrIaBoNPWZxEc+rfo5Osa/lBe 423tQnjQe8HjB1TGLNMqzZihoyQnjX9Hnvi6u9CCSZ5GaIZLcxgB1aXQmyObmI+NWDJZ UUKXGoaEX9he80U6aWz9+nGYDXupJ7YCEizu0jwsGm/4+CdlKjA9RGo98wvMXusp5PC7 31ydCKJrWB4nhDn7Dgt42Y/sLZt24Viot81yWqiyVQ7IP/WFlGxx+vc39oe5ciL8DCZ9 Ln/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ppXImhltsxcdhzpFhgx+Canp1HXjcIszeLgMMZbyMc0=; b=VdFd/BSRZQSHe8dzKvaFOYSCWBAHUdDk5zwL769qWfQ34hk3nS2a/zjqnET3zVszoA /CU18+EBeTwZ8zENxFHsFRx3F/iKzfvXoMhc1tMydSG/H/UCrNq/N9HPSsHSIegV4tFU 4BJS5gwCJ2MnpMgT7v53O1ip2XQ4QYSSbN1jVNhUG5dr6LXWyxGxmjQqlMLrZKQJpXaV C1PMSY6APIGZQ+bto/tqz84yPHNILqmiW8WD+1/2/JOnK28w3er2s7I84QMFZmoU9Dxi 3Ki8aUPmnhJV4t+JOgtyG4oPdRjyasdFu2jrwSMjhy956UksvpSDJgW6r9a5v8EUrqlK dwSw== X-Gm-Message-State: AGRZ1gKrvSi7mw2TCxcHIkGO4V1b22w3AhfeNjQli7jd49CqdJVSCkG6 KG+e9Y+y6NpMDtC3yFUEuquwdC9+ X-Google-Smtp-Source: AJdET5dshT2s+Sx5QVIgRXw9icwtz0+AQp7i78npAFKEubdtZiX6st1IDvuWqsYJxE9Phe4YlLO9dg== X-Received: by 2002:a7b:c095:: with SMTP id r21mr618123wmh.118.1542292293832; Thu, 15 Nov 2018 06:31:33 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 15:31:21 +0100 Message-Id: <20181115143124.19234-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115143124.19234-1-pbonzini@redhat.com> References: <20181115143124.19234-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH 07/10] vhost-user-test: reduce usage of global_qtest 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: lvivier@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , jasowang@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Whenever the code can run on multiple QTestStates, use them explicitly inst= ead of global_qtest. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/vhost-user-test.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 59e1aec397..c3a8af3d85 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -187,12 +187,12 @@ static char *get_qemu_cmd(TestServer *s, } } =20 -static void init_virtio_dev(TestServer *s, uint32_t features_mask) +static void init_virtio_dev(QTestState *qts, TestServer *s, uint32_t featu= res_mask) { uint32_t features; int i; =20 - s->bus =3D qpci_init_pc(global_qtest, NULL); + s->bus =3D qpci_init_pc(qts, NULL); g_assert_nonnull(s->bus); =20 s->dev =3D qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET); @@ -203,7 +203,7 @@ static void init_virtio_dev(TestServer *s, uint32_t fea= tures_mask) qvirtio_set_acknowledge(&s->dev->vdev); qvirtio_set_driver(&s->dev->vdev); =20 - s->alloc =3D pc_alloc_init(global_qtest); + s->alloc =3D pc_alloc_init(qts); =20 for (i =3D 0; i < s->queues * 2; i++) { s->vq[i] =3D qvirtqueue_setup(&s->dev->vdev, s->alloc, i); @@ -265,7 +265,7 @@ static bool wait_for_fds(TestServer *s) return got_region; } =20 -static void read_guest_mem_server(TestServer *s) +static void read_guest_mem_server(QTestState *qts, TestServer *s) { uint8_t *guest_mem; int i, j; @@ -293,7 +293,7 @@ static void read_guest_mem_server(TestServer *s) guest_mem +=3D (s->memory.regions[i].mmap_offset / sizeof(*guest_m= em)); =20 for (j =3D 0; j < 1024; j++) { - uint32_t a =3D readb(s->memory.regions[i].guest_phys_addr + j); + uint32_t a =3D qtest_readb(qts, s->memory.regions[i].guest_phy= s_addr + j); uint32_t b =3D guest_mem[j]; =20 g_assert_cmpint(a, =3D=3D, b); @@ -670,13 +670,13 @@ static void test_read_guest_mem(const void *arg) s =3D qtest_start(qemu_cmd); g_free(qemu_cmd); =20 - init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, server, 1u << VIRTIO_NET_F_MAC); =20 if (!wait_for_fds(server)) { goto exit; } =20 - read_guest_mem_server(server); + read_guest_mem_server(global_qtest, server); =20 exit: uninit_virtio_dev(server); @@ -690,7 +690,7 @@ static void test_migrate(void) TestServer *s =3D test_server_new("src"); TestServer *dest =3D test_server_new("dest"); char *uri =3D g_strdup_printf("%s%s", "unix:", dest->mig_path); - QTestState *global =3D global_qtest, *from, *to; + QTestState *from, *to; GSource *source; gchar *cmd, *tmp; QDict *rsp; @@ -704,7 +704,7 @@ static void test_migrate(void) from =3D qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(from, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -717,7 +717,7 @@ static void test_migrate(void) g_free(tmp); to =3D qtest_init(cmd); g_free(cmd); - init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(to, dest, 1u << VIRTIO_NET_F_MAC); =20 source =3D g_source_new(&test_migrate_source_funcs, sizeof(TestMigrateSource)); @@ -753,12 +753,10 @@ static void test_migrate(void) qobject_unref(rsp); =20 qmp_eventwait("STOP"); + qtest_qmp_eventwait(to, "RESUME"); =20 - global_qtest =3D to; - qmp_eventwait("RESUME"); - - g_assert(wait_for_fds(s)); - read_guest_mem_server(dest); + g_assert(wait_for_fds(dest)); + read_guest_mem_server(to, dest); =20 uninit_virtio_dev(dest); qtest_quit(to); @@ -773,8 +771,6 @@ exit: qtest_quit(from); test_server_free(s); g_free(uri); - - global_qtest =3D global; } =20 static void wait_for_rings_started(TestServer *s, size_t count) @@ -831,7 +827,7 @@ static void test_reconnect_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -873,7 +869,7 @@ static void test_connect_fail_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -906,7 +902,7 @@ static void test_flags_mismatch_subprocess(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC); if (!wait_for_fds(s)) { goto exit; } @@ -957,7 +953,7 @@ static void test_multiqueue(void) qtest_start(cmd); g_free(cmd); =20 - init_virtio_dev(s, features_mask); + init_virtio_dev(global_qtest, s, features_mask); =20 wait_for_rings_started(s, s->queues * 2); =20 --=20 2.19.1