All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Ilya Maximets <i.maximets@samsung.com>
Cc: dev@dpdk.org, Huawei Xie <huawei.xie@intel.com>,
	Dyasly Sergey <s.dyasly@samsung.com>,
	Heetae Ahn <heetae82.ahn@samsung.com>,
	Thomas Monjalon <thomas.monjalon@6wind.com>
Subject: Re: [PATCH] vhost: fix driver unregister for client mode
Date: Thu, 21 Jul 2016 16:24:19 +0800	[thread overview]
Message-ID: <20160721082419.GB28708@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1469003563-27340-1-git-send-email-i.maximets@samsung.com>

On Wed, Jul 20, 2016 at 11:32:43AM +0300, Ilya Maximets wrote:
> Currently while calling of 'rte_vhost_driver_unregister()' connection
> to QEMU will not be closed. This leads to inability to register driver
> again and reconnect to same virtual machine.
> 
> This scenario is reproducible with OVS. While executing of the following
> command vhost port will be re-created (will be executed
> 'rte_vhost_driver_register()' followed by 'rte_vhost_driver_unregister()')
> network will be broken and QEMU possibly will crash:
> 
> 	ovs-vsctl set Interface vhost1 ofport_request=15
> 
> Fix this by closing all established connections on driver unregister and
> removing of pending connections from reconnection list.
> 
> Fixes: 64ab701c3d1e ("vhost: add vhost-user client mode")
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>

Again, thanks for the fix.

> ---
> 
> Patch prepared for master branch because dpdk-next-virtio doesn't contain
> commit acbff5c67ea7 ("vhost: fix crash when exceeding file descriptors").
> Porting to dpdk-next-virtio/master is trivial and may be performed on
> demand.

Yeah, my bad, I haven't updated it after rc2, since Thomas no longer
pull request from it.  Anyway, you just remind me that I should have
done that.

>  /**
>   * Unregister the specified vhost socket
>   */
> @@ -672,20 +700,34 @@ rte_vhost_driver_unregister(const char *path)
>  {
>  	int i;
>  	int count;
> +	struct vhost_user_connection *conn;
>  
>  	pthread_mutex_lock(&vhost_user.mutex);
>  
>  	for (i = 0; i < vhost_user.vsocket_cnt; i++) {
> -		if (!strcmp(vhost_user.vsockets[i]->path, path)) {
> -			if (vhost_user.vsockets[i]->is_server) {
> -				fdset_del(&vhost_user.fdset,
> -					vhost_user.vsockets[i]->listenfd);
> -				close(vhost_user.vsockets[i]->listenfd);
> +		struct vhost_user_socket *vsocket = vhost_user.vsockets[i];
> +
> +		if (!strcmp(vsocket->path, path)) {
> +			if (vsocket->is_server) {
> +				(void) fdset_del(&vhost_user.fdset,
> +				                 vsocket->listenfd);

I would think the (void) cast is not neceessary here.

> +				close(vsocket->listenfd);
>  				unlink(path);
> +			} else if (vsocket->reconnect) {
> +				vhost_user_remove_reconnect(vsocket);
> +			}
> +
> +			conn = fdset_del(&vhost_user.fdset, vsocket->connfd);
> +			if (conn) {
> +				RTE_LOG(INFO, VHOST_CONFIG, "free connfd = %d"
> +				    "for device '%s'\n", vsocket->connfd, path);

We should try not to break a log message into several lines, which
hurts "git grep".  Here, it could be:

				RTE_LOG(INFO, VHOST_CONFIG,
					"free connfd = %d for device '%s'\n",
					vsocket->connfd, path);

Besides the two minor nits,

Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>

	--yliu

  parent reply	other threads:[~2016-07-21  8:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20  8:32 [PATCH] vhost: fix driver unregister for client mode Ilya Maximets
2016-07-20 12:38 ` Yuanhan Liu
2016-07-21  8:24 ` Yuanhan Liu [this message]
2016-07-21  8:33   ` Ilya Maximets
2016-07-21  8:31 ` [PATCH v2] " Ilya Maximets
2016-07-21 12:57   ` Ilya Maximets
2016-07-21 12:55 ` [PATCH v3] " Ilya Maximets
2016-07-21 13:18   ` Yuanhan Liu
2016-07-21 22:26     ` Thomas Monjalon

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=20160721082419.GB28708@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --cc=heetae82.ahn@samsung.com \
    --cc=huawei.xie@intel.com \
    --cc=i.maximets@samsung.com \
    --cc=s.dyasly@samsung.com \
    --cc=thomas.monjalon@6wind.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.