From patchwork Tue Mar 12 02:45:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 2252641 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 316ADDF5B1 for ; Tue, 12 Mar 2013 02:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755035Ab3CLCqD (ORCPT ); Mon, 11 Mar 2013 22:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28341 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754205Ab3CLCqB (ORCPT ); Mon, 11 Mar 2013 22:46:01 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2C2jws1003983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 11 Mar 2013 22:45:58 -0400 Received: from hj.localdomain.com ([10.66.4.126]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2C2jo8w017993; Mon, 11 Mar 2013 22:45:55 -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 V3 1/2] tcm_vhost: Introduce tcm_vhost_check_feature() Date: Tue, 12 Mar 2013 10:45:38 +0800 Message-Id: <1363056339-6061-2-git-send-email-asias@redhat.com> In-Reply-To: <1363056339-6061-1-git-send-email-asias@redhat.com> References: <1363056339-6061-1-git-send-email-asias@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 c5157cd..ee6dc47 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c @@ -91,6 +91,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_scsi *vs) { bool ret = false;