From patchwork Mon Sep 19 17:25:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felipe Franciosi X-Patchwork-Id: 9340511 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 8DCB3601C2 for ; Mon, 19 Sep 2016 20:59:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F44C298C2 for ; Mon, 19 Sep 2016 20:59:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74192298C6; Mon, 19 Sep 2016 20:59:14 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 C037E298C2 for ; Mon, 19 Sep 2016 20:59:13 +0000 (UTC) Received: from localhost ([::1]:58219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm5ei-0007zY-Vw for patchwork-qemu-devel@patchwork.kernel.org; Mon, 19 Sep 2016 16:59:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm5eI-0007wJ-Je for qemu-devel@nongnu.org; Mon, 19 Sep 2016 16:58:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bm5eE-00088U-7I for qemu-devel@nongnu.org; Mon, 19 Sep 2016 16:58:45 -0400 Received: from mail-cys01nam02on0091.outbound.protection.outlook.com ([104.47.37.91]:52795 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm5eD-00087y-Mg for qemu-devel@nongnu.org; Mon, 19 Sep 2016 16:58:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=x08Et1+9aEJC5xXXiaefCb7u50445i7XvoRckbkxXus=; b=7VR1MGnC1m3AL5cZeRBD4+Idj8WzjFMIbWz+cToRtqdBmGuw4Jt09yiIwdYD/Xsq6omsHka/S1ubzKTCFXN4plXu7LGaDuClV/gj/IZ7SNUZYWtz+cclXigNi4CdZPb1a3A43SgM6+myL1bmRh3+cjFc+xMcRwGD2N14jwpygLY= Received: from BLUPR02MB083.namprd02.prod.outlook.com (10.255.189.21) by BLUPR02MB084.namprd02.prod.outlook.com (10.255.189.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10; Mon, 19 Sep 2016 17:25:48 +0000 Received: from BLUPR02MB083.namprd02.prod.outlook.com ([169.254.2.228]) by BLUPR02MB083.namprd02.prod.outlook.com ([169.254.2.228]) with mapi id 15.01.0619.016; Mon, 19 Sep 2016 17:25:49 +0000 From: Felipe Franciosi To: "Michael S. Tsirkin" Thread-Topic: [Qemu-devel] [PATCH] Avoid additional GET_FEATURES call on vhost-user Thread-Index: AQHR+mvRgLSTkkkHEE+Z4fxtjfY65aBZjtsAgCfCyIA= Date: Mon, 19 Sep 2016 17:25:49 +0000 Message-ID: References: <1471596663-31298-1-git-send-email-felipe@nutanix.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=felipe@nutanix.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [86.26.35.229] x-ms-office365-filtering-correlation-id: 24551e1b-5800-4e2c-0f7a-08d3e0b2000c x-microsoft-exchange-diagnostics: 1; BLUPR02MB084; 6:i2O9F6NhAyYKkbPUwQ1YH5gFR/EwZLNEjNswiKqflaXD02GIDfPdvVog4niFPOHJmn6oR0mZwGXP/b9vNFKeuJvOZ5v1rdPa5LD6iJXp7lyGVVHmuJG+B6lBrlb/I/J56KXN0gQT+8wVtdn7bWTv15xGplmiO2I6rI4wbzMPYvDjZYUmluBRoLcmwcXE6D/uRdF6HHFp+wVYDDVEjEi70C2fQ78bXAoJr2CdH3qiD/gyH57/CdCH0/UwK+EmSFCaGYWGfXZDDQ/gqSQS/u5oXMJPiIcS8HMEXvc+q4LKvCk=; 5:rhRyAQWVwHieTGuap1YBWKjPayETbWwUt+5UJZyiSCvaWuy0nhjuYddD8HMiUfubpL3dc4a6nyQlZyJOYG8jDd7Uir+xb+pjiwC1k+SxC4COC6cdVhf0Y2Owo1gOZ98MFzKmrN09f/IhJSNURCDiRQ==; 24:EgvUSKvLaZcZv2stMRt6h94fR/Onh4hTAb4uRGNXkNL7LKCGBHq2qFqBZhhdSgvTc9MbawN1oKSzigK/ty21jxP7Wx+FZFTLPstWBA25OIQ=; 7:DzuNNy7r42ECENXcXEuzlBvuG2AlVckR+engMemfVmegqjKs8w0M9oxo8RodsPPl5Orcl/g1IWwlhwNFh/q23RmoVLiO88EW8yE20Ncku9PA1jXIDnlpf+1wIVFN7po//OdFKqV5kdmnDgAQzr6MyCzWOJJYepfw1xVhuDtXFE701FucNnD1m6WMaaIdBevEtDVGQQxA2GJM4eDLvgblJjnLDUDyudu+wA+GO3+rI9k6ZlA5Nl5/AmiFaSkw5+afVFsSGGc3fXGVApFKfKC5qZWhClV8anoicdiBPXsypOQouxGY3W4+Bk+Q3fgvrTKM x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB084; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(52384705835673)(21748063052155); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BLUPR02MB084; BCL:0; PCL:0; RULEID:; SRVR:BLUPR02MB084; x-forefront-prvs: 0070A8666B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(7916002)(199003)(377454003)(189002)(24454002)(19580395003)(189998001)(92566002)(106356001)(2900100001)(66066001)(19580405001)(5002640100001)(8936002)(15975445007)(5660300001)(4326007)(76176999)(83716003)(97736004)(87936001)(54356999)(50986999)(82746002)(3660700001)(3280700002)(19625215002)(36756003)(16236675004)(8676002)(33656002)(586003)(6116002)(81156014)(81166006)(3846002)(102836003)(101416001)(105586002)(19300405004)(2950100001)(86362001)(110136003)(68736007)(575784001)(122556002)(2906002)(106116001)(10400500002)(99286002)(7736002)(7846002)(64030200001)(104396002); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR02MB084; H:BLUPR02MB083.namprd02.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: nutanix.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2016 17:25:49.7192 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB084 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.91 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [Qemu-devel] [PATCH] Avoid additional GET_FEATURES call on vhost-user 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: =?utf-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Gentle ping. Thanks, Felipe From: Marc-André Lureau Date: Thursday, 25 August 2016 at 12:14 To: Felipe Franciosi , "qemu-devel@nongnu.org" , "Michael S. Tsirkin" Subject: Re: [Qemu-devel] [PATCH] Avoid additional GET_FEATURES call on vhost-user Hi On Sat, Aug 20, 2016 at 3:28 AM Felipe Franciosi > wrote: Vhost-user requires an early GET_FEATURES call to determine if the slave supports protocol feature negotiation. An extra GET_FEATURES call is made after vhost_backend_init() to actually set the device features. This patch moves the actual setting of the device features to both implementations (kernel/user) of vhost_backend_init(), therefore eliminating the need for a second call. Signed-off-by: Felipe Franciosi > Reviewed-by: Marc-André Lureau > --- hw/virtio/vhost-backend.c | 27 ++++++++++++++++++--------- hw/virtio/vhost-user.c | 1 + hw/virtio/vhost.c | 9 --------- 3 files changed, 19 insertions(+), 18 deletions(-) -- 1.9.5 -- Marc-André Lureau diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 7681f15..a519fe2 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -25,15 +25,6 @@ static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int request, return ioctl(fd, request, arg); } -static int vhost_kernel_init(struct vhost_dev *dev, void *opaque) -{ - assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_KERNEL); - - dev->opaque = opaque; - - return 0; -} - static int vhost_kernel_cleanup(struct vhost_dev *dev) { int fd = (uintptr_t) dev->opaque; @@ -172,6 +163,24 @@ static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx) return idx - dev->vq_index; } +static int vhost_kernel_init(struct vhost_dev *dev, void *opaque) +{ + uint64_t features; + int r; + + assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_KERNEL); + + dev->opaque = opaque; + + r = vhost_kernel_get_features(dev, &features); + if (r < 0) { + return r; + } + dev->features = features; + + return 0; +} + static const VhostOps kernel_ops = { .backend_type = VHOST_BACKEND_TYPE_KERNEL, .vhost_backend_init = vhost_kernel_init, diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index b57454a..684f6d7 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -578,6 +578,7 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque) if (err < 0) { return err; } + dev->features = features; if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) { dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 3d0c807..cb9870a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1037,7 +1037,6 @@ static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq) int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeout) { - uint64_t features; int i, r, n_initialized_vqs = 0; hdev->migration_blocker = NULL; @@ -1063,12 +1062,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, goto fail; } - r = hdev->vhost_ops->vhost_get_features(hdev, &features); - if (r < 0) { - VHOST_OPS_DEBUG("vhost_get_features failed"); - goto fail; - } - for (i = 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) { r = vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i); if (r < 0) { @@ -1086,8 +1079,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, } } - hdev->features = features; - hdev->memory_listener = (MemoryListener) { .begin = vhost_begin, .commit = vhost_commit,