File descriptor "leak" through /etc/qemu-ifup script
Qemu does not close its filedescriptors (or setting the FD_CLOEXEC) when invoking the /etc/qemu-ifup script.
Hence any background process spawned from there (such as a dhcpd) will also inherit the open filedescriptor, preventing the relevant decide (/dev/net/tup) to be reused later on:
If for example you chose a fixed network name using the -net ...ifname=
option and have an /etc/init.d/dhcp start in your if-up qemu (in order
to instruct dhcpd to handle the new interface), the newly spawned dhcp will inherit the filedescriptor controlling the tun device, a continue hogging it even after the qemu is stopped, and is started again.
Workaround:
Putting the following into the script:
exec 3>/dev/null
exec 4>/dev/null
exec 5>/dev/null
exec 6>/dev/null
But a cleaner solution would be if qemu itself was careful not to leak those descriptors in the first place.
Thanks,
Alain
Quoted 7 lines · Alain Knaff (qemu)
Workaround:
Putting the following into the script:
exec 3>/dev/null
exec 4>/dev/null
exec 5>/dev/null
exec 6>/dev/null
better yet: for i in {3..6}; do exec $i>&-; done