qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Raphael Norwitz <raphael.norwitz@nutanix.com>
To: ni.xun.intel@gmail.com, tonnylu@tencent.com, leomyan@tencent.com,
	lucascye@tencent.com
Cc: qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [PATCH] resend slave fd to vhost when reconnect to vhost
Date: Tue, 14 Apr 2020 06:02:08 -0400	[thread overview]
Message-ID: <20200414100208.GA14282@localhost.localdomain> (raw)
In-Reply-To: <20200417051400.30398-1-richardni@tencent.com>

On Fri, Apr 17, 2020 at 01:14:00PM +0800, ni.xun.intel@gmail.com wrote:
> 
> From: Ni Xun <richardni@tencent.com>
> 
> when reconnecting to vhost server, it doesn't send slave fd to vhost
> as the slave fd is only sent in vhost_user_init. also resend the slave fd
> in vhost reconnect.
> 

I don’t think that’s correct. See vhost_user_init() here:

https://git.qemu.org/?p=qemu.git;a=blob;f=hw/virtio/vhost-user.c;h=08e7e63790e5bcfae6cd31bf9ccd32c3a7347f4e;hb=HEAD#l1898

Rather, vhost_setup_slave_channel() is called by vhost_user_backend_init(),
which is called on every reconnect inside vhost_dev_init().

see vhost_user_blk_connect(): https://git.qemu.org/?p=qemu.git;a=blob;f=hw/block/vhost-user-blk.c;h=17df5338e77c684175a86e882b508849c246e78a;hb=HEAD#l297
and vhost_dev_init():https://git.qemu.org/?p=qemu.git;a=blob;f=hw/virtio/vhost.c;h=01ebe12f28e9d7e3150375dda6f55b6b8f04a42a;hb=HEAD#l1224

Note that the dev->vq_index is also set to 0 right before the
vhost_dev_init() call.

I tested myself and saw a VHOST_USER_SET_SLAVE_REQ_FD message sent on each
reconnect with the vhost-user-blk sample.

Are you seeing different behavior? If so, please provide more details on
your setup?

> 
> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
> index 17df5338e7..59650a570b 100644
> --- a/hw/block/vhost-user-blk.c
> +++ b/hw/block/vhost-user-blk.c
> @@ -138,6 +138,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev)
>              error_report("Error get inflight: %d", -ret);
>              goto err_guest_notifiers;
>          }

What's the justification for sending the slave fd here? Please elaborate.

> +    } else {
> +        ret = vhost_setup_slave_channel(&s->dev);
> +        if (ret < 0) {
> +            error_report("Error setting vhost slave channel: %d", -ret);
> +            return ret;
> +        }
>      }
> diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
> index 085450c6f8..cad60ad521 100644
> --- a/include/hw/virtio/vhost.h
> +++ b/include/hw/virtio/vhost.h

Why expose this through vhost.h? This is vhost-user specific.

> @@ -100,6 +100,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
>  void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
>  int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
>  void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
> +int vhost_setup_slave_channel(struct vhost_dev *hdev);
>  
>  /* Test and clear masked event pending status.
>   * Should be called after unmask to avoid losing events.
> -- 
> 2.24.1 (Apple Git-126)
> 
> 


  reply	other threads:[~2020-04-18  1:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-17  5:14 [PATCH] resend slave fd to vhost when reconnect to vhost ni.xun.intel
2020-04-14 10:02 ` Raphael Norwitz [this message]
2020-04-18 10:42   ` xun ni

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=20200414100208.GA14282@localhost.localdomain \
    --to=raphael.norwitz@nutanix.com \
    --cc=leomyan@tencent.com \
    --cc=lucascye@tencent.com \
    --cc=mst@redhat.com \
    --cc=ni.xun.intel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tonnylu@tencent.com \
    /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).