From patchwork Mon Dec 3 09:35:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1006735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 437g6X0d4rz9s47 for ; Mon, 3 Dec 2018 20:43:32 +1100 (AEDT) Received: from localhost ([::1]:47576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTklF-0003sT-GD for incoming@patchwork.ozlabs.org; Mon, 03 Dec 2018 04:43:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTkj4-0002bg-ED for qemu-devel@nongnu.org; Mon, 03 Dec 2018 04:41:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTkeC-0007t0-OF for qemu-devel@nongnu.org; Mon, 03 Dec 2018 04:36:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33698) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gTkeC-0007so-JG for qemu-devel@nongnu.org; Mon, 03 Dec 2018 04:36:12 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E21763082A33; Mon, 3 Dec 2018 09:36:11 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-193.pek2.redhat.com [10.72.12.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27C966061E; Mon, 3 Dec 2018 09:36:04 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Mon, 3 Dec 2018 17:35:42 +0800 Message-Id: <20181203093544.6184-3-jasowang@redhat.com> In-Reply-To: <20181203093544.6184-1-jasowang@redhat.com> References: <20181203093544.6184-1-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 03 Dec 2018 09:36:12 +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 V3 for 3.1 2/4] virtio-net-test: accept command line string instead of socket 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: thuth@redhat.com, mst@redhat.com, liq3ea@163.com, Jason Wang , liq3ea@gmail.com, ppandit@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This will allow passing different kinds of command line string. Signed-off-by: Jason Wang --- tests/virtio-net-test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index dcb87a8b6e..233b9ab5f7 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -52,17 +52,15 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot) return dev; } -static QOSState *pci_test_start(int socket) +static QOSState *pci_test_start(const char *cmd) { QOSState *qs; const char *arch = qtest_get_arch(); - const char *cmd = "-netdev socket,fd=%d,id=hs0 -device " - "virtio-net-pci,netdev=hs0"; if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { - qs = qtest_pc_boot(cmd, socket); + qs = qtest_pc_boot(cmd); } else if (strcmp(arch, "ppc64") == 0) { - qs = qtest_spapr_boot(cmd, socket); + qs = qtest_spapr_boot(cmd); } else { g_printerr("virtio-net tests are only available on x86 or ppc64\n"); exit(EXIT_FAILURE); @@ -219,11 +217,15 @@ static void pci_basic(gconstpointer data) QVirtQueue *tvq, int socket) = data; int sv[2], ret; + char cmd[256]; ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv); g_assert_cmpint(ret, !=, -1); - qs = pci_test_start(sv[1]); + sprintf(cmd, "-netdev socket,fd=%d,id=hs0 " + "-device virtio-net-pci,netdev=hs0", sv[1]); + + qs = pci_test_start(cmd); dev = virtio_net_pci_init(qs->pcibus, PCI_SLOT); rx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, qs->alloc, 0);