From patchwork Sat Apr 13 03:20:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 2439991 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 EE1A23FE81 for ; Sat, 13 Apr 2013 03:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753667Ab3DMDUp (ORCPT ); Fri, 12 Apr 2013 23:20:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35807 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132Ab3DMDUm (ORCPT ); Fri, 12 Apr 2013 23:20:42 -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 r3D3KdX8001713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Apr 2013 23:20:40 -0400 Received: from hj.localdomain.com (vpn1-114-201.nay.redhat.com [10.66.114.201]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3D3KVUW006651; Fri, 12 Apr 2013 23:20:36 -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 v6 1/3] tcm_vhost: Introduce tcm_vhost_check_feature() Date: Sat, 13 Apr 2013 11:20:24 +0800 Message-Id: <1365823226-27242-2-git-send-email-asias@redhat.com> In-Reply-To: <1365823226-27242-1-git-send-email-asias@redhat.com> References: <1365823226-27242-1-git-send-email-asias@redhat.com> In-Reply-To: <1365808250.26011.68.camel@haakon2.linux-iscsi.org> References: <1365808250.26011.68.camel@haakon2.linux-iscsi.org> 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 957a0b9..88ebb79 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c @@ -99,6 +99,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 int tcm_vhost_check_true(struct se_portal_group *se_tpg) { return 1;