MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vhost_user_add_connection

Function vhost_user_add_connection

dpdk/lib/vhost/socket.c:211–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211static void
212vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
213{
214 int vid;
215 size_t size;
216 struct vhost_user_connection *conn;
217 int ret;
218 struct virtio_net *dev;
219
220 if (vsocket == NULL)
221 return;
222
223 conn = malloc(sizeof(*conn));
224 if (conn == NULL) {
225 close(fd);
226 return;
227 }
228
229 vid = vhost_user_new_device();
230 if (vid == -1) {
231 goto err;
232 }
233
234 size = strnlen(vsocket->path, PATH_MAX);
235 vhost_set_ifname(vid, vsocket->path, size);
236
237 vhost_setup_virtio_net(vid, vsocket->use_builtin_virtio_net,
238 vsocket->net_compliant_ol_flags, vsocket->stats_enabled,
239 vsocket->iommu_support);
240
241 vhost_attach_vdpa_device(vid, vsocket->vdpa_dev);
242
243 if (vsocket->extbuf)
244 vhost_enable_extbuf(vid);
245
246 if (vsocket->linearbuf)
247 vhost_enable_linearbuf(vid);
248
249 if (vsocket->async_copy) {
250 dev = get_device(vid);
251
252 if (dev)
253 dev->async_copy = 1;
254 }
255
256 VHOST_LOG_CONFIG(vsocket->path, INFO, "new device, handle is %d\n", vid);
257
258 if (vsocket->notify_ops->new_connection) {
259 ret = vsocket->notify_ops->new_connection(vid);
260 if (ret < 0) {
261 VHOST_LOG_CONFIG(vsocket->path, ERR,
262 "failed to add vhost user connection with fd %d\n",
263 fd);
264 goto err_cleanup;
265 }
266 }
267
268 conn->connfd = fd;

Callers 3

vhost_user_start_clientFunction · 0.85

Calls 15

mallocFunction · 0.85
vhost_user_new_deviceFunction · 0.85
strnlenFunction · 0.85
vhost_set_ifnameFunction · 0.85
vhost_setup_virtio_netFunction · 0.85
vhost_attach_vdpa_deviceFunction · 0.85
vhost_enable_extbufFunction · 0.85
vhost_enable_linearbufFunction · 0.85
get_deviceFunction · 0.85
fdset_addFunction · 0.85
pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85

Tested by

no test coverage detected