From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH v7 1/3] tcm_vhost: Introduce tcm_vhost_check_feature() Date: Thu, 18 Apr 2013 10:06:06 +0300 Message-ID: <20130418070606.GC13787@redhat.com> References: <20130417131726.GA26157@redhat.com> <1366247154-3136-2-git-send-email-asias@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Nicholas Bellinger , Paolo Bonzini , Stefan Hajnoczi , Rusty Russell , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, target-devel@vger.kernel.org To: Asias He Return-path: Received: from mx1.redhat.com ([209.132.183.28]:6814 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965540Ab3DRIEx (ORCPT ); Thu, 18 Apr 2013 04:04:53 -0400 Content-Disposition: inline In-Reply-To: <1366247154-3136-2-git-send-email-asias@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Apr 18, 2013 at 09:05:52AM +0800, Asias He wrote: > This helper is useful to check if a feature is supported. > > Signed-off-by: Asias He > Reviewed-by: Stefan Hajnoczi Why do we need the locking here by the way? It seems features don't change while vhost is running. > --- > 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; > -- > 1.8.1.4