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

Function vduse_device_destroy

dpdk/lib/vhost/vduse.c:600–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

598}
599
600int
601vduse_device_destroy(const char *path)
602{
603 const char *name = path + strlen("/dev/vduse/");
604 struct virtio_net *dev;
605 int vid, ret;
606
607 for (vid = 0; vid < RTE_MAX_VHOST_DEVICE; vid++) {
608 dev = vhost_devices[vid];
609
610 if (dev == NULL)
611 continue;
612
613 if (!strcmp(path, dev->ifname))
614 break;
615 }
616
617 if (vid == RTE_MAX_VHOST_DEVICE)
618 return -1;
619
620 vduse_device_stop(dev);
621
622 fdset_del(&vduse.fdset, dev->vduse_dev_fd);
623 fdset_pipe_notify_sync(&vduse.fdset);
624
625 if (dev->vduse_dev_fd >= 0) {
626 close(dev->vduse_dev_fd);
627 dev->vduse_dev_fd = -1;
628 }
629
630 if (dev->vduse_ctrl_fd >= 0) {
631 ret = ioctl(dev->vduse_ctrl_fd, VDUSE_DESTROY_DEV, name);
632 if (ret)
633 VHOST_LOG_CONFIG(name, ERR, "Failed to destroy VDUSE device: %s\n",
634 strerror(errno));
635 close(dev->vduse_ctrl_fd);
636 dev->vduse_ctrl_fd = -1;
637 }
638
639 vhost_destroy_device(vid);
640
641 return 0;
642}

Callers 1

Calls 7

strcmpFunction · 0.85
vduse_device_stopFunction · 0.85
fdset_delFunction · 0.85
fdset_pipe_notify_syncFunction · 0.85
vhost_destroy_deviceFunction · 0.85
closeFunction · 0.50
ioctlFunction · 0.50

Tested by

no test coverage detected