qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Boeuf, Sebastien" <sebastien.boeuf@intel.com>
To: "dgilbert@redhat.com" <dgilbert@redhat.com>
Cc: "marcandre.lureau@redhat.com" <marcandre.lureau@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] libvhost-user: Fix the VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD check
Date: Wed, 7 Aug 2019 16:24:36 +0000	[thread overview]
Message-ID: <e99d520edca6deca1ff6b838fd43f1bde00761ee.camel@intel.com> (raw)
In-Reply-To: <20190807160917.GI2867@work-vm>

On Wed, 2019-08-07 at 17:09 +0100, Dr. David Alan Gilbert wrote:
> * Boeuf, Sebastien (sebastien.boeuf@intel.com) wrote:
> > From 0a53a81db6dd069f9b7bcdcd386845bceb3a2ac6 Mon Sep 17 00:00:00
> > 2001
> > From: Sebastien Boeuf <sebastien.boeuf@intel.com>
> > Date: Wed, 7 Aug 2019 07:15:32 -0700
> > Subject: [PATCH] libvhost-user: Fix the
> > VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD
> >  check
> > 
> > Vhost user protocol features are set as a bitmask. And the
> > following
> > constant VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD value is 10 because
> > the
> > bit
> > 10 indicates if the features is set or not.
> > 
> > The proper way to check for the presence or absence of this feature
> > is
> > to shift 1 by the value of this constant and then mask it with the
> > actual bitmask representing the supported protocol features.
> > 
> > This patch aims to fix the current code as it was not doing the
> > shifting, but instead it was masking directly with the value of the
> > constant itself.
> > 
> > Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
> 
> Nicely spotted.
> 
> Two things;
>   a) I think your mail client has wrapped the lines at some point.
>   b) I think this is why the has_feature() functione exists, so does
>      that become
> 
>       if (!has_feature(dev->protocol_features,
> VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD))

Ah yes but that's because I forgot to check the patch format first :(

I'm going to update the patch.

Thanks,
Sebastien
> 
> Dave
> 
> > ---
> >  contrib/libvhost-user/libvhost-user.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/contrib/libvhost-user/libvhost-user.c
> > b/contrib/libvhost-
> > user/libvhost-user.c
> > index fb61142bcc..11909fb7c1 100644
> > --- a/contrib/libvhost-user/libvhost-user.c
> > +++ b/contrib/libvhost-user/libvhost-user.c
> > @@ -1112,7 +1112,7 @@ bool vu_set_queue_host_notifier(VuDev *dev,
> > VuVirtq *vq, int fd,
> >  
> >      vmsg.fd_num = fd_num;
> >  
> > -    if ((dev->protocol_features &
> > VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)
> > == 0) {
> > +    if ((dev->protocol_features & (1ULL <<
> > VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) == 0) {
> >          return false;
> >      }
> >  
> > @@ -2537,7 +2537,7 @@ int64_t vu_fs_cache_request(VuDev *dev,
> > VhostUserSlaveRequest req, int fd,
> >  
> >      vmsg.fd_num = fd_num;
> >  
> > -    if ((dev->protocol_features &
> > VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)
> > == 0) {
> > +    if ((dev->protocol_features & (1ULL <<
> > VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) == 0) {
> >          return -EINVAL;
> >      }
> >  
> > -- 
> > 2.17.1
> 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2019-08-07 16:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 14:27 [Qemu-devel] libvhost-user: Fix the VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD check Boeuf, Sebastien
2019-08-07 16:09 ` Dr. David Alan Gilbert
2019-08-07 16:24   ` Boeuf, Sebastien [this message]
2019-08-07 16:35     ` Boeuf, Sebastien
2019-08-07 17:23       ` Boeuf, Sebastien
2019-08-23 16:32         ` Dr. David Alan Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e99d520edca6deca1ff6b838fd43f1bde00761ee.camel@intel.com \
    --to=sebastien.boeuf@intel.com \
    --cc=dgilbert@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).