spdk_uevent_connect
通过udev提供的异步监听方式检测热插拔事件;
socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
setsockopt(netlink_fd, SOL_SOCKET, SO_RCVBUFFORCE, &size, sizeof(size));
fcntl(netlink_fd, F_GETFL);
fcntl(netlink_fd, F_SETFL, flag | O_NONBLOCK)
bind(netlink_fd, (struct sockaddr *) &addr, sizeof(addr))
在监听的接口上可以接收到来自kernel的异步事件:
recv(fd, buf, SPDK_UEVENT_MSG_LEN - 1, MSG_DONTWAIT)
&&
parse_event
spdk nvme nvme_uevent
2019-11-06