On Wed, 03 Feb 2016 17:44:55 +0300 Ilya Maximets <i.maxim...@samsung.com> wrote:
> If ovs-vswitchd crashes, it will not be able to recreate the same > vhost user ports, since the socket will still be in the file system. > > This forces netdev-dpdk to create vhost-user sockets in > unique temporaty directories created by mkdtemp(). As already said, this will make life harder to use with qemu. What about the patch below? (RFC, completely untested). diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index d115de2..7ec9745 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -684,6 +684,9 @@ netdev_dpdk_vhost_user_construct(struct netdev *netdev_) */ snprintf(netdev->vhost_id, sizeof(netdev->vhost_id), "%s/%s", vhost_sock_dir, netdev_->name); + + /* remove old socket */ + unlink(netdev->vhost_id); err = rte_vhost_driver_register(netdev->vhost_id); if (err) { VLOG_ERR("vhost-user socket device setup failure for socket %s\n", > Signed-off-by: Ilya Maximets <i.maxim...@samsung.com> > --- > > This is the most proper solution that I come up with. > Code doesn't clean enough. Just a PoC. > Also, we need a proper way to notify user about path. > (Log messages - not a good solution) > > lib/netdev-dpdk.c | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c > index d115de2..deeac0e 100644 > --- a/lib/netdev-dpdk.c > +++ b/lib/netdev-dpdk.c > @@ -230,6 +230,7 @@ struct netdev_dpdk { > > /* Identifier used to distinguish vhost devices from each other > */ char vhost_id[PATH_MAX]; > + char vhost_temp_dir[PATH_MAX]; > > /* In dpdk_list. */ > struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex); > @@ -672,29 +673,47 @@ netdev_dpdk_vhost_cuse_construct(struct netdev > *netdev_) return err; > } > > +typedef void (hook_cb)(void *); > + > static int > netdev_dpdk_vhost_user_construct(struct netdev *netdev_) > { > struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_); > int err; > + static const char template[] = "vhost_XXXXXX"; > + char *res; > > ovs_mutex_lock(&dpdk_mutex); > + > + /* Make unique temporary directory for new socket. */ > + snprintf(netdev->vhost_temp_dir, sizeof(netdev->vhost_temp_dir), > "%s/%s", > + vhost_sock_dir, template); > + res = mkdtemp(netdev->vhost_temp_dir); > + if (!res) { > + VLOG_ERR("Can't create temporary directory for vhost-user > socket %s\n", > + netdev_->name); > + err = -1; > + goto unlock; > + } > /* Take the name of the vhost-user port and append it to the > location where > * the socket is to be created, then register the socket. > */ > snprintf(netdev->vhost_id, sizeof(netdev->vhost_id), "%s/%s", > - vhost_sock_dir, netdev_->name); > + netdev->vhost_temp_dir, netdev_->name); > err = rte_vhost_driver_register(netdev->vhost_id); > if (err) { > VLOG_ERR("vhost-user socket device setup failure for socket > %s\n", netdev->vhost_id); > + rmdir(netdev->vhost_temp_dir); > } else { > fatal_signal_add_file_to_unlink(netdev->vhost_id); > + fatal_signal_add_hook((hook_cb *)&rmdir, NULL, > netdev->vhost_temp_dir, true); VLOG_INFO("Socket %s created for > vhost-user port %s\n", netdev->vhost_id, netdev_->name); > err = vhost_construct_helper(netdev_); > } > > +unlock: > ovs_mutex_unlock(&dpdk_mutex); > return err; > } > @@ -752,6 +771,7 @@ netdev_dpdk_vhost_destruct(struct netdev *netdev_) > VLOG_ERR("Unable to remove vhost-user socket %s", > dev->vhost_id); } else { > fatal_signal_remove_file_to_unlink(dev->vhost_id); > + rmdir(dev->vhost_temp_dir); > } > > ovs_mutex_lock(&dpdk_mutex); -- fbl _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev