From patchwork Wed Jul 27 08:26:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9249447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5549E6077C for ; Wed, 27 Jul 2016 08:27:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 446412624C for ; Wed, 27 Jul 2016 08:27:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38AE227572; Wed, 27 Jul 2016 08:27:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D22192624C for ; Wed, 27 Jul 2016 08:27:22 +0000 (UTC) Received: from localhost ([::1]:44948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSKBV-0006HZ-JM for patchwork-qemu-devel@patchwork.kernel.org; Wed, 27 Jul 2016 04:27:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSKB8-0006HE-7h for qemu-devel@nongnu.org; Wed, 27 Jul 2016 04:26:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSKB6-0003N8-Hw for qemu-devel@nongnu.org; Wed, 27 Jul 2016 04:26:57 -0400 Received: from mail-vk0-x244.google.com ([2607:f8b0:400c:c05::244]:33214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSKB6-0003Mm-BG for qemu-devel@nongnu.org; Wed, 27 Jul 2016 04:26:56 -0400 Received: by mail-vk0-x244.google.com with SMTP id s189so219585vkh.0 for ; Wed, 27 Jul 2016 01:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=v9oheqMxFl5idtkaibFcCO1N/S+QF/vp4MzieTdTyRM=; b=Rrrr/aJrUQQDFEZfZ3CD8vSj/5NkR5QMiJybDyyiC6J69GSUPgqwyz0htil5bdu7bS uIkXNPzhqeL+Mc7yBhjdMnf3+K9AIDOKZmhz2bJWsJdtS0TxIGdnzoRGQTUdz3mgu/Y5 VwHLyOdmYvXoaOT3t3AndiA/ni2j2i3w5i0orGKmNF6BuDzbruUiOm2xX9Y1u93AGNaH czUk8eOxC9+RYRRekBT5nGKhWBWUBMKV1ZIo+4WnR0Q2HzFlH4+Bf6+7uLeiqSWnvVIS Y4On15HzGaBoprc3D8i3TIFdAJSxE0oBuy1l1TVJS9LBO99QdC2XcDOnY3xdbbkYUnMb Htig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=v9oheqMxFl5idtkaibFcCO1N/S+QF/vp4MzieTdTyRM=; b=mmhO8FMT6Mp51MIQFjtJP11kb6M9i5RN0ZY8S7+g6OMCwudV99TP9QeRduSgGCQpCs H7QYRRWY/9PX3srwRUiKY7XpoZfMrU8CeLx9ZmDIb0buaB5JN+n1hm13L8ujz1Y+EGxv rLP1mf52tOSEBX88JPfQUT9A41qglvZTZc0GDbn5aiwgfmxSkBZlN/yL4tzfg2koEOfz Gr9gGgRTLtuRND/WsbhyOW2AK3QmDulZxqeholIuAHAozqbIlylPlN3dPAk/JF8nZea1 IlDpDiZt9dJokO/9qhj8n54mJ3QDm119SB8ZY1ukjYob7ENZym0J+KOtAMUDQXRYOJb0 LLyw== X-Gm-Message-State: AEkoouu/hMPKtOkafvQTKCQePki5QXO4il/2zbthkl+hf5AFF6Wsz8pmUW0EyrR4kHhhn62rjeYJD1iE+8YG7g== X-Received: by 10.31.152.85 with SMTP id a82mr11658081vke.47.1469608015583; Wed, 27 Jul 2016 01:26:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.64.201 with HTTP; Wed, 27 Jul 2016 01:26:54 -0700 (PDT) In-Reply-To: <20160726211527.28510-30-marcandre.lureau@redhat.com> References: <20160726211527.28510-1-marcandre.lureau@redhat.com> <20160726211527.28510-30-marcandre.lureau@redhat.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Wed, 27 Jul 2016 12:26:54 +0400 Message-ID: To: QEMU X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c05::244 Subject: Re: [Qemu-devel] [PATCH v6 29/33] tests: add a simple /vhost-user/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: Yuanhan Liu , Victor Kaplansky , "Michael S. Tsirkin" , jonshin@cisco.com, Tetsuya Mukawa , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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: { On Wed, Jul 27, 2016 at 1:15 AM, wrote: > From: Marc-André Lureau > > 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 > --- > 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 > #include > > @@ -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 > > 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)