All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: "Yuanhan Liu" <yuanhan.liu@linux.intel.com>,
	"Victor Kaplansky" <victork@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	jonshin@cisco.com, "Tetsuya Mukawa" <mukawa@igel.co.jp>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 29/33] tests: add a simple /vhost-user/multiqueue test
Date: Wed, 27 Jul 2016 12:26:54 +0400	[thread overview]
Message-ID: <CAJ+F1CLZcQPDj2Lz3kKoAWBtcnxOuPNJczVPZDtDZH4_eiCidQ@mail.gmail.com> (raw)
In-Reply-To: <20160726211527.28510-30-marcandre.lureau@redhat.com>

Hi

I just realized that the travis build failed, because of
wait_for_rings_started is under CONFIG_HAS_GLIB_SUBPROCESS_TESTS, the
fix in this patch is:

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 8e2b63c..82dfd0d 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -669,7 +669,6 @@ static void test_migrate(void)
     global_qtest = global;
 }

-#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
 static void wait_for_rings_started(TestServer *s, size_t count)
 {
     gint64 end_time;
@@ -687,6 +686,7 @@ static void wait_for_rings_started(TestServer *s,
size_t count)
     g_mutex_unlock(&s->data_mutex);
 }

+#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
 static gboolean
 reconnect_cb(gpointer user_data)
 {

On Wed, Jul 27, 2016 at 1:15 AM,  <marcandre.lureau@redhat.com> wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> This test just checks that 2 virtio-net queues can be setup over
> vhost-user and waits for them to be started.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  tests/Makefile.include  |   2 +-
>  tests/vhost-user-test.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 107 insertions(+), 3 deletions(-)
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 9286148..a6ee20a 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -617,7 +617,7 @@ tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y)
>  tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
>  tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o
>  tests/postcopy-test$(EXESUF): tests/postcopy-test.o
> -tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) $(test-io-obj-y)
> +tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) $(test-io-obj-y) $(libqos-pc-obj-y) $(libqos-virtio-obj-y)
>  tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
>  tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y)
>  tests/test-write-threshold$(EXESUF): tests/test-write-threshold.o $(test-block-obj-y)
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index 2db8f3d..9c1438d 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -17,6 +17,11 @@
>  #include "sysemu/char.h"
>  #include "sysemu/sysemu.h"
>
> +#include "libqos/pci-pc.h"
> +#include "libqos/virtio-pci.h"
> +#include "libqos/malloc-pc.h"
> +#include "hw/virtio/virtio-net.h"
> +
>  #include <linux/vhost.h>
>  #include <sys/vfs.h>
>
> @@ -46,6 +51,7 @@
>  #define VHOST_MEMORY_MAX_NREGIONS    8
>
>  #define VHOST_USER_F_PROTOCOL_FEATURES 30
> +#define VHOST_USER_PROTOCOL_F_MQ 0
>  #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
>
>  #define VHOST_LOG_PAGE 0x1000
> @@ -68,6 +74,7 @@ typedef enum VhostUserRequest {
>      VHOST_USER_SET_VRING_ERR = 14,
>      VHOST_USER_GET_PROTOCOL_FEATURES = 15,
>      VHOST_USER_SET_PROTOCOL_FEATURES = 16,
> +    VHOST_USER_GET_QUEUE_NUM = 17,
>      VHOST_USER_SET_VRING_ENABLE = 18,
>      VHOST_USER_MAX
>  } VhostUserRequest;
> @@ -132,6 +139,7 @@ typedef struct TestServer {
>      int log_fd;
>      uint64_t rings;
>      bool test_fail;
> +    int queues;
>  } TestServer;
>
>  static const char *tmpfs;
> @@ -253,6 +261,9 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
>          msg.size = sizeof(m.payload.u64);
>          msg.payload.u64 = 0x1ULL << VHOST_F_LOG_ALL |
>              0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
> +        if (s->queues > 1) {
> +            msg.payload.u64 |= 0x1ULL << VIRTIO_NET_F_MQ;
> +        }
>          p = (uint8_t *) &msg;
>          qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
>          break;
> @@ -267,6 +278,9 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
>          msg.flags |= VHOST_USER_REPLY_MASK;
>          msg.size = sizeof(m.payload.u64);
>          msg.payload.u64 = 1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD;
> +        if (s->queues > 1) {
> +            msg.payload.u64 |= 1 << VHOST_USER_PROTOCOL_F_MQ;
> +        }
>          p = (uint8_t *) &msg;
>          qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
>          break;
> @@ -279,7 +293,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
>          p = (uint8_t *) &msg;
>          qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
>
> -        assert(msg.payload.state.index < 2);
> +        assert(msg.payload.state.index < s->queues * 2);
>          s->rings &= ~(0x1ULL << msg.payload.state.index);
>          break;
>
> @@ -319,10 +333,18 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
>          break;
>
>      case VHOST_USER_SET_VRING_BASE:
> -        assert(msg.payload.state.index < 2);
> +        assert(msg.payload.state.index < s->queues * 2);
>          s->rings |= 0x1ULL << msg.payload.state.index;
>          break;
>
> +    case VHOST_USER_GET_QUEUE_NUM:
> +        msg.flags |= VHOST_USER_REPLY_MASK;
> +        msg.size = sizeof(m.payload.u64);
> +        msg.payload.u64 = s->queues;
> +        p = (uint8_t *) &msg;
> +        qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE + msg.size);
> +        break;
> +
>      default:
>          break;
>      }
> @@ -369,6 +391,7 @@ static TestServer *test_server_new(const gchar *name)
>      g_cond_init(&server->data_cond);
>
>      server->log_fd = -1;
> +    server->queues = 1;
>
>      return server;
>  }
> @@ -722,6 +745,86 @@ static void test_connect_fail(void)
>
>  #endif
>
> +static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot)
> +{
> +    QVirtioPCIDevice *dev;
> +
> +    dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET);
> +    g_assert(dev != NULL);
> +    g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_NET);
> +
> +    qvirtio_pci_device_enable(dev);
> +    qvirtio_reset(&qvirtio_pci, &dev->vdev);
> +    qvirtio_set_acknowledge(&qvirtio_pci, &dev->vdev);
> +    qvirtio_set_driver(&qvirtio_pci, &dev->vdev);
> +
> +    return dev;
> +}
> +
> +static void driver_init(const QVirtioBus *bus, QVirtioDevice *dev)
> +{
> +    uint32_t features;
> +
> +    features = qvirtio_get_features(bus, dev);
> +    features = features & ~(QVIRTIO_F_BAD_FEATURE |
> +                            (1u << VIRTIO_RING_F_INDIRECT_DESC) |
> +                            (1u << VIRTIO_RING_F_EVENT_IDX));
> +    qvirtio_set_features(bus, dev, features);
> +
> +    qvirtio_set_driver_ok(bus, dev);
> +}
> +
> +#define PCI_SLOT                0x04
> +
> +static void test_multiqueue(void)
> +{
> +    const int queues = 2;
> +    TestServer *s = test_server_new("mq");
> +    QVirtioPCIDevice *dev;
> +    QPCIBus *bus;
> +    QVirtQueuePCI *vq[queues * 2];
> +    QGuestAllocator *alloc;
> +    char *cmd;
> +    int i;
> +
> +    s->queues = queues;
> +    test_server_listen(s);
> +
> +    cmd = g_strdup_printf(QEMU_CMD_ACCEL QEMU_CMD_MEM QEMU_CMD_CHR
> +                          QEMU_CMD_NETDEV ",queues=%d "
> +                          "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d",
> +                          512, 512, root, s->chr_name,
> +                          s->socket_path, "", s->chr_name,
> +                          queues, queues * 2 + 2);
> +    qtest_start(cmd);
> +    g_free(cmd);
> +
> +    bus = qpci_init_pc();
> +    dev = virtio_net_pci_init(bus, PCI_SLOT);
> +
> +    alloc = pc_alloc_init();
> +    for (i = 0; i < queues * 2; i++) {
> +        vq[i] = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev,
> +                                              alloc, i);
> +    }
> +
> +    driver_init(&qvirtio_pci, &dev->vdev);
> +    wait_for_rings_started(s, queues * 2);
> +
> +    /* End test */
> +    for (i = 0; i < queues * 2; i++) {
> +        qvirtqueue_cleanup(&qvirtio_pci, &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();
> +
> +    test_server_free(s);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      QTestState *s = NULL;
> @@ -766,6 +869,7 @@ int main(int argc, char **argv)
>
>      qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_mem);
>      qtest_add_func("/vhost-user/migrate", test_migrate);
> +    qtest_add_func("/vhost-user/multiqueue", test_multiqueue);
>  #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
>      qtest_add_func("/vhost-user/reconnect/subprocess",
>                     test_reconnect_subprocess);
> --
> 2.9.0
>
>



-- 
Marc-André Lureau

  reply	other threads:[~2016-07-27  8:26 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 21:14 [Qemu-devel] [PATCH v6 00/33] vhost-user reconnect fixes marcandre.lureau
2016-07-26 21:14 ` [Qemu-devel] [PATCH v6 01/33] misc: indentation marcandre.lureau
2016-07-26 21:14 ` [Qemu-devel] [PATCH v6 02/33] vhost-user: minor simplification marcandre.lureau
2016-07-26 21:14 ` [Qemu-devel] [PATCH v6 03/33] vhost-user: disconnect on HUP marcandre.lureau
2016-07-26 21:14 ` [Qemu-devel] [PATCH v6 04/33] vhost: don't assume opaque is a fd, use backend cleanup marcandre.lureau
2016-07-26 21:14 ` [Qemu-devel] [PATCH v6 05/33] vhost: make vhost_log_put() idempotent marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 06/33] vhost: assert the log was cleaned up marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 07/33] vhost: fix cleanup on not fully initialized device marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 08/33] vhost: make vhost_dev_cleanup() idempotent marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 09/33] vhost-net: always call vhost_dev_cleanup() on failure marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 10/33] vhost: fix calling vhost_dev_cleanup() after vhost_dev_init() marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 11/33] vhost: do not assert() on vhost_ops failure marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 12/33] vhost: add missing VHOST_OPS_DEBUG marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 13/33] vhost: use error_report() instead of fprintf(stderr, ...) marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 14/33] qemu-char: fix qemu_chr_fe_set_msgfds() crash when disconnected marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 15/33] vhost-user: call set_msgfds unconditionally marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 16/33] vhost-user: check qemu_chr_fe_set_msgfds() return value marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 17/33] vhost-user: check vhost_user_{read, write}() " marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 18/33] vhost-user: keep vhost_net after a disconnection marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 19/33] vhost-user: add get_vhost_net() assertions marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 20/33] Revert "vhost-net: do not crash if backend is not present" marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 21/33] vhost-net: vhost_migration_done is vhost-user specific marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 22/33] vhost: add assert() to check runtime behaviour marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 23/33] char: add chr_wait_connected callback marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 24/33] char: add and use tcp_chr_wait_connected marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 25/33] vhost-user: wait until backend init is completed marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 26/33] tests: plug some leaks in virtio-net-test marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 27/33] tests: fix vhost-user-test leak marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 28/33] tests: add /vhost-user/connect-fail test marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 29/33] tests: add a simple /vhost-user/multiqueue test marcandre.lureau
2016-07-27  8:26   ` Marc-André Lureau [this message]
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 30/33] vhost-user: add error report in vhost_user_write() marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 31/33] vhost: add vhost_net_set_backend() marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 32/33] vhost-user-test: add flags mismatch test marcandre.lureau
2016-07-26 21:15 ` [Qemu-devel] [PATCH v6 33/33] RFC: vhost: do not update last avail idx on get_vring_base() failure marcandre.lureau
2016-07-29  3:17 ` [Qemu-devel] [PATCH v6 00/33] vhost-user reconnect fixes Michael S. Tsirkin

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=CAJ+F1CLZcQPDj2Lz3kKoAWBtcnxOuPNJczVPZDtDZH4_eiCidQ@mail.gmail.com \
    --to=marcandre.lureau@gmail.com \
    --cc=jonshin@cisco.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=mukawa@igel.co.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=victork@redhat.com \
    --cc=yuanhan.liu@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.