Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit b8cf990

Browse files
committed
qemu: clear persist flag on tap device
In the scenario which tap device was not created by qemu but passed in(e.g, with some cni plugin), there was IFF_PERSIST flag set on it, the flag need to be cleared to make sure tap device removed cleanly on qemu exit. (cherry picked from commit c3fbef2)
1 parent 5e38811 commit b8cf990

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hypervisor/qemu/network.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func GetTapFd(device, bridge, options string) (int, error) {
4747
tapFile.Close()
4848
return -1, fmt.Errorf("create tap device failed\n")
4949
}
50+
_, _, errno = syscall.Syscall(syscall.SYS_IOCTL, tapFile.Fd(), uintptr(syscall.TUNSETPERSIST), 0)
51+
if errno != 0 {
52+
tapFile.Close()
53+
return -1, fmt.Errorf("clear tap device persist flag failed\n")
54+
}
5055

5156
err = network.UpAndAddToBridge(device, bridge, options)
5257
if err != nil {

0 commit comments

Comments
 (0)