From patchwork Fri Mar 22 05:39:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 2318131 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id CFEFA40B29 for ; Fri, 22 Mar 2013 05:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932177Ab3CVFjd (ORCPT ); Fri, 22 Mar 2013 01:39:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60097 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752601Ab3CVFj0 (ORCPT ); Fri, 22 Mar 2013 01:39:26 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2M5dNgE001741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Mar 2013 01:39:23 -0400 Received: from hj.localdomain.com ([10.66.4.126]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2M5dF59015028; Fri, 22 Mar 2013 01:39:19 -0400 From: Asias He To: Nicholas Bellinger Cc: Paolo Bonzini , Stefan Hajnoczi , "Michael S. Tsirkin" , Rusty Russell , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, target-devel@vger.kernel.org, Asias He Subject: [PATCH V4 1/2] tcm_vhost: Introduce tcm_vhost_check_feature() Date: Fri, 22 Mar 2013 13:39:04 +0800 Message-Id: <1363930745-7520-2-git-send-email-asias@redhat.com> In-Reply-To: <1363930745-7520-1-git-send-email-asias@redhat.com> References: <1363930745-7520-1-git-send-email-asias@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This helper is useful to check if a feature is supported. Signed-off-by: Asias He Reviewed-by: Stefan Hajnoczi --- drivers/vhost/tcm_vhost.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c index 0524267..d81e3a9 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c @@ -90,6 +90,18 @@ static int iov_num_pages(struct iovec *iov) ((unsigned long)iov->iov_base & PAGE_MASK)) >> PAGE_SHIFT; } +static bool tcm_vhost_check_feature(struct vhost_scsi *vs, int feature) +{ + bool ret = false; + + mutex_lock(&vs->dev.mutex); + if (vhost_has_feature(&vs->dev, feature)) + ret = true; + mutex_unlock(&vs->dev.mutex); + + return ret; +} + static bool tcm_vhost_check_endpoint(struct vhost_virtqueue *vq) { bool ret = false;