From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=57892 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpgqM-0005bx-6z for qemu-devel@nongnu.org; Wed, 16 Feb 2011 07:50:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpgqK-0000bv-35 for qemu-devel@nongnu.org; Wed, 16 Feb 2011 07:50:53 -0500 Received: from odin2.bull.net ([129.184.85.11]:44352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpgqJ-0000bK-2l for qemu-devel@nongnu.org; Wed, 16 Feb 2011 07:50:52 -0500 Received: from msgb-001.fraz.bull.fr (msgb-001.fraz.bull.fr [129.181.12.140]) by odin2.bull.net (Bull S.A.) with ESMTP id 70BBF1580B2 for ; Wed, 16 Feb 2011 13:58:38 +0100 (CET) From: Thomas Favre-Bulle Date: Wed, 16 Feb 2011 13:53:21 +0100 Message-ID: <1297860801.1978.140.camel@daruma> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="UTF-8" Subject: [Qemu-devel] Possible race condition when using TUN/TAP devices Reply-To: thomas.favre-bulle@bull.net List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, I noticed the following error when trying to run multiple Qemu/KVM instances: ------------ warning: could not open /dev/net/tun: no virtual network emulation qemu-kvm: -netdev tap,id=hostnet0: Device 'tap' could not be initialized ------------ Tracing the error showed that returned errno is 16 (EBUSY) and happens only when launching multiple instances in parallel. In net/tap-linux.c line 40, qemu attempts to open /dev/net/tun (rw mode). Then line 78, fcntl is called to set current file descriptor in non blocking mode. IMHO, the problem is there, isn't it ? Qemu/KVM version: 0.12.1.2 (also tested with 0.13.0) System: RHEL6 GA (2.6.32-71) Qemu command line: /usr/libexec/qemu-kvm -M rhel6.0.0 -enable-kvm -m 2048 -smp 8,sockets=8,cores=1,threads=1 -name vm5 -uuid dbcc794b-cda6-44cb-b9f1-5a2024a4281d -rtc base=utc -boot order=cn -chardev socket,id=monitor,port=15006,host=127.0.0.1,server,nowait -mon chardev=monitor,mode=control -pidfile /var/run/vm5.pid -drive file=/var/lib/libvirt/images/vm5.img,if=none,id=drive-ide0-0-0,boot=on -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,ifname=tap5,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,mac=52:54:99:12:34:45,bus=pci.0,addr=0x04 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -vnc 127.0.0.1:5 -vga cirrus -device virtio-balloon-pci,bus=pci.0,addr=0x03 more instances are run using a similar command line (only name, uuid, mac address, etc. changes) -- Thomas