qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: "Bonzini, Paolo" <pbonzini@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	Laurent Vivier <lvivier@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 07/10] vhost-user-test: reduce usage of global_qtest
Date: Tue, 20 Nov 2018 12:50:15 +0400	[thread overview]
Message-ID: <CAMxuvay8PM8si-F2Lp+TOgJ4pH17eicGRmOXpwijAG0Jkdy9Pg@mail.gmail.com> (raw)
In-Reply-To: <20181115143124.19234-8-pbonzini@redhat.com>

On Thu, Nov 15, 2018 at 6:31 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Whenever the code can run on multiple QTestStates, use them explicitly instead of
> global_qtest.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  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,
>      }
>  }
>
> -static void init_virtio_dev(TestServer *s, uint32_t features_mask)
> +static void init_virtio_dev(QTestState *qts, TestServer *s, uint32_t features_mask)
>  {
>      uint32_t features;
>      int i;
>
> -    s->bus = qpci_init_pc(global_qtest, NULL);
> +    s->bus = qpci_init_pc(qts, NULL);
>      g_assert_nonnull(s->bus);
>
>      s->dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
> @@ -203,7 +203,7 @@ static void init_virtio_dev(TestServer *s, uint32_t features_mask)
>      qvirtio_set_acknowledge(&s->dev->vdev);
>      qvirtio_set_driver(&s->dev->vdev);
>
> -    s->alloc = pc_alloc_init(global_qtest);
> +    s->alloc = pc_alloc_init(qts);
>
>      for (i = 0; i < s->queues * 2; i++) {
>          s->vq[i] = qvirtqueue_setup(&s->dev->vdev, s->alloc, i);
> @@ -265,7 +265,7 @@ static bool wait_for_fds(TestServer *s)
>      return got_region;
>  }
>
> -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 += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem));
>
>          for (j = 0; j < 1024; j++) {
> -            uint32_t a = readb(s->memory.regions[i].guest_phys_addr + j);
> +            uint32_t a = qtest_readb(qts, s->memory.regions[i].guest_phys_addr + j);
>              uint32_t b = guest_mem[j];
>
>              g_assert_cmpint(a, ==, b);
> @@ -670,13 +670,13 @@ static void test_read_guest_mem(const void *arg)
>      s = qtest_start(qemu_cmd);
>      g_free(qemu_cmd);
>
> -    init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC);
> +    init_virtio_dev(global_qtest, server, 1u << VIRTIO_NET_F_MAC);
>
>      if (!wait_for_fds(server)) {
>          goto exit;
>      }
>
> -    read_guest_mem_server(server);
> +    read_guest_mem_server(global_qtest, server);
>
>  exit:
>      uninit_virtio_dev(server);
> @@ -690,7 +690,7 @@ static void test_migrate(void)
>      TestServer *s = test_server_new("src");
>      TestServer *dest = test_server_new("dest");
>      char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path);
> -    QTestState *global = global_qtest, *from, *to;
> +    QTestState *from, *to;
>      GSource *source;
>      gchar *cmd, *tmp;
>      QDict *rsp;
> @@ -704,7 +704,7 @@ static void test_migrate(void)
>      from = qtest_start(cmd);
>      g_free(cmd);
>
> -    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 = 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);
>
>      source = g_source_new(&test_migrate_source_funcs,
>                            sizeof(TestMigrateSource));
> @@ -753,12 +753,10 @@ static void test_migrate(void)
>      qobject_unref(rsp);
>
>      qmp_eventwait("STOP");
> +    qtest_qmp_eventwait(to, "RESUME");
>
> -    global_qtest = 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);
>
>      uninit_virtio_dev(dest);
>      qtest_quit(to);
> @@ -773,8 +771,6 @@ exit:
>      qtest_quit(from);
>      test_server_free(s);
>      g_free(uri);
> -
> -    global_qtest = global;
>  }
>
>  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);
>
> -    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);
>
> -    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);
>
> -    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);
>
> -    init_virtio_dev(s, features_mask);
> +    init_virtio_dev(global_qtest, s, features_mask);
>
>      wait_for_rings_started(s, s->queues * 2);
>
> --
> 2.19.1
>
>

  reply	other threads:[~2018-11-20  8:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-15 14:31 [Qemu-devel] [PATCH for-3.2 00/10] vhost: preparation for qgraph conversion of vhost-user-test Paolo Bonzini
2018-11-15 14:31 ` [Qemu-devel] [PATCH 01/10] vhost-user-test: use g_cond_broadcast Paolo Bonzini
2018-11-20  8:50   ` Marc-André Lureau
2018-11-15 14:31 ` [Qemu-devel] [PATCH 02/10] vhost-user-test: signal data_cond when s->rings changes Paolo Bonzini
2018-11-20  8:50   ` Marc-André Lureau
2018-11-15 14:31 ` [Qemu-devel] [PATCH 03/10] vhost-net: compile it for all targets Paolo Bonzini
2018-11-15 18:42   ` Paolo Bonzini
2018-11-20  8:50     ` Marc-André Lureau
2019-01-15  3:50     ` Michael S. Tsirkin
2019-01-15  7:18       ` Paolo Bonzini
2018-11-15 14:31 ` [Qemu-devel] [PATCH 04/10] vhost-user: support cross-endian vnet headers Paolo Bonzini
2018-11-20  8:50   ` Marc-André Lureau
2018-11-15 14:31 ` [Qemu-devel] [PATCH 05/10] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN Paolo Bonzini
2018-11-20  8:50   ` Marc-André Lureau
2018-11-15 14:31 ` [Qemu-devel] [PATCH 06/10] vhost-user-test: skip if there is no memory at address 0 Paolo Bonzini
2018-11-15 14:31 ` [Qemu-devel] [PATCH 07/10] vhost-user-test: reduce usage of global_qtest Paolo Bonzini
2018-11-20  8:50   ` Marc-André Lureau [this message]
2018-11-15 14:31 ` [Qemu-devel] [PATCH 08/10] vhost-user-test: create a main loop per TestServer Paolo Bonzini
2018-11-20  8:50   ` Marc-André Lureau
2018-11-15 14:31 ` [Qemu-devel] [PATCH 09/10] vhost-user-test: small changes to init_hugepagefs Paolo Bonzini
2018-11-15 14:55   ` Philippe Mathieu-Daudé
2018-11-15 18:41     ` Paolo Bonzini
2018-11-15 18:45       ` Philippe Mathieu-Daudé
2018-11-15 18:46         ` Paolo Bonzini
2018-11-15 14:31 ` [Qemu-devel] [PATCH 10/10] vhost-user-test: create a temporary directory per TestServer Paolo Bonzini
2018-11-20  8:50   ` Marc-André Lureau
2018-11-16  0:43 ` [Qemu-devel] [PATCH for-3.2 00/10] vhost: preparation for qgraph conversion of vhost-user-test no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMxuvay8PM8si-F2Lp+TOgJ4pH17eicGRmOXpwijAG0Jkdy9Pg@mail.gmail.com \
    --to=marcandre.lureau@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).