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

Function vhost_user_start_server

dpdk/lib/vhost/socket.c:376–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376static int
377vhost_user_start_server(struct vhost_user_socket *vsocket)
378{
379 int ret;
380 int fd = vsocket->socket_fd;
381 const char *path = vsocket->path;
382
383 /*
384 * bind () may fail if the socket file with the same name already
385 * exists. But the library obviously should not delete the file
386 * provided by the user, since we can not be sure that it is not
387 * being used by other applications. Moreover, many applications form
388 * socket names based on user input, which is prone to errors.
389 *
390 * The user must ensure that the socket does not exist before
391 * registering the vhost driver in server mode.
392 */
393 ret = bind(fd, (struct sockaddr *)&vsocket->un, sizeof(vsocket->un));
394 if (ret < 0) {
395 VHOST_LOG_CONFIG(path, ERR, "failed to bind: %s; remove it and try again\n",
396 strerror(errno));
397 goto err;
398 }
399 VHOST_LOG_CONFIG(path, INFO, "binding succeeded\n");
400
401 ret = listen(fd, MAX_VIRTIO_BACKLOG);
402 if (ret < 0)
403 goto err;
404
405 ret = fdset_add(&vhost_user.fdset, fd, vhost_user_server_new_connection,
406 NULL, vsocket);
407 if (ret < 0) {
408 VHOST_LOG_CONFIG(path, ERR, "failed to add listen fd %d to vhost server fdset\n",
409 fd);
410 goto err;
411 }
412
413 return 0;
414
415err:
416 close(fd);
417 return -1;
418}
419
420struct vhost_user_reconnect {
421 struct sockaddr_un un;

Callers 1

rte_vhost_driver_startFunction · 0.70

Calls 4

fdset_addFunction · 0.85
bindFunction · 0.50
listenFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected