[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] libvhost-user: fix SLAVE_SEND_FD handling
From: |
Tiwei Bie |
Subject: |
Re: [Qemu-devel] [PATCH v2] libvhost-user: fix SLAVE_SEND_FD handling |
Date: |
Wed, 4 Sep 2019 10:06:55 +0800 |
User-agent: |
Mutt/1.9.4 (2018-02-28) |
On Tue, Sep 03, 2019 at 11:04:22PM +0300, Johannes Berg wrote:
> From: Johannes Berg <address@hidden>
>
> It doesn't look like this could possibly work properly since
> VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD is defined to 10, but the
> dev->protocol_features has a bitmap. I suppose the peer this
> was tested with also supported VHOST_USER_PROTOCOL_F_LOG_SHMFD,
> in which case the test would always be false, but nevertheless
> the code seems wrong.
Ooops.. I tested `tests/vhost-user-bridge -H`. But as you
said it worked because VHOST_USER_PROTOCOL_F_LOG_SHMFD has
been negotiated. Thanks for spotting this!
>
> Use has_feature() to fix this.
>
> Fixes: d84599f56c82 ("libvhost-user: support host notifier")
Cc: address@hidden
> Signed-off-by: Johannes Berg <address@hidden>
> ---
> contrib/libvhost-user/libvhost-user.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/libvhost-user/libvhost-user.c
> b/contrib/libvhost-user/libvhost-user.c
> index 6a02eaffc672..fcf4a8a00ed2 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -1097,7 +1097,8 @@ 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 (!has_feature(dev->protocol_features,
> + VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) {
We have both of has_feature() and vu_has_feature() called by
other code in this file directly. Not sure which one is preferred..
Personally, I think vu_has_feature() might be better.
Thanks!
Tiwei
> return false;
> }
>
> --
> 2.23.0
>