I have a following /etc/qemu-ifup script which is executed when I start /usr/bin/qemu-system-i386 binary:


set -x


if [ -n "$1" ];then
        /usr/sbin/tunctl -u `whoami` -t $1
        /sbin/ip link set dev $1 up
        sleep 0.5s
        /sbin/brctl addif $switch $1
        exit 0
        echo "Error: no interface specified"
        exit 1

The problem is, that tunctl complains that device or resource is busy:

root@VM-host:~# qemu -hda /root/1.raw -device e1000,netdev=net0,mac=DE:AD:BE:EF:69:01 -netdev tap,id=net0 -display vnc=:1
+ switch=br0
+ [ -n tap0 ]
+ whoami
+ /usr/sbin/tunctl -u root -t tap0
TUNSETIFF: Device or resource busy
+ /sbin/ip link set dev tap0 up sleep 0.5s
Error: either "dev" is duplicate, or "sleep" is a garbage.
+ /sbin/brctl addif br0 tap0
+ exit 0

When I execute simply the /usr/sbin/tunctl -u root -t tap0, then tap0 is created without any issues:

root@VM-host:~# /usr/sbin/tunctl -u root -t tap0
Set 'tap0' persistent and owned by uid 0

Any ideas what causes such behavior?


(I dont know from when), qemu will create the tap first and then call your /etc/qemu-ifup script. So you see the error report, just because the same tap already exists.

Reference: qemu source: net/tap-linux.c (check the function: tap_open()).


The error message "Error: either "dev" is duplicate, or "sleep" is a garbage" tells the cause of your problem.

Should use the following command to bring up the tap interface:

/sbin/ip link set $1 up

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.