Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1008046ybt; Fri, 19 Jun 2020 21:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH3U/a3hWrIGVfKPMZZjqHt/7Y+ec7BeDYuBztGallmQDX5azNACG5P5eveKopZwNTLZpm X-Received: by 2002:aa7:d5c7:: with SMTP id d7mr6639939eds.11.1592627176324; Fri, 19 Jun 2020 21:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592627176; cv=none; d=google.com; s=arc-20160816; b=wi9yvb8sIhpuW7KU+UIo91KW2PJsYbXwph/6J/+WBoYWM0OI2zzdm3WAHEGn+v19FS 1mmte72v6TTXDyMLdTuSZJNL8sa3V+CzeXFpJC0VfxEHQyjOr336ic5oJdu7tHDeQJkw CWcWwvc8gqBE0vsfu+hBrXOljrldQXojh/L//wRAHirG5u8a4YDiaHaKZxqkOvLIuoo3 FudeMotDyl+cZ8InU7ZspWW/q/BtTDFE6WtONfOASsOwbnWLzTcryTZOq8Vl2Ew1vMlK tmmryzlpjwsklLwFpWCmnGaOjososAAaXqtfDVt/CbgjeJVqWwPFTIfMrVXgu5duTiwQ nb+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MQa85S+Gu9mVyqbk6eUj8fFtN+Dd+Dol2b2QZrFCNIg=; b=tpfyY0va7hJ6tHkTVcdldb5eSXD63Na195LCRCBTe9dNK8A5SiQKJ54IuVtNtbnxf8 hbygDpNqKLRxZy0h1/IAsUPcaQW0fb/JZ9t+o+pbMYwCM4NAfIvctCeZI5U+M1QUPeDL CtD9Rid56sQ9/2hHRNOIhNmWTPJZMD2cc7WOr+QsMI7L0teQrGP+RI7M0PulkgGOabQX Hr9FbDhdj8IObkz6DmKwwZxJ05/PdVA4gxB38UKK7utvjsDz2CZ995GIsvJEEkGGDJiR +3ardEk+ScQq+z/ldv/aKo5FH2yK1pljwmgUYmFogJ4g/kZNNJKoq1/Ep9gKlnjdTA99 dIQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a51yvuZg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly19si4938751ejb.394.2020.06.19.21.25.54; Fri, 19 Jun 2020 21:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a51yvuZg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729836AbgFSSYg (ORCPT + 99 others); Fri, 19 Jun 2020 14:24:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52108 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405415AbgFSSXm (ORCPT ); Fri, 19 Jun 2020 14:23:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592591021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MQa85S+Gu9mVyqbk6eUj8fFtN+Dd+Dol2b2QZrFCNIg=; b=a51yvuZgVRwy93UXFg+jrP41K065x62hhcfvcIkb+RV8Yn2Wg/lrwbA0em1Kza1EeUdbFj cLNOdDj+Y3YFERuwQNfe6D4SN2rDhMc2JBOcrR+UukIufgPe6OjJU3HVMlaqZ0mUrjYrUQ wGyr8q8Rbo7//pFM+EOUHOpcM3jiiU4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-127-CiGvTY12PFKdDV5VNrlB1g-1; Fri, 19 Jun 2020 14:23:38 -0400 X-MC-Unique: CiGvTY12PFKdDV5VNrlB1g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F4AF8015CE; Fri, 19 Jun 2020 18:23:37 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-14.ams2.redhat.com [10.36.113.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D11A1C8; Fri, 19 Jun 2020 18:23:35 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: mst@redhat.com Cc: kvm list , Stefano Garzarella , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Stefan Hajnoczi , Jason Wang Subject: [RFC v9 08/11] vhost/test: convert to the buf API Date: Fri, 19 Jun 2020 20:22:59 +0200 Message-Id: <20200619182302.850-9-eperezma@redhat.com> In-Reply-To: <20200619182302.850-1-eperezma@redhat.com> References: <20200619182302.850-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Michael S. Tsirkin" Signed-off-by: Michael S. Tsirkin Signed-off-by: Eugenio PĂ©rez --- drivers/vhost/test.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index 650e69261557..39e68f797a93 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c @@ -44,9 +44,10 @@ static void handle_vq(struct vhost_test *n) { struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ]; unsigned out, in; - int head; + int ret; size_t len, total_len = 0; void *private; + struct vhost_buf buf; mutex_lock(&vq->mutex); private = vhost_vq_get_backend(vq); @@ -58,15 +59,15 @@ static void handle_vq(struct vhost_test *n) vhost_disable_notify(&n->dev, vq); for (;;) { - head = vhost_get_vq_desc(vq, vq->iov, - ARRAY_SIZE(vq->iov), - &out, &in, - NULL, NULL); + ret = vhost_get_avail_buf(vq, &buf, vq->iov, + ARRAY_SIZE(vq->iov), + &out, &in, + NULL, NULL); /* On error, stop handling until the next kick. */ - if (unlikely(head < 0)) + if (unlikely(ret < 0)) break; /* Nothing new? Wait for eventfd to tell us they refilled. */ - if (head == vq->num) { + if (!ret) { if (unlikely(vhost_enable_notify(&n->dev, vq))) { vhost_disable_notify(&n->dev, vq); continue; @@ -78,13 +79,14 @@ static void handle_vq(struct vhost_test *n) "out %d, int %d\n", out, in); break; } - len = iov_length(vq->iov, out); + len = buf.out_len; /* Sanity check */ if (!len) { vq_err(vq, "Unexpected 0 len for TX\n"); break; } - vhost_add_used_and_signal(&n->dev, vq, head, 0); + vhost_put_used_buf(vq, &buf); + vhost_signal(&n->dev, vq); total_len += len; if (unlikely(vhost_exceeds_weight(vq, 0, total_len))) break; -- 2.18.1